Skip to content

Commit 9081bdd

Browse files
committed
Improve <xref> vs. <command> formatting in the documentation
SQL commands are generally marked up as <command>, except when a link to a reference page is used using <xref>. But the latter doesn't create monospace markup, so this looks strange especially when a paragraph contains a mix of links and non-links. We considered putting <command> in the <refentrytitle> on the target side, but that creates some formatting side effects elsewhere. Generally, it seems safer to solve this on the link source side. We can't put the <xref> inside the <command>; the DTD doesn't allow this. DocBook 5 would allow the <command> to have the linkend attribute itself, but we are not there yet. So to solve this for now, convert the <xref>s to <link> plus <command>. This gives the correct look and also gives some more flexibility what we can put into the link text (e.g., subcommands or other clauses). In the future, these could then be converted to DocBook 5 style. I haven't converted absolutely all xrefs to SQL command reference pages, only those where we care about the appearance of the link text or where it was otherwise appropriate to make the appearance match a bit better. Also in some cases, the links where repetitive, so in those cases the links where just removed and replaced by a plain <command>. In cases where we just want the link and don't specifically care about the generated link text (typically phrased "for further information see <xref ...>") the xref is kept. Reported-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> Discussion: https://www.postgresql.org/message-id/flat/87o8pco34z.fsf@wibble.ilmari.org
1 parent 1a9388b commit 9081bdd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+348
-346
lines changed

doc/src/sgml/backup.sgml

+4-4
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ pg_dump -h <replaceable>host1</replaceable> <replaceable>dbname</replaceable> |
177177
</important>
178178

179179
<para>
180-
After restoring a backup, it is wise to run <xref
181-
linkend="sql-analyze"/> on each
180+
After restoring a backup, it is wise to run <link
181+
linkend="sql-analyze"><command>ANALYZE</command></link> on each
182182
database so the query optimizer has useful statistics;
183183
see <xref linkend="vacuum-for-statistics"/>
184184
and <xref linkend="autovacuum"/> for more information.
@@ -1594,7 +1594,7 @@ archive_command = 'local_backup_script.sh "%p" "%f"'
15941594
<itemizedlist>
15951595
<listitem>
15961596
<para>
1597-
If a <xref linkend="sql-createdatabase"/>
1597+
If a <link linkend="sql-createdatabase"><command>CREATE DATABASE</command></link>
15981598
command is executed while a base backup is being taken, and then
15991599
the template database that the <command>CREATE DATABASE</command> copied
16001600
is modified while the base backup is still in progress, it is
@@ -1607,7 +1607,7 @@ archive_command = 'local_backup_script.sh "%p" "%f"'
16071607

16081608
<listitem>
16091609
<para>
1610-
<xref linkend="sql-createtablespace"/>
1610+
<link linkend="sql-createtablespace"><command>CREATE TABLESPACE</command></link>
16111611
commands are WAL-logged with the literal absolute path, and will
16121612
therefore be replayed as tablespace creations with the same
16131613
absolute path. This might be undesirable if the log is being

doc/src/sgml/catalogs.sgml

+49-49
Large diffs are not rendered by default.

doc/src/sgml/config.sgml

+12-12
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ shared_buffers = 128MB
189189
<filename>postgresql.auto.conf</filename><indexterm><primary>postgresql.auto.conf</primary></indexterm>,
190190
which has the same format as <filename>postgresql.conf</filename> but
191191
is intended to be edited automatically, not manually. This file holds
192-
settings provided through the <xref linkend="sql-altersystem"/> command.
192+
settings provided through the <link linkend="sql-altersystem"><command>ALTER SYSTEM</command></link> command.
193193
This file is read whenever <filename>postgresql.conf</filename> is,
194194
and its settings take effect in the same way. Settings
195195
in <filename>postgresql.auto.conf</filename> override those
@@ -221,7 +221,7 @@ shared_buffers = 128MB
221221
<para>
222222
<productname>PostgreSQL</productname> provides three SQL
223223
commands to establish configuration defaults.
224-
The already-mentioned <xref linkend="sql-altersystem"/> command
224+
The already-mentioned <command>ALTER SYSTEM</command> command
225225
provides a SQL-accessible means of changing global defaults; it is
226226
functionally equivalent to editing <filename>postgresql.conf</filename>.
227227
In addition, there are two commands that allow setting of defaults
@@ -231,14 +231,14 @@ shared_buffers = 128MB
231231
<itemizedlist>
232232
<listitem>
233233
<para>
234-
The <xref linkend="sql-alterdatabase"/> command allows global
234+
The <link linkend="sql-alterdatabase"><command>ALTER DATABASE</command></link> command allows global
235235
settings to be overridden on a per-database basis.
236236
</para>
237237
</listitem>
238238

239239
<listitem>
240240
<para>
241-
The <xref linkend="sql-alterrole"/> command allows both global and
241+
The <link linkend="sql-alterrole"><command>ALTER ROLE</command></link> command allows both global and
242242
per-database settings to be overridden with user-specific values.
243243
</para>
244244
</listitem>
@@ -262,15 +262,15 @@ shared_buffers = 128MB
262262
<itemizedlist>
263263
<listitem>
264264
<para>
265-
The <xref linkend="sql-show"/> command allows inspection of the
265+
The <link linkend="sql-show"><command>SHOW</command></link> command allows inspection of the
266266
current value of all parameters. The corresponding function is
267267
<function>current_setting(setting_name text)</function>.
268268
</para>
269269
</listitem>
270270

271271
<listitem>
272272
<para>
273-
The <xref linkend="sql-set"/> command allows modification of the
273+
The <link linkend="sql-set"><command>SET</command></link> command allows modification of the
274274
current value of those parameters that can be set locally to a
275275
session; it has no effect on other sessions.
276276
The corresponding function is
@@ -296,7 +296,7 @@ shared_buffers = 128MB
296296

297297
<listitem>
298298
<para>
299-
Using <xref linkend="sql-update"/> on this view, specifically
299+
Using <command>UPDATE</command> on this view, specifically
300300
updating the <structname>setting</structname> column, is the equivalent
301301
of issuing <command>SET</command> commands. For example, the equivalent of
302302
<programlisting>
@@ -4608,7 +4608,7 @@ ANY <replaceable class="parameter">num_sync</replaceable> ( <replaceable class="
46084608
Better ways to improve the quality of the
46094609
plans chosen by the optimizer include adjusting the planner cost
46104610
constants (see <xref linkend="runtime-config-query-constants"/>),
4611-
running <xref linkend="sql-analyze"/> manually, increasing
4611+
running <link linkend="sql-analyze"><command>ANALYZE</command></link> manually, increasing
46124612
the value of the <xref
46134613
linkend="guc-default-statistics-target"/> configuration parameter,
46144614
and increasing the amount of statistics collected for
@@ -8095,7 +8095,7 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
80958095
set it to <literal>replica</literal> when they are applying replicated
80968096
changes. The effect of that will be that triggers and rules (that
80978097
have not been altered from their default configuration) will not fire
8098-
on the replica. See the <xref linkend="sql-altertable"/> clauses
8098+
on the replica. See the <link linkend="sql-altertable"><command>ALTER TABLE</command></link> clauses
80998099
<literal>ENABLE TRIGGER</literal> and <literal>ENABLE RULE</literal>
81008100
for more information.
81018101
</para>
@@ -8781,7 +8781,7 @@ SET XML OPTION { DOCUMENT | CONTENT };
87818781
This variable specifies one or more shared libraries that are to be
87828782
preloaded at connection start.
87838783
It contains a comma-separated list of library names, where each name
8784-
is interpreted as for the <xref linkend="sql-load"/> command.
8784+
is interpreted as for the <link linkend="sql-load"><command>LOAD</command></link> command.
87858785
Whitespace between entries is ignored; surround a library name with
87868786
double quotes if you need to include whitespace or commas in the name.
87878787
The parameter value only takes effect at the start of the connection.
@@ -8832,7 +8832,7 @@ SET XML OPTION { DOCUMENT | CONTENT };
88328832
This variable specifies one or more shared libraries that are to be
88338833
preloaded at connection start.
88348834
It contains a comma-separated list of library names, where each name
8835-
is interpreted as for the <xref linkend="sql-load"/> command.
8835+
is interpreted as for the <link linkend="sql-load"><command>LOAD</command></link> command.
88368836
Whitespace between entries is ignored; surround a library name with
88378837
double quotes if you need to include whitespace or commas in the name.
88388838
The parameter value only takes effect at the start of the connection.
@@ -8874,7 +8874,7 @@ SET XML OPTION { DOCUMENT | CONTENT };
88748874
This variable specifies one or more shared libraries to be preloaded at
88758875
server start.
88768876
It contains a comma-separated list of library names, where each name
8877-
is interpreted as for the <xref linkend="sql-load"/> command.
8877+
is interpreted as for the <link linkend="sql-load"><command>LOAD</command></link> command.
88788878
Whitespace between entries is ignored; surround a library name with
88798879
double quotes if you need to include whitespace or commas in the name.
88808880
This parameter can only be set at server start. If a specified

doc/src/sgml/ddl.sgml

+11-11
Original file line numberDiff line numberDiff line change
@@ -1675,12 +1675,12 @@ REVOKE ALL ON accounts FROM PUBLIC;
16751675
<term><literal>SELECT</literal></term>
16761676
<listitem>
16771677
<para>
1678-
Allows <xref linkend="sql-select"/> from
1678+
Allows <command>SELECT</command> from
16791679
any column, or specific column(s), of a table, view, materialized
16801680
view, or other table-like object.
1681-
Also allows use of <xref linkend="sql-copy"/> TO.
1681+
Also allows use of <command>COPY TO</command>.
16821682
This privilege is also needed to reference existing column values in
1683-
<xref linkend="sql-update"/> or <xref linkend="sql-delete"/>.
1683+
<command>UPDATE</command> or <command>DELETE</command>.
16841684
For sequences, this privilege also allows use of the
16851685
<function>currval</function> function.
16861686
For large objects, this privilege allows the object to be read.
@@ -1692,11 +1692,11 @@ REVOKE ALL ON accounts FROM PUBLIC;
16921692
<term><literal>INSERT</literal></term>
16931693
<listitem>
16941694
<para>
1695-
Allows <xref linkend="sql-insert"/> of a new row into a table, view,
1695+
Allows <command>INSERT</command> of a new row into a table, view,
16961696
etc. Can be granted on specific column(s), in which case
16971697
only those columns may be assigned to in the <command>INSERT</command>
16981698
command (other columns will therefore receive default values).
1699-
Also allows use of <xref linkend="sql-copy"/> FROM.
1699+
Also allows use of <command>COPY FROM</command>.
17001700
</para>
17011701
</listitem>
17021702
</varlistentry>
@@ -1705,7 +1705,7 @@ REVOKE ALL ON accounts FROM PUBLIC;
17051705
<term><literal>UPDATE</literal></term>
17061706
<listitem>
17071707
<para>
1708-
Allows <xref linkend="sql-update"/> of any
1708+
Allows <command>UPDATE</command> of any
17091709
column, or specific column(s), of a table, view, etc.
17101710
(In practice, any nontrivial <command>UPDATE</command> command will
17111711
require <literal>SELECT</literal> privilege as well, since it must
@@ -1727,7 +1727,7 @@ REVOKE ALL ON accounts FROM PUBLIC;
17271727
<term><literal>DELETE</literal></term>
17281728
<listitem>
17291729
<para>
1730-
Allows <xref linkend="sql-delete"/> of a row from a table, view, etc.
1730+
Allows <command>DELETE</command> of a row from a table, view, etc.
17311731
(In practice, any nontrivial <command>DELETE</command> command will
17321732
require <literal>SELECT</literal> privilege as well, since it must
17331733
reference table columns to determine which rows to delete.)
@@ -1739,7 +1739,7 @@ REVOKE ALL ON accounts FROM PUBLIC;
17391739
<term><literal>TRUNCATE</literal></term>
17401740
<listitem>
17411741
<para>
1742-
Allows <xref linkend="sql-truncate"/> on a table, view, etc.
1742+
Allows <command>TRUNCATE</command> on a table, view, etc.
17431743
</para>
17441744
</listitem>
17451745
</varlistentry>
@@ -3370,11 +3370,11 @@ VALUES ('Albany', NULL, NULL, 'NY');
33703370
<para>
33713371
Table inheritance is typically established when the child table is
33723372
created, using the <literal>INHERITS</literal> clause of the
3373-
<xref linkend="sql-createtable"/>
3373+
<link linkend="sql-createtable"><command>CREATE TABLE</command></link>
33743374
statement.
33753375
Alternatively, a table which is already defined in a compatible way can
33763376
have a new parent relationship added, using the <literal>INHERIT</literal>
3377-
variant of <xref linkend="sql-altertable"/>.
3377+
variant of <link linkend="sql-altertable"><command>ALTER TABLE</command></link>.
33783378
To do this the new child table must already include columns with
33793379
the same names and types as the columns of the parent. It must also include
33803380
check constraints with the same names and check expressions as those of the
@@ -3406,7 +3406,7 @@ VALUES ('Albany', NULL, NULL, 'NY');
34063406
</para>
34073407

34083408
<para>
3409-
<xref linkend="sql-altertable"/> will
3409+
<command>ALTER TABLE</command> will
34103410
propagate any changes in column data definitions and check
34113411
constraints down the inheritance hierarchy. Again, dropping
34123412
columns that are depended on by other tables is only possible when using

doc/src/sgml/dml.sgml

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ UPDATE mytable SET a = 5, b = 3, c = 1 WHERE a &gt; 0;
245245
<para>
246246
You use the <xref linkend="sql-delete"/>
247247
command to remove rows; the syntax is very similar to the
248-
<command>UPDATE</command> command. For instance, to remove all
248+
<xref linkend="sql-update"/> command. For instance, to remove all
249249
rows from the products table that have a price of 10, use:
250250
<programlisting>
251251
DELETE FROM products WHERE price = 10;

doc/src/sgml/ecpg.sgml

+3-4
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,9 @@ EXEC SQL COMMIT;
479479
</para>
480480

481481
<para>
482-
For more details about declaration of the cursor,
483-
see <xref linkend="ecpg-sql-declare"/>, and
484-
see <xref linkend="sql-fetch"/> for <literal>FETCH</literal> command
485-
details.
482+
For more details about declaring a cursor, see <xref
483+
linkend="ecpg-sql-declare"/>; for more details about fetching rows from a
484+
cursor, see <xref linkend="sql-fetch"/>.
486485
</para>
487486

488487
<note>

doc/src/sgml/extend.sgml

+5-5
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ RETURNS anycompatible AS ...
504504
of the extension itself. If the extension includes C code, there
505505
will typically also be a shared library file into which the C code
506506
has been built. Once you have these files, a simple
507-
<xref linkend="sql-createextension"/> command loads the objects into
507+
<link linkend="sql-createextension"><command>CREATE EXTENSION</command></link> command loads the objects into
508508
your database.
509509
</para>
510510

@@ -513,7 +513,7 @@ RETURNS anycompatible AS ...
513513
<acronym>SQL</acronym> script to load a bunch of <quote>loose</quote> objects
514514
into your database, is that <productname>PostgreSQL</productname> will then
515515
understand that the objects of the extension go together. You can
516-
drop all the objects with a single <xref linkend="sql-dropextension"/>
516+
drop all the objects with a single <link linkend="sql-dropextension"><command>DROP EXTENSION</command></link>
517517
command (no need to maintain a separate <quote>uninstall</quote> script).
518518
Even more useful, <application>pg_dump</application> knows that it should not
519519
dump the individual member objects of the extension &mdash; it will
@@ -572,7 +572,7 @@ RETURNS anycompatible AS ...
572572

573573
<para>
574574
The kinds of SQL objects that can be members of an extension are shown in
575-
the description of <xref linkend="sql-alterextension"/>. Notably, objects
575+
the description of <link linkend="sql-alterextension"><command>ALTER EXTENSION</command></link>. Notably, objects
576576
that are database-cluster-wide, such as databases, roles, and tablespaces,
577577
cannot be extension members since an extension is only known within one
578578
database. (Although an extension script is not prohibited from creating
@@ -605,7 +605,7 @@ RETURNS anycompatible AS ...
605605
</indexterm>
606606

607607
<para>
608-
The <xref linkend="sql-createextension"/> command relies on a control
608+
The <command>CREATE EXTENSION</command> command relies on a control
609609
file for each extension, which must be named the same as the extension
610610
with a suffix of <literal>.control</literal>, and must be placed in the
611611
installation's <literal>SHAREDIR/extension</literal> directory. There
@@ -1373,7 +1373,7 @@ include $(PGXS)
13731373

13741374
<para>
13751375
Once the files are installed, use the
1376-
<xref linkend="sql-createextension"/> command to load the objects into
1376+
<command>CREATE EXTENSION</command> command to load the objects into
13771377
any particular database.
13781378
</para>
13791379
</sect2>

doc/src/sgml/logical-replication.sgml

+6-6
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,13 @@
147147
</para>
148148

149149
<para>
150-
A publication is created using the <xref linkend="sql-createpublication"/>
150+
A publication is created using the <link linkend="sql-createpublication"><command>CREATE PUBLICATION</command></link>
151151
command and may later be altered or dropped using corresponding commands.
152152
</para>
153153

154154
<para>
155155
The individual tables can be added and removed dynamically using
156-
<xref linkend="sql-alterpublication"/>. Both the <literal>ADD
156+
<link linkend="sql-alterpublication"><command>ALTER PUBLICATION</command></link>. Both the <literal>ADD
157157
TABLE</literal> and <literal>DROP TABLE</literal> operations are
158158
transactional; so the table will start or stop replicating at the correct
159159
snapshot once the transaction has committed.
@@ -207,10 +207,10 @@
207207
</para>
208208

209209
<para>
210-
The subscription is added using <xref linkend="sql-createsubscription"/> and
210+
The subscription is added using <link linkend="sql-createsubscription"><command>CREATE SUBSCRIPTION</command></link> and
211211
can be stopped/resumed at any time using the
212-
<xref linkend="sql-altersubscription"/> command and removed using
213-
<xref linkend="sql-dropsubscription"/>.
212+
<link linkend="sql-altersubscription"><command>ALTER SUBSCRIPTION</command></link> command and removed using
213+
<link linkend="sql-dropsubscription"><command>DROP SUBSCRIPTION</command></link>.
214214
</para>
215215

216216
<para>
@@ -418,7 +418,7 @@
418418
tables.) Publications can also specify that changes are to be replicated
419419
using the identity and schema of the partitioned root table instead of
420420
that of the individual leaf partitions in which the changes actually
421-
originate (see <xref linkend="sql-createpublication"/>).
421+
originate (see <link linkend="sql-createpublication"><command>CREATE PUBLICATION</command></link>).
422422
</para>
423423
</listitem>
424424
</itemizedlist>

doc/src/sgml/maintenance.sgml

+5-5
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787

8888
<para>
8989
<productname>PostgreSQL</productname>'s
90-
<xref linkend="sql-vacuum"/> command has to
90+
<link linkend="sql-vacuum"><command>VACUUM</command></link> command has to
9191
process each table on a regular basis for several reasons:
9292

9393
<orderedlist>
@@ -227,9 +227,9 @@
227227
massive update or delete activity. If you have such a table and
228228
you need to reclaim the excess disk space it occupies, you will need
229229
to use <command>VACUUM FULL</command>, or alternatively
230-
<xref linkend="sql-cluster"/>
230+
<link linkend="sql-cluster"><command>CLUSTER</command></link>
231231
or one of the table-rewriting variants of
232-
<xref linkend="sql-altertable"/>.
232+
<link linkend="sql-altertable"><command>ALTER TABLE</command></link>.
233233
These commands rewrite an entire new copy of the table and build
234234
new indexes for it. All these options require exclusive lock. Note that
235235
they also temporarily use extra disk space approximately equal to the size
@@ -242,7 +242,7 @@
242242
<para>
243243
If you have a table whose entire contents are deleted on a periodic
244244
basis, consider doing it with
245-
<xref linkend="sql-truncate"/> rather
245+
<link linkend="sql-truncate"><command>TRUNCATE</command></link> rather
246246
than using <command>DELETE</command> followed by
247247
<command>VACUUM</command>. <command>TRUNCATE</command> removes the
248248
entire content of the table immediately, without requiring a
@@ -269,7 +269,7 @@
269269
The <productname>PostgreSQL</productname> query planner relies on
270270
statistical information about the contents of tables in order to
271271
generate good plans for queries. These statistics are gathered by
272-
the <xref linkend="sql-analyze"/> command,
272+
the <link linkend="sql-analyze"><command>ANALYZE</command></link> command,
273273
which can be invoked by itself or
274274
as an optional step in <command>VACUUM</command>. It is important to have
275275
reasonably accurate statistics, otherwise poor choices of plans might

doc/src/sgml/monitoring.sgml

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<command>ps</command>, <command>top</command>, <command>iostat</command>, and <command>vmstat</command>.
2828
Also, once one has identified a
2929
poorly-performing query, further investigation might be needed using
30-
<productname>PostgreSQL</productname>'s <xref linkend="sql-explain"/> command.
30+
<productname>PostgreSQL</productname>'s <link linkend="sql-explain"><command>EXPLAIN</command></link> command.
3131
<xref linkend="using-explain"/> discusses <command>EXPLAIN</command>
3232
and other methods for understanding the behavior of an individual
3333
query.
@@ -5278,8 +5278,8 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid,
52785278
<note>
52795279
<para>
52805280
Note that when <command>ANALYZE</command> is run on a partitioned table,
5281-
all of its partitions are also recursively analyzed as also mentioned in
5282-
<xref linkend="sql-analyze"/>. In that case, <command>ANALYZE</command>
5281+
all of its partitions are also recursively analyzed.
5282+
In that case, <command>ANALYZE</command>
52835283
progress is reported first for the parent table, whereby its inheritance
52845284
statistics are collected, followed by that for each partition.
52855285
</para>

0 commit comments

Comments
 (0)