Add id's to various elements in protocol.sgml

Started by Brar Pieningabout 4 years ago35 messages
#1Brar Piening
brar@gmx.de
1 attachment(s)

When working with the Frontend/Backend Protocol implementation in Npgsql
and discussing things with the team, I often struggle with the fact that
you can't set deep links to individual message formats in the somewhat
lengthy html docs pages.

The attached patch adds id's to various elements in protocol.sgml to
make them more accesssible via the public html documentation interface.

I've tried to follow the style that was already there in a few of the
elements.

Do you consider this useful and worth merging?

Is there anything I can improve?

Best Regards,

Brar

Attachments:

protocol.sgml-anchors.patchtext/plain; charset=UTF-8; name=protocol.sgml-anchors.patchDownload
diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml
index 34a7034282..e22dc5f3b0 100644
--- a/doc/src/sgml/protocol.sgml
+++ b/doc/src/sgml/protocol.sgml
@@ -1810,7 +1810,7 @@ Replication commands are logged in the server log when
 <para>
 The commands accepted in replication mode are:
 <variablelist>
-  <varlistentry>
+  <varlistentry id="protocol-replication-identify-system" xreflabel="IDENTIFY_SYSTEM">
     <term><literal>IDENTIFY_SYSTEM</literal>
      <indexterm><primary>IDENTIFY_SYSTEM</primary></indexterm>
     </term>
@@ -1875,7 +1875,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-show" xreflabel="SHOW">
     <term><literal>SHOW</literal> <replaceable class="parameter">name</replaceable>
      <indexterm><primary>SHOW</primary></indexterm>
     </term>
@@ -1899,7 +1899,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-timeline-history" xreflabel="TIMELINE_HISTORY">
     <term><literal>TIMELINE_HISTORY</literal> <replaceable class="parameter">tli</replaceable>
      <indexterm><primary>TIMELINE_HISTORY</primary></indexterm>
     </term>
@@ -2084,7 +2084,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-create-slot-legacy">
     <term><literal>CREATE_REPLICATION_SLOT</literal> <replaceable class="parameter">slot_name</replaceable> [ <literal>TEMPORARY</literal> ] { <literal>PHYSICAL</literal> [ <literal>RESERVE_WAL</literal> ] | <literal>LOGICAL</literal> <replaceable class="parameter">output_plugin</replaceable> [ <literal>EXPORT_SNAPSHOT</literal> | <literal>NOEXPORT_SNAPSHOT</literal> | <literal>USE_SNAPSHOT</literal> | <literal>TWO_PHASE</literal> ] }
     </term>
     <listitem>
@@ -2095,7 +2095,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-read-replication-slot" xreflabel="READ_REPLICATION_SLOT">
     <term><literal>READ_REPLICATION_SLOT</literal> <replaceable class="parameter">slot_name</replaceable>
       <indexterm><primary>READ_REPLICATION_SLOT</primary></indexterm>
     </term>
@@ -2143,7 +2143,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-start-replication" xreflabel="START_REPLICATION">
     <term><literal>START_REPLICATION</literal> [ <literal>SLOT</literal> <replaceable class="parameter">slot_name</replaceable> ] [ <literal>PHYSICAL</literal> ] <replaceable class="parameter">XXX/XXX</replaceable> [ <literal>TIMELINE</literal> <replaceable class="parameter">tli</replaceable> ]
      <indexterm><primary>START_REPLICATION</primary></indexterm>
     </term>
@@ -2201,7 +2201,7 @@ The commands accepted in replication mode are:
 
      <para>
       <variablelist>
-      <varlistentry>
+      <varlistentry id="protocol-replication-xlogdata" xreflabel="XLogData">
       <term>
           XLogData (B)
       </term>
@@ -2270,7 +2270,7 @@ The commands accepted in replication mode are:
       </para>
       </listitem>
       </varlistentry>
-      <varlistentry>
+      <varlistentry id="protocol-replication-primary-keepalive-message" xreflabel="Primary keepalive message">
       <term>
           Primary keepalive message (B)
       </term>
@@ -2334,7 +2334,7 @@ The commands accepted in replication mode are:
 
      <para>
       <variablelist>
-      <varlistentry>
+      <varlistentry id="protocol-replication-standby-status-update" xreflabel="Standby status update">
       <term>
           Standby status update (F)
       </term>
@@ -2415,7 +2415,7 @@ The commands accepted in replication mode are:
 
      <para>
       <variablelist>
-      <varlistentry>
+      <varlistentry id="protocol-replication-hot-standby-feedback-message" xreflabel="Hot Standby feedback message">
       <term>
           Hot Standby feedback message (F)
       </term>
@@ -2497,7 +2497,7 @@ The commands accepted in replication mode are:
      </para>
     </listitem>
   </varlistentry>
-  <varlistentry>
+  <varlistentry id="protocol-replication-start-replication-slot-logical" xreflabel="START_REPLICATION SLOT">
     <term><literal>START_REPLICATION</literal> <literal>SLOT</literal> <replaceable class="parameter">slot_name</replaceable> <literal>LOGICAL</literal> <replaceable class="parameter">XXX/XXX</replaceable> [ ( <replaceable>option_name</replaceable> [ <replaceable>option_value</replaceable> ] [, ...] ) ]</term>
     <listitem>
      <para>
@@ -2572,7 +2572,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-drop-replication-slot" xreflabel="DROP_REPLICATION_SLOT">
     <term>
      <literal>DROP_REPLICATION_SLOT</literal> <replaceable class="parameter">slot_name</replaceable> <optional> <literal>WAIT</literal> </optional>
      <indexterm><primary>DROP_REPLICATION_SLOT</primary></indexterm>
@@ -2886,7 +2886,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-base-backup-legacy">
     <term><literal>BASE_BACKUP</literal> [ <literal>LABEL</literal> <replaceable>'label'</replaceable> ] [ <literal>PROGRESS</literal> ] [ <literal>FAST</literal> ] [ <literal>WAL</literal> ] [ <literal>NOWAIT</literal> ] [ <literal>MAX_RATE</literal> <replaceable>rate</replaceable> ] [ <literal>TABLESPACE_MAP</literal> ] [ <literal>NOVERIFY_CHECKSUMS</literal> ] [ <literal>MANIFEST</literal> <replaceable>manifest_option</replaceable> ] [ <literal>MANIFEST_CHECKSUMS</literal> <replaceable>checksum_algorithm</replaceable> ]
     </term>
     <listitem>
@@ -3138,7 +3138,7 @@ of any individual CopyData message cannot be interpretable on their own.)
 <variablelist>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationok" xreflabel="AuthenticationOk">
 <term>
 AuthenticationOk (B)
 </term>
@@ -3183,7 +3183,7 @@ AuthenticationOk (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationkerberosv5" xreflabel="AuthenticationKerberosV5">
 <term>
 AuthenticationKerberosV5 (B)
 </term>
@@ -3227,7 +3227,7 @@ AuthenticationKerberosV5 (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationcleartextpassword" xreflabel="AuthenticationCleartextPassword">
 <term>
 AuthenticationCleartextPassword (B)
 </term>
@@ -3271,7 +3271,7 @@ AuthenticationCleartextPassword (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationmd5password" xreflabel="AuthenticationMD5Password">
 <term>
 AuthenticationMD5Password (B)
 </term>
@@ -3326,7 +3326,7 @@ AuthenticationMD5Password (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationscmcredential" xreflabel="AuthenticationSCMCredential">
 <term>
 AuthenticationSCMCredential (B)
 </term>
@@ -3371,7 +3371,7 @@ AuthenticationSCMCredential (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationgss" xreflabel="AuthenticationGSS">
 <term>
 AuthenticationGSS (B)
 </term>
@@ -3416,7 +3416,7 @@ AuthenticationGSS (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationgsscontinue" xreflabel="AuthenticationGSSContinue">
 <term>
 AuthenticationGSSContinue (B)
 </term>
@@ -3471,7 +3471,7 @@ AuthenticationGSSContinue (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationsspi" xreflabel="AuthenticationSSPI">
 <term>
 AuthenticationSSPI (B)
 </term>
@@ -3516,7 +3516,7 @@ AuthenticationSSPI (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationsasl" xreflabel="AuthenticationSASL">
 <term>
 AuthenticationSASL (B)
 </term>
@@ -3577,7 +3577,7 @@ following:
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationsaslcontinue" xreflabel="AuthenticationSASLContinue">
 <term>
 AuthenticationSASLContinue (B)
 </term>
@@ -3632,7 +3632,7 @@ AuthenticationSASLContinue (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationsaslfinal" xreflabel="AuthenticationSASLFinal">
 <term>
 AuthenticationSASLFinal (B)
 </term>
@@ -3688,7 +3688,7 @@ AuthenticationSASLFinal (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-backendkeydata" xreflabel="BackendKeyData">
 <term>
 BackendKeyData (B)
 </term>
@@ -3745,7 +3745,7 @@ BackendKeyData (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-bind" xreflabel="Bind">
 <term>
 Bind (F)
 </term>
@@ -3898,7 +3898,7 @@ Bind (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-bindcomplete" xreflabel="BindComplete">
 <term>
 BindComplete (B)
 </term>
@@ -3933,7 +3933,7 @@ BindComplete (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-cancelrequest" xreflabel="CancelRequest">
 <term>
 CancelRequest (F)
 </term>
@@ -3991,7 +3991,7 @@ CancelRequest (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-close" xreflabel="Close">
 <term>
 Close (F)
 </term>
@@ -4048,7 +4048,7 @@ Close (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-closecomplete" xreflabel="CloseComplete">
 <term>
 CloseComplete (B)
 </term>
@@ -4083,7 +4083,7 @@ CloseComplete (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-commandcomplete" xreflabel="CommandComplete">
 <term>
 CommandComplete (B)
 </term>
@@ -4182,7 +4182,7 @@ CommandComplete (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-copydata" xreflabel="CopyData">
 <term>
 CopyData (F &amp; B)
 </term>
@@ -4228,7 +4228,7 @@ CopyData (F &amp; B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-copydone" xreflabel="CopyDone">
 <term>
 CopyDone (F &amp; B)
 </term>
@@ -4263,7 +4263,7 @@ CopyDone (F &amp; B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-copyfail" xreflabel="CopyFail">
 <term>
 CopyFail (F)
 </term>
@@ -4308,7 +4308,7 @@ CopyFail (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-copyinresponse" xreflabel="CopyInResponse">
 <term>
 CopyInResponse (B)
 </term>
@@ -4384,7 +4384,7 @@ CopyInResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-copyoutresponse" xreflabel="CopyOutResponse">
 <term>
 CopyOutResponse (B)
 </term>
@@ -4457,7 +4457,7 @@ CopyOutResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-copybothresponse" xreflabel="CopyBothResponse">
 <term>
 CopyBothResponse (B)
 </term>
@@ -4530,7 +4530,7 @@ CopyBothResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-datarow" xreflabel="DataRow">
 <term>
 DataRow (B)
 </term>
@@ -4602,7 +4602,7 @@ DataRow (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-describe" xreflabel="Describe">
 <term>
 Describe (F)
 </term>
@@ -4659,7 +4659,7 @@ Describe (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-emptyqueryresponse" xreflabel="EmptyQueryResponse">
 <term>
 EmptyQueryResponse (B)
 </term>
@@ -4695,7 +4695,7 @@ EmptyQueryResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-errorresponse" xreflabel="ErrorResponse">
 <term>
 ErrorResponse (B)
 </term>
@@ -4761,7 +4761,7 @@ ErrorResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-execute" xreflabel="Execute">
 <term>
 Execute (F)
 </term>
@@ -4818,7 +4818,7 @@ Execute (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-flush" xreflabel="Flush">
 <term>
 Flush (F)
 </term>
@@ -4853,7 +4853,7 @@ Flush (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-functioncall" xreflabel="FunctionCall">
 <term>
 FunctionCall (F)
 </term>
@@ -4978,7 +4978,7 @@ FunctionCall (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-functioncallresponse" xreflabel="FunctionCallResponse">
 <term>
 FunctionCallResponse (B)
 </term>
@@ -5038,7 +5038,7 @@ FunctionCallResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-gssencrequest" xreflabel="GSSENCRequest">
 <term>
 GSSENCRequest (F)
 </term>
@@ -5076,7 +5076,7 @@ GSSENCRequest (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-gssresponse" xreflabel="GSSResponse">
 <term>
 GSSResponse (F)
 </term>
@@ -5121,7 +5121,7 @@ GSSResponse (F)
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-negotiateprotocolversion" xreflabel="NegotiateProtocolVersion">
 <term>
 NegotiateProtocolVersion (B)
 </term>
@@ -5190,7 +5190,7 @@ NegotiateProtocolVersion (B)
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-nodata" xreflabel="NoData">
 <term>
 NoData (B)
 </term>
@@ -5225,7 +5225,7 @@ NoData (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-noticeresponse" xreflabel="NoticeResponse">
 <term>
 NoticeResponse (B)
 </term>
@@ -5291,7 +5291,7 @@ NoticeResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-notificationresponse" xreflabel="NotificationResponse">
 <term>
 NotificationResponse (B)
 </term>
@@ -5356,7 +5356,7 @@ NotificationResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-parameterdescription" xreflabel="ParameterDescription">
 <term>
 ParameterDescription (B)
 </term>
@@ -5414,7 +5414,7 @@ ParameterDescription (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-parameterstatus" xreflabel="ParameterStatus">
 <term>
 ParameterStatus (B)
 </term>
@@ -5468,7 +5468,7 @@ ParameterStatus (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-parse" xreflabel="Parse">
 <term>
 Parse (F)
 </term>
@@ -5552,7 +5552,7 @@ Parse (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-parsecomplete" xreflabel="ParseComplete">
 <term>
 ParseComplete (B)
 </term>
@@ -5587,7 +5587,7 @@ ParseComplete (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-passwordmessage" xreflabel="PasswordMessage">
 <term>
 PasswordMessage (F)
 </term>
@@ -5633,7 +5633,7 @@ PasswordMessage (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-portalsuspended" xreflabel="PortalSuspended">
 <term>
 PortalSuspended (B)
 </term>
@@ -5670,7 +5670,7 @@ PortalSuspended (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-query" xreflabel="Query">
 <term>
 Query (F)
 </term>
@@ -5715,7 +5715,7 @@ Query (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-readyforquery" xreflabel="ReadyForQuery">
 <term>
 ReadyForQuery (B)
 </term>
@@ -5765,7 +5765,7 @@ ReadyForQuery (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-rowdescription" xreflabel="RowDescription">
 <term>
 RowDescription (B)
 </term>
@@ -5890,7 +5890,7 @@ RowDescription (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-saslinitialresponse" xreflabel="SASLInitialResponse">
 <term>
 SASLInitialResponse (F)
 </term>
@@ -5958,7 +5958,7 @@ SASLInitialResponse (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-saslresponse" xreflabel="SASLResponse">
 <term>
 SASLResponse (F)
 </term>
@@ -6004,7 +6004,7 @@ SASLResponse (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-sslrequest" xreflabel="SSLRequest">
 <term>
 SSLRequest (F)
 </term>
@@ -6042,7 +6042,7 @@ SSLRequest (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-startupmessage" xreflabel="StartupMessage">
 <term>
 StartupMessage (F)
 </term>
@@ -6171,7 +6171,7 @@ StartupMessage (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-sync" xreflabel="Sync">
 <term>
 Sync (F)
 </term>
@@ -6206,7 +6206,7 @@ Sync (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-terminate" xreflabel="Terminate">
 <term>
 Terminate (F)
 </term>
@@ -6537,7 +6537,7 @@ flow as physical replication.
 
 <variablelist>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-begin" xreflabel="Begin">
 <term>
 Begin
 </term>
@@ -6592,7 +6592,7 @@ Begin
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-message" xreflabel="Message">
 <term>
 Message
 </term>
@@ -6680,7 +6680,7 @@ Message
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-commit" xreflabel="Commit">
 <term>
 Commit
 </term>
@@ -6745,7 +6745,7 @@ Commit
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-origin" xreflabel="Origin">
 <term>
 Origin
 </term>
@@ -6794,7 +6794,7 @@ Origin
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-relation" xreflabel="Relation">
 <term>
 Relation
 </term>
@@ -6926,7 +6926,7 @@ Relation
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-type" xreflabel="Type">
 <term>
 Type
 </term>
@@ -6991,7 +6991,7 @@ Type
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-insert" xreflabel="Insert">
 <term>
 Insert
 </term>
@@ -7058,7 +7058,7 @@ Insert
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-update" xreflabel="Update">
 <term>
 Update
 </term>
@@ -7172,7 +7172,7 @@ Update
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-delete" xreflabel="Delete">
 <term>
 Delete
 </term>
@@ -7261,7 +7261,7 @@ Delete
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-truncate" xreflabel="Truncate">
 <term>
 Truncate
 </term>
@@ -7339,7 +7339,7 @@ Stream Abort) are available since protocol version 2.
 
 <variablelist>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-stream-start" xreflabel="Stream Start">
 <term>
 Stream Start
 </term>
@@ -7384,7 +7384,7 @@ Stream Start
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-stream-stop" xreflabel="Stream Stop">
 <term>
 Stream Stop
 </term>
@@ -7408,7 +7408,7 @@ Stream Stop
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-stream-commit" xreflabel="Stream Commit">
 <term>
 Stream Commit
 </term>
@@ -7483,7 +7483,7 @@ Stream Commit
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-stream-abort" xreflabel="Stream Abort">
 <term>
 Stream Abort
 </term>
@@ -7537,7 +7537,7 @@ are available since protocol version 3.
 
 <variablelist>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-begin-prepare" xreflabel="Begin Prepare">
 
 <term>Begin Prepare</term>
 <listitem>
@@ -7602,7 +7602,7 @@ are available since protocol version 3.
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-prepare" xreflabel="Prepare">
 
 <term>Prepare</term>
 <listitem>
@@ -7676,7 +7676,7 @@ are available since protocol version 3.
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-commit-prepared" xreflabel="Commit Prepared">
 
 <term>Commit Prepared</term>
 <listitem>
@@ -7750,7 +7750,7 @@ are available since protocol version 3.
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-rollback-prepared" xreflabel="Rollback Prepared">
 
 <term>Rollback Prepared</term>
 <listitem>
@@ -7834,7 +7834,7 @@ are available since protocol version 3.
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-stream-prepare" xreflabel="Stream Prepare">
 
 <term>Stream Prepare</term>
 <listitem>
@@ -7918,7 +7918,7 @@ The following message parts are shared by the above messages.
 
 <variablelist>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-tupledata" xreflabel="TupleData">
 <term>
 TupleData
 </term>
#2Daniel Gustafsson
daniel@yesql.se
In reply to: Brar Piening (#1)
Re: Add id's to various elements in protocol.sgml

On 5 Dec 2021, at 16:51, Brar Piening <brar@gmx.de> wrote:

The attached patch adds id's to various elements in protocol.sgml to
make them more accesssible via the public html documentation interface.

Off the cuff without having checked the compiled results yet, it seems like a good idea.


Daniel Gustafsson

#3Corey Huinker
corey.huinker@gmail.com
In reply to: Daniel Gustafsson (#2)
Re: Add id's to various elements in protocol.sgml

On Sun, Dec 5, 2021 at 11:15 AM Daniel Gustafsson <daniel@yesql.se> wrote:

On 5 Dec 2021, at 16:51, Brar Piening <brar@gmx.de> wrote:

The attached patch adds id's to various elements in protocol.sgml to
make them more accesssible via the public html documentation interface.

Off the cuff without having checked the compiled results yet, it seems
like a good idea.


Daniel Gustafsson

I wanted to do something similar for every function specification in the
docs. This may inspire me to take another shot at that.

#4Alvaro Herrera
alvherre@alvh.no-ip.org
In reply to: Brar Piening (#1)
Re: Add id's to various elements in protocol.sgml

On 2021-Dec-05, Brar Piening wrote:

When working with the Frontend/Backend Protocol implementation in Npgsql
and discussing things with the team, I often struggle with the fact that
you can't set deep links to individual message formats in the somewhat
lengthy html docs pages.

The attached patch adds id's to various elements in protocol.sgml to
make them more accesssible via the public html documentation interface.

I've tried to follow the style that was already there in a few of the
elements.

Hmm, I think we tend to avoid xreflabels; see
/messages/by-id/8315c0ca-7758-8823-fcb6-f37f9413e6b6@2ndquadrant.com

--
Álvaro Herrera Valdivia, Chile — https://www.EnterpriseDB.com/

#5Brar Piening
brar@gmx.de
In reply to: Alvaro Herrera (#4)
Re: Add id's to various elements in protocol.sgml

On Dec 14, 2021 at 20:47, Alvaro Herrera wrote:

Hmm, I think we tend to avoid xreflabels; see
/messages/by-id/8315c0ca-7758-8823-fcb6-f37f9413e6b6@2ndquadrant.com

Ok, thank you for the hint.
I added them because <varlistentry> doesn't automatically generate
labels and they were present in the current docs for
CREATE_REPLICATION_SLOT
(https://github.com/postgres/postgres/blob/22bd3cbe0c284758d7174321f5596763095cdd55/doc/src/sgml/protocol.sgml#L1944).

After reading the aforementioned thread to
/messages/by-id/20200611223836.GA2507@momjian.us
I infer the following conclusions:
a) Do *not* include xreflabel for elements that get numbered.
b) There should be some general utility for the xreflabel, not just the
linking needs of one particular source location.
c) Generally, xreflabels are a bit of antipattern, so there need to be
solid arguments in favor of adding more.

Since I can't argue towards some general utility for the xreflabels and
don't have any other solid argument in favor of adding more, I will
remove them from my current patch but leave the existing ones intact.

Objections?

#6Alvaro Herrera
alvherre@alvh.no-ip.org
In reply to: Brar Piening (#5)
Re: Add id's to various elements in protocol.sgml

On 2021-Dec-15, Brar Piening wrote:

On Dec 14, 2021 at 20:47, Alvaro Herrera wrote:

Hmm, I think we tend to avoid xreflabels; see
/messages/by-id/8315c0ca-7758-8823-fcb6-f37f9413e6b6@2ndquadrant.com

Ok, thank you for the hint.
I added them because <varlistentry> doesn't automatically generate
labels and they were present in the current docs for
CREATE_REPLICATION_SLOT
(https://github.com/postgres/postgres/blob/22bd3cbe0c284758d7174321f5596763095cdd55/doc/src/sgml/protocol.sgml#L1944).

Hmm, now that you mention it, we do have xreflabels for varlistentrys in
quite a few places. Maybe we need to update README.links to mention
this.

Since I can't argue towards some general utility for the xreflabels and
don't have any other solid argument in favor of adding more, I will
remove them from my current patch but leave the existing ones intact.

Yeah, I think not adding them until we have a use for them might be
wisest.

--
Álvaro Herrera 39°49'30"S 73°17'W — https://www.EnterpriseDB.com/
"La vida es para el que se aventura"

#7Brar Piening
brar@gmx.de
In reply to: Alvaro Herrera (#6)
1 attachment(s)
Re: Add id's to various elements in protocol.sgml

On Dec 15, 2021 at 15:49, Alvaro Herrera wrote:

On 2021-Dec-15, Brar Piening wrote:

Since I can't argue towards some general utility for the xreflabels
and don't have any other solid argument in favor of adding more, I
will remove them from my current patch but leave the existing ones
intact.

Yeah, I think not adding them until we have a use for them might be
wisest.

A new version of the patch that doesn't add xreflabels is attached.
Thanks for your support.

Attachments:

protocol.sgml-anchors_v2.patchtext/plain; charset=UTF-8; name=protocol.sgml-anchors_v2.patchDownload
diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml
index 34a7034282..0bca5831b1 100644
--- a/doc/src/sgml/protocol.sgml
+++ b/doc/src/sgml/protocol.sgml
@@ -1810,7 +1810,7 @@ Replication commands are logged in the server log when
 <para>
 The commands accepted in replication mode are:
 <variablelist>
-  <varlistentry>
+  <varlistentry id="protocol-replication-identify-system">
     <term><literal>IDENTIFY_SYSTEM</literal>
      <indexterm><primary>IDENTIFY_SYSTEM</primary></indexterm>
     </term>
@@ -1875,7 +1875,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-show">
     <term><literal>SHOW</literal> <replaceable class="parameter">name</replaceable>
      <indexterm><primary>SHOW</primary></indexterm>
     </term>
@@ -1899,7 +1899,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-timeline-history">
     <term><literal>TIMELINE_HISTORY</literal> <replaceable class="parameter">tli</replaceable>
      <indexterm><primary>TIMELINE_HISTORY</primary></indexterm>
     </term>
@@ -2084,7 +2084,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-create-slot-legacy">
     <term><literal>CREATE_REPLICATION_SLOT</literal> <replaceable class="parameter">slot_name</replaceable> [ <literal>TEMPORARY</literal> ] { <literal>PHYSICAL</literal> [ <literal>RESERVE_WAL</literal> ] | <literal>LOGICAL</literal> <replaceable class="parameter">output_plugin</replaceable> [ <literal>EXPORT_SNAPSHOT</literal> | <literal>NOEXPORT_SNAPSHOT</literal> | <literal>USE_SNAPSHOT</literal> | <literal>TWO_PHASE</literal> ] }
     </term>
     <listitem>
@@ -2095,7 +2095,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-read-replication-slot">
     <term><literal>READ_REPLICATION_SLOT</literal> <replaceable class="parameter">slot_name</replaceable>
       <indexterm><primary>READ_REPLICATION_SLOT</primary></indexterm>
     </term>
@@ -2143,7 +2143,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-start-replication">
     <term><literal>START_REPLICATION</literal> [ <literal>SLOT</literal> <replaceable class="parameter">slot_name</replaceable> ] [ <literal>PHYSICAL</literal> ] <replaceable class="parameter">XXX/XXX</replaceable> [ <literal>TIMELINE</literal> <replaceable class="parameter">tli</replaceable> ]
      <indexterm><primary>START_REPLICATION</primary></indexterm>
     </term>
@@ -2201,7 +2201,7 @@ The commands accepted in replication mode are:
 
      <para>
       <variablelist>
-      <varlistentry>
+      <varlistentry id="protocol-replication-xlogdata">
       <term>
           XLogData (B)
       </term>
@@ -2270,7 +2270,7 @@ The commands accepted in replication mode are:
       </para>
       </listitem>
       </varlistentry>
-      <varlistentry>
+      <varlistentry id="protocol-replication-primary-keepalive-message">
       <term>
           Primary keepalive message (B)
       </term>
@@ -2334,7 +2334,7 @@ The commands accepted in replication mode are:
 
      <para>
       <variablelist>
-      <varlistentry>
+      <varlistentry id="protocol-replication-standby-status-update">
       <term>
           Standby status update (F)
       </term>
@@ -2415,7 +2415,7 @@ The commands accepted in replication mode are:
 
      <para>
       <variablelist>
-      <varlistentry>
+      <varlistentry id="protocol-replication-hot-standby-feedback-message">
       <term>
           Hot Standby feedback message (F)
       </term>
@@ -2497,7 +2497,7 @@ The commands accepted in replication mode are:
      </para>
     </listitem>
   </varlistentry>
-  <varlistentry>
+  <varlistentry id="protocol-replication-start-replication-slot-logical">
     <term><literal>START_REPLICATION</literal> <literal>SLOT</literal> <replaceable class="parameter">slot_name</replaceable> <literal>LOGICAL</literal> <replaceable class="parameter">XXX/XXX</replaceable> [ ( <replaceable>option_name</replaceable> [ <replaceable>option_value</replaceable> ] [, ...] ) ]</term>
     <listitem>
      <para>
@@ -2572,7 +2572,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-drop-replication-slot">
     <term>
      <literal>DROP_REPLICATION_SLOT</literal> <replaceable class="parameter">slot_name</replaceable> <optional> <literal>WAIT</literal> </optional>
      <indexterm><primary>DROP_REPLICATION_SLOT</primary></indexterm>
@@ -2886,7 +2886,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-base-backup-legacy">
     <term><literal>BASE_BACKUP</literal> [ <literal>LABEL</literal> <replaceable>'label'</replaceable> ] [ <literal>PROGRESS</literal> ] [ <literal>FAST</literal> ] [ <literal>WAL</literal> ] [ <literal>NOWAIT</literal> ] [ <literal>MAX_RATE</literal> <replaceable>rate</replaceable> ] [ <literal>TABLESPACE_MAP</literal> ] [ <literal>NOVERIFY_CHECKSUMS</literal> ] [ <literal>MANIFEST</literal> <replaceable>manifest_option</replaceable> ] [ <literal>MANIFEST_CHECKSUMS</literal> <replaceable>checksum_algorithm</replaceable> ]
     </term>
     <listitem>
@@ -3138,7 +3138,7 @@ of any individual CopyData message cannot be interpretable on their own.)
 <variablelist>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationok">
 <term>
 AuthenticationOk (B)
 </term>
@@ -3183,7 +3183,7 @@ AuthenticationOk (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationkerberosv5">
 <term>
 AuthenticationKerberosV5 (B)
 </term>
@@ -3227,7 +3227,7 @@ AuthenticationKerberosV5 (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationcleartextpassword">
 <term>
 AuthenticationCleartextPassword (B)
 </term>
@@ -3271,7 +3271,7 @@ AuthenticationCleartextPassword (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationmd5password">
 <term>
 AuthenticationMD5Password (B)
 </term>
@@ -3326,7 +3326,7 @@ AuthenticationMD5Password (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationscmcredential">
 <term>
 AuthenticationSCMCredential (B)
 </term>
@@ -3371,7 +3371,7 @@ AuthenticationSCMCredential (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationgss">
 <term>
 AuthenticationGSS (B)
 </term>
@@ -3416,7 +3416,7 @@ AuthenticationGSS (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationgsscontinue">
 <term>
 AuthenticationGSSContinue (B)
 </term>
@@ -3471,7 +3471,7 @@ AuthenticationGSSContinue (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationsspi">
 <term>
 AuthenticationSSPI (B)
 </term>
@@ -3516,7 +3516,7 @@ AuthenticationSSPI (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationsasl">
 <term>
 AuthenticationSASL (B)
 </term>
@@ -3577,7 +3577,7 @@ following:
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationsaslcontinue">
 <term>
 AuthenticationSASLContinue (B)
 </term>
@@ -3632,7 +3632,7 @@ AuthenticationSASLContinue (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationsaslfinal">
 <term>
 AuthenticationSASLFinal (B)
 </term>
@@ -3688,7 +3688,7 @@ AuthenticationSASLFinal (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-backendkeydata">
 <term>
 BackendKeyData (B)
 </term>
@@ -3745,7 +3745,7 @@ BackendKeyData (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-bind">
 <term>
 Bind (F)
 </term>
@@ -3898,7 +3898,7 @@ Bind (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-bindcomplete">
 <term>
 BindComplete (B)
 </term>
@@ -3933,7 +3933,7 @@ BindComplete (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-cancelrequest">
 <term>
 CancelRequest (F)
 </term>
@@ -3991,7 +3991,7 @@ CancelRequest (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-close">
 <term>
 Close (F)
 </term>
@@ -4048,7 +4048,7 @@ Close (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-closecomplete">
 <term>
 CloseComplete (B)
 </term>
@@ -4083,7 +4083,7 @@ CloseComplete (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-commandcomplete">
 <term>
 CommandComplete (B)
 </term>
@@ -4182,7 +4182,7 @@ CommandComplete (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-copydata">
 <term>
 CopyData (F &amp; B)
 </term>
@@ -4228,7 +4228,7 @@ CopyData (F &amp; B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-copydone">
 <term>
 CopyDone (F &amp; B)
 </term>
@@ -4263,7 +4263,7 @@ CopyDone (F &amp; B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-copyfail">
 <term>
 CopyFail (F)
 </term>
@@ -4308,7 +4308,7 @@ CopyFail (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-copyinresponse">
 <term>
 CopyInResponse (B)
 </term>
@@ -4384,7 +4384,7 @@ CopyInResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-copyoutresponse">
 <term>
 CopyOutResponse (B)
 </term>
@@ -4457,7 +4457,7 @@ CopyOutResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-copybothresponse">
 <term>
 CopyBothResponse (B)
 </term>
@@ -4530,7 +4530,7 @@ CopyBothResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-datarow">
 <term>
 DataRow (B)
 </term>
@@ -4602,7 +4602,7 @@ DataRow (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-describe">
 <term>
 Describe (F)
 </term>
@@ -4659,7 +4659,7 @@ Describe (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-emptyqueryresponse">
 <term>
 EmptyQueryResponse (B)
 </term>
@@ -4695,7 +4695,7 @@ EmptyQueryResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-errorresponse">
 <term>
 ErrorResponse (B)
 </term>
@@ -4761,7 +4761,7 @@ ErrorResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-execute">
 <term>
 Execute (F)
 </term>
@@ -4818,7 +4818,7 @@ Execute (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-flush">
 <term>
 Flush (F)
 </term>
@@ -4853,7 +4853,7 @@ Flush (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-functioncall">
 <term>
 FunctionCall (F)
 </term>
@@ -4978,7 +4978,7 @@ FunctionCall (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-functioncallresponse">
 <term>
 FunctionCallResponse (B)
 </term>
@@ -5038,7 +5038,7 @@ FunctionCallResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-gssencrequest">
 <term>
 GSSENCRequest (F)
 </term>
@@ -5076,7 +5076,7 @@ GSSENCRequest (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-gssresponse">
 <term>
 GSSResponse (F)
 </term>
@@ -5121,7 +5121,7 @@ GSSResponse (F)
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-negotiateprotocolversion">
 <term>
 NegotiateProtocolVersion (B)
 </term>
@@ -5190,7 +5190,7 @@ NegotiateProtocolVersion (B)
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-nodata">
 <term>
 NoData (B)
 </term>
@@ -5225,7 +5225,7 @@ NoData (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-noticeresponse">
 <term>
 NoticeResponse (B)
 </term>
@@ -5291,7 +5291,7 @@ NoticeResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-notificationresponse">
 <term>
 NotificationResponse (B)
 </term>
@@ -5356,7 +5356,7 @@ NotificationResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-parameterdescription">
 <term>
 ParameterDescription (B)
 </term>
@@ -5414,7 +5414,7 @@ ParameterDescription (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-parameterstatus">
 <term>
 ParameterStatus (B)
 </term>
@@ -5468,7 +5468,7 @@ ParameterStatus (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-parse">
 <term>
 Parse (F)
 </term>
@@ -5552,7 +5552,7 @@ Parse (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-parsecomplete">
 <term>
 ParseComplete (B)
 </term>
@@ -5587,7 +5587,7 @@ ParseComplete (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-passwordmessage">
 <term>
 PasswordMessage (F)
 </term>
@@ -5633,7 +5633,7 @@ PasswordMessage (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-portalsuspended">
 <term>
 PortalSuspended (B)
 </term>
@@ -5670,7 +5670,7 @@ PortalSuspended (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-query">
 <term>
 Query (F)
 </term>
@@ -5715,7 +5715,7 @@ Query (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-readyforquery">
 <term>
 ReadyForQuery (B)
 </term>
@@ -5765,7 +5765,7 @@ ReadyForQuery (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-rowdescription">
 <term>
 RowDescription (B)
 </term>
@@ -5890,7 +5890,7 @@ RowDescription (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-saslinitialresponse">
 <term>
 SASLInitialResponse (F)
 </term>
@@ -5958,7 +5958,7 @@ SASLInitialResponse (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-saslresponse">
 <term>
 SASLResponse (F)
 </term>
@@ -6004,7 +6004,7 @@ SASLResponse (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-sslrequest">
 <term>
 SSLRequest (F)
 </term>
@@ -6042,7 +6042,7 @@ SSLRequest (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-startupmessage">
 <term>
 StartupMessage (F)
 </term>
@@ -6171,7 +6171,7 @@ StartupMessage (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-sync">
 <term>
 Sync (F)
 </term>
@@ -6206,7 +6206,7 @@ Sync (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-terminate">
 <term>
 Terminate (F)
 </term>
@@ -6537,7 +6537,7 @@ flow as physical replication.
 
 <variablelist>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-begin">
 <term>
 Begin
 </term>
@@ -6592,7 +6592,7 @@ Begin
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-message">
 <term>
 Message
 </term>
@@ -6680,7 +6680,7 @@ Message
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-commit">
 <term>
 Commit
 </term>
@@ -6745,7 +6745,7 @@ Commit
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-origin">
 <term>
 Origin
 </term>
@@ -6794,7 +6794,7 @@ Origin
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-relation">
 <term>
 Relation
 </term>
@@ -6926,7 +6926,7 @@ Relation
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-type">
 <term>
 Type
 </term>
@@ -6991,7 +6991,7 @@ Type
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-insert">
 <term>
 Insert
 </term>
@@ -7058,7 +7058,7 @@ Insert
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-update">
 <term>
 Update
 </term>
@@ -7172,7 +7172,7 @@ Update
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-delete">
 <term>
 Delete
 </term>
@@ -7261,7 +7261,7 @@ Delete
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-truncate">
 <term>
 Truncate
 </term>
@@ -7339,7 +7339,7 @@ Stream Abort) are available since protocol version 2.
 
 <variablelist>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-stream-start">
 <term>
 Stream Start
 </term>
@@ -7384,7 +7384,7 @@ Stream Start
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-stream-stop">
 <term>
 Stream Stop
 </term>
@@ -7408,7 +7408,7 @@ Stream Stop
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-stream-commit">
 <term>
 Stream Commit
 </term>
@@ -7483,7 +7483,7 @@ Stream Commit
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-stream-abort">
 <term>
 Stream Abort
 </term>
@@ -7537,7 +7537,7 @@ are available since protocol version 3.
 
 <variablelist>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-begin-prepare">
 
 <term>Begin Prepare</term>
 <listitem>
@@ -7602,7 +7602,7 @@ are available since protocol version 3.
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-prepare">
 
 <term>Prepare</term>
 <listitem>
@@ -7676,7 +7676,7 @@ are available since protocol version 3.
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-commit-prepared">
 
 <term>Commit Prepared</term>
 <listitem>
@@ -7750,7 +7750,7 @@ are available since protocol version 3.
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-rollback-prepared">
 
 <term>Rollback Prepared</term>
 <listitem>
@@ -7834,7 +7834,7 @@ are available since protocol version 3.
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-stream-prepare">
 
 <term>Stream Prepare</term>
 <listitem>
@@ -7918,7 +7918,7 @@ The following message parts are shared by the above messages.
 
 <variablelist>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-tupledata">
 <term>
 TupleData
 </term>
#8Peter Eisentraut
peter.eisentraut@enterprisedb.com
In reply to: Brar Piening (#7)
Re: Add id's to various elements in protocol.sgml

On 15.12.21 16:59, Brar Piening wrote:

On Dec 15, 2021 at 15:49, Alvaro Herrera wrote:

On 2021-Dec-15, Brar Piening wrote:

Since I can't argue towards some general utility for the xreflabels
and don't have any other solid argument in favor of adding more, I
will remove them from my current patch but leave the existing ones
intact.

Yeah, I think not adding them until we have a use for them might be
wisest.

A new version of the patch that doesn't add xreflabels is attached.

Now this patch adds a bunch of ids, but you can't use them to link to,
because as soon as you do, you will get complaints about a missing
xreflabel. So what is the remaining purpose?

#9Brar Piening
brar@gmx.de
In reply to: Peter Eisentraut (#8)
Re: Add id's to various elements in protocol.sgml

On Dec 17, 2021 at 08:13, Peter Eisentraut wrote:

On 15.12.21 16:59, Brar Piening wrote:

On Dec 15, 2021 at 15:49, Alvaro Herrera wrote:

On 2021-Dec-15, Brar Piening wrote:

Since I can't argue towards some general utility for the xreflabels
and don't have any other solid argument in favor of adding more, I
will remove them from my current patch but leave the existing ones
intact.

Yeah, I think not adding them until we have a use for them might be
wisest.

A new version of the patch that doesn't add xreflabels is attached.

Now this patch adds a bunch of ids, but you can't use them to link to,
because as soon as you do, you will get complaints about a missing
xreflabel.  So what is the remaining purpose?

The purpose is that you can directly link to the id in the public html
docs which still gets generated (e. g.
https://www.postgresql.org/docs/14/protocol-replication.html#PROTOCOL-REPLICATION-BASE-BACKUP).

Essentially it gives people discussing the protocol and pointing to a
certain command or message format the chance to link to the very thing
they are discussing instead of the top of the lengthy html page.

#10Robert Haas
robertmhaas@gmail.com
In reply to: Brar Piening (#9)
Re: Add id's to various elements in protocol.sgml

On Fri, Dec 17, 2021 at 6:54 PM Brar Piening <brar@gmx.de> wrote:

The purpose is that you can directly link to the id in the public html
docs which still gets generated (e. g.
https://www.postgresql.org/docs/14/protocol-replication.html#PROTOCOL-REPLICATION-BASE-BACKUP).

Essentially it gives people discussing the protocol and pointing to a
certain command or message format the chance to link to the very thing
they are discussing instead of the top of the lengthy html page.

As a data point, this is something I have also wanted to do, from time
to time. I am generally of the opinion that any place the
documentation has a long list of things, which should add ids, so that
people can link to the particular thing in the list to which they want
to draw someone's attention.

--
Robert Haas
EDB: http://www.enterprisedb.com

#11Brar Piening
brar@gmx.de
In reply to: Robert Haas (#10)
Re: Add id's to various elements in protocol.sgml

On 20.12.2021 at 16:09, Robert Haas wrote:

As a data point, this is something I have also wanted to do, from time
to time. I am generally of the opinion that any place the
documentation has a long list of things, which should add ids, so that
people can link to the particular thing in the list to which they want
to draw someone's attention.

Thank you.

If there is consensus on generally adding links to long lists I'd take
suggestions for other places where people think that this would make
sense and amend my patch.

#12Peter Eisentraut
peter.eisentraut@enterprisedb.com
In reply to: Brar Piening (#9)
Re: Add id's to various elements in protocol.sgml

On 18.12.21 00:53, Brar Piening wrote:

The purpose is that you can directly link to the id in the public html
docs which still gets generated (e. g.
https://www.postgresql.org/docs/14/protocol-replication.html#PROTOCOL-REPLICATION-BASE-BACKUP).

Essentially it gives people discussing the protocol and pointing to a
certain command or message format the chance to link to the very thing
they are discussing instead of the top of the lengthy html page.

Is there a way to obtain those URLs other than going into the HTML
sources and checking if there is an anchor near where you want go?

In reply to: Peter Eisentraut (#12)
Re: Add id's to various elements in protocol.sgml

Peter Eisentraut <peter.eisentraut@enterprisedb.com> writes:

On 18.12.21 00:53, Brar Piening wrote:

The purpose is that you can directly link to the id in the public html
docs which still gets generated (e. g.
https://www.postgresql.org/docs/14/protocol-replication.html#PROTOCOL-REPLICATION-BASE-BACKUP).
Essentially it gives people discussing the protocol and pointing to a
certain command or message format the chance to link to the very thing
they are discussing instead of the top of the lengthy html page.

Is there a way to obtain those URLs other than going into the HTML
sources and checking if there is an anchor near where you want go?

I use the jump-to-anchor extension: https://github.com/brettz9/jump-to-anchor/

Some sites have javascript that adds a link next to the element that
becomes visible when hovering, e.g. the NAME and other headings on
https://metacpan.org/pod/perl.

- ilmari

#14Alvaro Herrera
alvherre@alvh.no-ip.org
In reply to: Dagfinn Ilmari Mannsåker (#13)
Re: Add id's to various elements in protocol.sgml

On 2022-Feb-24, Dagfinn Ilmari Mannsåker wrote:

Peter Eisentraut <peter.eisentraut@enterprisedb.com> writes:

Is there a way to obtain those URLs other than going into the HTML
sources and checking if there is an anchor near where you want go?

I use the jump-to-anchor extension: https://github.com/brettz9/jump-to-anchor/

Some sites have javascript that adds a link next to the element that
becomes visible when hovering, e.g. the NAME and other headings on
https://metacpan.org/pod/perl.

Would it be possible to create such anchor links as part of the XSL
stylesheets for HTML?

--
Álvaro Herrera 39°49'30"S 73°17'W — https://www.EnterpriseDB.com/

#15Brar Piening
brar@gmx.de
In reply to: Alvaro Herrera (#14)
Re: Add id's to various elements in protocol.sgml

On 24.02.2022 at 16:46, Alvaro Herrera wrote:

On 2022-Feb-24, Dagfinn Ilmari Mannsåker wrote:

Peter Eisentraut <peter.eisentraut@enterprisedb.com> writes:

Is there a way to obtain those URLs other than going into the HTML
sources and checking if there is an anchor near where you want go?

I use the jump-to-anchor extension: https://github.com/brettz9/jump-to-anchor/

Some sites have javascript that adds a link next to the element that
becomes visible when hovering, e.g. the NAME and other headings on
https://metacpan.org/pod/perl.

Would it be possible to create such anchor links as part of the XSL
stylesheets for HTML?

Initially I thought that most use cases would involve developers who
would be perfectly capable of extracting the id they need from the html
sources but I agree that making that a bit more comfortable (especially
given the fact that others do that too) seems worthwhile.

I'll investiogate our options and report back.

#16Kyotaro Horiguchi
horikyota.ntt@gmail.com
In reply to: Brar Piening (#11)
Re: Add id's to various elements in protocol.sgml

At Tue, 21 Dec 2021 08:47:27 +0100, Brar Piening <brar@gmx.de> wrote in

On 20.12.2021 at 16:09, Robert Haas wrote:

As a data point, this is something I have also wanted to do, from time
to time. I am generally of the opinion that any place the

+1 from me. When I put an URL in the answer for inquiries, I always
look into the html for name/id tags so that the inquirer quickly find
the information source (or the backing or reference point) on the
page. If not found, I place a snippet instead.

documentation has a long list of things, which should add ids, so that
people can link to the particular thing in the list to which they want
to draw someone's attention.

Thank you.

If there is consensus on generally adding links to long lists I'd take
suggestions for other places where people think that this would make
sense and amend my patch.

I don't think there is.

I remember sometimes wanted ids on some sections(x.x) and
items(x.x.x or lower) (or even clauses, ignoring costs:p)

FWIW in that perspecive, there's no requirement from me that it should
be human-readable. I'm fine with automatically-generated ids.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

#17Chapman Flack
chap@anastigmatix.net
In reply to: Kyotaro Horiguchi (#16)
Re: Add id's to various elements in protocol.sgml

On 02/24/22 19:52, Kyotaro Horiguchi wrote:

FWIW in that perspecive, there's no requirement from me that it should
be human-readable. I'm fine with automatically-generated ids.

One thing I would be −many on, though, would be automatically-generated ids
that are not, somehow, stable. I've been burned too many times making links
to auto-generated anchors in other projects' docs that change every time
they republish the wretched things.

Regards,
-Chap

#18Maciek Sakrejda
m.sakrejda@gmail.com
In reply to: Kyotaro Horiguchi (#16)
Re: Add id's to various elements in protocol.sgml

On Thu, Feb 24, 2022, 16:52 Kyotaro Horiguchi <horikyota.ntt@gmail.com>
wrote:

At Tue, 21 Dec 2021 08:47:27 +0100, Brar Piening <brar@gmx.de> wrote in

On 20.12.2021 at 16:09, Robert Haas wrote:

As a data point, this is something I have also wanted to do, from time
to time. I am generally of the opinion that any place the

+1 from me. When I put an URL in the answer for inquiries, I always
look into the html for name/id tags so that the inquirer quickly find
the information source (or the backing or reference point) on the
page.

+1 here as well. I often do the exact same thing. It's not hard, but it's a
little tedious, especially considering most modern doc systems support
linkable sections.

#19Brar Piening
brar@gmx.de
In reply to: Brar Piening (#15)
Re: Add id's to various elements in protocol.sgml

On 24.02.2022 at 17:07, Brar Piening wrote:

On 24.02.2022 at 16:46, Alvaro Herrera wrote:

Would it be possible to create such anchor links as part of the XSL
stylesheets for HTML?

I'll investiogate our options and report back.

Yes, that would be possible. In fact appending a link and optionally
adding a tiny bit of CSS like I show below does the trick.

The major problem in that regard would probably be my lack of
XSLT/docbook skills but if no one can jump in here, I can see if I can
make it work.

Obviously adding the links via javascript would also work (and even be
easier for me personally) but that seems like the second best solution
to me since it involves javascript where no javasript is needed.

Personally I consider having ids to link to and making them more
comfortable to use/find as orthogonal problems in that case (mostly
developer documentation) so IMHO solving this doesn't necessarily need
to hold back the original patch.

<dl class="variablelist">
  <dt id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS-INSERT">
    <span class="term">Insert</span>
    <a href="#PROTOCOL-LOGICALREP-MESSAGE-FORMATS-INSERT"
class="anchor">#</a></dt>
  <dd>...</dd>
</dl>

<!-- Optional style to hide the links and make them visible on hover -->
<style>
.variablelist a.anchor {
  visibility: hidden;
}
.variablelist *:hover > a.anchor,
.variablelist a.anchor:focus {
  visibility: visible;
}
</style>

#20Peter Eisentraut
peter.eisentraut@enterprisedb.com
In reply to: Brar Piening (#19)
Re: Add id's to various elements in protocol.sgml

On 25.02.22 06:36, Brar Piening wrote:

Yes, that would be possible. In fact appending a link and optionally
adding a tiny bit of CSS like I show below does the trick.

The major problem in that regard would probably be my lack of
XSLT/docbook skills but if no one can jump in here, I can see if I can
make it work.

I think that kind of stuff would be added in via the web site
stylesheets, so you wouldn't have to deal with XSLT at all.

#21Brar Piening
brar@gmx.de
In reply to: Peter Eisentraut (#20)
Re: Add id's to various elements in protocol.sgml

On Feb 25, 2022 at 14:31, Peter Eisentraut wrote:

I think that kind of stuff would be added in via the web site
stylesheets, so you wouldn't have to deal with XSLT at all.

True for the CSS but  adding the HTML (<a
href="#PROTOCOL-LOGICALREP-MESSAGE-FORMATS-INSERT" class="anchor">#</a>)
will need either XSLT or Javascript.

#22Peter Eisentraut
peter.eisentraut@enterprisedb.com
In reply to: Brar Piening (#21)
Re: Add id's to various elements in protocol.sgml

On 28.02.22 09:41, Brar Piening wrote:

On Feb 25, 2022 at 14:31, Peter Eisentraut wrote:

I think that kind of stuff would be added in via the web site
stylesheets, so you wouldn't have to deal with XSLT at all.

True for the CSS but  adding the HTML (<a
href="#PROTOCOL-LOGICALREP-MESSAGE-FORMATS-INSERT" class="anchor">#</a>)
will need either XSLT or Javascript.

That is already done by your proposed patch, isn't it?

#23Brar Piening
brar@gmx.de
In reply to: Peter Eisentraut (#22)
Re: Add id's to various elements in protocol.sgml

On 28.02.2022 at 10:24, Peter Eisentraut wrote:

On 28.02.22 09:41, Brar Piening wrote:

On Feb 25, 2022 at 14:31, Peter Eisentraut wrote:

I think that kind of stuff would be added in via the web site
stylesheets, so you wouldn't have to deal with XSLT at all.

True for the CSS but  adding the HTML (<a
href="#PROTOCOL-LOGICALREP-MESSAGE-FORMATS-INSERT" class="anchor">#</a>)
will need either XSLT or Javascript.

That is already done by your proposed patch, isn't it?

No it isn't. My proposed patch performs the simple task of adding ids to
the dt elements (e.g. <dt id="PROTOCOL-LOGICALREP-MESSAGE-FORMATS-INSERT">).

This makes them usable as targets for links but they remain invisible to
users of the docs who don't know about them, and unusable to users who
don't know how to extract them from the HTML source code.

The links (e.g. <a href="#PROTOCOL-LOGICALREP-MESSAGE-FORMATS-INSERT"
class="anchor">#</a>) aren't added by the current XSLT transformations
from Docbooc to HTML.

Adding them would create a visible element (I propose a hash '#') next
to the description term (inside the <dt> element after the text) that
you can click on to put the link into the address bar, from where it can
be copied for further usage.

#24Brar Piening
brar@gmx.de
In reply to: Brar Piening (#19)
1 attachment(s)
Re: Add id's to various elements in protocol.sgml

On Feb 25, 2022 at 06:36, Brar Piening wrote:

The major problem in that regard would probably be my lack of
XSLT/docbook skills but if no one can jump in here, I can see if I can
make it work.

Ok, I've figured it out.

Attached is an extended version of the patch that changes the XSL and
CSS stylesheets to add links to the ids that are visible when hovering.

Attachments:

protocol.sgml-anchors_v3.patchtext/plain; charset=UTF-8; name=protocol.sgml-anchors_v3.patchDownload
diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml
index 1c5ab00879..cb138b53ad 100644
--- a/doc/src/sgml/protocol.sgml
+++ b/doc/src/sgml/protocol.sgml
@@ -1810,7 +1810,7 @@ Replication commands are logged in the server log when
 <para>
 The commands accepted in replication mode are:
 <variablelist>
-  <varlistentry>
+  <varlistentry id="protocol-replication-identify-system">
     <term><literal>IDENTIFY_SYSTEM</literal>
      <indexterm><primary>IDENTIFY_SYSTEM</primary></indexterm>
     </term>
@@ -1875,7 +1875,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-show">
     <term><literal>SHOW</literal> <replaceable class="parameter">name</replaceable>
      <indexterm><primary>SHOW</primary></indexterm>
     </term>
@@ -1899,7 +1899,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-timeline-history">
     <term><literal>TIMELINE_HISTORY</literal> <replaceable class="parameter">tli</replaceable>
      <indexterm><primary>TIMELINE_HISTORY</primary></indexterm>
     </term>
@@ -2084,7 +2084,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-create-slot-legacy">
     <term><literal>CREATE_REPLICATION_SLOT</literal> <replaceable class="parameter">slot_name</replaceable> [ <literal>TEMPORARY</literal> ] { <literal>PHYSICAL</literal> [ <literal>RESERVE_WAL</literal> ] | <literal>LOGICAL</literal> <replaceable class="parameter">output_plugin</replaceable> [ <literal>EXPORT_SNAPSHOT</literal> | <literal>NOEXPORT_SNAPSHOT</literal> | <literal>USE_SNAPSHOT</literal> | <literal>TWO_PHASE</literal> ] }
     </term>
     <listitem>
@@ -2095,7 +2095,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-read-replication-slot">
     <term><literal>READ_REPLICATION_SLOT</literal> <replaceable class="parameter">slot_name</replaceable>
       <indexterm><primary>READ_REPLICATION_SLOT</primary></indexterm>
     </term>
@@ -2143,7 +2143,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-start-replication">
     <term><literal>START_REPLICATION</literal> [ <literal>SLOT</literal> <replaceable class="parameter">slot_name</replaceable> ] [ <literal>PHYSICAL</literal> ] <replaceable class="parameter">XXX/XXX</replaceable> [ <literal>TIMELINE</literal> <replaceable class="parameter">tli</replaceable> ]
      <indexterm><primary>START_REPLICATION</primary></indexterm>
     </term>
@@ -2201,7 +2201,7 @@ The commands accepted in replication mode are:
 
      <para>
       <variablelist>
-      <varlistentry>
+      <varlistentry id="protocol-replication-xlogdata">
       <term>
           XLogData (B)
       </term>
@@ -2270,7 +2270,7 @@ The commands accepted in replication mode are:
       </para>
       </listitem>
       </varlistentry>
-      <varlistentry>
+      <varlistentry id="protocol-replication-primary-keepalive-message">
       <term>
           Primary keepalive message (B)
       </term>
@@ -2334,7 +2334,7 @@ The commands accepted in replication mode are:
 
      <para>
       <variablelist>
-      <varlistentry>
+      <varlistentry id="protocol-replication-standby-status-update">
       <term>
           Standby status update (F)
       </term>
@@ -2415,7 +2415,7 @@ The commands accepted in replication mode are:
 
      <para>
       <variablelist>
-      <varlistentry>
+      <varlistentry id="protocol-replication-hot-standby-feedback-message">
       <term>
           Hot Standby feedback message (F)
       </term>
@@ -2497,7 +2497,7 @@ The commands accepted in replication mode are:
      </para>
     </listitem>
   </varlistentry>
-  <varlistentry>
+  <varlistentry id="protocol-replication-start-replication-slot-logical">
     <term><literal>START_REPLICATION</literal> <literal>SLOT</literal> <replaceable class="parameter">slot_name</replaceable> <literal>LOGICAL</literal> <replaceable class="parameter">XXX/XXX</replaceable> [ ( <replaceable>option_name</replaceable> [ <replaceable>option_value</replaceable> ] [, ...] ) ]</term>
     <listitem>
      <para>
@@ -2572,7 +2572,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-drop-replication-slot">
     <term>
      <literal>DROP_REPLICATION_SLOT</literal> <replaceable class="parameter">slot_name</replaceable> <optional> <literal>WAIT</literal> </optional>
      <indexterm><primary>DROP_REPLICATION_SLOT</primary></indexterm>
@@ -3266,7 +3266,7 @@ of any individual CopyData message cannot be interpretable on their own.)
 <variablelist>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationok">
 <term>
 AuthenticationOk (B)
 </term>
@@ -3311,7 +3311,7 @@ AuthenticationOk (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationkerberosv5">
 <term>
 AuthenticationKerberosV5 (B)
 </term>
@@ -3355,7 +3355,7 @@ AuthenticationKerberosV5 (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationcleartextpassword">
 <term>
 AuthenticationCleartextPassword (B)
 </term>
@@ -3399,7 +3399,7 @@ AuthenticationCleartextPassword (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationmd5password">
 <term>
 AuthenticationMD5Password (B)
 </term>
@@ -3454,7 +3454,7 @@ AuthenticationMD5Password (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationscmcredential">
 <term>
 AuthenticationSCMCredential (B)
 </term>
@@ -3499,7 +3499,7 @@ AuthenticationSCMCredential (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationgss">
 <term>
 AuthenticationGSS (B)
 </term>
@@ -3544,7 +3544,7 @@ AuthenticationGSS (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationgsscontinue">
 <term>
 AuthenticationGSSContinue (B)
 </term>
@@ -3599,7 +3599,7 @@ AuthenticationGSSContinue (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationsspi">
 <term>
 AuthenticationSSPI (B)
 </term>
@@ -3644,7 +3644,7 @@ AuthenticationSSPI (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationsasl">
 <term>
 AuthenticationSASL (B)
 </term>
@@ -3705,7 +3705,7 @@ following:
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationsaslcontinue">
 <term>
 AuthenticationSASLContinue (B)
 </term>
@@ -3760,7 +3760,7 @@ AuthenticationSASLContinue (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationsaslfinal">
 <term>
 AuthenticationSASLFinal (B)
 </term>
@@ -3816,7 +3816,7 @@ AuthenticationSASLFinal (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-backendkeydata">
 <term>
 BackendKeyData (B)
 </term>
@@ -3873,7 +3873,7 @@ BackendKeyData (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-bind">
 <term>
 Bind (F)
 </term>
@@ -4026,7 +4026,7 @@ Bind (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-bindcomplete">
 <term>
 BindComplete (B)
 </term>
@@ -4061,7 +4061,7 @@ BindComplete (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-cancelrequest">
 <term>
 CancelRequest (F)
 </term>
@@ -4119,7 +4119,7 @@ CancelRequest (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-close">
 <term>
 Close (F)
 </term>
@@ -4176,7 +4176,7 @@ Close (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-closecomplete">
 <term>
 CloseComplete (B)
 </term>
@@ -4211,7 +4211,7 @@ CloseComplete (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-commandcomplete">
 <term>
 CommandComplete (B)
 </term>
@@ -4310,7 +4310,7 @@ CommandComplete (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-copydata">
 <term>
 CopyData (F &amp; B)
 </term>
@@ -4356,7 +4356,7 @@ CopyData (F &amp; B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-copydone">
 <term>
 CopyDone (F &amp; B)
 </term>
@@ -4391,7 +4391,7 @@ CopyDone (F &amp; B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-copyfail">
 <term>
 CopyFail (F)
 </term>
@@ -4436,7 +4436,7 @@ CopyFail (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-copyinresponse">
 <term>
 CopyInResponse (B)
 </term>
@@ -4512,7 +4512,7 @@ CopyInResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-copyoutresponse">
 <term>
 CopyOutResponse (B)
 </term>
@@ -4585,7 +4585,7 @@ CopyOutResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-copybothresponse">
 <term>
 CopyBothResponse (B)
 </term>
@@ -4658,7 +4658,7 @@ CopyBothResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-datarow">
 <term>
 DataRow (B)
 </term>
@@ -4730,7 +4730,7 @@ DataRow (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-describe">
 <term>
 Describe (F)
 </term>
@@ -4787,7 +4787,7 @@ Describe (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-emptyqueryresponse">
 <term>
 EmptyQueryResponse (B)
 </term>
@@ -4823,7 +4823,7 @@ EmptyQueryResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-errorresponse">
 <term>
 ErrorResponse (B)
 </term>
@@ -4889,7 +4889,7 @@ ErrorResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-execute">
 <term>
 Execute (F)
 </term>
@@ -4946,7 +4946,7 @@ Execute (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-flush">
 <term>
 Flush (F)
 </term>
@@ -4981,7 +4981,7 @@ Flush (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-functioncall">
 <term>
 FunctionCall (F)
 </term>
@@ -5106,7 +5106,7 @@ FunctionCall (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-functioncallresponse">
 <term>
 FunctionCallResponse (B)
 </term>
@@ -5166,7 +5166,7 @@ FunctionCallResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-gssencrequest">
 <term>
 GSSENCRequest (F)
 </term>
@@ -5204,7 +5204,7 @@ GSSENCRequest (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-gssresponse">
 <term>
 GSSResponse (F)
 </term>
@@ -5249,7 +5249,7 @@ GSSResponse (F)
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-negotiateprotocolversion">
 <term>
 NegotiateProtocolVersion (B)
 </term>
@@ -5318,7 +5318,7 @@ NegotiateProtocolVersion (B)
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-nodata">
 <term>
 NoData (B)
 </term>
@@ -5353,7 +5353,7 @@ NoData (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-noticeresponse">
 <term>
 NoticeResponse (B)
 </term>
@@ -5419,7 +5419,7 @@ NoticeResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-notificationresponse">
 <term>
 NotificationResponse (B)
 </term>
@@ -5484,7 +5484,7 @@ NotificationResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-parameterdescription">
 <term>
 ParameterDescription (B)
 </term>
@@ -5542,7 +5542,7 @@ ParameterDescription (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-parameterstatus">
 <term>
 ParameterStatus (B)
 </term>
@@ -5596,7 +5596,7 @@ ParameterStatus (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-parse">
 <term>
 Parse (F)
 </term>
@@ -5680,7 +5680,7 @@ Parse (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-parsecomplete">
 <term>
 ParseComplete (B)
 </term>
@@ -5715,7 +5715,7 @@ ParseComplete (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-passwordmessage">
 <term>
 PasswordMessage (F)
 </term>
@@ -5761,7 +5761,7 @@ PasswordMessage (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-portalsuspended">
 <term>
 PortalSuspended (B)
 </term>
@@ -5798,7 +5798,7 @@ PortalSuspended (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-query">
 <term>
 Query (F)
 </term>
@@ -5843,7 +5843,7 @@ Query (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-readyforquery">
 <term>
 ReadyForQuery (B)
 </term>
@@ -5893,7 +5893,7 @@ ReadyForQuery (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-rowdescription">
 <term>
 RowDescription (B)
 </term>
@@ -6018,7 +6018,7 @@ RowDescription (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-saslinitialresponse">
 <term>
 SASLInitialResponse (F)
 </term>
@@ -6086,7 +6086,7 @@ SASLInitialResponse (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-saslresponse">
 <term>
 SASLResponse (F)
 </term>
@@ -6132,7 +6132,7 @@ SASLResponse (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-sslrequest">
 <term>
 SSLRequest (F)
 </term>
@@ -6170,7 +6170,7 @@ SSLRequest (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-startupmessage">
 <term>
 StartupMessage (F)
 </term>
@@ -6299,7 +6299,7 @@ StartupMessage (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-sync">
 <term>
 Sync (F)
 </term>
@@ -6334,7 +6334,7 @@ Sync (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-terminate">
 <term>
 Terminate (F)
 </term>
@@ -6665,7 +6665,7 @@ flow as physical replication.
 
 <variablelist>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-begin">
 <term>
 Begin
 </term>
@@ -6720,7 +6720,7 @@ Begin
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-message">
 <term>
 Message
 </term>
@@ -6808,7 +6808,7 @@ Message
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-commit">
 <term>
 Commit
 </term>
@@ -6873,7 +6873,7 @@ Commit
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-origin">
 <term>
 Origin
 </term>
@@ -6922,7 +6922,7 @@ Origin
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-relation">
 <term>
 Relation
 </term>
@@ -7054,7 +7054,7 @@ Relation
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-type">
 <term>
 Type
 </term>
@@ -7119,7 +7119,7 @@ Type
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-insert">
 <term>
 Insert
 </term>
@@ -7186,7 +7186,7 @@ Insert
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-update">
 <term>
 Update
 </term>
@@ -7300,7 +7300,7 @@ Update
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-delete">
 <term>
 Delete
 </term>
@@ -7389,7 +7389,7 @@ Delete
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-truncate">
 <term>
 Truncate
 </term>
@@ -7467,7 +7467,7 @@ Stream Abort) are available since protocol version 2.
 
 <variablelist>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-stream-start">
 <term>
 Stream Start
 </term>
@@ -7512,7 +7512,7 @@ Stream Start
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-stream-stop">
 <term>
 Stream Stop
 </term>
@@ -7536,7 +7536,7 @@ Stream Stop
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-stream-commit">
 <term>
 Stream Commit
 </term>
@@ -7611,7 +7611,7 @@ Stream Commit
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-stream-abort">
 <term>
 Stream Abort
 </term>
@@ -7665,7 +7665,7 @@ are available since protocol version 3.
 
 <variablelist>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-begin-prepare">
 
 <term>Begin Prepare</term>
 <listitem>
@@ -7730,7 +7730,7 @@ are available since protocol version 3.
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-prepare">
 
 <term>Prepare</term>
 <listitem>
@@ -7804,7 +7804,7 @@ are available since protocol version 3.
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-commit-prepared">
 
 <term>Commit Prepared</term>
 <listitem>
@@ -7878,7 +7878,7 @@ are available since protocol version 3.
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-rollback-prepared">
 
 <term>Rollback Prepared</term>
 <listitem>
@@ -7962,7 +7962,7 @@ are available since protocol version 3.
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-stream-prepare">
 
 <term>Stream Prepare</term>
 <listitem>
@@ -8046,7 +8046,7 @@ The following message parts are shared by the above messages.
 
 <variablelist>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-tupledata">
 <term>
 TupleData
 </term>
diff --git a/doc/src/sgml/stylesheet-html-common.xsl b/doc/src/sgml/stylesheet-html-common.xsl
index 9df2782ce4..1bb2445f4e 100644
--- a/doc/src/sgml/stylesheet-html-common.xsl
+++ b/doc/src/sgml/stylesheet-html-common.xsl
@@ -301,4 +301,31 @@ set       toc,title
   </xsl:choose>
 </xsl:template>
 
+
+<!-- Add links to ids in varlists to make them easier to use -->
+<xsl:template match="varlistentry">
+  <dt>
+    <xsl:call-template name="id.attribute"/>
+    <xsl:call-template name="anchor"/>
+    <xsl:apply-templates select="term"/>
+    <xsl:choose>
+      <xsl:when test="@id or @xml:id">
+        <a>
+          <xsl:attribute name="href">
+            <xsl:text>#</xsl:text>
+            <xsl:call-template name="object.id"/>
+          </xsl:attribute>
+          <xsl:attribute name="class">
+            <xsl:text>id_link</xsl:text>
+          </xsl:attribute>
+          <xsl:text>#</xsl:text>
+        </a>
+      </xsl:when>
+    </xsl:choose>
+  </dt>
+  <dd>
+    <xsl:apply-templates select="listitem"/>
+  </dd>
+</xsl:template>
+
 </xsl:stylesheet>
diff --git a/doc/src/sgml/stylesheet.css b/doc/src/sgml/stylesheet.css
index 6410a47958..d3ea9a9f48 100644
--- a/doc/src/sgml/stylesheet.css
+++ b/doc/src/sgml/stylesheet.css
@@ -163,3 +163,12 @@ acronym		{ font-style: inherit; }
     width: 75%;
   }
 }
+
+/* Links to ids in long lists */
+.variablelist a.id_link {
+	visibility: hidden;
+}
+.variablelist *:hover > a.id_link,
+.variablelist a.id_link:focus {
+	visibility: visible;
+}
#25Chapman Flack
chap@anastigmatix.net
In reply to: Brar Piening (#24)
Re: Add id's to various elements in protocol.sgml

On 02/28/22 14:41, Brar Piening wrote:

Attached is an extended version of the patch that changes the XSL and
CSS stylesheets to add links to the ids that are visible when hovering.

That works nicely over here.

I think that in other recent examples I've seen, there might be
(something like a) consensus forming around the Unicode LINK SYMBOL
&#x1f517; rather than # as the symbol for such things.

... and now that the concept is proven, how hard would it be to broaden
that template's pattern to apply to all the other DocBook constructs
(such as section headings) that emit anchors?

Regards,
-Chap

#26Brar Piening
brar@gmx.de
In reply to: Chapman Flack (#25)
Re: Add id's to various elements in protocol.sgml

On Feb 28, 2022 at 21:06, Chapman Flack wrote:

I think that in other recent examples I've seen, there might be
(something like a) consensus forming around the Unicode LINK SYMBOL
&#x1f517; rather than # as the symbol for such things.

I intentionally opted for an ASCII character as that definitely won't
cause any display/font/portability issues but changing that is no problem.

... and now that the concept is proven, how hard would it be to broaden
that template's pattern to apply to all the other DocBook constructs
(such as section headings) that emit anchors?

As long as we stick to manually assigned ids in the same way my patch
does it, it shouldn't be too hard. Speaking of autogenerated ids, I
failed to make use of them since I wasn't able to reproduce the same
autogenerated id twice in order to use it for the link.

Also I'm not sure how well the autogenerated ids are reproducible over
time/versions/builds, and if it is wise to use them as targets to link
to from somewhere else.

#27Brar Piening
brar@gmx.de
In reply to: Brar Piening (#26)
1 attachment(s)
Re: Add id's to various elements in protocol.sgml

On Mar 01, 2022 at 18:27, Brar Piening wrote:

On Feb 28, 2022 at 21:06, Chapman Flack wrote:

I think that in other recent examples I've seen, there might be
(something like a) consensus forming around the Unicode LINK SYMBOL
&#x1f517; rather than # as the symbol for such things.

I intentionally opted for an ASCII character as that definitely won't
cause any display/font/portability issues but changing that is no
problem.

TBH I don't like the visual representation of the unicode link symbol
(U+1F517) in my browser. It's a bold black fat thing that doesn't
inherit colors. I've tried to soften it by decreasing the size but that
doesn't really solve it for me. Font support also doesn't seem
overwhelming. Anyway, I've changed my patch to use it so that you can
judge it yourself.

... and now that the concept is proven, how hard would it be to broaden
that template's pattern to apply to all the other DocBook constructs
(such as section headings) that emit anchors?

As long as we stick to manually assigned ids in the same way my patch
does it, it shouldn't be too hard.

Patch is attached. I don't think it should get applied this way, though.
The fact that you only get links for section headers that have manually
assigned ids would be pretty surprising for users of the docs and in
some files (e.g. protocol-flow.html) only every other section has a
manually assigned id. It would be easy to emit a message (or even fail)
whenever the template fails to find an id and then manually assign ids
until they are everywhere (currently that means all varlistentries and
sections) but that would a) be quite some work and b) make the patch
quite heavy, so I wouldn't even start this before there is really
consensus that this is the right direction.

Attachments:

protocol.sgml-anchors_v4.patchtext/plain; charset=UTF-8; name=protocol.sgml-anchors_v4.patchDownload
diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml
index 1c5ab00879..cb138b53ad 100644
--- a/doc/src/sgml/protocol.sgml
+++ b/doc/src/sgml/protocol.sgml
@@ -1810,7 +1810,7 @@ Replication commands are logged in the server log when
 <para>
 The commands accepted in replication mode are:
 <variablelist>
-  <varlistentry>
+  <varlistentry id="protocol-replication-identify-system">
     <term><literal>IDENTIFY_SYSTEM</literal>
      <indexterm><primary>IDENTIFY_SYSTEM</primary></indexterm>
     </term>
@@ -1875,7 +1875,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-show">
     <term><literal>SHOW</literal> <replaceable class="parameter">name</replaceable>
      <indexterm><primary>SHOW</primary></indexterm>
     </term>
@@ -1899,7 +1899,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-timeline-history">
     <term><literal>TIMELINE_HISTORY</literal> <replaceable class="parameter">tli</replaceable>
      <indexterm><primary>TIMELINE_HISTORY</primary></indexterm>
     </term>
@@ -2084,7 +2084,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-create-slot-legacy">
     <term><literal>CREATE_REPLICATION_SLOT</literal> <replaceable class="parameter">slot_name</replaceable> [ <literal>TEMPORARY</literal> ] { <literal>PHYSICAL</literal> [ <literal>RESERVE_WAL</literal> ] | <literal>LOGICAL</literal> <replaceable class="parameter">output_plugin</replaceable> [ <literal>EXPORT_SNAPSHOT</literal> | <literal>NOEXPORT_SNAPSHOT</literal> | <literal>USE_SNAPSHOT</literal> | <literal>TWO_PHASE</literal> ] }
     </term>
     <listitem>
@@ -2095,7 +2095,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-read-replication-slot">
     <term><literal>READ_REPLICATION_SLOT</literal> <replaceable class="parameter">slot_name</replaceable>
       <indexterm><primary>READ_REPLICATION_SLOT</primary></indexterm>
     </term>
@@ -2143,7 +2143,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-start-replication">
     <term><literal>START_REPLICATION</literal> [ <literal>SLOT</literal> <replaceable class="parameter">slot_name</replaceable> ] [ <literal>PHYSICAL</literal> ] <replaceable class="parameter">XXX/XXX</replaceable> [ <literal>TIMELINE</literal> <replaceable class="parameter">tli</replaceable> ]
      <indexterm><primary>START_REPLICATION</primary></indexterm>
     </term>
@@ -2201,7 +2201,7 @@ The commands accepted in replication mode are:
 
      <para>
       <variablelist>
-      <varlistentry>
+      <varlistentry id="protocol-replication-xlogdata">
       <term>
           XLogData (B)
       </term>
@@ -2270,7 +2270,7 @@ The commands accepted in replication mode are:
       </para>
       </listitem>
       </varlistentry>
-      <varlistentry>
+      <varlistentry id="protocol-replication-primary-keepalive-message">
       <term>
           Primary keepalive message (B)
       </term>
@@ -2334,7 +2334,7 @@ The commands accepted in replication mode are:
 
      <para>
       <variablelist>
-      <varlistentry>
+      <varlistentry id="protocol-replication-standby-status-update">
       <term>
           Standby status update (F)
       </term>
@@ -2415,7 +2415,7 @@ The commands accepted in replication mode are:
 
      <para>
       <variablelist>
-      <varlistentry>
+      <varlistentry id="protocol-replication-hot-standby-feedback-message">
       <term>
           Hot Standby feedback message (F)
       </term>
@@ -2497,7 +2497,7 @@ The commands accepted in replication mode are:
      </para>
     </listitem>
   </varlistentry>
-  <varlistentry>
+  <varlistentry id="protocol-replication-start-replication-slot-logical">
     <term><literal>START_REPLICATION</literal> <literal>SLOT</literal> <replaceable class="parameter">slot_name</replaceable> <literal>LOGICAL</literal> <replaceable class="parameter">XXX/XXX</replaceable> [ ( <replaceable>option_name</replaceable> [ <replaceable>option_value</replaceable> ] [, ...] ) ]</term>
     <listitem>
      <para>
@@ -2572,7 +2572,7 @@ The commands accepted in replication mode are:
     </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="protocol-replication-drop-replication-slot">
     <term>
      <literal>DROP_REPLICATION_SLOT</literal> <replaceable class="parameter">slot_name</replaceable> <optional> <literal>WAIT</literal> </optional>
      <indexterm><primary>DROP_REPLICATION_SLOT</primary></indexterm>
@@ -3266,7 +3266,7 @@ of any individual CopyData message cannot be interpretable on their own.)
 <variablelist>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationok">
 <term>
 AuthenticationOk (B)
 </term>
@@ -3311,7 +3311,7 @@ AuthenticationOk (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationkerberosv5">
 <term>
 AuthenticationKerberosV5 (B)
 </term>
@@ -3355,7 +3355,7 @@ AuthenticationKerberosV5 (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationcleartextpassword">
 <term>
 AuthenticationCleartextPassword (B)
 </term>
@@ -3399,7 +3399,7 @@ AuthenticationCleartextPassword (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationmd5password">
 <term>
 AuthenticationMD5Password (B)
 </term>
@@ -3454,7 +3454,7 @@ AuthenticationMD5Password (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationscmcredential">
 <term>
 AuthenticationSCMCredential (B)
 </term>
@@ -3499,7 +3499,7 @@ AuthenticationSCMCredential (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationgss">
 <term>
 AuthenticationGSS (B)
 </term>
@@ -3544,7 +3544,7 @@ AuthenticationGSS (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationgsscontinue">
 <term>
 AuthenticationGSSContinue (B)
 </term>
@@ -3599,7 +3599,7 @@ AuthenticationGSSContinue (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationsspi">
 <term>
 AuthenticationSSPI (B)
 </term>
@@ -3644,7 +3644,7 @@ AuthenticationSSPI (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationsasl">
 <term>
 AuthenticationSASL (B)
 </term>
@@ -3705,7 +3705,7 @@ following:
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationsaslcontinue">
 <term>
 AuthenticationSASLContinue (B)
 </term>
@@ -3760,7 +3760,7 @@ AuthenticationSASLContinue (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-authenticationsaslfinal">
 <term>
 AuthenticationSASLFinal (B)
 </term>
@@ -3816,7 +3816,7 @@ AuthenticationSASLFinal (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-backendkeydata">
 <term>
 BackendKeyData (B)
 </term>
@@ -3873,7 +3873,7 @@ BackendKeyData (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-bind">
 <term>
 Bind (F)
 </term>
@@ -4026,7 +4026,7 @@ Bind (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-bindcomplete">
 <term>
 BindComplete (B)
 </term>
@@ -4061,7 +4061,7 @@ BindComplete (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-cancelrequest">
 <term>
 CancelRequest (F)
 </term>
@@ -4119,7 +4119,7 @@ CancelRequest (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-close">
 <term>
 Close (F)
 </term>
@@ -4176,7 +4176,7 @@ Close (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-closecomplete">
 <term>
 CloseComplete (B)
 </term>
@@ -4211,7 +4211,7 @@ CloseComplete (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-commandcomplete">
 <term>
 CommandComplete (B)
 </term>
@@ -4310,7 +4310,7 @@ CommandComplete (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-copydata">
 <term>
 CopyData (F &amp; B)
 </term>
@@ -4356,7 +4356,7 @@ CopyData (F &amp; B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-copydone">
 <term>
 CopyDone (F &amp; B)
 </term>
@@ -4391,7 +4391,7 @@ CopyDone (F &amp; B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-copyfail">
 <term>
 CopyFail (F)
 </term>
@@ -4436,7 +4436,7 @@ CopyFail (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-copyinresponse">
 <term>
 CopyInResponse (B)
 </term>
@@ -4512,7 +4512,7 @@ CopyInResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-copyoutresponse">
 <term>
 CopyOutResponse (B)
 </term>
@@ -4585,7 +4585,7 @@ CopyOutResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-copybothresponse">
 <term>
 CopyBothResponse (B)
 </term>
@@ -4658,7 +4658,7 @@ CopyBothResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-datarow">
 <term>
 DataRow (B)
 </term>
@@ -4730,7 +4730,7 @@ DataRow (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-describe">
 <term>
 Describe (F)
 </term>
@@ -4787,7 +4787,7 @@ Describe (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-emptyqueryresponse">
 <term>
 EmptyQueryResponse (B)
 </term>
@@ -4823,7 +4823,7 @@ EmptyQueryResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-errorresponse">
 <term>
 ErrorResponse (B)
 </term>
@@ -4889,7 +4889,7 @@ ErrorResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-execute">
 <term>
 Execute (F)
 </term>
@@ -4946,7 +4946,7 @@ Execute (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-flush">
 <term>
 Flush (F)
 </term>
@@ -4981,7 +4981,7 @@ Flush (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-functioncall">
 <term>
 FunctionCall (F)
 </term>
@@ -5106,7 +5106,7 @@ FunctionCall (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-functioncallresponse">
 <term>
 FunctionCallResponse (B)
 </term>
@@ -5166,7 +5166,7 @@ FunctionCallResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-gssencrequest">
 <term>
 GSSENCRequest (F)
 </term>
@@ -5204,7 +5204,7 @@ GSSENCRequest (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-gssresponse">
 <term>
 GSSResponse (F)
 </term>
@@ -5249,7 +5249,7 @@ GSSResponse (F)
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-negotiateprotocolversion">
 <term>
 NegotiateProtocolVersion (B)
 </term>
@@ -5318,7 +5318,7 @@ NegotiateProtocolVersion (B)
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-nodata">
 <term>
 NoData (B)
 </term>
@@ -5353,7 +5353,7 @@ NoData (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-noticeresponse">
 <term>
 NoticeResponse (B)
 </term>
@@ -5419,7 +5419,7 @@ NoticeResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-notificationresponse">
 <term>
 NotificationResponse (B)
 </term>
@@ -5484,7 +5484,7 @@ NotificationResponse (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-parameterdescription">
 <term>
 ParameterDescription (B)
 </term>
@@ -5542,7 +5542,7 @@ ParameterDescription (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-parameterstatus">
 <term>
 ParameterStatus (B)
 </term>
@@ -5596,7 +5596,7 @@ ParameterStatus (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-parse">
 <term>
 Parse (F)
 </term>
@@ -5680,7 +5680,7 @@ Parse (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-parsecomplete">
 <term>
 ParseComplete (B)
 </term>
@@ -5715,7 +5715,7 @@ ParseComplete (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-passwordmessage">
 <term>
 PasswordMessage (F)
 </term>
@@ -5761,7 +5761,7 @@ PasswordMessage (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-portalsuspended">
 <term>
 PortalSuspended (B)
 </term>
@@ -5798,7 +5798,7 @@ PortalSuspended (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-query">
 <term>
 Query (F)
 </term>
@@ -5843,7 +5843,7 @@ Query (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-readyforquery">
 <term>
 ReadyForQuery (B)
 </term>
@@ -5893,7 +5893,7 @@ ReadyForQuery (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-rowdescription">
 <term>
 RowDescription (B)
 </term>
@@ -6018,7 +6018,7 @@ RowDescription (B)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-saslinitialresponse">
 <term>
 SASLInitialResponse (F)
 </term>
@@ -6086,7 +6086,7 @@ SASLInitialResponse (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-saslresponse">
 <term>
 SASLResponse (F)
 </term>
@@ -6132,7 +6132,7 @@ SASLResponse (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-sslrequest">
 <term>
 SSLRequest (F)
 </term>
@@ -6170,7 +6170,7 @@ SSLRequest (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-startupmessage">
 <term>
 StartupMessage (F)
 </term>
@@ -6299,7 +6299,7 @@ StartupMessage (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-sync">
 <term>
 Sync (F)
 </term>
@@ -6334,7 +6334,7 @@ Sync (F)
 </varlistentry>
 
 
-<varlistentry>
+<varlistentry id="protocol-message-formats-terminate">
 <term>
 Terminate (F)
 </term>
@@ -6665,7 +6665,7 @@ flow as physical replication.
 
 <variablelist>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-begin">
 <term>
 Begin
 </term>
@@ -6720,7 +6720,7 @@ Begin
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-message">
 <term>
 Message
 </term>
@@ -6808,7 +6808,7 @@ Message
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-commit">
 <term>
 Commit
 </term>
@@ -6873,7 +6873,7 @@ Commit
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-origin">
 <term>
 Origin
 </term>
@@ -6922,7 +6922,7 @@ Origin
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-relation">
 <term>
 Relation
 </term>
@@ -7054,7 +7054,7 @@ Relation
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-type">
 <term>
 Type
 </term>
@@ -7119,7 +7119,7 @@ Type
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-insert">
 <term>
 Insert
 </term>
@@ -7186,7 +7186,7 @@ Insert
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-update">
 <term>
 Update
 </term>
@@ -7300,7 +7300,7 @@ Update
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-delete">
 <term>
 Delete
 </term>
@@ -7389,7 +7389,7 @@ Delete
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-truncate">
 <term>
 Truncate
 </term>
@@ -7467,7 +7467,7 @@ Stream Abort) are available since protocol version 2.
 
 <variablelist>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-stream-start">
 <term>
 Stream Start
 </term>
@@ -7512,7 +7512,7 @@ Stream Start
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-stream-stop">
 <term>
 Stream Stop
 </term>
@@ -7536,7 +7536,7 @@ Stream Stop
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-stream-commit">
 <term>
 Stream Commit
 </term>
@@ -7611,7 +7611,7 @@ Stream Commit
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-stream-abort">
 <term>
 Stream Abort
 </term>
@@ -7665,7 +7665,7 @@ are available since protocol version 3.
 
 <variablelist>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-begin-prepare">
 
 <term>Begin Prepare</term>
 <listitem>
@@ -7730,7 +7730,7 @@ are available since protocol version 3.
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-prepare">
 
 <term>Prepare</term>
 <listitem>
@@ -7804,7 +7804,7 @@ are available since protocol version 3.
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-commit-prepared">
 
 <term>Commit Prepared</term>
 <listitem>
@@ -7878,7 +7878,7 @@ are available since protocol version 3.
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-rollback-prepared">
 
 <term>Rollback Prepared</term>
 <listitem>
@@ -7962,7 +7962,7 @@ are available since protocol version 3.
 </listitem>
 </varlistentry>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-stream-prepare">
 
 <term>Stream Prepare</term>
 <listitem>
@@ -8046,7 +8046,7 @@ The following message parts are shared by the above messages.
 
 <variablelist>
 
-<varlistentry>
+<varlistentry id="protocol-logicalrep-message-formats-tupledata">
 <term>
 TupleData
 </term>
diff --git a/doc/src/sgml/stylesheet-html-common.xsl b/doc/src/sgml/stylesheet-html-common.xsl
index 9df2782ce4..a277978402 100644
--- a/doc/src/sgml/stylesheet-html-common.xsl
+++ b/doc/src/sgml/stylesheet-html-common.xsl
@@ -301,4 +301,98 @@ set       toc,title
   </xsl:choose>
 </xsl:template>
 
+
+<!-- Add links to ids in varlists to make them easier to use -->
+<xsl:template match="varlistentry">
+  <dt>
+    <xsl:call-template name="id.attribute"/>
+    <xsl:call-template name="anchor"/>
+    <xsl:apply-templates select="term"/>
+    <xsl:call-template name="pg.id.link"/>
+  </dt>
+  <dd>
+    <xsl:apply-templates select="listitem"/>
+  </dd>
+</xsl:template>
+
+<xsl:template name="section.heading">
+  <xsl:param name="section" select="."/>
+  <xsl:param name="level" select="1"/>
+  <xsl:param name="allow-anchors" select="1"/>
+  <xsl:param name="title"/>
+  <xsl:param name="class" select="'title'"/>
+
+  <xsl:variable name="id">
+    <xsl:choose>
+      <!-- Make sure the subtitle doesn't get the same id as the title -->
+      <xsl:when test="self::subtitle">
+        <xsl:call-template name="object.id">
+          <xsl:with-param name="object" select="."/>
+        </xsl:call-template>
+      </xsl:when>
+      <!-- if title is in an *info wrapper, get the grandparent -->
+      <xsl:when test="contains(local-name(..), 'info')">
+        <xsl:call-template name="object.id">
+          <xsl:with-param name="object" select="../.."/>
+        </xsl:call-template>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:call-template name="object.id">
+          <xsl:with-param name="object" select=".."/>
+        </xsl:call-template>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <!-- HTML H level is one higher than section level -->
+  <xsl:variable name="hlevel">
+    <xsl:choose>
+      <!-- highest valid HTML H level is H6; so anything nested deeper
+           than 5 levels down just becomes H6 -->
+      <xsl:when test="$level &gt; 5">6</xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$level + 1"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:element name="h{$hlevel}" namespace="http://www.w3.org/1999/xhtml">
+    <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+    <xsl:if test="$css.decoration != '0'">
+      <xsl:if test="$hlevel&lt;3">
+        <xsl:attribute name="style">clear: both</xsl:attribute>
+      </xsl:if>
+    </xsl:if>
+    <xsl:if test="$allow-anchors != 0">
+      <xsl:call-template name="anchor">
+        <xsl:with-param name="node" select="$section"/>
+        <xsl:with-param name="conditional" select="0"/>
+      </xsl:call-template>
+    </xsl:if>
+    <xsl:copy-of select="$title"/>
+    <xsl:call-template name="pg.id.link">
+      <xsl:with-param name="object" select="$section"/>
+    </xsl:call-template>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template name="pg.id.link">
+  <xsl:param name="object" select="."/>
+  <xsl:choose>
+    <xsl:when test="$object/@id or $object/@xml:id">
+      <a>
+        <xsl:attribute name="href">
+          <xsl:text>#</xsl:text>
+          <xsl:call-template name="object.id">
+            <xsl:with-param name="object" select="$object"/>
+          </xsl:call-template>
+        </xsl:attribute>
+        <xsl:attribute name="class">
+          <xsl:text>id_link</xsl:text>
+        </xsl:attribute>
+        <xsl:text> &#x1f517;</xsl:text>
+      </a>
+    </xsl:when>
+  </xsl:choose>
+</xsl:template>
+
 </xsl:stylesheet>
diff --git a/doc/src/sgml/stylesheet.css b/doc/src/sgml/stylesheet.css
index 6410a47958..6f9f24c38f 100644
--- a/doc/src/sgml/stylesheet.css
+++ b/doc/src/sgml/stylesheet.css
@@ -163,3 +163,14 @@ acronym		{ font-style: inherit; }
     width: 75%;
   }
 }
+
+/* Links to ids in long lists */
+.title a.id_link,
+.variablelist a.id_link {
+	font-size: 60%;
+	visibility: hidden;
+}
+.title:hover > a.id_link,
+.variablelist *:hover > a.id_link {
+	visibility: visible;
+}
#28Chapman Flack
chap@anastigmatix.net
In reply to: Brar Piening (#27)
Re: Add id's to various elements in protocol.sgml

On 03/01/22 14:50, Brar Piening wrote:

TBH I don't like the visual representation of the unicode link symbol
(U+1F517) in my browser. It's a bold black fat thing that doesn't
inherit colors. I've tried to soften it by decreasing the size but that
doesn't really solve it for me. Font support also doesn't seem
overwhelming.

That sounds like it's probably in less wide use than I thought, and if the
font support is spotty, that seems like a good enough reason not to go
there. I've no objection to the # symbol. Maybe this should really get
a comment from someone more actively involved in styling the web site.

As long as we stick to manually assigned ids in the same way my patch
does it, it shouldn't be too hard.

Patch is attached. I don't think it should get applied this way, though.
The fact that you only get links for section headers that have manually
assigned ids would be pretty surprising for users of the docs and in
some files (e.g. protocol-flow.html) only every other section has a
manually assigned id. It would be easy to emit a message (or even fail)
whenever the template fails to find an id and then manually assign ids
until they are everywhere (currently that means all varlistentries and
sections) but that would a) be quite some work and b) make the patch
quite heavy, so I wouldn't even start this before there is really
consensus that this is the right direction.

This sounds like a bigger deal, and I wonder if it is big enough to merit
splitting the patch, so the added ids can go into protocol.sgml promptly
(and not be any harder to find than any of our fragment ids currently are),
and "improve html docs to expose fragment ids" can get more thought.

As long as we haven't assigned ids to all sections, I could almost think
of the surprising behavior as a feature, distinguishing the links you can
reasonably bet on being stable from the ones you can't. (Maybe the latter
should have their own symbol! 1F3B2?) But you're probably right that it
would seem surprising and arbitrary. And I don't know how much enthusiasm
there will be for assigning ids everywhere.

Regards,
-Chap

#29Peter Eisentraut
peter.eisentraut@enterprisedb.com
In reply to: Brar Piening (#27)
Re: Add id's to various elements in protocol.sgml

On 01.03.22 20:50, Brar Piening wrote:

Patch is attached. I don't think it should get applied this way, though.
The fact that you only get links for section headers that have manually
assigned ids would be pretty surprising for users of the docs and in
some files (e.g. protocol-flow.html) only every other section has a
manually assigned id. It would be easy to emit a message (or even fail)
whenever the template fails to find an id and then manually assign ids
until they are everywhere (currently that means all varlistentries and
sections) but that would a) be quite some work and b) make the patch
quite heavy, so I wouldn't even start this before there is really
consensus that this is the right direction.

I have applied the part of your patch that adds the id's. The
discussion about the formatting aspect can continue.

I changed the id's for the protocol messages to mixed case, so that it
matches how these are commonly referred to elsewhere. It doesn't affect
the output.

#30Peter Eisentraut
peter.eisentraut@enterprisedb.com
In reply to: Brar Piening (#26)
Re: Add id's to various elements in protocol.sgml

On 01.03.22 18:27, Brar Piening wrote:

Also I'm not sure how well the autogenerated ids are reproducible over
time/versions/builds, and if it is wise to use them as targets to link
to from somewhere else.

Autogenerated ids are stable across builds of the same source. They
would change if the document structure is changed, for example, a
section is inserted.

#31Brar Piening
brar@gmx.de
In reply to: Peter Eisentraut (#29)
Re: Add id's to various elements in protocol.sgml

On 02.03.2022 at 10:37, Peter Eisentraut wrote:

I have applied the part of your patch that adds the id's.  The
discussion about the formatting aspect can continue.

Thank you!

I've generated some data by outputting the element name whenever a
section or varlistentry lacks an id. That's how the situation in the
docs currently looks like:

   element    | count
--------------+-------
 sect2        |   275
 sect3        |    94
 sect4        |    20
 simplesect   |    20
 varlistentry |  3976

Looking at this, I think that manually assigning an id to all ~400
sections currently lacking one to make them referable in a consistent
way is a bit of work but feasible.

Once we consitently have stable ids on section headers IMHO it makes
sense to also expose them as links. I'd probably also make the
stylesheet emit a non-terminating message/comment whenever it finds a
section without id in order to help keeping the layout consistent over time.

With regard to varlistentry I'd suggest to decide whether to add ids or
not on a case by case base. I already offered to add ids to long lists
upon request but I wouldn't want to blindly add ~4k ids that nobody
cares about. That part can also grow over time by people adding ids as
they deem them useful.

Any objections/thoughts?

#32Chapman Flack
chap@anastigmatix.net
In reply to: Brar Piening (#31)
Re: Add id's to various elements in protocol.sgml

On 03/02/22 12:46, Brar Piening wrote:

With regard to varlistentry I'd suggest to decide whether to add ids or
not on a case by case base. I already offered to add ids to long lists
upon request but I wouldn't want to blindly add ~4k ids that nobody

Perhaps there are a bunch of variablelists where no one cares about
linking to any of the entries.

So maybe a useful non-terminating message to add eventually would
be one that identifies any varlistentry lacking an id, with a
variablelist where at least one other entry has an id.

Regards,
-Chap

#33Brar Piening
brar@gmx.de
In reply to: Chapman Flack (#32)
Re: Add id's to various elements in protocol.sgml

On 02.03.2022 at 18:54, Chapman Flack wrote:

Perhaps there are a bunch of variablelists where no one cares about
linking to any of the entries.

So maybe a useful non-terminating message to add eventually would
be one that identifies any varlistentry lacking an id, with a
variablelist where at least one other entry has an id.

That sounds like areasonable approach for now.

Is there anybody objecting to pursue this? Do you need more examples how
it would look like?

It would be a bit hurtful to generate a patch that manually adds ~600
ids just to have it rejected as unwanted.

#34Brar Piening
brar@gmx.de
In reply to: Brar Piening (#33)
1 attachment(s)
Re: Add id's to various elements in protocol.sgml

On 03.03.2022 at 15:17, Brar Piening wrote:

On 02.03.2022 at 18:54, Chapman Flack wrote:

Perhaps there are a bunch of variablelists where no one cares about
linking to any of the entries.

So maybe a useful non-terminating message to add eventually would
be one that identifies any varlistentry lacking an id, with a
variablelist where at least one other entry has an id.

That sounds like areasonable approach for now.

Attached is a pretty huge patch that adds ids to all sections and all
the varlistentries where the containing variablelist already had at
least one id (plus a few additional ones that I stumbled upon and deemed
useful). It also adds html links next to the respective heading in the
html documentation and emits a build message and a comment when a
section or a relevant (see before) varlistentry doesn't have an id.

I don't really like how the length of the id tends to grow for deeply
nested elements if you try to create it in a systematic way, so if
sonebody has a better idea for somewhat mnemonic manual ids or wants to
put an upper limit to the length, please say so. Personally I don't care
that much since for me they are meant for copy-paste anyway.

I didn't change any existing id, even if that meant that ids of sibling
elements end up being inconsistent. I did so because I consider URLs as
user interface that shouldn't change without a really good reason.

I also didn't add any ids to refsect{1:2:3} elements, although we should
probably discuss this since within the docs there ist no real visual
difference between a sect{1;2;3} and a refsect{1:2:3}.

Here are some stats about elements where at least one currently has an
id before and after my patch for today's HEAD.

Before:
     name      | with_id | without_id | id_coverage | max_id_len
---------------+---------+------------+-------------+------------
 sect1         |     726 |          0 |      100.00 |         46
 refentry      |     306 |          0 |      100.00 |         37
 chapter       |      74 |          0 |      100.00 |         24
 biblioentry   |      23 |          0 |      100.00 |         15
 appendix      |      15 |          0 |      100.00 |         23
 part          |       8 |          0 |      100.00 |         20
 co            |       4 |          0 |      100.00 |         30
 figure        |       3 |          0 |      100.00 |         28
 reference     |       3 |          0 |      100.00 |         18
 anchor        |       1 |          0 |      100.00 |         21
 bibliography  |       1 |          0 |      100.00 |          8
 book          |       1 |          0 |      100.00 |         10
 index         |       1 |          0 |      100.00 |         11
 legalnotice   |       1 |          0 |      100.00 |         13
 preface       |       1 |          0 |      100.00 |          9
 glossentry    |     115 |         14 |       89.15 |         32
 sect2         |     568 |        274 |       67.46 |         45
 table         |     280 |        161 |       63.49 |         46
 example       |      27 |         16 |       62.79 |         42
 refsect3      |       5 |          3 |       62.50 |         24
 sect3         |     110 |         94 |       53.92 |         49
 refsect2      |      39 |         55 |       41.49 |         36
 sect4         |       8 |         20 |       28.57 |         27
 footnote      |       5 |         18 |       21.74 |         32
 step          |      25 |        128 |       16.34 |         28
 varlistentry  |     746 |       3976 |       15.80 |         58
 refsect1      |     151 |       1326 |       10.22 |         40
 informaltable |       1 |         15 |        6.25 |         25
 phrase        |       1 |         81 |        1.22 |         20
 indexterm     |       5 |       3225 |        0.15 |         26
 variablelist  |       1 |        800 |        0.12 |         21
 function      |       4 |       4000 |        0.10 |         28
 entry         |      10 |      17609 |        0.06 |         40
 para          |       3 |      25180 |        0.01 |         27

 After:
     name      | with_id | without_id | id_coverage | max_id_len
---------------+---------+------------+-------------+------------
 sect2         |     842 |          0 |      100.00 |         49
 sect1         |     726 |          0 |      100.00 |         46
 refentry      |     306 |          0 |      100.00 |         37
 sect3         |     204 |          0 |      100.00 |         57
 chapter       |      74 |          0 |      100.00 |         24
 sect4         |      28 |          0 |      100.00 |         47
 biblioentry   |      23 |          0 |      100.00 |         15
 simplesect    |      20 |          0 |      100.00 |         39
 appendix      |      15 |          0 |      100.00 |         23
 part          |       8 |          0 |      100.00 |         20
 co            |       4 |          0 |      100.00 |         30
 figure        |       3 |          0 |      100.00 |         28
 reference     |       3 |          0 |      100.00 |         18
 anchor        |       1 |          0 |      100.00 |         21
 bibliography  |       1 |          0 |      100.00 |          8
 book          |       1 |          0 |      100.00 |         10
 index         |       1 |          0 |      100.00 |         11
 legalnotice   |       1 |          0 |      100.00 |         13
 preface       |       1 |          0 |      100.00 |          9
 glossentry    |     115 |         14 |       89.15 |         32
 table         |     280 |        161 |       63.49 |         46
 example       |      27 |         16 |       62.79 |         42
 refsect3      |       5 |          3 |       62.50 |         24
 refsect2      |      39 |         55 |       41.49 |         36
 varlistentry  |    1607 |       3115 |       34.03 |         61
 footnote      |       5 |         18 |       21.74 |         32
 step          |      25 |        128 |       16.34 |         28
 refsect1      |     151 |       1326 |       10.22 |         40
 informaltable |       1 |         15 |        6.25 |         25
 phrase        |       1 |         81 |        1.22 |         20
 indexterm     |       5 |       3225 |        0.15 |         26
 variablelist  |       1 |        800 |        0.12 |         21
 function      |       4 |       4000 |        0.10 |         28
 entry         |      10 |      17609 |        0.06 |         40
 para          |       3 |      25180 |        0.01 |         27

Regards,

Brar

Attachments:

add_section_ids.patchtext/plain; charset=UTF-8; name=add_section_ids.patchDownload
diff --git a/doc/src/sgml/amcheck.sgml b/doc/src/sgml/amcheck.sgml
index 11d1eb5af2..6cc0c66909 100644
--- a/doc/src/sgml/amcheck.sgml
+++ b/doc/src/sgml/amcheck.sgml
@@ -52,7 +52,7 @@
   able to infer something of the data itself from such messages.
  </para>
 
- <sect2>
+ <sect2 id="amcheck-functions">
   <title>Functions</title>
 
   <variablelist>
@@ -346,7 +346,7 @@ SET client_min_messages = DEBUG1;
   </variablelist>
  </sect2>
 
- <sect2>
+ <sect2 id="amcheck-optional-heapallindexed-verification">
   <title>Optional <parameter>heapallindexed</parameter> Verification</title>
  <para>
   When the <parameter>heapallindexed</parameter> argument to B-Tree
@@ -387,7 +387,7 @@ SET client_min_messages = DEBUG1;
 
  </sect2>
 
- <sect2>
+ <sect2 id="amcheck-using-amcheck-effectively">
   <title>Using <filename>amcheck</filename> Effectively</title>
 
  <para>
@@ -535,7 +535,7 @@ SET client_min_messages = DEBUG1;
  </para>
 
  </sect2>
- <sect2>
+ <sect2 id="amcheck-repairing-corruption">
   <title>Repairing Corruption</title>
  <para>
   No error concerning corruption raised by <filename>amcheck</filename> should
diff --git a/doc/src/sgml/arch-dev.sgml b/doc/src/sgml/arch-dev.sgml
index c2be28fac8..d10a3f0d58 100644
--- a/doc/src/sgml/arch-dev.sgml
+++ b/doc/src/sgml/arch-dev.sgml
@@ -178,7 +178,7 @@
     </itemizedlist>
    </para>
 
-   <sect2>
+   <sect2 id="parser-stage-parser">
     <title>Parser</title>
 
     <para>
@@ -241,7 +241,7 @@
 
    </sect2>
 
-   <sect2>
+   <sect2 id="parser-stage-transformation-process">
      <title>Transformation Process</title>
 
     <para>
@@ -365,7 +365,7 @@
     and plans.
    </para>
 
-   <sect2>
+   <sect2 id="planner-optimizer-generatingepossible-plans">
     <title>Generating Possible Plans</title>
 
     <para>
diff --git a/doc/src/sgml/auth-delay.sgml b/doc/src/sgml/auth-delay.sgml
index bd3ef7128d..108427b205 100644
--- a/doc/src/sgml/auth-delay.sgml
+++ b/doc/src/sgml/auth-delay.sgml
@@ -21,7 +21,7 @@
   <xref linkend="guc-shared-preload-libraries"/> in <filename>postgresql.conf</filename>.
  </para>
 
- <sect2>
+ <sect2 id="auth-delay-configuration-parameters">
   <title>Configuration Parameters</title>
 
   <variablelist>
@@ -54,7 +54,7 @@ auth_delay.milliseconds = '500'
 </programlisting>
  </sect2>
 
- <sect2>
+ <sect2 id="auth-delay-author">
   <title>Author</title>
 
   <para>
diff --git a/doc/src/sgml/auto-explain.sgml b/doc/src/sgml/auto-explain.sgml
index 30e35a714a..a93ed626b4 100644
--- a/doc/src/sgml/auto-explain.sgml
+++ b/doc/src/sgml/auto-explain.sgml
@@ -32,7 +32,7 @@ LOAD 'auto_explain';
   that.
  </para>
 
- <sect2>
+ <sect2 id="auto-explain-configuration-parameters">
   <title>Configuration Parameters</title>
 
  <para>
@@ -43,7 +43,7 @@ LOAD 'auto_explain';
  </para>
 
   <variablelist>
-   <varlistentry>
+   <varlistentry id="auto-explain-configuration-parameters-log_min_duration">
     <term>
      <varname>auto_explain.log_min_duration</varname> (<type>integer</type>)
      <indexterm>
@@ -63,7 +63,7 @@ LOAD 'auto_explain';
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="auto-explain-configuration-parameters-log_analyze">
     <term>
      <varname>auto_explain.log_analyze</varname> (<type>boolean</type>)
      <indexterm>
@@ -89,7 +89,7 @@ LOAD 'auto_explain';
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="auto-explain-configuration-parameters-log_buffers">
     <term>
      <varname>auto_explain.log_buffers</varname> (<type>boolean</type>)
      <indexterm>
@@ -109,7 +109,7 @@ LOAD 'auto_explain';
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="auto-explain-configuration-parameters-log_wal">
     <term>
      <varname>auto_explain.log_wal</varname> (<type>boolean</type>)
      <indexterm>
@@ -129,7 +129,7 @@ LOAD 'auto_explain';
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="auto-explain-configuration-parameters-log_timing">
     <term>
      <varname>auto_explain.log_timing</varname> (<type>boolean</type>)
      <indexterm>
@@ -153,7 +153,7 @@ LOAD 'auto_explain';
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="auto-explain-configuration-parameters-log_triggers">
     <term>
      <varname>auto_explain.log_triggers</varname> (<type>boolean</type>)
      <indexterm>
@@ -172,7 +172,7 @@ LOAD 'auto_explain';
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="auto-explain-configuration-parameters-log_verbose">
     <term>
      <varname>auto_explain.log_verbose</varname> (<type>boolean</type>)
      <indexterm>
@@ -190,7 +190,7 @@ LOAD 'auto_explain';
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="auto-explain-configuration-parameters-log_settings">
     <term>
      <varname>auto_explain.log_settings</varname> (<type>boolean</type>)
      <indexterm>
@@ -208,7 +208,7 @@ LOAD 'auto_explain';
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="auto-explain-configuration-parameters-log_format">
     <term>
      <varname>auto_explain.log_format</varname> (<type>enum</type>)
      <indexterm>
@@ -226,7 +226,7 @@ LOAD 'auto_explain';
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="auto-explain-configuration-parameters-log_level">
     <term>
      <varname>auto_explain.log_level</varname> (<type>enum</type>)
      <indexterm>
@@ -247,7 +247,7 @@ LOAD 'auto_explain';
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="auto-explain-configuration-parameters-log_nested_statements">
     <term>
      <varname>auto_explain.log_nested_statements</varname> (<type>boolean</type>)
      <indexterm>
@@ -264,7 +264,7 @@ LOAD 'auto_explain';
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="auto-explain-configuration-parameters-sample_rate">
     <term>
      <varname>auto_explain.sample_rate</varname> (<type>real</type>)
      <indexterm>
@@ -297,7 +297,7 @@ auto_explain.log_min_duration = '3s'
 </programlisting>
  </sect2>
 
- <sect2>
+ <sect2 id="auto-explain-example">
   <title>Example</title>
 
 <programlisting>
@@ -329,7 +329,7 @@ LOG:  duration: 3.651 ms  plan:
 ]]></screen>
  </sect2>
 
- <sect2>
+ <sect2 id="auto-explain-author">
   <title>Author</title>
 
   <para>
diff --git a/doc/src/sgml/basic-archive.sgml b/doc/src/sgml/basic-archive.sgml
index 0b650f17a8..60f23d2855 100644
--- a/doc/src/sgml/basic-archive.sgml
+++ b/doc/src/sgml/basic-archive.sgml
@@ -21,7 +21,7 @@
   must be enabled.
  </para>
 
- <sect2>
+ <sect2 id="basic-archive-configuration-parameters">
   <title>Configuration Parameters</title>
 
   <variablelist>
@@ -57,7 +57,7 @@ basic_archive.archive_directory = '/path/to/archive/directory'
 </programlisting>
  </sect2>
 
- <sect2>
+ <sect2 id="basic-archive-notes">
   <title>Notes</title>
 
   <para>
@@ -70,7 +70,7 @@ basic_archive.archive_directory = '/path/to/archive/directory'
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="basic-archive-author">
   <title>Author</title>
 
   <para>
diff --git a/doc/src/sgml/bloom.sgml b/doc/src/sgml/bloom.sgml
index d1cf9ac24a..b43d9d4e44 100644
--- a/doc/src/sgml/bloom.sgml
+++ b/doc/src/sgml/bloom.sgml
@@ -38,7 +38,7 @@
   indexes can also perform inequality and range searches.
  </para>
 
- <sect2>
+ <sect2 id="bloom-parameters">
   <title>Parameters</title>
 
   <para>
@@ -73,7 +73,7 @@
    </variablelist>
  </sect2>
 
- <sect2>
+ <sect2 id="bloom-examples">
   <title>Examples</title>
 
   <para>
@@ -215,7 +215,7 @@ CREATE INDEX
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="bloom-operator-class-interface">
   <title>Operator Class Interface</title>
 
   <para>
@@ -232,7 +232,7 @@ DEFAULT FOR TYPE text USING bloom AS
 </programlisting>
  </sect2>
 
- <sect2>
+ <sect2 id="bloom-limitations">
   <title>Limitations</title>
   <para>
    <itemizedlist>
@@ -268,7 +268,7 @@ DEFAULT FOR TYPE text USING bloom AS
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="bloom-authors">
   <title>Authors</title>
 
   <para>
diff --git a/doc/src/sgml/btree-gin.sgml b/doc/src/sgml/btree-gin.sgml
index 5bc5a054e8..870c25559e 100644
--- a/doc/src/sgml/btree-gin.sgml
+++ b/doc/src/sgml/btree-gin.sgml
@@ -38,7 +38,7 @@
   on the current database.
  </para>
 
- <sect2>
+ <sect2 id="btree-gin-example-usage">
   <title>Example Usage</title>
 
 <programlisting>
@@ -51,7 +51,7 @@ SELECT * FROM test WHERE a &lt; 10;
 
  </sect2>
 
- <sect2>
+ <sect2 id="btree-gin-authors">
   <title>Authors</title>
 
   <para>
diff --git a/doc/src/sgml/btree-gist.sgml b/doc/src/sgml/btree-gist.sgml
index b67f20a00f..92aa8e277e 100644
--- a/doc/src/sgml/btree-gist.sgml
+++ b/doc/src/sgml/btree-gist.sgml
@@ -58,7 +58,7 @@
   on the current database.
  </para>
 
- <sect2>
+ <sect2 id="btree-gist-example-usage">
   <title>Example Usage</title>
 
   <para>
@@ -101,7 +101,7 @@ INSERT 0 1
 
  </sect2>
 
- <sect2>
+ <sect2 id="btree-gist-authors">
   <title>Authors</title>
 
   <para>
diff --git a/doc/src/sgml/charset.sgml b/doc/src/sgml/charset.sgml
index f203c368c2..b0d2783d21 100644
--- a/doc/src/sgml/charset.sgml
+++ b/doc/src/sgml/charset.sgml
@@ -46,7 +46,7 @@
    system.
   </para>
 
-  <sect2>
+  <sect2 id="locale-overview">
    <title>Overview</title>
 
    <para>
@@ -206,7 +206,7 @@ initdb --locale=sv_SE
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="locale-behavior">
    <title>Behavior</title>
 
    <para>
@@ -276,7 +276,7 @@ initdb --locale=sv_SE
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="locale-problems">
    <title>Problems</title>
 
    <para>
@@ -338,7 +338,7 @@ initdb --locale=sv_SE
    of a database cannot be changed after its creation.
   </para>
 
-  <sect2>
+  <sect2 id="collation-concepts">
    <title>Concepts</title>
 
    <para>
@@ -540,7 +540,7 @@ SELECT * FROM test1 ORDER BY a || b COLLATE "fr_FR";
     a database.
    </para>
 
-   <sect3>
+   <sect3 id="collation-managing-standard">
     <title>Standard Collations</title>
 
    <para>
@@ -563,7 +563,7 @@ SELECT * FROM test1 ORDER BY a || b COLLATE "fr_FR";
    </para>
   </sect3>
 
-  <sect3>
+  <sect3 id="collation-managing-predefined">
    <title>Predefined Collations</title>
 
    <para>
@@ -582,7 +582,7 @@ SELECT * FROM test1 ORDER BY a || b COLLATE "fr_FR";
     in <application>psql</application>.
    </para>
 
-  <sect4>
+  <sect4 id="collation-managing-predefined-libc">
    <title>libc Collations</title>
 
    <para>
@@ -639,7 +639,7 @@ SELECT a COLLATE "C" &lt; b COLLATE "POSIX" FROM test1;
    </para>
   </sect4>
 
-  <sect4>
+  <sect4 id="collation-managing-predefined-icu">
    <title>ICU Collations</title>
 
    <para>
@@ -658,14 +658,14 @@ SELECT a COLLATE "C" &lt; b COLLATE "POSIX" FROM test1;
     Here are some example collations that might be created:
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="collation-managing-predefined-icu-de-x-icu">
       <term><literal>de-x-icu</literal></term>
       <listitem>
        <para>German collation, default variant</para>
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="collation-managing-predefined-icu-de-at-x-icu">
       <term><literal>de-AT-x-icu</literal></term>
       <listitem>
        <para>German collation for Austria, default variant</para>
@@ -677,7 +677,7 @@ SELECT a COLLATE "C" &lt; b COLLATE "POSIX" FROM test1;
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="collation-managing-predefined-icu-und-x-icu">
       <term><literal>und-x-icu</literal> (for <quote>undefined</quote>)</term>
       <listitem>
        <para>
@@ -715,7 +715,7 @@ SELECT a COLLATE "C" &lt; b COLLATE "POSIX" FROM test1;
     ensures that they are saved by <command>pg_dump</command>.
    </para>
 
-   <sect4>
+   <sect4 id="collation-managing-create-libc">
     <title>libc Collations</title>
 
     <para>
@@ -739,7 +739,7 @@ CREATE COLLATION german (provider = libc, locale = 'de_DE');
     </para>
    </sect4>
 
-   <sect4>
+   <sect4 id="collation-managing-create-icu">
     <title>ICU Collations</title>
 
    <para>
@@ -757,7 +757,7 @@ CREATE COLLATION german (provider = libc, locale = 'de_DE');
     Here are some examples:
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="collation-managing-create-icu-de-u-co-phonebk-x-icu">
       <term><literal>CREATE COLLATION "de-u-co-phonebk-x-icu" (provider = icu, locale = 'de-u-co-phonebk');</literal></term>
       <term><literal>CREATE COLLATION "de-u-co-phonebk-x-icu" (provider = icu, locale = 'de@collation=phonebook');</literal></term>
       <listitem>
@@ -777,7 +777,7 @@ CREATE COLLATION german (provider = libc, locale = 'de_DE');
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="collation-managing-create-icu-und-u-co-emoji-x-icu">
       <term><literal>CREATE COLLATION "und-u-co-emoji-x-icu" (provider = icu, locale = 'und-u-co-emoji');</literal></term>
       <term><literal>CREATE COLLATION "und-u-co-emoji-x-icu" (provider = icu, locale = '@collation=emoji');</literal></term>
       <listitem>
@@ -791,7 +791,7 @@ CREATE COLLATION german (provider = libc, locale = 'de_DE');
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="collation-managing-create-icu-en-u-kr-grek-latn">
       <term><literal>CREATE COLLATION latinlast (provider = icu, locale = 'en-u-kr-grek-latn');</literal></term>
       <term><literal>CREATE COLLATION latinlast (provider = icu, locale = 'en@colReorder=grek-latn');</literal></term>
       <listitem>
@@ -801,7 +801,7 @@ CREATE COLLATION german (provider = libc, locale = 'de_DE');
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="collation-managing-create-icu-en-u-kf-upper">
       <term><literal>CREATE COLLATION upperfirst (provider = icu, locale = 'en-u-kf-upper');</literal></term>
       <term><literal>CREATE COLLATION upperfirst (provider = icu, locale = 'en@colCaseFirst=upper');</literal></term>
       <listitem>
@@ -812,7 +812,7 @@ CREATE COLLATION german (provider = libc, locale = 'de_DE');
       </listitem>
      </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="collation-managing-create-icu-en-u-kf-upper-kr-grek-latn">
       <term><literal>CREATE COLLATION special (provider = icu, locale = 'en-u-kf-upper-kr-grek-latn');</literal></term>
       <term><literal>CREATE COLLATION special (provider = icu, locale = 'en@colCaseFirst=upper;colReorder=grek-latn');</literal></term>
       <listitem>
@@ -822,7 +822,7 @@ CREATE COLLATION german (provider = libc, locale = 'de_DE');
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="collation-managing-create-icu-en-u-kn-true">
       <term><literal>CREATE COLLATION numeric (provider = icu, locale = 'en-u-kn-true');</literal></term>
       <term><literal>CREATE COLLATION numeric (provider = icu, locale = 'en@colNumeric=yes');</literal></term>
       <listitem>
@@ -1420,7 +1420,7 @@ CREATE COLLATION ignore_accents (provider = icu, locale = 'und-u-ks-level1-kc-tr
      </para>
     </sect2>
 
-   <sect2>
+   <sect2 id="multibyte-setting">
     <title>Setting the Character Set</title>
 
     <para>
@@ -1508,7 +1508,7 @@ $ <userinput>psql -l</userinput>
     </important>
    </sect2>
 
-   <sect2>
+   <sect2 id="multibyte-automatic-conversion">
     <title>Automatic Character Set Conversion Between Server and Client</title>
 
     <para>
@@ -2590,7 +2590,7 @@ RESET client_encoding;
     </table>
    </sect2>
 
-   <sect2>
+   <sect2 id="multibyte-further-reading">
     <title>Further Reading</title>
 
     <para>
diff --git a/doc/src/sgml/citext.sgml b/doc/src/sgml/citext.sgml
index 5986601327..3df2825592 100644
--- a/doc/src/sgml/citext.sgml
+++ b/doc/src/sgml/citext.sgml
@@ -30,7 +30,7 @@
   on the current database.
  </para>
 
- <sect2>
+ <sect2 id="citext-rationale">
   <title>Rationale</title>
 
   <para>
@@ -84,7 +84,7 @@ SELECT * FROM tab WHERE lower(col) = LOWER(?);
 
  </sect2>
 
- <sect2>
+ <sect2 id="citext-how-to-use-it">
   <title>How to Use It</title>
 
   <para>
@@ -111,7 +111,7 @@ SELECT * FROM users WHERE nick = 'Larry';
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="citext-string-comparison-behavior">
   <title>String Comparison Behavior</title>
 
   <para>
@@ -196,7 +196,7 @@ SELECT * FROM users WHERE nick = 'Larry';
 
  </sect2>
 
- <sect2>
+ <sect2 id="citext-limitations">
   <title>Limitations</title>
 
    <itemizedlist>
@@ -277,7 +277,7 @@ SELECT * FROM users WHERE nick = 'Larry';
    </itemizedlist>
  </sect2>
 
- <sect2>
+ <sect2 id="citext-author">
   <title>Author</title>
 
   <para>
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 7ed8c82a9d..9f63d8140e 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -314,7 +314,7 @@ UPDATE pg_settings SET setting = reset_val WHERE name = 'configuration_parameter
 
    </sect2>
 
-   <sect2>
+   <sect2 id="config-setting-parameter-interaction">
     <title>Parameter Interaction via the Shell</title>
 
      <para>
@@ -1339,7 +1339,7 @@ include_dir 'conf.d'
        <para>
         Explanation of the default value:
         <variablelist>
-         <varlistentry>
+         <varlistentry id="guc-ssl-ciphers-high">
           <term><literal>HIGH</literal></term>
           <listitem>
            <para>
@@ -1349,7 +1349,7 @@ include_dir 'conf.d'
           </listitem>
          </varlistentry>
 
-         <varlistentry>
+         <varlistentry id="guc-ssl-ciphers-medium">
           <term><literal>MEDIUM</literal></term>
           <listitem>
            <para>
@@ -1359,7 +1359,7 @@ include_dir 'conf.d'
           </listitem>
          </varlistentry>
 
-         <varlistentry>
+         <varlistentry id="guc-ssl-ciphers-plus-3des">
           <term><literal>+3DES</literal></term>
           <listitem>
            <para>
@@ -1373,7 +1373,7 @@ include_dir 'conf.d'
           </listitem>
          </varlistentry>
 
-         <varlistentry>
+         <varlistentry id="guc-ssl-ciphers-not-anull">
           <term><literal>!aNULL</literal></term>
           <listitem>
            <para>
@@ -6742,7 +6742,7 @@ local0.*    /var/log/postgresql
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="guc-debug_print_parse-et-al">
       <term><varname>debug_print_parse</varname> (<type>boolean</type>)
       <indexterm>
        <primary><varname>debug_print_parse</varname> configuration parameter</primary>
@@ -6773,7 +6773,7 @@ local0.*    /var/log/postgresql
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="guc-debug_pretty_print">
       <term><varname>debug_pretty_print</varname> (<type>boolean</type>)
       <indexterm>
        <primary><varname>debug_pretty_print</varname> configuration parameter</primary>
@@ -7687,7 +7687,7 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
      </table>
     </sect2>
 
-   <sect2>
+   <sect2 id="runtime-config-logging-proc-title">
     <title>Process Title</title>
 
     <para>
@@ -7952,7 +7952,7 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="guc-log_statement_stats-et-al">
       <term><varname>log_statement_stats</varname> (<type>boolean</type>)
       <indexterm>
        <primary><varname>log_statement_stats</varname> configuration parameter</primary>
@@ -10918,7 +10918,7 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="guc-trace_locks">
       <term><varname>trace_locks</varname> (<type>boolean</type>)
       <indexterm>
        <primary><varname>trace_locks</varname> configuration parameter</primary>
@@ -10959,7 +10959,7 @@ LOG:  CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="guc-trace_lwlocks">
       <term><varname>trace_lwlocks</varname> (<type>boolean</type>)
       <indexterm>
        <primary><varname>trace_lwlocks</varname> configuration parameter</primary>
@@ -10979,7 +10979,7 @@ LOG:  CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="guc-trace_userlocks">
       <term><varname>trace_userlocks</varname> (<type>boolean</type>)
       <indexterm>
        <primary><varname>trace_userlocks</varname> configuration parameter</primary>
@@ -10998,7 +10998,7 @@ LOG:  CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="guc-trace_lock_oidmin">
       <term><varname>trace_lock_oidmin</varname> (<type>integer</type>)
       <indexterm>
        <primary><varname>trace_lock_oidmin</varname> configuration parameter</primary>
@@ -11017,7 +11017,7 @@ LOG:  CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="guc-trace_lock_table">
       <term><varname>trace_lock_table</varname> (<type>integer</type>)
       <indexterm>
        <primary><varname>trace_lock_table</varname> configuration parameter</primary>
@@ -11035,7 +11035,7 @@ LOG:  CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="guc-debug_deadlocks">
       <term><varname>debug_deadlocks</varname> (<type>boolean</type>)
       <indexterm>
        <primary><varname>debug_deadlocks</varname> configuration parameter</primary>
@@ -11054,7 +11054,7 @@ LOG:  CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="guc-log_btree_build_stats">
       <term><varname>log_btree_build_stats</varname> (<type>boolean</type>)
       <indexterm>
        <primary><varname>log_btree_build_stats</varname> configuration parameter</primary>
diff --git a/doc/src/sgml/contrib-spi.sgml b/doc/src/sgml/contrib-spi.sgml
index fed6f24932..f4b0a01a81 100644
--- a/doc/src/sgml/contrib-spi.sgml
+++ b/doc/src/sgml/contrib-spi.sgml
@@ -24,7 +24,7 @@
   separately-installable extension.
  </para>
 
- <sect2>
+ <sect2 id="contrib-spi-refint">
   <title>refint &mdash; Functions for Implementing Referential Integrity</title>
 
   <para>
@@ -65,7 +65,7 @@
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="contrib-spi-autoinc">
   <title>autoinc &mdash; Functions for Autoincrementing Fields</title>
 
   <para>
@@ -92,7 +92,7 @@
 
  </sect2>
 
- <sect2>
+ <sect2 id="contrib-spi-insert_username">
   <title>insert_username &mdash; Functions for Tracking Who Changed a Table</title>
 
   <para>
@@ -113,7 +113,7 @@
 
  </sect2>
 
- <sect2>
+ <sect2 id="contrib-spi-moddatetime">
   <title>moddatetime &mdash; Functions for Tracking Last Modification Time</title>
 
   <para>
diff --git a/doc/src/sgml/cube.sgml b/doc/src/sgml/cube.sgml
index adf8dbaa91..9bdf894fd1 100644
--- a/doc/src/sgml/cube.sgml
+++ b/doc/src/sgml/cube.sgml
@@ -18,7 +18,7 @@
   on the current database.
  </para>
 
- <sect2>
+ <sect2 id="cube-syntax">
   <title>Syntax</title>
 
   <para>
@@ -99,7 +99,7 @@
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="cube-precision">
   <title>Precision</title>
 
   <para>
@@ -108,7 +108,7 @@
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="cube-usage">
   <title>Usage</title>
 
   <para>
@@ -533,7 +533,7 @@ SELECT c FROM test ORDER BY c ~&gt; 3 DESC LIMIT 5;
   </table>
  </sect2>
 
- <sect2>
+ <sect2 id="cube-defaults">
   <title>Defaults</title>
 
   <para>
@@ -587,7 +587,7 @@ t
 </programlisting>
  </sect2>
 
- <sect2>
+ <sect2 id="cube-notes">
   <title>Notes</title>
 
   <para>
@@ -601,7 +601,7 @@ t
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="cube-credits">
   <title>Credits</title>
 
   <para>
diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml
index 0932c812da..8e059e675c 100644
--- a/doc/src/sgml/datatype.sgml
+++ b/doc/src/sgml/datatype.sgml
@@ -1454,7 +1454,7 @@ SELECT b, char_length(b) FROM test2;
     mostly the same.
    </para>
 
-  <sect2>
+  <sect2 id="datatype-binary-bytea-hex-format">
    <title><type>bytea</type> Hex Format</title>
 
    <para>
@@ -1481,7 +1481,7 @@ SELECT '\xDEADBEEF';
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="datatype-binary-bytea-escape-format">
    <title><type>bytea</type> Escape Format</title>
 
    <para>
@@ -1887,7 +1887,7 @@ MINUTE TO SECOND
      more than 6 digits).
     </para>
 
-    <sect3>
+    <sect3 id="datatype-datetime-input-dates">
     <title>Dates</title>
 
     <indexterm>
@@ -1986,7 +1986,7 @@ MINUTE TO SECOND
      </table>
     </sect3>
 
-    <sect3>
+    <sect3 id="datatype-datetime-input-times">
      <title>Times</title>
 
      <indexterm>
@@ -2150,7 +2150,7 @@ MINUTE TO SECOND
     </para>
     </sect3>
 
-    <sect3>
+    <sect3 id="datatype-datetime-input-time-stamps">
     <title>Time Stamps</title>
 
     <indexterm>
@@ -3155,7 +3155,7 @@ SELECT * FROM test1 WHERE a;
     a piece of data.
    </para>
 
-   <sect2>
+   <sect2 id="datatype-enum-declaration">
     <title>Declaration of Enumerated Types</title>
 
     <para>
@@ -3185,7 +3185,7 @@ SELECT * FROM person WHERE current_mood = 'happy';
     </para>
     </sect2>
 
-    <sect2>
+    <sect2 id="datatype-enum-ordering">
      <title>Ordering</title>
 
      <para>
@@ -3222,7 +3222,7 @@ WHERE current_mood = (SELECT MIN(current_mood) FROM person);
      </para>
    </sect2>
 
-   <sect2>
+   <sect2 id="datatype-enum-type-safety">
     <title>Type Safety</title>
 
     <para>
@@ -3262,7 +3262,7 @@ SELECT person.name, holidays.num_weeks FROM person, holidays
     </para>
    </sect2>
 
-   <sect2>
+   <sect2 id="datatype-enum-implementation-details">
     <title>Implementation Details</title>
 
     <para>
@@ -3379,7 +3379,7 @@ SELECT person.name, holidays.num_weeks FROM person, holidays
     intersections.  They are explained in <xref linkend="functions-geometry"/>.
    </para>
 
-   <sect2>
+   <sect2 id="datatype-geometric-points">
     <title>Points</title>
 
     <indexterm>
@@ -3473,7 +3473,7 @@ SELECT person.name, holidays.num_weeks FROM person, holidays
     </para>
    </sect2>
 
-   <sect2>
+   <sect2 id="datatype-geometric-boxes">
     <title>Boxes</title>
 
     <indexterm>
@@ -3514,7 +3514,7 @@ SELECT person.name, holidays.num_weeks FROM person, holidays
     </para>
    </sect2>
 
-   <sect2>
+   <sect2 id="datatype-geometric-paths">
     <title>Paths</title>
 
     <indexterm>
@@ -4405,7 +4405,7 @@ a0ee-bc99-9c0b-4ef8-bb6d-6bb9-bd38-0a11
     can be found in <xref linkend="xml-limits-conformance"/>.
    </para>
 
-   <sect2>
+   <sect2 id="datatype-xml-creating">
     <title>Creating XML Values</title>
    <para>
     To produce a value of type <type>xml</type> from character data,
@@ -4475,7 +4475,7 @@ SET xmloption TO { DOCUMENT | CONTENT };
 
    </sect2>
 
-   <sect2>
+   <sect2 id="datatype-xml-encoding-handling">
     <title>Encoding Handling</title>
    <para>
     Care must be taken when dealing with multiple character encodings
@@ -4533,7 +4533,7 @@ SET xmloption TO { DOCUMENT | CONTENT };
    </caution>
    </sect2>
 
-   <sect2>
+   <sect2 id="datatype-xml-accessing-xml-values">
    <title>Accessing XML Values</title>
 
    <para>
diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 166b7a352d..1c47dc5498 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -602,7 +602,7 @@ CREATE TABLE products (
    </note>
   </sect2>
 
-  <sect2>
+  <sect2 id="ddl-constraints-not-null">
    <title>Not-Null Constraints</title>
 
    <indexterm>
@@ -1230,7 +1230,7 @@ CREATE TABLE circles (
   </indexterm>
 
   <variablelist>
-   <varlistentry>
+   <varlistentry id="ddl-system-columns-tableoid">
     <term><structfield>tableoid</structfield></term>
     <listitem>
      <indexterm>
@@ -1250,7 +1250,7 @@ CREATE TABLE circles (
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="ddl-system-columns-xmin">
     <term><structfield>xmin</structfield></term>
     <listitem>
      <indexterm>
@@ -1266,7 +1266,7 @@ CREATE TABLE circles (
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="ddl-system-columns-cmin">
     <term><structfield>cmin</structfield></term>
     <listitem>
      <indexterm>
@@ -1280,7 +1280,7 @@ CREATE TABLE circles (
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="ddl-system-columns-xmax">
     <term><structfield>xmax</structfield></term>
     <listitem>
      <indexterm>
@@ -1297,7 +1297,7 @@ CREATE TABLE circles (
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="ddl-system-columns-cmax">
     <term><structfield>cmax</structfield></term>
     <listitem>
      <indexterm>
@@ -1310,7 +1310,7 @@ CREATE TABLE circles (
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="ddl-system-columns-ctid">
     <term><structfield>ctid</structfield></term>
     <listitem>
      <indexterm>
@@ -1558,7 +1558,7 @@ ALTER TABLE products ALTER COLUMN product_no DROP NOT NULL;
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="ddl-alter-column-default">
    <title>Changing a Column's Default Value</title>
 
    <indexterm>
@@ -1587,7 +1587,7 @@ ALTER TABLE products ALTER COLUMN price DROP DEFAULT;
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="ddl-alter-column-type">
    <title>Changing a Column's Data Type</title>
 
    <indexterm>
@@ -1616,7 +1616,7 @@ ALTER TABLE products ALTER COLUMN price TYPE numeric(10,2);
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="ddl-alter-renaming-column">
    <title>Renaming a Column</title>
 
    <indexterm>
@@ -1632,7 +1632,7 @@ ALTER TABLE products RENAME COLUMN product_no TO product_number;
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="ddl-alter-renaming-table">
    <title>Renaming a Table</title>
 
    <indexterm>
@@ -1767,7 +1767,7 @@ REVOKE ALL ON accounts FROM PUBLIC;
    The available privileges are:
 
    <variablelist>
-    <varlistentry>
+    <varlistentry id="ddl-priv-select">
      <term><literal>SELECT</literal></term>
      <listitem>
       <para>
@@ -1784,7 +1784,7 @@ REVOKE ALL ON accounts FROM PUBLIC;
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ddl-priv-insert">
      <term><literal>INSERT</literal></term>
      <listitem>
       <para>
@@ -1797,7 +1797,7 @@ REVOKE ALL ON accounts FROM PUBLIC;
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ddl-priv-update">
      <term><literal>UPDATE</literal></term>
      <listitem>
       <para>
@@ -1819,7 +1819,7 @@ REVOKE ALL ON accounts FROM PUBLIC;
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ddl-priv-delete">
      <term><literal>DELETE</literal></term>
      <listitem>
       <para>
@@ -1831,7 +1831,7 @@ REVOKE ALL ON accounts FROM PUBLIC;
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ddl-priv-truncate">
      <term><literal>TRUNCATE</literal></term>
      <listitem>
       <para>
@@ -1840,7 +1840,7 @@ REVOKE ALL ON accounts FROM PUBLIC;
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ddl-priv-references">
      <term><literal>REFERENCES</literal></term>
      <listitem>
       <para>
@@ -1850,7 +1850,7 @@ REVOKE ALL ON accounts FROM PUBLIC;
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ddl-priv-trigger">
      <term><literal>TRIGGER</literal></term>
      <listitem>
       <para>
@@ -1859,7 +1859,7 @@ REVOKE ALL ON accounts FROM PUBLIC;
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ddl-priv-create">
      <term><literal>CREATE</literal></term>
      <listitem>
       <para>
@@ -1885,7 +1885,7 @@ REVOKE ALL ON accounts FROM PUBLIC;
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ddl-priv-connect">
      <term><literal>CONNECT</literal></term>
      <listitem>
       <para>
@@ -1896,7 +1896,7 @@ REVOKE ALL ON accounts FROM PUBLIC;
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ddl-priv-temporary">
      <term><literal>TEMPORARY</literal></term>
      <listitem>
       <para>
@@ -1905,7 +1905,7 @@ REVOKE ALL ON accounts FROM PUBLIC;
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ddl-priv-execute">
      <term><literal>EXECUTE</literal></term>
      <listitem>
       <para>
@@ -1916,7 +1916,7 @@ REVOKE ALL ON accounts FROM PUBLIC;
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ddl-priv-usage">
      <term><literal>USAGE</literal></term>
      <listitem>
       <para>
@@ -3688,7 +3688,7 @@ VALUES ('Albany', NULL, NULL, 'NY');
      following forms of partitioning:
 
      <variablelist>
-      <varlistentry>
+      <varlistentry id="ddl-partitioning-overview-range">
        <term>Range Partitioning</term>
 
        <listitem>
@@ -3709,7 +3709,7 @@ VALUES ('Albany', NULL, NULL, 'NY');
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="ddl-partitioning-overview-list">
        <term>List Partitioning</term>
 
        <listitem>
@@ -3720,7 +3720,7 @@ VALUES ('Albany', NULL, NULL, 'NY');
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="ddl-partitioning-overview-hash">
        <term>Hash Partitioning</term>
 
        <listitem>
diff --git a/doc/src/sgml/dict-int.sgml b/doc/src/sgml/dict-int.sgml
index 8babfdd5c2..53ae8b6637 100644
--- a/doc/src/sgml/dict-int.sgml
+++ b/doc/src/sgml/dict-int.sgml
@@ -21,7 +21,7 @@
   on the current database.
  </para>
 
- <sect2>
+ <sect2 id="dict-int-config">
   <title>Configuration</title>
 
   <para>
@@ -58,7 +58,7 @@
   </itemizedlist>
  </sect2>
 
- <sect2>
+ <sect2 id="dict-int-usage">
   <title>Usage</title>
 
   <para>
diff --git a/doc/src/sgml/dict-xsyn.sgml b/doc/src/sgml/dict-xsyn.sgml
index 256aff7c58..27b24628d4 100644
--- a/doc/src/sgml/dict-xsyn.sgml
+++ b/doc/src/sgml/dict-xsyn.sgml
@@ -14,7 +14,7 @@
   search for a word using any of its synonyms.
  </para>
 
- <sect2>
+ <sect2 id="dict-xsyn-config">
   <title>Configuration</title>
 
   <para>
@@ -83,7 +83,7 @@ word syn1 syn2 syn3
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="dict-xsyn-usage">
   <title>Usage</title>
 
   <para>
diff --git a/doc/src/sgml/docguide.sgml b/doc/src/sgml/docguide.sgml
index 05dd9a8b44..c7d4ce3737 100644
--- a/doc/src/sgml/docguide.sgml
+++ b/doc/src/sgml/docguide.sgml
@@ -79,7 +79,7 @@
    might be optional, as noted.
 
    <variablelist>
-    <varlistentry>
+    <varlistentry id="docguide-toolsets-docbook-dtd">
      <term><ulink url="https://www.oasis-open.org/docbook/">DocBook DTD</ulink></term>
      <listitem>
       <para>
@@ -91,7 +91,7 @@
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="docguide-toolsets-docbook-xsl">
      <term><ulink url="https://github.com/docbook/wiki/wiki/DocBookXslStylesheets">DocBook XSL Stylesheets</ulink></term>
      <listitem>
       <para>
@@ -107,7 +107,7 @@
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="docguide-toolsets-libxml2">
      <term><ulink url="http://xmlsoft.org/">Libxml2</ulink> for <command>xmllint</command></term>
      <listitem>
       <para>
@@ -121,7 +121,7 @@
      </listitem>
      </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="docguide-toolsets-libxslt">
      <term><ulink url="http://xmlsoft.org/XSLT/">Libxslt</ulink> for <command>xsltproc</command></term>
      <listitem>
       <para>
@@ -131,7 +131,7 @@
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="docguide-toolsets-fop">
      <term><ulink url="https://xmlgraphics.apache.org/fop/">FOP</ulink></term>
      <listitem>
       <para>
@@ -163,7 +163,7 @@
    for an example.
   </para>
 
-  <sect2>
+  <sect2 id="docguide-toolsets-inst-fedora-et-al">
    <title>Installation on Fedora, RHEL, and Derivatives</title>
 
    <para>
@@ -174,7 +174,7 @@ yum install docbook-dtds docbook-style-xsl fop libxslt
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="docguide-toolsets-inst-freebsd">
    <title>Installation on FreeBSD</title>
 
    <para>
@@ -191,7 +191,7 @@ pkg install docbook-xml docbook-xsl fop libxslt
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="docguide-toolsets-inst-debian">
    <title>Debian Packages</title>
 
    <para>
@@ -204,7 +204,7 @@ apt-get install docbook-xml docbook-xsl fop libxml2-utils xsltproc
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="docguide-toolsets-inst-macos">
    <title>macOS</title>
 
    <para>
@@ -274,7 +274,7 @@ checking for dbtoepub... dbtoepub
    documentation. (Remember to use GNU make.)
   </para>
 
-  <sect2>
+  <sect2 id="docguide-build-html">
    <title>HTML</title>
 
    <para>
@@ -303,7 +303,7 @@ checking for dbtoepub... dbtoepub
    </para>
  </sect2>
 
- <sect2>
+ <sect2 id="docguide-build-manpages">
   <title>Manpages</title>
 
   <para>
@@ -317,7 +317,7 @@ checking for dbtoepub... dbtoepub
   </para>
  </sect2>
 
-  <sect2>
+  <sect2 id="docguide-build-pdf">
    <title>PDF</title>
 
    <para>
@@ -373,7 +373,7 @@ ADDITIONAL_FLAGS='-Xmx1500m'
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="docguide-build-plain-text">
    <title>Plain Text Files</title>
 
    <para>
@@ -395,7 +395,7 @@ ADDITIONAL_FLAGS='-Xmx1500m'
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="docguide-build-syntax-check">
    <title>Syntax Check</title>
 
    <para>
@@ -427,7 +427,7 @@ ADDITIONAL_FLAGS='-Xmx1500m'
     correct mode.
    </para>
 
-   <sect2>
+   <sect2 id="docguide-authoring-emacs">
     <title>Emacs</title>
 
     <para>
@@ -453,7 +453,7 @@ ADDITIONAL_FLAGS='-Xmx1500m'
  <sect1 id="docguide-style">
   <title>Style Guide</title>
 
-  <sect2>
+  <sect2 id="docguide-style-ref-pages">
    <title>Reference Pages</title>
 
    <para>
@@ -476,7 +476,7 @@ ADDITIONAL_FLAGS='-Xmx1500m'
     <quote>Usage</quote> section.
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="docguide-style-ref-pages-name">
       <term>Name</term>
       <listitem>
        <para>
@@ -486,7 +486,7 @@ ADDITIONAL_FLAGS='-Xmx1500m'
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="docguide-style-ref-pages-synopsis">
       <term>Synopsis</term>
       <listitem>
        <para>
@@ -498,7 +498,7 @@ ADDITIONAL_FLAGS='-Xmx1500m'
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="docguide-style-ref-pages-description">
       <term>Description</term>
       <listitem>
        <para>
@@ -507,7 +507,7 @@ ADDITIONAL_FLAGS='-Xmx1500m'
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="docguide-style-ref-pages-options">
       <term>Options</term>
       <listitem>
        <para>
@@ -517,7 +517,7 @@ ADDITIONAL_FLAGS='-Xmx1500m'
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="docguide-style-ref-pages-exit-status">
       <term>Exit Status</term>
       <listitem>
        <para>
@@ -528,7 +528,7 @@ ADDITIONAL_FLAGS='-Xmx1500m'
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="docguide-style-ref-pages-usage">
       <term>Usage</term>
       <listitem>
        <para>
@@ -540,7 +540,7 @@ ADDITIONAL_FLAGS='-Xmx1500m'
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="docguide-style-ref-pages-environment">
       <term>Environment</term>
       <listitem>
        <para>
@@ -551,7 +551,7 @@ ADDITIONAL_FLAGS='-Xmx1500m'
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="docguide-style-ref-pages-files">
       <term>Files</term>
       <listitem>
        <para>
@@ -562,7 +562,7 @@ ADDITIONAL_FLAGS='-Xmx1500m'
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="docguide-style-ref-pages-diagnostics">
       <term>Diagnostics</term>
       <listitem>
        <para>
@@ -575,7 +575,7 @@ ADDITIONAL_FLAGS='-Xmx1500m'
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="docguide-style-ref-pages-notes">
       <term>Notes</term>
       <listitem>
        <para>
@@ -586,7 +586,7 @@ ADDITIONAL_FLAGS='-Xmx1500m'
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="docguide-style-ref-pages-examples">
       <term>Examples</term>
       <listitem>
        <para>
@@ -595,7 +595,7 @@ ADDITIONAL_FLAGS='-Xmx1500m'
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="docguide-style-ref-pages-history">
       <term>History</term>
       <listitem>
        <para>
@@ -606,7 +606,7 @@ ADDITIONAL_FLAGS='-Xmx1500m'
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="docguide-style-ref-pages-author">
       <term>Author</term>
       <listitem>
        <para>
@@ -615,7 +615,7 @@ ADDITIONAL_FLAGS='-Xmx1500m'
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="docguide-style-ref-pages-see-also">
       <term>See Also</term>
       <listitem>
        <para>
diff --git a/doc/src/sgml/earthdistance.sgml b/doc/src/sgml/earthdistance.sgml
index 4377249c36..f15dde3a66 100644
--- a/doc/src/sgml/earthdistance.sgml
+++ b/doc/src/sgml/earthdistance.sgml
@@ -44,7 +44,7 @@
   </para>
  </caution>
 
- <sect2>
+ <sect2 id="earthdistance-cube-based">
   <title>Cube-Based Earth Distances</title>
 
   <para>
@@ -202,7 +202,7 @@
 
  </sect2>
 
- <sect2>
+ <sect2 id="earthdistance-point-based">
   <title>Point-Based Earth Distances</title>
 
   <para>
diff --git a/doc/src/sgml/ecpg.sgml b/doc/src/sgml/ecpg.sgml
index cdc4761c60..0de121e678 100644
--- a/doc/src/sgml/ecpg.sgml
+++ b/doc/src/sgml/ecpg.sgml
@@ -584,7 +584,7 @@ EXEC SQL COMMIT;
     The following transaction management commands are available:
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-transactions-exec-sql-commit">
       <term><literal>EXEC SQL COMMIT</literal></term>
       <listitem>
        <para>
@@ -593,7 +593,7 @@ EXEC SQL COMMIT;
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-transactions-exec-sql-rollback">
       <term><literal>EXEC SQL ROLLBACK</literal></term>
       <listitem>
        <para>
@@ -602,7 +602,7 @@ EXEC SQL COMMIT;
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-transactions-exec-sql-prepare-transaction">
       <term><literal>EXEC SQL PREPARE TRANSACTION </literal><replaceable class="parameter">transaction_id</replaceable></term>
       <listitem>
        <para>
@@ -611,7 +611,7 @@ EXEC SQL COMMIT;
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-transactions-exec-sql-commit-prepared">
       <term><literal>EXEC SQL COMMIT PREPARED </literal><replaceable class="parameter">transaction_id</replaceable></term>
       <listitem>
        <para>
@@ -620,7 +620,7 @@ EXEC SQL COMMIT;
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-transactions-exec-sql-rollback-prepared">
       <term><literal>EXEC SQL ROLLBACK PREPARED </literal><replaceable class="parameter">transaction_id</replaceable></term>
       <listitem>
        <para>
@@ -629,7 +629,7 @@ EXEC SQL COMMIT;
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-transactions-exec-sql-autocommit-on">
       <term><literal>EXEC SQL SET AUTOCOMMIT TO ON</literal></term>
       <listitem>
        <para>
@@ -638,7 +638,7 @@ EXEC SQL COMMIT;
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-transactions-exec-sql-autocommit-off">
       <term><literal>EXEC SQL SET AUTOCOMMIT TO OFF</literal></term>
       <listitem>
        <para>
@@ -1110,7 +1110,7 @@ struct varchar_var { int len; char arr[180]; } var;
      see <xref linkend="ecpg-pgtypes"/>.
     </para>
 
-    <sect4>
+    <sect4 id="ecpg-special-types-timestamp-date">
      <title>timestamp, date</title>
 
      <para>
@@ -1275,7 +1275,7 @@ EXEC SQL END DECLARE SECTION;
      </para>
     </sect4>
 
-    <sect4>
+    <sect4 id="ecpg-special-types-bytea">
      <title>bytea</title>
 
      <para>
@@ -1481,7 +1481,7 @@ EXEC SQL END DECLARE SECTION;
      </para>
     </sect4>
 
-    <sect4>
+    <sect4 id="ecpg-variables-nonprimitive-c-typedefs">
      <title>Typedefs</title>
 
      <para>
@@ -1501,7 +1501,7 @@ EXEC SQL TYPE serial_t IS long;
      </para>
     </sect4>
 
-    <sect4>
+    <sect4 id="ecpg-variables-nonprimitive-c-pointers">
      <title>Pointers</title>
 
      <para>
@@ -1533,7 +1533,7 @@ EXEC SQL END DECLARE SECTION;
     nonprimitive types, described in the previous section.
    </para>
 
-   <sect3>
+   <sect3 id="ecpg-variables-nonprimitive-sql-arrays">
     <title>Arrays</title>
 
     <para>
@@ -1656,7 +1656,7 @@ while (1)
     </para>
    </sect3>
 
-   <sect3>
+   <sect3 id="ecpg-variables-nonprimitive-sql-composite">
     <title>Composite Types</title>
 
     <para>
@@ -1776,7 +1776,7 @@ while (1)
     </para>
    </sect3>
 
-   <sect3>
+   <sect3 id="ecpg-variables-nonprimitive-sql-user-defined-base-types">
     <title>User-Defined Base Types</title>
 
     <para>
@@ -2094,7 +2094,7 @@ PGTYPESchar_free(out);
    <para>
    The following functions can be used to work with the numeric type:
    <variablelist>
-    <varlistentry>
+    <varlistentry id="ecpg-pgtypes-numeric-new">
      <term><function>PGTYPESnumeric_new</function></term>
      <listitem>
       <para>
@@ -2106,7 +2106,7 @@ numeric *PGTYPESnumeric_new(void);
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-pgtypes-numeric-free">
      <term><function>PGTYPESnumeric_free</function></term>
      <listitem>
       <para>
@@ -2118,7 +2118,7 @@ void PGTYPESnumeric_free(numeric *var);
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-pgtypes-numeric-from_asc">
      <term><function>PGTYPESnumeric_from_asc</function></term>
      <listitem>
       <para>
@@ -2141,7 +2141,7 @@ numeric *PGTYPESnumeric_from_asc(char *str, char **endptr);
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-pgtypes-numeric-to_asc">
      <term><function>PGTYPESnumeric_to_asc</function></term>
      <listitem>
       <para>
@@ -2157,7 +2157,7 @@ char *PGTYPESnumeric_to_asc(numeric *num, int dscale);
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-pgtypes-numeric-add">
      <term><function>PGTYPESnumeric_add</function></term>
      <listitem>
       <para>
@@ -2173,7 +2173,7 @@ int PGTYPESnumeric_add(numeric *var1, numeric *var2, numeric *result);
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-pgtypes-numeric-sub">
      <term><function>PGTYPESnumeric_sub</function></term>
      <listitem>
       <para>
@@ -2189,7 +2189,7 @@ int PGTYPESnumeric_sub(numeric *var1, numeric *var2, numeric *result);
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-pgtypes-numeric-mul">
      <term><function>PGTYPESnumeric_mul</function></term>
      <listitem>
       <para>
@@ -2205,7 +2205,7 @@ int PGTYPESnumeric_mul(numeric *var1, numeric *var2, numeric *result);
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-pgtypes-numeric-div">
      <term><function>PGTYPESnumeric_div</function></term>
      <listitem>
       <para>
@@ -2221,7 +2221,7 @@ int PGTYPESnumeric_div(numeric *var1, numeric *var2, numeric *result);
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-pgtypes-numeric-cmp">
      <term><function>PGTYPESnumeric_cmp</function></term>
      <listitem>
       <para>
@@ -2253,7 +2253,7 @@ int PGTYPESnumeric_cmp(numeric *var1, numeric *var2)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-pgtypes-numeric-from_int">
      <term><function>PGTYPESnumeric_from_int</function></term>
      <listitem>
       <para>
@@ -2268,7 +2268,7 @@ int PGTYPESnumeric_from_int(signed int int_val, numeric *var);
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-pgtypes-numeric-from_long">
      <term><function>PGTYPESnumeric_from_long</function></term>
      <listitem>
       <para>
@@ -2283,7 +2283,7 @@ int PGTYPESnumeric_from_long(signed long int long_val, numeric *var);
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-pgtypes-numeric-copy">
      <term><function>PGTYPESnumeric_copy</function></term>
      <listitem>
       <para>
@@ -2298,7 +2298,7 @@ int PGTYPESnumeric_copy(numeric *src, numeric *dst);
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-pgtypes-numeric-from_double">
      <term><function>PGTYPESnumeric_from_double</function></term>
      <listitem>
       <para>
@@ -2313,7 +2313,7 @@ int  PGTYPESnumeric_from_double(double d, numeric *dst);
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-pgtypes-numeric-to_double">
      <term><function>PGTYPESnumeric_to_double</function></term>
      <listitem>
       <para>
@@ -2330,7 +2330,7 @@ int PGTYPESnumeric_to_double(numeric *nv, double *dp)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-pgtypes-numeric-to_int">
      <term><function>PGTYPESnumeric_to_int</function></term>
      <listitem>
       <para>
@@ -2347,7 +2347,7 @@ int PGTYPESnumeric_to_int(numeric *nv, int *ip);
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-pgtypes-numeric-to_long">
      <term><function>PGTYPESnumeric_to_long</function></term>
      <listitem>
       <para>
@@ -2365,7 +2365,7 @@ int PGTYPESnumeric_to_long(numeric *nv, long *lp);
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-pgtypes-numeric-to_decimal">
      <term><function>PGTYPESnumeric_to_decimal</function></term>
      <listitem>
       <para>
@@ -2383,7 +2383,7 @@ int PGTYPESnumeric_to_decimal(numeric *src, decimal *dst);
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-pgtypes-numeric-from_decimal">
      <term><function>PGTYPESnumeric_from_decimal</function></term>
      <listitem>
       <para>
@@ -3516,7 +3516,7 @@ int PGTYPESinterval_copy(interval *intvlsrc, interval *intvldest);
     The following functions can be used to work with the decimal type and are
     not only contained in the <literal>libcompat</literal> library.
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-pgtypes-decimal-new">
       <term><function>PGTYPESdecimal_new</function></term>
       <listitem>
        <para>
@@ -3528,7 +3528,7 @@ decimal *PGTYPESdecimal_new(void);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-pgtypes-decimal-free">
       <term><function>PGTYPESdecimal_free</function></term>
       <listitem>
        <para>
@@ -3547,7 +3547,7 @@ void PGTYPESdecimal_free(decimal *var);
     <title>errno Values of pgtypeslib</title>
    <para>
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-pgtypes-errno-pgtypes_num_bad_numeric">
       <term><literal>PGTYPES_NUM_BAD_NUMERIC</literal></term>
       <listitem>
        <para>
@@ -3557,7 +3557,7 @@ void PGTYPESdecimal_free(decimal *var);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-pgtypes-errno-pgtypes_num_overflow">
       <term><literal>PGTYPES_NUM_OVERFLOW</literal></term>
       <listitem>
        <para>
@@ -3568,7 +3568,7 @@ void PGTYPESdecimal_free(decimal *var);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-pgtypes-errno-pgtypes_num_underflow">
       <term><literal>PGTYPES_NUM_UNDERFLOW</literal></term>
       <listitem>
        <para>
@@ -3579,7 +3579,7 @@ void PGTYPESdecimal_free(decimal *var);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-pgtypes-errno-pgtypes_num_divide_zero">
       <term><literal>PGTYPES_NUM_DIVIDE_ZERO</literal></term>
       <listitem>
        <para>
@@ -3588,7 +3588,7 @@ void PGTYPESdecimal_free(decimal *var);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-pgtypes-errno-pgtypes_date_bad_date">
       <term><literal>PGTYPES_DATE_BAD_DATE</literal></term>
       <listitem>
        <para>
@@ -3598,7 +3598,7 @@ void PGTYPESdecimal_free(decimal *var);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-pgtypes-errno-pgtypes_date_err_eargs">
       <term><literal>PGTYPES_DATE_ERR_EARGS</literal></term>
       <listitem>
        <para>
@@ -3608,7 +3608,7 @@ void PGTYPESdecimal_free(decimal *var);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-pgtypes-errno-pgtypes_date_err_enoshortdate">
       <term><literal>PGTYPES_DATE_ERR_ENOSHORTDATE</literal></term>
       <listitem>
        <para>
@@ -3618,7 +3618,7 @@ void PGTYPESdecimal_free(decimal *var);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-pgtypes-errno-pgtypes_intvl_bad_interval">
       <term><literal>PGTYPES_INTVL_BAD_INTERVAL</literal></term>
       <listitem>
        <para>
@@ -3630,7 +3630,7 @@ void PGTYPESdecimal_free(decimal *var);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-pgtypes-errno-pgtypes_date_err_enotdmy">
       <term><literal>PGTYPES_DATE_ERR_ENOTDMY</literal></term>
       <listitem>
        <para>
@@ -3640,7 +3640,7 @@ void PGTYPESdecimal_free(decimal *var);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-pgtypes-errno-pgtypes_date_bad_day">
       <term><literal>PGTYPES_DATE_BAD_DAY</literal></term>
       <listitem>
        <para>
@@ -3650,7 +3650,7 @@ void PGTYPESdecimal_free(decimal *var);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-pgtypes-errno-pgtypes_date_bad_month">
       <term><literal>PGTYPES_DATE_BAD_MONTH</literal></term>
       <listitem>
        <para>
@@ -3660,7 +3660,7 @@ void PGTYPESdecimal_free(decimal *var);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-pgtypes-errno-pgtypes_ts_bad_timestamp">
       <term><literal>PGTYPES_TS_BAD_TIMESTAMP</literal></term>
       <listitem>
        <para>
@@ -3672,7 +3672,7 @@ void PGTYPESdecimal_free(decimal *var);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-pgtypes-errno-pgtypes_ts_err_einftime">
       <term><literal>PGTYPES_TS_ERR_EINFTIME</literal></term>
       <listitem>
        <para>
@@ -3809,7 +3809,7 @@ EXEC SQL GET DESCRIPTOR <replaceable>name</replaceable> VALUE <replaceable>num</
     variable containing an integer. Possible fields are:
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-named-descriptors-cardinality">
       <term><literal>CARDINALITY</literal> (integer)</term>
       <listitem>
        <para>
@@ -3818,7 +3818,7 @@ EXEC SQL GET DESCRIPTOR <replaceable>name</replaceable> VALUE <replaceable>num</
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-named-descriptors-data">
       <term><literal>DATA</literal></term>
       <listitem>
        <para>
@@ -3828,7 +3828,7 @@ EXEC SQL GET DESCRIPTOR <replaceable>name</replaceable> VALUE <replaceable>num</
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-named-descriptors-datetime_interval_code">
       <term><literal>DATETIME_INTERVAL_CODE</literal> (integer)</term>
       <listitem>
        <para>
@@ -3843,7 +3843,7 @@ EXEC SQL GET DESCRIPTOR <replaceable>name</replaceable> VALUE <replaceable>num</
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-named-descriptors-datetime_interval_precision">
       <term><literal>DATETIME_INTERVAL_PRECISION</literal> (integer)</term>
       <listitem>
        <para>
@@ -3852,7 +3852,7 @@ EXEC SQL GET DESCRIPTOR <replaceable>name</replaceable> VALUE <replaceable>num</
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-named-descriptors-indicator">
       <term><literal>INDICATOR</literal> (integer)</term>
       <listitem>
        <para>
@@ -3861,7 +3861,7 @@ EXEC SQL GET DESCRIPTOR <replaceable>name</replaceable> VALUE <replaceable>num</
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-named-descriptors-key_member">
       <term><literal>KEY_MEMBER</literal> (integer)</term>
       <listitem>
        <para>
@@ -3870,7 +3870,7 @@ EXEC SQL GET DESCRIPTOR <replaceable>name</replaceable> VALUE <replaceable>num</
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-named-descriptors-length">
       <term><literal>LENGTH</literal> (integer)</term>
       <listitem>
        <para>
@@ -3879,7 +3879,7 @@ EXEC SQL GET DESCRIPTOR <replaceable>name</replaceable> VALUE <replaceable>num</
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-named-descriptors-name">
       <term><literal>NAME</literal> (string)</term>
       <listitem>
        <para>
@@ -3888,7 +3888,7 @@ EXEC SQL GET DESCRIPTOR <replaceable>name</replaceable> VALUE <replaceable>num</
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-named-descriptors-nullable">
       <term><literal>NULLABLE</literal> (integer)</term>
       <listitem>
        <para>
@@ -3897,7 +3897,7 @@ EXEC SQL GET DESCRIPTOR <replaceable>name</replaceable> VALUE <replaceable>num</
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-named-descriptors-octet_length">
       <term><literal>OCTET_LENGTH</literal> (integer)</term>
       <listitem>
        <para>
@@ -3906,7 +3906,7 @@ EXEC SQL GET DESCRIPTOR <replaceable>name</replaceable> VALUE <replaceable>num</
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-named-descriptors-precision">
       <term><literal>PRECISION</literal> (integer)</term>
       <listitem>
        <para>
@@ -3915,7 +3915,7 @@ EXEC SQL GET DESCRIPTOR <replaceable>name</replaceable> VALUE <replaceable>num</
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-named-descriptors-returned_length">
       <term><literal>RETURNED_LENGTH</literal> (integer)</term>
       <listitem>
        <para>
@@ -3924,7 +3924,7 @@ EXEC SQL GET DESCRIPTOR <replaceable>name</replaceable> VALUE <replaceable>num</
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-named-descriptors-returned_octet_length">
       <term><literal>RETURNED_OCTET_LENGTH</literal> (integer)</term>
       <listitem>
        <para>
@@ -3933,7 +3933,7 @@ EXEC SQL GET DESCRIPTOR <replaceable>name</replaceable> VALUE <replaceable>num</
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-named-descriptors-scale">
       <term><literal>SCALE</literal> (integer)</term>
       <listitem>
        <para>
@@ -3942,7 +3942,7 @@ EXEC SQL GET DESCRIPTOR <replaceable>name</replaceable> VALUE <replaceable>num</
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-named-descriptors-type">
       <term><literal>TYPE</literal> (integer)</term>
       <listitem>
        <para>
@@ -4021,7 +4021,7 @@ EXEC SQL DESCRIBE prepared_statement INTO mysqlda;
      <step><simpara>Free the memory area allocated for the input SQLDA.</simpara></step>
     </procedure>
 
-   <sect3>
+   <sect3 id="ecpg-sqlda-descriptors-sqlda">
     <title>SQLDA Data Structure</title>
 
     <para>
@@ -4072,7 +4072,7 @@ typedef struct sqlda_struct sqlda_t;
       The meaning of the fields is:
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-sqlda-sqlda-sqldaid">
       <term><literal>sqldaid</literal></term>
       <listitem>
        <para>
@@ -4081,7 +4081,7 @@ typedef struct sqlda_struct sqlda_t;
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sqlda-sqlda-sqldabc">
       <term><literal>sqldabc</literal></term>
       <listitem>
        <para>
@@ -4090,7 +4090,7 @@ typedef struct sqlda_struct sqlda_t;
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sqlda-sqlda-sqln">
       <term><literal>sqln</literal></term>
       <listitem>
        <para>
@@ -4105,7 +4105,7 @@ typedef struct sqlda_struct sqlda_t;
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sqlda-sqlda-sqld">
       <term><literal>sqld</literal></term>
       <listitem>
        <para>
@@ -4114,7 +4114,7 @@ typedef struct sqlda_struct sqlda_t;
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sqlda-sqlda-desc_next">
       <term><literal>desc_next</literal></term>
       <listitem>
        <para>
@@ -4124,7 +4124,7 @@ typedef struct sqlda_struct sqlda_t;
        </para>
       </listitem>
      </varlistentry>
-     <varlistentry>
+     <varlistentry id="ecpg-sqlda-sqlda-sqlvar">
       <term><literal>sqlvar</literal></term>
       <listitem>
        <para>
@@ -4160,7 +4160,7 @@ typedef struct sqlvar_struct sqlvar_t;
       The meaning of the fields is:
 
         <variablelist>
-         <varlistentry>
+         <varlistentry id="ecpg-sqlda-sqlvar-sqltype">
          <term><literal>sqltype</literal></term>
           <listitem>
            <para>
@@ -4170,7 +4170,7 @@ typedef struct sqlvar_struct sqlvar_t;
           </listitem>
          </varlistentry>
 
-         <varlistentry>
+         <varlistentry id="ecpg-sqlda-sqlvar-sqllen">
          <term><literal>sqllen</literal></term>
           <listitem>
            <para>
@@ -4179,7 +4179,7 @@ typedef struct sqlvar_struct sqlvar_t;
           </listitem>
          </varlistentry>
 
-         <varlistentry>
+         <varlistentry id="ecpg-sqlda-sqlvar-sqldata">
          <term><literal>sqldata</literal></term>
           <listitem>
            <para>
@@ -4189,7 +4189,7 @@ typedef struct sqlvar_struct sqlvar_t;
           </listitem>
          </varlistentry>
 
-         <varlistentry>
+         <varlistentry id="ecpg-sqlda-sqlvar-sqlind">
          <term><literal>sqlind</literal></term>
           <listitem>
            <para>
@@ -4199,7 +4199,7 @@ typedef struct sqlvar_struct sqlvar_t;
           </listitem>
          </varlistentry>
 
-         <varlistentry>
+         <varlistentry id="ecpg-sqlda-sqlvar-sqlname">
          <term><literal>sqlname</literal></term>
           <listitem>
            <para>
@@ -4229,7 +4229,7 @@ struct sqlname
 </programlisting>
       The meaning of the fields is:
             <variablelist>
-             <varlistentry>
+             <varlistentry id="ecpg-sqlda-sqlname-length">
               <term><literal>length</literal></term>
                <listitem>
                 <para>
@@ -4237,7 +4237,7 @@ struct sqlname
                 </para>
                </listitem>
               </varlistentry>
-             <varlistentry>
+             <varlistentry id="ecpg-sqlda-sqlname-data">
               <term><literal>data</literal></term>
                <listitem>
                 <para>
@@ -4819,7 +4819,7 @@ EXEC SQL WHENEVER <replaceable>condition</replaceable> <replaceable>action</repl
     <replaceable>condition</replaceable> can be one of the following:
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-whenever-sqlerror">
       <term><literal>SQLERROR</literal></term>
       <listitem>
        <para>
@@ -4829,7 +4829,7 @@ EXEC SQL WHENEVER <replaceable>condition</replaceable> <replaceable>action</repl
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-whenever-sqlwarning">
       <term><literal>SQLWARNING</literal></term>
       <listitem>
        <para>
@@ -4839,7 +4839,7 @@ EXEC SQL WHENEVER <replaceable>condition</replaceable> <replaceable>action</repl
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-whenever-not-found">
       <term><literal>NOT FOUND</literal></term>
       <listitem>
        <para>
@@ -4856,7 +4856,7 @@ EXEC SQL WHENEVER <replaceable>condition</replaceable> <replaceable>action</repl
     <replaceable>action</replaceable> can be one of the following:
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-whenever-continue">
       <term><literal>CONTINUE</literal></term>
       <listitem>
        <para>
@@ -4866,7 +4866,7 @@ EXEC SQL WHENEVER <replaceable>condition</replaceable> <replaceable>action</repl
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-whenever-goto">
       <term><literal>GOTO <replaceable>label</replaceable></literal></term>
       <term><literal>GO TO <replaceable>label</replaceable></literal></term>
       <listitem>
@@ -4877,7 +4877,7 @@ EXEC SQL WHENEVER <replaceable>condition</replaceable> <replaceable>action</repl
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-whenever-sqlprint">
       <term><literal>SQLPRINT</literal></term>
       <listitem>
        <para>
@@ -4888,7 +4888,7 @@ EXEC SQL WHENEVER <replaceable>condition</replaceable> <replaceable>action</repl
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-whenever-stop">
       <term><literal>STOP</literal></term>
       <listitem>
        <para>
@@ -4898,7 +4898,7 @@ EXEC SQL WHENEVER <replaceable>condition</replaceable> <replaceable>action</repl
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-whenever-do-break">
       <term><literal>DO BREAK</literal></term>
       <listitem>
        <para>
@@ -4908,7 +4908,7 @@ EXEC SQL WHENEVER <replaceable>condition</replaceable> <replaceable>action</repl
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-whenever-do-continue">
       <term><literal>DO CONTINUE</literal></term>
       <listitem>
        <para>
@@ -4919,7 +4919,7 @@ EXEC SQL WHENEVER <replaceable>condition</replaceable> <replaceable>action</repl
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-whenever-call">
       <term><literal>CALL <replaceable>name</replaceable> (<replaceable>args</replaceable>)</literal></term>
       <term><literal>DO <replaceable>name</replaceable> (<replaceable>args</replaceable>)</literal></term>
       <listitem>
@@ -5193,7 +5193,7 @@ sqlstate: 42P01
     These are the assigned <literal>SQLCODE</literal> values:
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_no_error">
       <term>0 (<symbol>ECPG_NO_ERROR</symbol>)</term>
       <listitem>
        <para>
@@ -5202,7 +5202,7 @@ sqlstate: 42P01
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_not_found">
      <term>100 (<symbol>ECPG_NOT_FOUND</symbol>)</term>
      <listitem>
       <para>
@@ -5229,7 +5229,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_out_of_memory">
       <term>-12 (<symbol>ECPG_OUT_OF_MEMORY</symbol>)</term>
       <listitem>
        <para>
@@ -5240,7 +5240,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_unsupported">
      <term>-200 (<symbol>ECPG_UNSUPPORTED</symbol>)</term>
      <listitem>
       <para>
@@ -5252,7 +5252,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_too_many_arguments">
      <term>-201 (<symbol>ECPG_TOO_MANY_ARGUMENTS</symbol>)</term>
      <listitem>
       <para>
@@ -5262,7 +5262,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_too_few_arguments">
      <term>-202 (<symbol>ECPG_TOO_FEW_ARGUMENTS</symbol>)</term>
      <listitem>
       <para>
@@ -5272,7 +5272,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_too_many_matches">
      <term>-203 (<symbol>ECPG_TOO_MANY_MATCHES</symbol>)</term>
      <listitem>
       <para>
@@ -5283,7 +5283,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_int_format">
      <term>-204 (<symbol>ECPG_INT_FORMAT</symbol>)</term>
      <listitem>
       <para>
@@ -5296,7 +5296,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_uint_format">
      <term>-205 (<symbol>ECPG_UINT_FORMAT</symbol>)</term>
      <listitem>
       <para>
@@ -5309,7 +5309,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_float_format">
      <term>-206 (<symbol>ECPG_FLOAT_FORMAT</symbol>)</term>
      <listitem>
       <para>
@@ -5322,7 +5322,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_numeric_format">
      <term>-207 (<symbol>ECPG_NUMERIC_FORMAT</symbol>)</term>
      <listitem>
       <para>
@@ -5334,7 +5334,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_interval_format">
      <term>-208 (<symbol>ECPG_INTERVAL_FORMAT</symbol>)</term>
      <listitem>
       <para>
@@ -5346,7 +5346,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_date_format">
      <term>-209 (<symbol>ECPG_DATE_FORMAT</symbol>)</term>
      <listitem>
       <para>
@@ -5358,7 +5358,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_timestamp_format">
      <term>-210 (<symbol>ECPG_TIMESTAMP_FORMAT</symbol>)</term>
      <listitem>
       <para>
@@ -5370,7 +5370,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_convert_bool">
      <term>-211 (<symbol>ECPG_CONVERT_BOOL</symbol>)</term>
      <listitem>
       <para>
@@ -5381,7 +5381,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_empty">
      <term>-212 (<symbol>ECPG_EMPTY</symbol>)</term>
      <listitem>
       <para>
@@ -5393,7 +5393,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_missing_indicator">
      <term>-213 (<symbol>ECPG_MISSING_INDICATOR</symbol>)</term>
      <listitem>
       <para>
@@ -5403,7 +5403,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_no_array">
      <term>-214 (<symbol>ECPG_NO_ARRAY</symbol>)</term>
      <listitem>
       <para>
@@ -5413,7 +5413,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_data_not_array">
      <term>-215 (<symbol>ECPG_DATA_NOT_ARRAY</symbol>)</term>
      <listitem>
       <para>
@@ -5423,7 +5423,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_array_insert">
      <term>-216 (<symbol>ECPG_ARRAY_INSERT</symbol>)</term>
      <listitem>
       <para>
@@ -5433,7 +5433,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_no_conn">
      <term>-220 (<symbol>ECPG_NO_CONN</symbol>)</term>
      <listitem>
       <para>
@@ -5443,7 +5443,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_not_conn">
      <term>-221 (<symbol>ECPG_NOT_CONN</symbol>)</term>
      <listitem>
       <para>
@@ -5453,7 +5453,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_invalid_stmt">
      <term>-230 (<symbol>ECPG_INVALID_STMT</symbol>)</term>
      <listitem>
       <para>
@@ -5463,7 +5463,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_informix_duplicate_key">
      <term>-239 (<symbol>ECPG_INFORMIX_DUPLICATE_KEY</symbol>)</term>
      <listitem>
       <para>
@@ -5473,7 +5473,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_unknown_descriptor">
      <term>-240 (<symbol>ECPG_UNKNOWN_DESCRIPTOR</symbol>)</term>
      <listitem>
       <para>
@@ -5483,7 +5483,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_invalid_descriptor_index">
      <term>-241 (<symbol>ECPG_INVALID_DESCRIPTOR_INDEX</symbol>)</term>
      <listitem>
       <para>
@@ -5493,7 +5493,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_unknown_descriptor_item">
      <term>-242 (<symbol>ECPG_UNKNOWN_DESCRIPTOR_ITEM</symbol>)</term>
      <listitem>
       <para>
@@ -5503,7 +5503,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_var_not_numeric">
      <term>-243 (<symbol>ECPG_VAR_NOT_NUMERIC</symbol>)</term>
      <listitem>
       <para>
@@ -5514,7 +5514,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_var_not_char">
      <term>-244 (<symbol>ECPG_VAR_NOT_CHAR</symbol>)</term>
      <listitem>
       <para>
@@ -5525,7 +5525,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_informix_subselect_not_one">
      <term>-284 (<symbol>ECPG_INFORMIX_SUBSELECT_NOT_ONE</symbol>)</term>
      <listitem>
       <para>
@@ -5535,7 +5535,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_pgsql">
      <term>-400 (<symbol>ECPG_PGSQL</symbol>)</term>
      <listitem>
       <para>
@@ -5546,7 +5546,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_trans">
      <term>-401 (<symbol>ECPG_TRANS</symbol>)</term>
      <listitem>
       <para>
@@ -5557,7 +5557,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_connect">
      <term>-402 (<symbol>ECPG_CONNECT</symbol>)</term>
      <listitem>
       <para>
@@ -5567,7 +5567,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_duplicate_key">
      <term>-403 (<symbol>ECPG_DUPLICATE_KEY</symbol>)</term>
      <listitem>
       <para>
@@ -5577,7 +5577,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_subselect_not_one">
      <term>-404 (<symbol>ECPG_SUBSELECT_NOT_ONE</symbol>)</term>
      <listitem>
       <para>
@@ -5588,7 +5588,7 @@ while (1)
 
     <!-- currently not used by the code -->
 <!--
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_warning_unrecognized">
      <term>-600 (<symbol>ECPG_WARNING_UNRECOGNIZED</symbol>)</term>
      <listitem>
       <para>
@@ -5597,7 +5597,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_warning_query_ignored">
      <term>-601 (<symbol>ECPG_WARNING_QUERY_IGNORED</symbol>)</term>
      <listitem>
       <para>
@@ -5608,7 +5608,7 @@ while (1)
     </varlistentry>
 -->
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_warning_unknown_portal">
      <term>-602 (<symbol>ECPG_WARNING_UNKNOWN_PORTAL</symbol>)</term>
      <listitem>
       <para>
@@ -5617,7 +5617,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_warning_in_transaction">
      <term>-603 (<symbol>ECPG_WARNING_IN_TRANSACTION</symbol>)</term>
      <listitem>
       <para>
@@ -5626,7 +5626,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_warning_no_transaction">
      <term>-604 (<symbol>ECPG_WARNING_NO_TRANSACTION</symbol>)</term>
      <listitem>
       <para>
@@ -5635,7 +5635,7 @@ while (1)
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-sqlstate-sqlcode-ecpg_warning_portal_exists">
      <term>-605 (<symbol>ECPG_WARNING_PORTAL_EXISTS</symbol>)</term>
      <listitem>
       <para>
@@ -5766,7 +5766,7 @@ EXEC SQL UPDATE Tbl SET col = MYNUMBER;
    You can use the following directives to compile code sections conditionally:
 
    <variablelist>
-    <varlistentry>
+    <varlistentry id="ecpg-ifdef-ifdef">
      <term><literal>EXEC SQL ifdef <replaceable>name</replaceable>;</literal></term>
      <listitem>
      <para>
@@ -5777,7 +5777,7 @@ EXEC SQL UPDATE Tbl SET col = MYNUMBER;
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-ifdef-ifndef">
      <term><literal>EXEC SQL ifndef <replaceable>name</replaceable>;</literal></term>
      <listitem>
      <para>
@@ -5788,7 +5788,7 @@ EXEC SQL UPDATE Tbl SET col = MYNUMBER;
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-ifdef-elif">
      <term><literal>EXEC SQL elif <replaceable>name</replaceable>;</literal></term>
      <listitem>
      <para>
@@ -5805,7 +5805,7 @@ EXEC SQL UPDATE Tbl SET col = MYNUMBER;
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-ifdef-else">
      <term><literal>EXEC SQL else;</literal></term>
      <listitem>
      <para>
@@ -5820,7 +5820,7 @@ EXEC SQL UPDATE Tbl SET col = MYNUMBER;
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="ecpg-ifdef-endif">
      <term><literal>EXEC SQL endif;</literal></term>
      <listitem>
      <para>
@@ -6267,7 +6267,7 @@ void TestCpp::test()
     (<filename>*.pgc</filename>), a header file, and a C++ file:
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-cpp-and-c-test_mod_pgc">
       <term><filename>test_mod.pgc</filename></term>
       <listitem>
        <para>
@@ -6307,7 +6307,7 @@ db_disconnect()
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-cpp-and-c-test_mod_h">
       <term><filename>test_mod.h</filename></term>
       <listitem>
        <para>
@@ -6334,7 +6334,7 @@ void db_disconnect();
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-cpp-and-c-test_cpp_cpp">
       <term><filename>test_cpp.cpp</filename></term>
       <listitem>
        <para>
@@ -6456,7 +6456,7 @@ ALLOCATE DESCRIPTOR <replaceable class="parameter">name</replaceable>
     <title>Parameters</title>
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-sql-allocate-descriptor-name">
       <term><replaceable class="parameter">name</replaceable></term>
       <listitem>
        <para>
@@ -6524,7 +6524,7 @@ DATABASE <replaceable>connection_target</replaceable>
     <title>Parameters</title>
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-sql-connect-connection_target">
       <term><replaceable class="parameter">connection_target</replaceable></term>
       <listitem>
        <para>
@@ -6533,7 +6533,7 @@ DATABASE <replaceable>connection_target</replaceable>
         several forms.
 
         <variablelist>
-         <varlistentry>
+         <varlistentry id="ecpg-sql-connect-connection_target-database_name">
           <term>[ <replaceable>database_name</replaceable> ] [ <literal>@</literal><replaceable>host</replaceable> ] [ <literal>:</literal><replaceable>port</replaceable> ]</term>
           <listitem>
            <para>
@@ -6542,7 +6542,7 @@ DATABASE <replaceable>connection_target</replaceable>
           </listitem>
          </varlistentry>
 
-         <varlistentry>
+         <varlistentry id="ecpg-sql-connect-connection_target-unix-domain-sockets">
           <term><literal>unix:postgresql://</literal><replaceable>host</replaceable> [ <literal>:</literal><replaceable>port</replaceable> ] <literal>/</literal> [ <replaceable>database_name</replaceable> ] [ <literal>?</literal><replaceable>connection_option</replaceable> ]</term>
           <listitem>
            <para>
@@ -6551,7 +6551,7 @@ DATABASE <replaceable>connection_target</replaceable>
           </listitem>
          </varlistentry>
 
-         <varlistentry>
+         <varlistentry id="ecpg-sql-connect-connection_target-tcp-ip">
           <term><literal>tcp:postgresql://</literal><replaceable>host</replaceable> [ <literal>:</literal><replaceable>port</replaceable> ] <literal>/</literal> [ <replaceable>database_name</replaceable> ] [ <literal>?</literal><replaceable>connection_option</replaceable> ]</term>
           <listitem>
            <para>
@@ -6560,7 +6560,7 @@ DATABASE <replaceable>connection_target</replaceable>
           </listitem>
          </varlistentry>
 
-         <varlistentry>
+         <varlistentry id="ecpg-sql-connect-connection_target-constant">
           <term>SQL string constant</term>
           <listitem>
            <para>
@@ -6569,7 +6569,7 @@ DATABASE <replaceable>connection_target</replaceable>
           </listitem>
          </varlistentry>
 
-         <varlistentry>
+         <varlistentry id="ecpg-sql-connect-connection_target-host-variable">
           <term>host variable</term>
           <listitem>
            <para>
@@ -6584,7 +6584,7 @@ DATABASE <replaceable>connection_target</replaceable>
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-connect-connection_name">
       <term><replaceable class="parameter">connection_name</replaceable></term>
       <listitem>
        <para>
@@ -6595,7 +6595,7 @@ DATABASE <replaceable>connection_target</replaceable>
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-connect-connection_user">
       <term><replaceable class="parameter">connection_user</replaceable></term>
       <listitem>
        <para>
@@ -6616,7 +6616,7 @@ DATABASE <replaceable>connection_target</replaceable>
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-connect-default">
       <term><literal>DEFAULT</literal></term>
       <listitem>
        <para>
@@ -6741,7 +6741,7 @@ DEALLOCATE DESCRIPTOR <replaceable class="parameter">name</replaceable>
     <title>Parameters</title>
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-sql-deallocate-descriptor-name">
       <term><replaceable class="parameter">name</replaceable></term>
       <listitem>
        <para>
@@ -6815,7 +6815,7 @@ DECLARE <replaceable class="parameter">cursor_name</replaceable> [ BINARY ] [ AS
     <title>Parameters</title>
     <variablelist>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-declare-cursor_name">
       <term><replaceable class="parameter">cursor_name</replaceable></term>
       <listitem>
        <para>
@@ -6825,7 +6825,7 @@ DECLARE <replaceable class="parameter">cursor_name</replaceable> [ BINARY ] [ AS
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-declare-prepared_name">
       <term><replaceable class="parameter">prepared_name</replaceable></term>
       <listitem>
        <para>
@@ -6835,7 +6835,7 @@ DECLARE <replaceable class="parameter">cursor_name</replaceable> [ BINARY ] [ AS
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-declare-query">
       <term><replaceable class="parameter">query</replaceable></term>
       <listitem>
        <para>
@@ -6925,7 +6925,7 @@ EXEC SQL [ AT <replaceable class="parameter">connection_name</replaceable> ] DEC
     <title>Parameters</title>
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-sql-declare-statement-connection_name">
       <term><replaceable class="parameter">connection_name</replaceable></term>
       <listitem>
        <para>
@@ -6939,7 +6939,7 @@ EXEC SQL [ AT <replaceable class="parameter">connection_name</replaceable> ] DEC
     </variablelist>
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-sql-declare-statement-statement_name">
       <term><replaceable class="parameter">statement_name</replaceable></term>
       <listitem>
        <para>
@@ -7019,7 +7019,7 @@ DESCRIBE [ OUTPUT ] <replaceable class="parameter">prepared_name</replaceable> I
     <title>Parameters</title>
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-sql-describe-prepared_name">
       <term><replaceable class="parameter">prepared_name</replaceable></term>
       <listitem>
        <para>
@@ -7029,7 +7029,7 @@ DESCRIBE [ OUTPUT ] <replaceable class="parameter">prepared_name</replaceable> I
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-describe-descriptor_name">
       <term><replaceable class="parameter">descriptor_name</replaceable></term>
       <listitem>
        <para>
@@ -7039,7 +7039,7 @@ DESCRIBE [ OUTPUT ] <replaceable class="parameter">prepared_name</replaceable> I
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-describe-sqlda_name">
       <term><replaceable class="parameter">sqlda_name</replaceable></term>
       <listitem>
        <para>
@@ -7108,7 +7108,7 @@ DISCONNECT ALL
     <title>Parameters</title>
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-sql-disconnect-connection_name">
       <term><replaceable class="parameter">connection_name</replaceable></term>
       <listitem>
        <para>
@@ -7118,7 +7118,7 @@ DISCONNECT ALL
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-disconnect-current">
       <term><literal>CURRENT</literal></term>
       <listitem>
        <para>
@@ -7131,7 +7131,7 @@ DISCONNECT ALL
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-disconnect-default">
       <term><literal>DEFAULT</literal></term>
       <listitem>
        <para>
@@ -7140,7 +7140,7 @@ DISCONNECT ALL
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-disconnect-all">
       <term><literal>ALL</literal></term>
       <listitem>
        <para>
@@ -7216,7 +7216,7 @@ EXECUTE IMMEDIATE <replaceable class="parameter">string</replaceable>
     <title>Parameters</title>
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-sql-execute-immediate-string">
       <term><replaceable class="parameter">string</replaceable></term>
       <listitem>
        <para>
@@ -7314,7 +7314,7 @@ GET DESCRIPTOR <replaceable class="parameter">descriptor_name</replaceable> VALU
     <title>Parameters</title>
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-sql-get-descriptor-descriptor_name">
       <term><replaceable class="parameter">descriptor_name</replaceable></term>
       <listitem>
        <para>
@@ -7323,7 +7323,7 @@ GET DESCRIPTOR <replaceable class="parameter">descriptor_name</replaceable> VALU
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-get-descriptor-descriptor_header_item">
       <term><replaceable class="parameter">descriptor_header_item</replaceable></term>
       <listitem>
        <para>
@@ -7334,7 +7334,7 @@ GET DESCRIPTOR <replaceable class="parameter">descriptor_name</replaceable> VALU
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-get-descriptor-column_number">
       <term><replaceable class="parameter">column_number</replaceable></term>
       <listitem>
        <para>
@@ -7344,7 +7344,7 @@ GET DESCRIPTOR <replaceable class="parameter">descriptor_name</replaceable> VALU
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-get-descriptor-descriptor_item">
       <term><replaceable class="parameter">descriptor_item</replaceable></term>
       <listitem>
        <para>
@@ -7355,7 +7355,7 @@ GET DESCRIPTOR <replaceable class="parameter">descriptor_name</replaceable> VALU
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-get-descriptor-cvariable">
       <term><replaceable class="parameter">cvariable</replaceable></term>
       <listitem>
        <para>
@@ -7495,7 +7495,7 @@ OPEN <replaceable class="parameter">cursor_name</replaceable> USING SQL DESCRIPT
     <title>Parameters</title>
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-sql-open-cursor_name">
       <term><replaceable class="parameter">cursor_name</replaceable></term>
       <listitem>
        <para>
@@ -7505,7 +7505,7 @@ OPEN <replaceable class="parameter">cursor_name</replaceable> USING SQL DESCRIPT
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-open-value">
       <term><replaceable class="parameter">value</replaceable></term>
       <listitem>
        <para>
@@ -7516,7 +7516,7 @@ OPEN <replaceable class="parameter">cursor_name</replaceable> USING SQL DESCRIPT
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-open-descriptor_name">
       <term><replaceable class="parameter">descriptor_name</replaceable></term>
       <listitem>
        <para>
@@ -7586,7 +7586,7 @@ PREPARE <replaceable class="parameter">prepared_name</replaceable> FROM <replace
     <title>Parameters</title>
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-sql-prepare-prepared_name">
       <term><replaceable class="parameter">prepared_name</replaceable></term>
       <listitem>
        <para>
@@ -7595,7 +7595,7 @@ PREPARE <replaceable class="parameter">prepared_name</replaceable> FROM <replace
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-prepare-string">
       <term><replaceable class="parameter">string</replaceable></term>
       <listitem>
        <para>
@@ -7722,7 +7722,7 @@ SET CONNECTION [ TO | = ] <replaceable class="parameter">connection_name</replac
     <title>Parameters</title>
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-sql-set-connection-connection_name">
       <term><replaceable class="parameter">connection_name</replaceable></term>
       <listitem>
        <para>
@@ -7732,7 +7732,7 @@ SET CONNECTION [ TO | = ] <replaceable class="parameter">connection_name</replac
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-set-connection-default">
       <term><literal>DEFAULT</literal></term>
       <listitem>
        <para>
@@ -7804,7 +7804,7 @@ SET DESCRIPTOR <replaceable class="parameter">descriptor_name</replaceable> VALU
     <title>Parameters</title>
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-sql-set-descriptor-descriptor_name">
       <term><replaceable class="parameter">descriptor_name</replaceable></term>
       <listitem>
        <para>
@@ -7813,7 +7813,7 @@ SET DESCRIPTOR <replaceable class="parameter">descriptor_name</replaceable> VALU
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-set-descriptor-descriptor_header_item">
       <term><replaceable class="parameter">descriptor_header_item</replaceable></term>
       <listitem>
        <para>
@@ -7824,7 +7824,7 @@ SET DESCRIPTOR <replaceable class="parameter">descriptor_name</replaceable> VALU
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-set-descriptor-number">
       <term><replaceable class="parameter">number</replaceable></term>
       <listitem>
        <para>
@@ -7834,7 +7834,7 @@ SET DESCRIPTOR <replaceable class="parameter">descriptor_name</replaceable> VALU
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-set-descriptor-descriptor_item">
       <term><replaceable class="parameter">descriptor_item</replaceable></term>
       <listitem>
        <para>
@@ -7845,7 +7845,7 @@ SET DESCRIPTOR <replaceable class="parameter">descriptor_name</replaceable> VALU
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-set-descriptor-value">
       <term><replaceable class="parameter">value</replaceable></term>
       <listitem>
        <para>
@@ -7917,7 +7917,7 @@ TYPE <replaceable class="parameter">type_name</replaceable> IS <replaceable clas
     <title>Parameters</title>
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-sql-type-type_name">
       <term><replaceable class="parameter">type_name</replaceable></term>
       <listitem>
        <para>
@@ -7926,7 +7926,7 @@ TYPE <replaceable class="parameter">type_name</replaceable> IS <replaceable clas
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-type-ctype">
       <term><replaceable class="parameter">ctype</replaceable></term>
       <listitem>
        <para>
@@ -8051,7 +8051,7 @@ VAR <replaceable>varname</replaceable> IS <replaceable>ctype</replaceable>
     <title>Parameters</title>
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-sql-var-varname">
       <term><replaceable class="parameter">varname</replaceable></term>
       <listitem>
        <para>
@@ -8060,7 +8060,7 @@ VAR <replaceable>varname</replaceable> IS <replaceable>ctype</replaceable>
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-sql-var-ctype">
       <term><replaceable class="parameter">ctype</replaceable></term>
       <listitem>
        <para>
@@ -8258,7 +8258,7 @@ EXEC SQL FETCH MYCUR INTO :userid;
    <title>Additional/Missing Embedded SQL Statements</title>
    <para>
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-informix-statements-close-database">
       <term><literal>CLOSE DATABASE</literal></term>
       <listitem>
        <para>
@@ -8271,7 +8271,7 @@ EXEC SQL CLOSE DATABASE;
        </para>
       </listitem>
      </varlistentry>
-     <varlistentry>
+     <varlistentry id="ecpg-informix-statements-free-cursor_name">
       <term><literal>FREE cursor_name</literal></term>
       <listitem>
        <para>
@@ -8284,7 +8284,7 @@ EXEC SQL CLOSE DATABASE;
        </para>
       </listitem>
      </varlistentry>
-     <varlistentry>
+     <varlistentry id="ecpg-informix-statements-free-statement_name">
       <term><literal>FREE statement_name</literal></term>
       <listitem>
        <para>
@@ -8344,7 +8344,7 @@ typedef struct sqlda_compat     sqlda_t;
     The global properties are:
     <variablelist>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-sqlda-sqld">
      <term><literal>sqld</literal></term>
       <listitem>
        <para>
@@ -8353,7 +8353,7 @@ typedef struct sqlda_compat     sqlda_t;
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-sqlda-sqlvar">
      <term><literal>sqlvar</literal></term>
       <listitem>
        <para>
@@ -8362,7 +8362,7 @@ typedef struct sqlda_compat     sqlda_t;
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-sqlda-desc_name">
      <term><literal>desc_name</literal></term>
       <listitem>
        <para>
@@ -8371,7 +8371,7 @@ typedef struct sqlda_compat     sqlda_t;
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-sqlda-desc_occ">
      <term><literal>desc_occ</literal></term>
       <listitem>
        <para>
@@ -8380,7 +8380,7 @@ typedef struct sqlda_compat     sqlda_t;
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-sqlda-desc_next">
      <term><literal>desc_next</literal></term>
       <listitem>
        <para>
@@ -8389,7 +8389,7 @@ typedef struct sqlda_compat     sqlda_t;
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-sqlda-reserved">
      <term><literal>reserved</literal></term>
       <listitem>
        <para>
@@ -8404,7 +8404,7 @@ typedef struct sqlda_compat     sqlda_t;
 
     <variablelist>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-sqlda-sqltype">
      <term><literal>sqltype</literal></term>
       <listitem>
        <para>
@@ -8413,7 +8413,7 @@ typedef struct sqlda_compat     sqlda_t;
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-sqlda-sqllen">
      <term><literal>sqllen</literal></term>
       <listitem>
        <para>
@@ -8422,7 +8422,7 @@ typedef struct sqlda_compat     sqlda_t;
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-sqlda-sqldata">
      <term><literal>sqldata</literal></term>
       <listitem>
        <para>
@@ -8443,7 +8443,7 @@ switch (sqldata->sqlvar[i].sqltype)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-sqlda-sqlind">
      <term><literal>sqlind</literal></term>
       <listitem>
        <para>
@@ -8459,7 +8459,7 @@ if (*(int2 *)sqldata->sqlvar[i].sqlind != 0)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-sqlda-sqlname">
      <term><literal>sqlname</literal></term>
       <listitem>
        <para>
@@ -8468,7 +8468,7 @@ if (*(int2 *)sqldata->sqlvar[i].sqlind != 0)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-sqlda-sqlformat">
      <term><literal>sqlformat</literal></term>
       <listitem>
        <para>
@@ -8477,7 +8477,7 @@ if (*(int2 *)sqldata->sqlvar[i].sqlind != 0)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-sqlda-sqlitype">
      <term><literal>sqlitype</literal></term>
       <listitem>
        <para>
@@ -8488,7 +8488,7 @@ if (*(int2 *)sqldata->sqlvar[i].sqlind != 0)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-sqlda-sqlilen">
      <term><literal>sqlilen</literal></term>
       <listitem>
        <para>
@@ -8497,7 +8497,7 @@ if (*(int2 *)sqldata->sqlvar[i].sqlind != 0)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-sqlda-sqlxid">
      <term><literal>sqlxid</literal></term>
       <listitem>
        <para>
@@ -8506,7 +8506,7 @@ if (*(int2 *)sqldata->sqlvar[i].sqlind != 0)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-sqlda-sqltypename-et-al">
      <term><literal>sqltypename</literal></term>
      <term><literal>sqltypelen</literal></term>
      <term><literal>sqlownerlen</literal></term>
@@ -8522,7 +8522,7 @@ if (*(int2 *)sqldata->sqlvar[i].sqlind != 0)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-sqlda-sqlilongdata">
      <term><literal>sqlilongdata</literal></term>
       <listitem>
        <para>
@@ -8577,7 +8577,7 @@ EXEC SQL INCLUDE sqlda.h;
    <title>Additional Functions</title>
    <para>
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-decadd">
       <term><function>decadd</function></term>
       <listitem>
        <para>
@@ -8597,7 +8597,7 @@ int decadd(decimal *arg1, decimal *arg2, decimal *sum);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-deccmp">
       <term><function>deccmp</function></term>
       <listitem>
        <para>
@@ -8632,7 +8632,7 @@ int deccmp(decimal *arg1, decimal *arg2);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-deccopy">
       <term><function>deccopy</function></term>
       <listitem>
        <para>
@@ -8648,7 +8648,7 @@ void deccopy(decimal *src, decimal *target);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-deccvasc">
       <term><function>deccvasc</function></term>
       <listitem>
        <para>
@@ -8681,7 +8681,7 @@ int deccvasc(char *cp, int len, decimal *np);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-deccvdbl">
       <term><function>deccvdbl</function></term>
       <listitem>
        <para>
@@ -8701,7 +8701,7 @@ int deccvdbl(double dbl, decimal *np);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-deccvint">
       <term><function>deccvint</function></term>
       <listitem>
        <para>
@@ -8721,7 +8721,7 @@ int deccvint(int in, decimal *np);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-deccvlong">
       <term><function>deccvlong</function></term>
       <listitem>
        <para>
@@ -8741,7 +8741,7 @@ int deccvlong(long lng, decimal *np);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-decdiv">
       <term><function>decdiv</function></term>
       <listitem>
        <para>
@@ -8765,7 +8765,7 @@ int decdiv(decimal *n1, decimal *n2, decimal *result);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-decmul">
       <term><function>decmul</function></term>
       <listitem>
        <para>
@@ -8787,7 +8787,7 @@ int decmul(decimal *n1, decimal *n2, decimal *result);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-decsub">
       <term><function>decsub</function></term>
       <listitem>
        <para>
@@ -8809,7 +8809,7 @@ int decsub(decimal *n1, decimal *n2, decimal *result);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-dectoasc">
       <term><function>dectoasc</function></term>
       <listitem>
        <para>
@@ -8839,7 +8839,7 @@ int dectoasc(decimal *np, char *cp, int len, int right)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-dectodbl">
       <term><function>dectodbl</function></term>
       <listitem>
        <para>
@@ -8858,7 +8858,7 @@ int dectodbl(decimal *np, double *dblp);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-dectoint">
       <term><function>dectoint</function></term>
       <listitem>
        <para>
@@ -8884,7 +8884,7 @@ int dectoint(decimal *np, int *ip);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-dectolong">
       <term><function>dectolong</function></term>
       <listitem>
        <para>
@@ -8911,7 +8911,7 @@ int dectolong(decimal *np, long *lngp);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-rdatestr">
       <term><function>rdatestr</function></term>
       <listitem>
        <para>
@@ -8938,7 +8938,7 @@ int rdatestr(date d, char *str);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-rstrdate">
       <term><function>rstrdate</function></term>
       <listitem>
        <para>
@@ -8962,7 +8962,7 @@ int rstrdate(char *str, date *d);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-rtoday">
       <term><function>rtoday</function></term>
       <listitem>
        <para>
@@ -8980,7 +8980,7 @@ void rtoday(date *d);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-rjulmdy">
       <term><function>rjulmdy</function></term>
       <listitem>
        <para>
@@ -9005,7 +9005,7 @@ int rjulmdy(date d, short mdy[3]);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-rdefmtdate">
       <term><function>rdefmtdate</function></term>
       <listitem>
        <para>
@@ -9075,7 +9075,7 @@ int rdefmtdate(date *d, char *fmt, char *str);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-rfmtdate">
       <term><function>rfmtdate</function></term>
       <listitem>
        <para>
@@ -9098,7 +9098,7 @@ int rfmtdate(date d, char *fmt, char *str);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-rmdyjul">
       <term><function>rmdyjul</function></term>
       <listitem>
        <para>
@@ -9121,7 +9121,7 @@ int rmdyjul(short mdy[3], date *d);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-rdayofweek">
       <term><function>rdayofweek</function></term>
       <listitem>
        <para>
@@ -9177,7 +9177,7 @@ int rdayofweek(date d);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-dtcurrent">
       <term><function>dtcurrent</function></term>
       <listitem>
        <para>
@@ -9191,7 +9191,7 @@ void dtcurrent(timestamp *ts);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-dtcvasc">
       <term><function>dtcvasc</function></term>
       <listitem>
        <para>
@@ -9216,7 +9216,7 @@ int dtcvasc(char *str, timestamp *ts);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-dtcvfmtasc">
       <term><function>dtcvfmtasc</function></term>
       <listitem>
        <para>
@@ -9242,7 +9242,7 @@ dtcvfmtasc(char *inbuf, char *fmtstr, timestamp *dtvalue)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-dtsub">
       <term><function>dtsub</function></term>
       <listitem>
        <para>
@@ -9263,7 +9263,7 @@ int dtsub(timestamp *ts1, timestamp *ts2, interval *iv);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-dttoasc">
       <term><function>dttoasc</function></term>
       <listitem>
        <para>
@@ -9284,7 +9284,7 @@ int dttoasc(timestamp *ts, char *output);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-dttofmtasc">
       <term><function>dttofmtasc</function></term>
       <listitem>
        <para>
@@ -9310,7 +9310,7 @@ int dttofmtasc(timestamp *ts, char *output, int str_len, char *fmtstr);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-intoasc">
       <term><function>intoasc</function></term>
       <listitem>
        <para>
@@ -9331,7 +9331,7 @@ int intoasc(interval *i, char *str);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-rfmtlong">
       <term><function>rfmtlong</function></term>
       <listitem>
        <para>
@@ -9417,7 +9417,7 @@ int rfmtlong(long lng_val, char *fmt, char *outbuf);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-rupshift">
       <term><function>rupshift</function></term>
       <listitem>
        <para>
@@ -9431,7 +9431,7 @@ void rupshift(char *str);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-byleng">
       <term><function>byleng</function></term>
       <listitem>
        <para>
@@ -9448,7 +9448,7 @@ int byleng(char *str, int len);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-ldchar">
       <term><function>ldchar</function></term>
       <listitem>
        <para>
@@ -9467,7 +9467,7 @@ void ldchar(char *src, int len, char *dest);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-rgetmsg">
       <term><function>rgetmsg</function></term>
       <listitem>
        <para>
@@ -9479,7 +9479,7 @@ int rgetmsg(int msgnum, char *s, int maxsize);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-rtypalign">
       <term><function>rtypalign</function></term>
       <listitem>
        <para>
@@ -9491,7 +9491,7 @@ int rtypalign(int offset, int type);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-rtypmsize">
       <term><function>rtypmsize</function></term>
       <listitem>
        <para>
@@ -9503,7 +9503,7 @@ int rtypmsize(int type, int len);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-rtypwidth">
       <term><function>rtypwidth</function></term>
       <listitem>
        <para>
@@ -9599,7 +9599,7 @@ rsetnull(CINTTYPE, (char *) &i);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-functions-risnull">
       <term><function>risnull</function></term>
       <listitem>
        <para>
@@ -9641,7 +9641,7 @@ risnull(CINTTYPE, (char *) &i);
     however rely on the fact all of them are defined to represent negative
     values.
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-informix-constants-ecpg_informix_num_overflow">
       <term><literal>ECPG_INFORMIX_NUM_OVERFLOW</literal></term>
       <listitem>
        <para>
@@ -9652,7 +9652,7 @@ risnull(CINTTYPE, (char *) &i);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-constants-ecpg_informix_num_underflow">
       <term><literal>ECPG_INFORMIX_NUM_UNDERFLOW</literal></term>
       <listitem>
        <para>
@@ -9662,7 +9662,7 @@ risnull(CINTTYPE, (char *) &i);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-constants-ecpg_informix_divide_zero">
       <term><literal>ECPG_INFORMIX_DIVIDE_ZERO</literal></term>
       <listitem>
        <para>
@@ -9672,7 +9672,7 @@ risnull(CINTTYPE, (char *) &i);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-constants-ecpg_informix_bad_year">
       <term><literal>ECPG_INFORMIX_BAD_YEAR</literal></term>
       <listitem>
        <para>
@@ -9683,7 +9683,7 @@ risnull(CINTTYPE, (char *) &i);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-constants-ecpg_informix_bad_month">
       <term><literal>ECPG_INFORMIX_BAD_MONTH</literal></term>
       <listitem>
        <para>
@@ -9694,7 +9694,7 @@ risnull(CINTTYPE, (char *) &i);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-constants-ecpg_informix_bad_day">
       <term><literal>ECPG_INFORMIX_BAD_DAY</literal></term>
       <listitem>
        <para>
@@ -9705,7 +9705,7 @@ risnull(CINTTYPE, (char *) &i);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-constants-ecpg_informix_enoshortdate">
       <term><literal>ECPG_INFORMIX_ENOSHORTDATE</literal></term>
       <listitem>
        <para>
@@ -9716,7 +9716,7 @@ risnull(CINTTYPE, (char *) &i);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-constants-ecpg_informix_date_convert">
       <term><literal>ECPG_INFORMIX_DATE_CONVERT</literal></term>
       <listitem>
        <para>
@@ -9727,7 +9727,7 @@ risnull(CINTTYPE, (char *) &i);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-constants-ecpg_informix_out_of_memory">
       <term><literal>ECPG_INFORMIX_OUT_OF_MEMORY</literal></term>
       <listitem>
        <para>
@@ -9738,7 +9738,7 @@ risnull(CINTTYPE, (char *) &i);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-constants-ecpg_informix_enotdmy">
       <term><literal>ECPG_INFORMIX_ENOTDMY</literal></term>
       <listitem>
        <para>
@@ -9749,7 +9749,7 @@ risnull(CINTTYPE, (char *) &i);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-constants-ecpg_informix_bad_numeric">
       <term><literal>ECPG_INFORMIX_BAD_NUMERIC</literal></term>
       <listitem>
        <para>
@@ -9762,7 +9762,7 @@ risnull(CINTTYPE, (char *) &i);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-constants-ecpg_informix_bad_exponent">
       <term><literal>ECPG_INFORMIX_BAD_EXPONENT</literal></term>
       <listitem>
        <para>
@@ -9773,7 +9773,7 @@ risnull(CINTTYPE, (char *) &i);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-constants-ecpg_informix_bad_date">
       <term><literal>ECPG_INFORMIX_BAD_DATE</literal></term>
       <listitem>
        <para>
@@ -9784,7 +9784,7 @@ risnull(CINTTYPE, (char *) &i);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-informix-constants-ecpg_informix_extra_chars">
       <term><literal>ECPG_INFORMIX_EXTRA_CHARS</literal></term>
       <listitem>
        <para>
@@ -9843,7 +9843,7 @@ risnull(CINTTYPE, (char *) &i);
     The arguments are:
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="ecpg-develop-line-number">
       <term>A line number</term>
       <listitem>
        <para>
@@ -9853,7 +9853,7 @@ risnull(CINTTYPE, (char *) &i);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-develop-string">
       <term>A string</term>
       <listitem>
        <para>
@@ -9866,7 +9866,7 @@ risnull(CINTTYPE, (char *) &i);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-develop-input-variables">
       <term>Input variables</term>
       <listitem>
        <para>
@@ -9875,7 +9875,7 @@ risnull(CINTTYPE, (char *) &i);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-develop-ecpgt_eoit">
       <term><parameter>ECPGt_EOIT</parameter></term>
       <listitem>
        <para>
@@ -9885,7 +9885,7 @@ risnull(CINTTYPE, (char *) &i);
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="ecpg-develop-output-variables">
       <term>Output variables</term>
       <listitem>
        <para>
@@ -9895,7 +9895,7 @@ risnull(CINTTYPE, (char *) &i);
       </listitem>
      </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="ecpg-develop-ecpgt_eort">
        <term><parameter>ECPGt_EORT</parameter></term>
        <listitem>
        <para>
diff --git a/doc/src/sgml/extend.sgml b/doc/src/sgml/extend.sgml
index e928894726..679dffda14 100644
--- a/doc/src/sgml/extend.sgml
+++ b/doc/src/sgml/extend.sgml
@@ -120,7 +120,7 @@
     types, container types, domains, and pseudo-types.
    </para>
 
-   <sect2>
+   <sect2 id="extend-type-system-base">
     <title>Base Types</title>
 
     <para>
@@ -143,7 +143,7 @@
     </para>
    </sect2>
 
-   <sect2>
+   <sect2 id="extend-type-system-container">
     <title>Container Types</title>
 
     <para>
@@ -193,7 +193,7 @@
     </para>
    </sect2>
 
-   <sect2>
+   <sect2 id="extend-type-system-pseudo">
     <title>Pseudo-Types</title>
 
     <para>
@@ -628,7 +628,7 @@ RETURNS anycompatible AS ...
     dropping the whole extension.
    </para>
 
-   <sect2>
+   <sect2 id="extend-extensions-files">
     <title>Extension Files</title>
 
    <indexterm>
@@ -663,7 +663,7 @@ RETURNS anycompatible AS ...
     </para>
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="extend-extensions-files-directory">
       <term><varname>directory</varname> (<type>string</type>)</term>
       <listitem>
        <para>
@@ -676,7 +676,7 @@ RETURNS anycompatible AS ...
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-extensions-files-default_version">
       <term><varname>default_version</varname> (<type>string</type>)</term>
       <listitem>
        <para>
@@ -689,7 +689,7 @@ RETURNS anycompatible AS ...
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-extensions-files-comment">
       <term><varname>comment</varname> (<type>string</type>)</term>
       <listitem>
        <para>
@@ -702,7 +702,7 @@ RETURNS anycompatible AS ...
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-extensions-files-encoding">
       <term><varname>encoding</varname> (<type>string</type>)</term>
       <listitem>
        <para>
@@ -713,7 +713,7 @@ RETURNS anycompatible AS ...
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-extensions-files-module_pathname">
       <term><varname>module_pathname</varname> (<type>string</type>)</term>
       <listitem>
        <para>
@@ -728,7 +728,7 @@ RETURNS anycompatible AS ...
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-extensions-files-requires">
       <term><varname>requires</varname> (<type>string</type>)</term>
       <listitem>
        <para>
@@ -739,7 +739,7 @@ RETURNS anycompatible AS ...
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-extensions-files-superuser">
       <term><varname>superuser</varname> (<type>boolean</type>)</term>
       <listitem>
        <para>
@@ -756,7 +756,7 @@ RETURNS anycompatible AS ...
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-extensions-files-trusted">
       <term><varname>trusted</varname> (<type>boolean</type>)</term>
       <listitem>
        <para>
@@ -781,7 +781,7 @@ RETURNS anycompatible AS ...
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-extensions-files-relocatable">
       <term><varname>relocatable</varname> (<type>boolean</type>)</term>
       <listitem>
        <para>
@@ -794,7 +794,7 @@ RETURNS anycompatible AS ...
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-extensions-files-schema">
       <term><varname>schema</varname> (<type>string</type>)</term>
       <listitem>
        <para>
@@ -1063,7 +1063,7 @@ SELECT pg_catalog.pg_extension_config_dump('my_config', 'WHERE NOT standard_entr
     </para>
    </sect2>
 
-   <sect2>
+   <sect2 id="extend-extensions-updates">
     <title>Extension Updates</title>
 
     <para>
@@ -1144,7 +1144,7 @@ SELECT * FROM pg_extension_update_paths('<replaceable>extension_name</replaceabl
     </para>
    </sect2>
 
-   <sect2>
+   <sect2 id="extend-extensions-update-scripts">
     <title>Installing Extensions Using Update Scripts</title>
 
     <para>
@@ -1464,7 +1464,7 @@ include $(PGXS)
     Set one of these three variables to specify what is built:
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="extend-pgxs-modules">
       <term><varname>MODULES</varname></term>
       <listitem>
        <para>
@@ -1474,7 +1474,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-module_big">
       <term><varname>MODULE_big</varname></term>
       <listitem>
        <para>
@@ -1484,7 +1484,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-program">
       <term><varname>PROGRAM</varname></term>
       <listitem>
        <para>
@@ -1498,7 +1498,7 @@ include $(PGXS)
     The following variables can also be set:
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="extend-pgxs-extension">
       <term><varname>EXTENSION</varname></term>
       <listitem>
        <para>
@@ -1510,7 +1510,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-moduledir">
       <term><varname>MODULEDIR</varname></term>
       <listitem>
        <para>
@@ -1523,7 +1523,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-data">
       <term><varname>DATA</varname></term>
       <listitem>
        <para>
@@ -1532,7 +1532,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-data_built">
       <term><varname>DATA_built</varname></term>
       <listitem>
        <para>
@@ -1543,7 +1543,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-data_tsearch">
       <term><varname>DATA_TSEARCH</varname></term>
       <listitem>
        <para>
@@ -1553,7 +1553,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-docs">
       <term><varname>DOCS</varname></term>
       <listitem>
        <para>
@@ -1563,7 +1563,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-headers">
       <term><varname>HEADERS</varname></term>
       <term><varname>HEADERS_built</varname></term>
       <listitem>
@@ -1579,7 +1579,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-headers_module">
       <term><varname>HEADERS_$MODULE</varname></term>
       <term><varname>HEADERS_built_$MODULE</varname></term>
       <listitem>
@@ -1605,7 +1605,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-scripts">
       <term><varname>SCRIPTS</varname></term>
       <listitem>
        <para>
@@ -1615,7 +1615,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-scripts_built">
       <term><varname>SCRIPTS_built</varname></term>
       <listitem>
        <para>
@@ -1626,7 +1626,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-regress">
       <term><varname>REGRESS</varname></term>
       <listitem>
        <para>
@@ -1635,7 +1635,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-regress_opts">
       <term><varname>REGRESS_OPTS</varname></term>
       <listitem>
        <para>
@@ -1644,7 +1644,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-isolation">
       <term><varname>ISOLATION</varname></term>
       <listitem>
        <para>
@@ -1653,7 +1653,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-isolation_opts">
       <term><varname>ISOLATION_OPTS</varname></term>
       <listitem>
        <para>
@@ -1663,7 +1663,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-tap_tests">
       <term><varname>TAP_TESTS</varname></term>
       <listitem>
        <para>
@@ -1672,7 +1672,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-no_install">
       <term><varname>NO_INSTALL</varname></term>
       <listitem>
        <para>
@@ -1682,7 +1682,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-no_installcheck">
       <term><varname>NO_INSTALLCHECK</varname></term>
       <listitem>
        <para>
@@ -1691,7 +1691,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-extra_clean">
       <term><varname>EXTRA_CLEAN</varname></term>
       <listitem>
        <para>
@@ -1700,7 +1700,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-pg_cppflags">
       <term><varname>PG_CPPFLAGS</varname></term>
       <listitem>
        <para>
@@ -1709,7 +1709,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-pg_cflags">
       <term><varname>PG_CFLAGS</varname></term>
       <listitem>
        <para>
@@ -1718,7 +1718,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-pg_cxxflags">
       <term><varname>PG_CXXFLAGS</varname></term>
       <listitem>
        <para>
@@ -1727,7 +1727,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-pg_ldflags">
       <term><varname>PG_LDFLAGS</varname></term>
       <listitem>
        <para>
@@ -1736,7 +1736,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-pg_libs">
       <term><varname>PG_LIBS</varname></term>
       <listitem>
        <para>
@@ -1745,7 +1745,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-shlib_link">
       <term><varname>SHLIB_LINK</varname></term>
       <listitem>
        <para>
@@ -1754,7 +1754,7 @@ include $(PGXS)
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="extend-pgxs-pg_config">
       <term><varname>PG_CONFIG</varname></term>
       <listitem>
        <para>
diff --git a/doc/src/sgml/features.sgml b/doc/src/sgml/features.sgml
index 05365d890b..afbea9d982 100644
--- a/doc/src/sgml/features.sgml
+++ b/doc/src/sgml/features.sgml
@@ -238,7 +238,7 @@
      <productname>PostgreSQL</productname>-specific functions.
     </para>
 
-    <sect3>
+    <sect3 id="functions-xml-limits-xpath1-xquery-restriction">
      <title>Restriction of XQuery to XPath</title>
 
      <para>
@@ -427,7 +427,7 @@
      implementation in <productname>PostgreSQL</productname>.
     </para>
 
-    <sect3>
+    <sect3 id="functions-xml-limits-postgresql-by-value-only">
      <title>Only <literal>BY VALUE</literal> Passing Mechanism Is Supported</title>
 
      <para>
@@ -463,7 +463,7 @@ SELECT XMLQUERY('$a is $b' PASSING BY VALUE <replaceable>x</replaceable> AS a, <
      </para>
     </sect3>
 
-    <sect3>
+    <sect3 id="functions-xml-limits-postgresql-named-parameters">
      <title>Cannot Pass Named Parameters to Queries</title>
 
      <para>
@@ -473,7 +473,7 @@ SELECT XMLQUERY('$a is $b' PASSING BY VALUE <replaceable>x</replaceable> AS a, <
      </para>
     </sect3>
 
-    <sect3>
+    <sect3 id="functions-xml-limits-postgresql-no-xml-sequence">
      <title>No <type>XML(SEQUENCE)</type> Type</title>
 
      <para>
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 8a802fb225..4254c009fd 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -13880,7 +13880,7 @@ CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple
     documents for processing in client applications.
    </para>
 
-   <sect3>
+   <sect3 id="functions-producing-xml-xmlcomment">
     <title><literal>xmlcomment</literal></title>
 
     <indexterm>
@@ -13912,7 +13912,7 @@ SELECT xmlcomment('hello');
     </para>
    </sect3>
 
-   <sect3>
+   <sect3 id="functions-producing-xml-xmlconcat">
     <title><literal>xmlconcat</literal></title>
 
     <indexterm>
@@ -13969,7 +13969,7 @@ SELECT xmlconcat('<?xml version="1.1"?><foo/>', '<?xml version="1.1" standalone=
     </para>
    </sect3>
 
-   <sect3>
+   <sect3 id="functions-producing-xml-xmlelement">
     <title><literal>xmlelement</literal></title>
 
    <indexterm>
@@ -14075,7 +14075,7 @@ SELECT xmlelement(name foo, xmlattributes('xyz' as bar),
     </para>
    </sect3>
 
-   <sect3>
+   <sect3 id="functions-producing-xml-xmlforest">
     <title><literal>xmlforest</literal></title>
 
    <indexterm>
@@ -14136,7 +14136,7 @@ WHERE table_schema = 'pg_catalog';
     </para>
    </sect3>
 
-   <sect3>
+   <sect3 id="functions-producing-xml-xmlpi">
     <title><literal>xmlpi</literal></title>
 
    <indexterm>
@@ -14169,7 +14169,7 @@ SELECT xmlpi(name php, 'echo "hello world";');
     </para>
    </sect3>
 
-   <sect3>
+   <sect3 id="functions-producing-xml-xmlroot">
     <title><literal>xmlroot</literal></title>
 
    <indexterm>
@@ -14271,7 +14271,7 @@ SELECT xmlagg(x) FROM (SELECT * FROM test ORDER BY y DESC) AS tab;
      of <type>xml</type> values.
     </para>
 
-   <sect3>
+   <sect3 id="functions-producing-xml-is-document">
     <title><literal>IS DOCUMENT</literal></title>
 
     <indexterm>
@@ -14291,7 +14291,7 @@ SELECT xmlagg(x) FROM (SELECT * FROM test ORDER BY y DESC) AS tab;
     </para>
    </sect3>
 
-   <sect3>
+   <sect3 id="functions-producing-xml-is-not-document">
     <title><literal>IS NOT DOCUMENT</literal></title>
 
     <indexterm>
@@ -21471,7 +21471,7 @@ WHERE EXISTS (SELECT 1 FROM tab2 WHERE col2 = tab1.col2);
   </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="functions-subquery-single-row-comp">
    <title>Single-Row Comparison</title>
 
    <indexterm zone="functions-subquery">
@@ -21594,7 +21594,7 @@ OR
   </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="functions-comparisons-not-in">
    <title><literal>NOT IN</literal></title>
 
 <synopsis>
@@ -21635,7 +21635,7 @@ AND
   </tip>
   </sect2>
 
-  <sect2>
+  <sect2 id="functions-comparisons-any-some">
    <title><literal>ANY</literal>/<literal>SOME</literal> (array)</title>
 
 <synopsis>
@@ -21672,7 +21672,7 @@ AND
   </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="functions-comparisons-all">
    <title><literal>ALL</literal> (array)</title>
 
 <synopsis>
diff --git a/doc/src/sgml/fuzzystrmatch.sgml b/doc/src/sgml/fuzzystrmatch.sgml
index 382e54be91..5dedbd8f7a 100644
--- a/doc/src/sgml/fuzzystrmatch.sgml
+++ b/doc/src/sgml/fuzzystrmatch.sgml
@@ -26,7 +26,7 @@
   on the current database.
  </para>
 
- <sect2>
+ <sect2 id="fuzzystrmatch-soundex">
   <title>Soundex</title>
 
   <para>
@@ -88,7 +88,7 @@ SELECT * FROM s WHERE difference(s.nm, 'john') &gt; 2;
 </programlisting>
  </sect2>
 
- <sect2>
+ <sect2 id="fuzzystrmatch-levenshtein">
   <title>Levenshtein</title>
 
   <para>
@@ -159,7 +159,7 @@ test=# SELECT levenshtein_less_equal('extensive', 'exhaustive', 4);
 </screen>
  </sect2>
 
- <sect2>
+ <sect2 id="fuzzystrmatch-metaphone">
   <title>Metaphone</title>
 
   <para>
@@ -200,7 +200,7 @@ test=# SELECT metaphone('GUMBO', 4);
 </screen>
  </sect2>
 
- <sect2>
+ <sect2 id="fuzzystrmatch-double-metaphone">
   <title>Double Metaphone</title>
 
   <para>
diff --git a/doc/src/sgml/geqo.sgml b/doc/src/sgml/geqo.sgml
index ac552efd84..82bf3b690d 100644
--- a/doc/src/sgml/geqo.sgml
+++ b/doc/src/sgml/geqo.sgml
@@ -173,7 +173,7 @@
     non-exhaustive search.
    </para>
 
-  <sect2>
+  <sect2 id="geqo-pg-intro-gen-possible-plans">
    <title>Generating Possible Plans with <acronym>GEQO</acronym></title>
 
    <para>
diff --git a/doc/src/sgml/history.sgml b/doc/src/sgml/history.sgml
index aa171823a8..5273c47580 100644
--- a/doc/src/sgml/history.sgml
+++ b/doc/src/sgml/history.sgml
@@ -183,7 +183,7 @@
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="history-postgresql">
   <title><productname>PostgreSQL</productname></title>
 
   <para>
diff --git a/doc/src/sgml/hstore.sgml b/doc/src/sgml/hstore.sgml
index 679878b3af..807cf9806b 100644
--- a/doc/src/sgml/hstore.sgml
+++ b/doc/src/sgml/hstore.sgml
@@ -21,7 +21,7 @@
   on the current database.
  </para>
 
- <sect2>
+ <sect2 id="hstore-external-rep">
   <title><type>hstore</type> External Representation</title>
 
   <para>
@@ -88,7 +88,7 @@ key =&gt; NULL
 
  </sect2>
 
- <sect2>
+ <sect2 id="hstore-ops-funcs">
   <title><type>hstore</type> Operators and Functions</title>
 
   <para>
@@ -738,7 +738,7 @@ SELECT h FROM mytable;
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="hstore-indexes">
   <title>Indexes</title>
 
   <para>
@@ -784,7 +784,7 @@ CREATE INDEX hidx ON testhstore USING HASH (h);
 </programlisting>
  </sect2>
 
- <sect2>
+ <sect2 id="hstore-examples">
   <title>Examples</title>
 
   <para>
@@ -853,7 +853,7 @@ SELECT (r).* FROM (SELECT t #= '"col3"=&gt;"baz"' AS r FROM test t) s;
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="hstore-statistics">
   <title>Statistics</title>
 
   <para>
@@ -900,7 +900,7 @@ SELECT key, count(*) FROM
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="hstore-compatibility">
   <title>Compatibility</title>
 
   <para>
@@ -933,7 +933,7 @@ ALTER TABLE tablename ALTER hstorecol TYPE hstore USING hstorecol || '';
 
  </sect2>
 
- <sect2>
+ <sect2 id="hstore-transforms">
   <title>Transforms</title>
 
   <para>
@@ -957,7 +957,7 @@ ALTER TABLE tablename ALTER hstorecol TYPE hstore USING hstorecol || '';
   </caution>
  </sect2>
 
- <sect2>
+ <sect2 id="hstore-authors">
   <title>Authors</title>
 
   <para>
diff --git a/doc/src/sgml/install-windows.sgml b/doc/src/sgml/install-windows.sgml
index 43d05bde4e..f0aec170f4 100644
--- a/doc/src/sgml/install-windows.sgml
+++ b/doc/src/sgml/install-windows.sgml
@@ -160,7 +160,7 @@ $ENV{MSBFLAGS}="/m";
 </programlisting>
  </para>
 
- <sect2>
+ <sect2 id="install-windows-full-requirements">
   <title>Requirements</title>
   <para>
    The following additional products are required to build
@@ -354,7 +354,7 @@ $ENV{MSBFLAGS}="/m";
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="install-windows-full-64-bit">
   <title>Special Considerations for 64-Bit Windows</title>
 
   <para>
@@ -379,7 +379,7 @@ $ENV{MSBFLAGS}="/m";
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="install-windows-full-build">
   <title>Building</title>
 
   <para>
@@ -416,7 +416,7 @@ $ENV{CONFIG}="Debug";
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="install-windows-full-clean-inst">
   <title>Cleaning and Installing</title>
 
   <para>
@@ -449,7 +449,7 @@ $ENV{CONFIG}="Debug";
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="install-windows-full-reg-tests">
   <title>Running the Regression Tests</title>
 
   <para>
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index 0f74252590..34a3e562e8 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -655,7 +655,7 @@ build-postgresql:
      </para>
 
      <variablelist>
-      <varlistentry>
+      <varlistentry id="configure-options-prefix">
        <term><option>--prefix=<replaceable>PREFIX</replaceable></option></term>
        <listitem>
         <para>
@@ -668,7 +668,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-exec-prefix">
        <term><option>--exec-prefix=<replaceable>EXEC-PREFIX</replaceable></option></term>
        <listitem>
         <para>
@@ -684,7 +684,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-bindir">
        <term><option>--bindir=<replaceable>DIRECTORY</replaceable></option></term>
        <listitem>
         <para>
@@ -695,7 +695,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-sysconfdir">
        <term><option>--sysconfdir=<replaceable>DIRECTORY</replaceable></option></term>
        <listitem>
         <para>
@@ -705,7 +705,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-libdir">
        <term><option>--libdir=<replaceable>DIRECTORY</replaceable></option></term>
        <listitem>
         <para>
@@ -716,7 +716,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-includedir">
        <term><option>--includedir=<replaceable>DIRECTORY</replaceable></option></term>
        <listitem>
         <para>
@@ -726,7 +726,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-datarootdir">
        <term><option>--datarootdir=<replaceable>DIRECTORY</replaceable></option></term>
        <listitem>
         <para>
@@ -738,7 +738,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-datadir">
        <term><option>--datadir=<replaceable>DIRECTORY</replaceable></option></term>
        <listitem>
         <para>
@@ -750,7 +750,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-localedir">
        <term><option>--localedir=<replaceable>DIRECTORY</replaceable></option></term>
        <listitem>
         <para>
@@ -761,7 +761,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-mandir">
        <term><option>--mandir=<replaceable>DIRECTORY</replaceable></option></term>
        <listitem>
         <para>
@@ -773,7 +773,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-docdir">
        <term><option>--docdir=<replaceable>DIRECTORY</replaceable></option></term>
        <listitem>
         <para>
@@ -785,7 +785,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-htmldir">
        <term><option>--htmldir=<replaceable>DIRECTORY</replaceable></option></term>
        <listitem>
         <para>
@@ -840,7 +840,7 @@ build-postgresql:
 
      <variablelist>
 
-      <varlistentry>
+      <varlistentry id="configure-options-enable-nls">
        <term><option>--enable-nls<optional>=<replaceable>LANGUAGES</replaceable></optional></option></term>
        <listitem>
         <para>
@@ -863,7 +863,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-perl">
        <term><option>--with-perl</option></term>
        <listitem>
         <para>
@@ -872,7 +872,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-python">
        <term><option>--with-python</option></term>
        <listitem>
         <para>
@@ -881,7 +881,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-tcl">
        <term><option>--with-tcl</option></term>
        <listitem>
         <para>
@@ -890,7 +890,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-tclconfig">
        <term><option>--with-tclconfig=<replaceable>DIRECTORY</replaceable></option></term>
        <listitem>
         <para>
@@ -904,7 +904,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-icu">
        <term><option>--with-icu</option></term>
        <listitem>
         <para>
@@ -974,7 +974,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-lz4">
        <term><option>--with-lz4</option></term>
        <listitem>
         <para>
@@ -983,7 +983,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-zstd">
        <term><option>--with-zstd</option></term>
        <listitem>
         <para>
@@ -992,7 +992,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-ssl">
        <term><option>--with-ssl=<replaceable>LIBRARY</replaceable></option>
        <indexterm>
         <primary>OpenSSL</primary>
@@ -1013,7 +1013,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-openssl">
        <term><option>--with-openssl</option></term>
        <listitem>
         <para>
@@ -1022,7 +1022,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-gssapi">
        <term><option>--with-gssapi</option></term>
        <listitem>
         <para>
@@ -1039,7 +1039,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-ldap">
        <term><option>--with-ldap</option></term>
        <listitem>
         <para>
@@ -1057,7 +1057,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-pam">
        <term><option>--with-pam</option></term>
        <listitem>
         <para>
@@ -1067,7 +1067,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-bsd-auth">
        <term><option>--with-bsd-auth</option></term>
        <listitem>
         <para>
@@ -1078,7 +1078,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-systemd">
        <term><option>--with-systemd</option></term>
        <listitem>
         <para>
@@ -1093,7 +1093,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-bonjour">
        <term><option>--with-bonjour</option></term>
        <listitem>
         <para>
@@ -1104,7 +1104,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-uuid">
        <term><option>--with-uuid=<replaceable>LIBRARY</replaceable></option></term>
        <listitem>
         <para>
@@ -1138,7 +1138,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-ossp-uuid">
        <term><option>--with-ossp-uuid</option></term>
        <listitem>
         <para>
@@ -1147,7 +1147,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-libxml">
        <term><option>--with-libxml</option></term>
        <listitem>
         <para>
@@ -1180,7 +1180,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-libxslt">
        <term><option>--with-libxslt</option></term>
        <listitem>
         <para>
@@ -1209,7 +1209,7 @@ build-postgresql:
 
      <variablelist>
 
-      <varlistentry>
+      <varlistentry id="configure-options-without-readline">
        <term><option>--without-readline</option></term>
        <listitem>
         <para>
@@ -1221,7 +1221,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-libedit-preferred">
        <term><option>--with-libedit-preferred</option></term>
        <listitem>
         <para>
@@ -1233,7 +1233,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-without-zlib">
        <term><option>--without-zlib</option></term>
        <listitem>
         <para>
@@ -1248,7 +1248,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-disable-spinlocks">
        <term><option>--disable-spinlocks</option></term>
        <listitem>
         <para>
@@ -1264,7 +1264,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-disable-atomics">
        <term><option>--disable-atomics</option></term>
        <listitem>
         <para>
@@ -1276,7 +1276,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-disable-thread-safety">
        <term><option>--disable-thread-safety</option></term>
        <listitem>
         <para>
@@ -1298,7 +1298,7 @@ build-postgresql:
 
      <variablelist>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-includes">
        <term><option>--with-includes=<replaceable>DIRECTORIES</replaceable></option></term>
        <listitem>
         <para>
@@ -1316,7 +1316,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-libraries">
        <term><option>--with-libraries=<replaceable>DIRECTORIES</replaceable></option></term>
        <listitem>
         <para>
@@ -1332,7 +1332,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-system-tzdata">
        <term><option>--with-system-tzdata=<replaceable>DIRECTORY</replaceable></option>
        <indexterm>
         <primary>time zone data</primary>
@@ -1372,7 +1372,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-extra-version">
        <term><option>--with-extra-version=<replaceable>STRING</replaceable></option></term>
        <listitem>
         <para>
@@ -1385,7 +1385,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-disable-rpath">
        <term><option>--disable-rpath</option></term>
        <listitem>
         <para>
@@ -1419,7 +1419,7 @@ build-postgresql:
 
      <variablelist>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-pgport">
        <term><option>--with-pgport=<replaceable>NUMBER</replaceable></option></term>
        <listitem>
         <para>
@@ -1434,7 +1434,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-krb-srvnam">
        <term><option>--with-krb-srvnam=<replaceable>NAME</replaceable></option></term>
        <listitem>
         <para>
@@ -1448,7 +1448,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-segsize">
        <term><option>--with-segsize=<replaceable>SEGSIZE</replaceable></option></term>
        <listitem>
         <para>
@@ -1473,7 +1473,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-blocksize">
        <term><option>--with-blocksize=<replaceable>BLOCKSIZE</replaceable></option></term>
        <listitem>
         <para>
@@ -1489,7 +1489,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-with-wal-blocksize">
        <term><option>--with-wal-blocksize=<replaceable>BLOCKSIZE</replaceable></option></term>
        <listitem>
         <para>
@@ -1531,7 +1531,7 @@ build-postgresql:
 
      <variablelist>
 
-      <varlistentry>
+      <varlistentry id="configure-options-enable-debug">
        <term><option>--enable-debug</option></term>
        <listitem>
         <para>
@@ -1549,7 +1549,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-enable-cassert">
        <term><option>--enable-cassert</option></term>
        <listitem>
         <para>
@@ -1568,7 +1568,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-enable-tap-tests">
        <term><option>--enable-tap-tests</option></term>
        <listitem>
         <para>
@@ -1579,7 +1579,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-enable-depend">
        <term><option>--enable-depend</option></term>
        <listitem>
         <para>
@@ -1593,7 +1593,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-enable-coverage">
        <term><option>--enable-coverage</option></term>
        <listitem>
         <para>
@@ -1608,7 +1608,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-enable-profiling">
        <term><option>--enable-profiling</option></term>
        <listitem>
         <para>
@@ -1621,7 +1621,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-options-enable-dtrace">
        <term><option>--enable-dtrace</option></term>
        <listitem>
         <para>
@@ -1710,7 +1710,7 @@ build-postgresql:
      this manner:
 
      <variablelist>
-      <varlistentry>
+      <varlistentry id="configure-envvars-bison">
        <term><envar>BISON</envar></term>
        <listitem>
         <para>
@@ -1719,7 +1719,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-envvars-cc">
        <term><envar>CC</envar></term>
        <listitem>
         <para>
@@ -1728,7 +1728,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-envvars-cflags">
        <term><envar>CFLAGS</envar></term>
        <listitem>
         <para>
@@ -1737,7 +1737,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-envvars-clang">
        <term><envar>CLANG</envar></term>
        <listitem>
         <para>
@@ -1747,7 +1747,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-envvars-cpp">
        <term><envar>CPP</envar></term>
        <listitem>
         <para>
@@ -1756,7 +1756,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-envvars-cppflags">
        <term><envar>CPPFLAGS</envar></term>
        <listitem>
         <para>
@@ -1765,7 +1765,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-envvars-cxx">
        <term><envar>CXX</envar></term>
        <listitem>
         <para>
@@ -1774,7 +1774,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-envvars-cxxflags">
        <term><envar>CXXFLAGS</envar></term>
        <listitem>
         <para>
@@ -1783,7 +1783,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-envvars-dtrace">
        <term><envar>DTRACE</envar></term>
        <listitem>
         <para>
@@ -1792,7 +1792,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-envvars-dtraceflags">
        <term><envar>DTRACEFLAGS</envar></term>
        <listitem>
         <para>
@@ -1801,7 +1801,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-envvars-flex">
        <term><envar>FLEX</envar></term>
        <listitem>
         <para>
@@ -1810,7 +1810,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-envvars-ldflags">
        <term><envar>LDFLAGS</envar></term>
        <listitem>
         <para>
@@ -1819,7 +1819,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-envvars-ldflags_ex">
        <term><envar>LDFLAGS_EX</envar></term>
        <listitem>
         <para>
@@ -1828,7 +1828,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-envvars-ldflags_sl">
        <term><envar>LDFLAGS_SL</envar></term>
        <listitem>
         <para>
@@ -1837,7 +1837,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-envvars-llvm_config">
        <term><envar>LLVM_CONFIG</envar></term>
        <listitem>
         <para>
@@ -1847,7 +1847,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-envvars-msgfmt">
        <term><envar>MSGFMT</envar></term>
        <listitem>
         <para>
@@ -1856,7 +1856,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-envvars-perl">
        <term><envar>PERL</envar></term>
        <listitem>
         <para>
@@ -1867,7 +1867,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-envvars-python">
        <term><envar>PYTHON</envar></term>
        <listitem>
         <para>
@@ -1879,7 +1879,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-envvars-tclsh">
        <term><envar>TCLSH</envar></term>
        <listitem>
         <para>
@@ -1892,7 +1892,7 @@ build-postgresql:
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="configure-envvars-xml2_config">
        <term><envar>XML2_CONFIG</envar></term>
        <listitem>
         <para>
@@ -2041,7 +2041,7 @@ libpq.so.2.1: cannot open shared object file: No such file or directory
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="install-post-env-vars">
    <title>Environment Variables</title>
 
    <indexterm>
@@ -2184,7 +2184,7 @@ export MANPATH
     community.
    </para>
 
-   <sect3>
+   <sect3 id="installation-notes-aix-mem-management">
     <title>Memory Management</title>
     <!-- https://archives.postgresql.org/message-id/603bgqmpl9.fsf@dba2.int.libertyrms.com -->
 
@@ -2533,7 +2533,7 @@ xcrun --show-sdk-path
     operating system, the fewer issues you will experience.
    </para>
 
-   <sect3>
+   <sect3 id="installation-notes-solaris-req-tools">
     <title>Required Tools</title>
 
     <para>
@@ -2558,7 +2558,7 @@ xcrun --show-sdk-path
     </para>
    </sect3>
 
-   <sect3>
+   <sect3 id="installation-notes-solaris-configure-complains">
     <title>configure Complains About a Failed Test Program</title>
 
     <para>
@@ -2577,7 +2577,7 @@ configure ... LDFLAGS="-R /usr/sfw/lib:/opt/sfw/lib:/usr/local/lib"
     </para>
    </sect3>
 
-   <sect3>
+   <sect3 id="installation-notes-solaris-comp-opt-perf">
     <title>Compiling for Optimal Performance</title>
 
     <para>
@@ -2598,7 +2598,7 @@ configure ... LDFLAGS="-R /usr/sfw/lib:/opt/sfw/lib:/usr/local/lib"
     </para>
    </sect3>
 
-   <sect3>
+   <sect3 id="installation-notes-solaris-using-dtrace">
     <title>Using DTrace for Tracing PostgreSQL</title>
 
     <para>
diff --git a/doc/src/sgml/intagg.sgml b/doc/src/sgml/intagg.sgml
index c410f64f3e..56ed510b48 100644
--- a/doc/src/sgml/intagg.sgml
+++ b/doc/src/sgml/intagg.sgml
@@ -15,7 +15,7 @@
   the built-in functions.
  </para>
 
- <sect2>
+ <sect2  id="intagg-functions">
   <title>Functions</title>
 
  <indexterm>
@@ -50,7 +50,7 @@
 
  </sect2>
 
- <sect2>
+ <sect2  id="intagg-samples">
   <title>Sample Uses</title>
 
   <para>
diff --git a/doc/src/sgml/intarray.sgml b/doc/src/sgml/intarray.sgml
index f930c08eeb..472f7a246b 100644
--- a/doc/src/sgml/intarray.sgml
+++ b/doc/src/sgml/intarray.sgml
@@ -30,7 +30,7 @@
   on the current database.
  </para>
 
- <sect2>
+ <sect2 id="intarray-funcs-ops">
   <title><filename>intarray</filename> Functions and Operators</title>
 
   <para>
@@ -386,7 +386,7 @@
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="intarray-index">
   <title>Index Support</title>
 
   <para>
@@ -438,7 +438,7 @@
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="intarray-example">
   <title>Example</title>
 
 <programlisting>
@@ -459,7 +459,7 @@ SELECT message.mid FROM message WHERE message.sections @@ '1&amp;2'::query_int;
 </programlisting>
  </sect2>
 
- <sect2>
+ <sect2 id="intarray-benchmark">
   <title>Benchmark</title>
 
   <para>
@@ -483,7 +483,7 @@ psql -c "CREATE EXTENSION intarray" TEST
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="intarray-Authors">
   <title>Authors</title>
 
   <para>
diff --git a/doc/src/sgml/isn.sgml b/doc/src/sgml/isn.sgml
index 709bc8345c..14bf2d14aa 100644
--- a/doc/src/sgml/isn.sgml
+++ b/doc/src/sgml/isn.sgml
@@ -27,7 +27,7 @@
   on the current database.
  </para>
 
- <sect2>
+ <sect2 id="isn-data-types">
   <title>Data Types</title>
 
   <para>
@@ -156,7 +156,7 @@
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="isn-casts">
   <title>Casts</title>
 
   <para>
@@ -224,7 +224,7 @@
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="isn-funcs-ops">
   <title>Functions and Operators</title>
 
   <para>
@@ -337,7 +337,7 @@
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="isn-examples">
   <title>Examples</title>
 
 <programlisting>
@@ -381,7 +381,7 @@ SELECT isbn13(id) FROM test;
 </programlisting>
  </sect2>
 
- <sect2>
+ <sect2 id="isn-bibliography">
   <title>Bibliography</title>
 
   <para>
@@ -409,7 +409,7 @@ SELECT isbn13(id) FROM test;
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="isn-author">
   <title>Author</title>
   <para>
    Germ&aacute;n M&eacute;ndez Bravo (Kronuz), 2004&ndash;2006
diff --git a/doc/src/sgml/jit.sgml b/doc/src/sgml/jit.sgml
index 0c6838930b..998c972e8b 100644
--- a/doc/src/sgml/jit.sgml
+++ b/doc/src/sgml/jit.sgml
@@ -256,7 +256,7 @@ SET
     <xref linkend="guc-jit-provider"/>.
    </para>
 
-   <sect3>
+   <sect3 id="jit-pluggable-provider-interface">
     <title><acronym>JIT</acronym> Provider Interface</title>
     <para>
      A <acronym>JIT</acronym> provider is loaded by dynamically loading the
diff --git a/doc/src/sgml/json.sgml b/doc/src/sgml/json.sgml
index c4223fafb6..7b1cada61e 100644
--- a/doc/src/sgml/json.sgml
+++ b/doc/src/sgml/json.sgml
@@ -701,7 +701,7 @@ UPDATE table_name SET jsonb_field[1]['a'] = '1';
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="datatype-json-transforms">
   <title>Transforms</title>
 
   <para>
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index 3998b1781b..4f468a6db2 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -878,7 +878,7 @@ PQsslKeyPassHook_OpenSSL_type PQgetSSLKeyPassHook_OpenSSL(void);
     as further described below.
    </para>
 
-   <sect3>
+   <sect3 id="libpq-connstring-keyword-value">
     <title>Keyword/Value Connection Strings</title>
 
    <para>
@@ -906,7 +906,7 @@ host=localhost port=5432 dbname=mydb connect_timeout=10
    </para>
    </sect3>
 
-   <sect3>
+   <sect3 id="libpq-connstring-uris">
     <title>Connection URIs</title>
 
    <para>
diff --git a/doc/src/sgml/lo.sgml b/doc/src/sgml/lo.sgml
index f46cd392df..d6076aeb7f 100644
--- a/doc/src/sgml/lo.sgml
+++ b/doc/src/sgml/lo.sgml
@@ -19,7 +19,7 @@
   on the current database.
  </para>
 
- <sect2>
+ <sect2 id="lo-rationale">
   <title>Rationale</title>
 
   <para>
@@ -66,7 +66,7 @@
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="lo-how-to-use">
   <title>How to Use It</title>
 
   <para>
@@ -92,7 +92,7 @@ CREATE TRIGGER t_raster BEFORE UPDATE OR DELETE ON image
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="lo-limitations">
   <title>Limitations</title>
 
   <itemizedlist>
@@ -125,7 +125,7 @@ CREATE TRIGGER t_raster BEFORE UPDATE OR DELETE ON image
   </itemizedlist>
  </sect2>
 
- <sect2>
+ <sect2 id="lo-author">
   <title>Author</title>
 
   <para>
diff --git a/doc/src/sgml/logicaldecoding.sgml b/doc/src/sgml/logicaldecoding.sgml
index 3d7d52a84d..44c6959f00 100644
--- a/doc/src/sgml/logicaldecoding.sgml
+++ b/doc/src/sgml/logicaldecoding.sgml
@@ -237,7 +237,7 @@ postgres=# select * from pg_logical_slot_get_changes('regression_slot', NULL, NU
 
   <sect1 id="logicaldecoding-explanation">
    <title>Logical Decoding Concepts</title>
-   <sect2>
+   <sect2 id="logicaldecoding-explanation-log-dec">
     <title>Logical Decoding</title>
 
     <indexterm>
@@ -330,7 +330,7 @@ postgres=# select * from pg_logical_slot_get_changes('regression_slot', NULL, NU
     </caution>
    </sect2>
 
-   <sect2>
+   <sect2 id="logicaldecoding-explanation-output-plugins">
     <title>Output Plugins</title>
     <para>
      Output plugins transform the data from the write-ahead log's internal
@@ -338,7 +338,7 @@ postgres=# select * from pg_logical_slot_get_changes('regression_slot', NULL, NU
     </para>
    </sect2>
 
-   <sect2>
+   <sect2 id="logicaldecoding-explanation-exported-snapshots">
     <title>Exported Snapshots</title>
     <para>
      When a new replication slot is created using the streaming replication
@@ -1139,7 +1139,7 @@ OutputPluginWrite(ctx, true);
 
   <sect1 id="logicaldecoding-synchronous">
    <title>Synchronous Replication Support for Logical Decoding</title>
-   <sect2>
+   <sect2 id="logicaldecoding-synchronous-overview">
     <title>Overview</title>
 
     <para>
diff --git a/doc/src/sgml/ltree.sgml b/doc/src/sgml/ltree.sgml
index 508f404ae8..38b76b674c 100644
--- a/doc/src/sgml/ltree.sgml
+++ b/doc/src/sgml/ltree.sgml
@@ -19,7 +19,7 @@
   on the current database.
  </para>
 
- <sect2>
+ <sect2 id="ltree-definitions">
   <title>Definitions</title>
 
   <para>
@@ -187,7 +187,7 @@ Europe &amp; Russia*@ &amp; !Transportation
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="ltree-ops-funcs">
   <title>Operators and Functions</title>
 
   <para>
@@ -607,7 +607,7 @@ Europe &amp; Russia*@ &amp; !Transportation
   </table>
  </sect2>
 
- <sect2>
+ <sect2 id="ltree-indexes">
   <title>Indexes</title>
   <para>
    <filename>ltree</filename> supports several types of indexes that can speed
@@ -685,7 +685,7 @@ CREATE INDEX path_gist_idx ON test USING GIST (array_path gist__ltree_ops(siglen
   </itemizedlist>
  </sect2>
 
- <sect2>
+ <sect2 id="ltree-example">
   <title>Example</title>
 
   <para>
@@ -822,7 +822,7 @@ ltreetest=&gt; SELECT ins_label(path,2,'Space') FROM test WHERE path &lt;@ 'Top.
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="ltree-transforms">
   <title>Transforms</title>
 
   <para>
@@ -842,7 +842,7 @@ ltreetest=&gt; SELECT ins_label(path,2,'Space') FROM test WHERE path &lt;@ 'Top.
   </caution>
  </sect2>
 
- <sect2>
+ <sect2 id="ltree-authors">
   <title>Authors</title>
 
   <para>
diff --git a/doc/src/sgml/nls.sgml b/doc/src/sgml/nls.sgml
index d49f44f3f2..5c9121a1f5 100644
--- a/doc/src/sgml/nls.sgml
+++ b/doc/src/sgml/nls.sgml
@@ -17,7 +17,7 @@
    to do this.  This section explains how to help.
   </para>
 
-  <sect2>
+  <sect2 id="nls-translator-requirements">
    <title>Requirements</title>
 
    <para>
@@ -50,7 +50,7 @@
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="nls-translator-concepts">
    <title>Concepts</title>
 
    <para>
@@ -130,7 +130,7 @@ msgstr "another translated"
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="nls-translator-message-catalogs">
    <title>Creating and Maintaining Message Catalogs</title>
 
    <para>
@@ -198,7 +198,7 @@ make update-po
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="nls-translator-editing-po">
    <title>Editing the PO Files</title>
 
    <para>
diff --git a/doc/src/sgml/oldsnapshot.sgml b/doc/src/sgml/oldsnapshot.sgml
index a665ae72e7..0e03084562 100644
--- a/doc/src/sgml/oldsnapshot.sgml
+++ b/doc/src/sgml/oldsnapshot.sgml
@@ -13,7 +13,7 @@
   <xref linkend="guc-old-snapshot-threshold" />.
  </para>
 
- <sect2>
+ <sect2 id="oldsnapshot-functions">
   <title>Functions</title>
 
   <variablelist>
diff --git a/doc/src/sgml/pageinspect.sgml b/doc/src/sgml/pageinspect.sgml
index 55513cf522..e7d3b5bb70 100644
--- a/doc/src/sgml/pageinspect.sgml
+++ b/doc/src/sgml/pageinspect.sgml
@@ -13,7 +13,7 @@
   debugging purposes.  All of these functions may be used only by superusers.
  </para>
 
- <sect2>
+ <sect2 id="pageinspect-general-funcs">
   <title>General Functions</title>
 
   <variablelist>
@@ -156,7 +156,7 @@ test=# SELECT fsm_page_contents(get_raw_page('pg_class', 'fsm', 0));
   </variablelist>
  </sect2>
 
- <sect2>
+ <sect2 id="pageinspect-heap-funcs">
   <title>Heap Functions</title>
 
   <variablelist>
@@ -282,7 +282,7 @@ test=# SELECT t_ctid, raw_flags, combined_flags
   </variablelist>
  </sect2>
 
- <sect2>
+ <sect2 id="pageinspect-b-tree-funcs">
   <title>B-Tree Functions</title>
 
   <variablelist>
@@ -473,7 +473,7 @@ test=# SELECT itemoffset, ctid, itemlen, nulls, vars, data, dead, htid, tids[0:2
   </variablelist>
  </sect2>
 
- <sect2>
+ <sect2 id="pageinspect-brin-funcs">
   <title>BRIN Functions</title>
 
   <variablelist>
@@ -583,7 +583,7 @@ test=# SELECT * FROM brin_page_items(get_raw_page('brinidx', 5),
   </variablelist>
  </sect2>
 
- <sect2>
+ <sect2 id="pageinspect-gin-funcs">
   <title>GIN Functions</title>
 
   <variablelist>
@@ -673,7 +673,7 @@ test=# SELECT first_tid, nbytes, tids[0:5] AS some_tids
   </variablelist>
  </sect2>
 
- <sect2>
+ <sect2 id="pageinspect-gist-funcs">
   <title>GiST Functions</title>
 
   <variablelist>
@@ -764,7 +764,7 @@ test=# SELECT * FROM gist_page_items_bytea(get_raw_page('test_gist_idx', 0));
   </variablelist>
  </sect2>
 
- <sect2>
+ <sect2 id="pageinspect-hash-funcs">
   <title>Hash Functions</title>
 
   <variablelist>
diff --git a/doc/src/sgml/perform.sgml b/doc/src/sgml/perform.sgml
index 9cf8ebea80..a88c6af547 100644
--- a/doc/src/sgml/perform.sgml
+++ b/doc/src/sgml/perform.sgml
@@ -960,7 +960,7 @@ EXPLAIN ANALYZE SELECT * FROM tenk1 WHERE unique1 &lt; 100 AND unique2 &gt; 9000
    <secondary>of the planner</secondary>
   </indexterm>
 
-  <sect2>
+  <sect2 id="planner-stats-single-column">
    <title>Single-Column Statistics</title>
   <para>
    As we saw in the previous section, the query planner needs to estimate
@@ -1169,7 +1169,7 @@ WHERE tablename = 'road';
     that are currently supported.
    </para>
 
-   <sect3>
+   <sect3 id="planner-stats-extended-functional-deps">
     <title>Functional Dependencies</title>
 
     <para>
@@ -1239,7 +1239,7 @@ SELECT stxname, stxkeys, stxddependencies
      an underestimate.
     </para>
 
-    <sect4>
+    <sect4 id="planner-stats-extended-functional-deps-limits">
      <title>Limitations of Functional Dependencies</title>
 
      <para>
@@ -1280,7 +1280,7 @@ SELECT * FROM zipcodes WHERE city = 'San Francisco' AND zip = '90210';
     </sect4>
    </sect3>
 
-   <sect3>
+   <sect3 id="planner-stats-extended-n-distinct-counts">
     <title>Multivariate N-Distinct Counts</title>
 
     <para>
@@ -1333,7 +1333,7 @@ nd | {"1, 2": 33178, "1, 5": 33178, "2, 5": 27435, "1, 2, 5": 33178}
     </para>
    </sect3>
 
-   <sect3>
+   <sect3 id="planner-stats-extended-mcv-lists">
     <title>Multivariate MCV Lists</title>
 
     <para>
diff --git a/doc/src/sgml/pgbuffercache.sgml b/doc/src/sgml/pgbuffercache.sgml
index e68d159d30..04e600f8f0 100644
--- a/doc/src/sgml/pgbuffercache.sgml
+++ b/doc/src/sgml/pgbuffercache.sgml
@@ -29,7 +29,7 @@
   using <command>GRANT</command>.
  </para>
 
- <sect2>
+ <sect2 id="pgbuffercache-pg_buffercache">
   <title>The <structname>pg_buffercache</structname> View</title>
 
   <para>
@@ -164,7 +164,7 @@
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="pgbuffercache-sample-output">
   <title>Sample Output</title>
 
 <screen>
@@ -194,7 +194,7 @@ regression=# SELECT n.nspname, c.relname, count(*) AS buffers
 </screen>
  </sect2>
 
- <sect2>
+ <sect2 id="pgbuffercache-authors">
   <title>Authors</title>
 
   <para>
diff --git a/doc/src/sgml/pgcrypto.sgml b/doc/src/sgml/pgcrypto.sgml
index 79759654a7..585d1f07e6 100644
--- a/doc/src/sgml/pgcrypto.sgml
+++ b/doc/src/sgml/pgcrypto.sgml
@@ -28,10 +28,10 @@
   OpenSSL support was not selected when PostgreSQL was built.
  </para>
 
- <sect2>
+ <sect2 id="pgcrypto-general-hashing-funcs">
   <title>General Hashing Functions</title>
 
-  <sect3>
+  <sect3 id="pgcrypto-general-hashing-funcs-digest">
    <title><function>digest()</function></title>
 
    <indexterm>
@@ -64,7 +64,7 @@ $$ LANGUAGE SQL STRICT IMMUTABLE;
    </para>
   </sect3>
 
-  <sect3>
+  <sect3 id="pgcrypto-general-hashing-funcs-hmac">
    <title><function>hmac()</function></title>
 
    <indexterm>
@@ -94,7 +94,7 @@ hmac(data bytea, key bytea, type text) returns bytea
   </sect3>
  </sect2>
 
- <sect2>
+ <sect2 id="pgcrypto-password-hashing-funcs">
   <title>Password Hashing Functions</title>
 
   <para>
@@ -193,7 +193,7 @@ hmac(data bytea, key bytea, type text) returns bytea
    </tgroup>
   </table>
 
-  <sect3>
+  <sect3 id="pgcrypto-password-hashing-funcs-crypt">
    <title><function>crypt()</function></title>
 
    <indexterm>
@@ -226,7 +226,7 @@ SELECT (pswhash = crypt('entered password', pswhash)) AS pswmatch FROM ... ;
    </para>
   </sect3>
 
-  <sect3>
+  <sect3 id="pgcrypto-password-hashing-funcs-gen_salt">
    <title><function>gen_salt()</function></title>
 
   <indexterm>
@@ -437,7 +437,7 @@ gen_salt(type text [, iter_count integer ]) returns text
   </sect3>
  </sect2>
 
- <sect2>
+ <sect2 id="pgcrypto-pgp-enc-funcs">
   <title>PGP Encryption Functions</title>
 
   <para>
@@ -535,7 +535,7 @@ gen_salt(type text [, iter_count integer ]) returns text
    </listitem>
   </orderedlist>
 
-  <sect3>
+  <sect3 id="pgcrypto-pgp-enc-funcs-pgp_sym_encrypt">
    <title><function>pgp_sym_encrypt()</function></title>
 
    <indexterm>
@@ -557,7 +557,7 @@ pgp_sym_encrypt_bytea(data bytea, psw text [, options text ]) returns bytea
    </para>
   </sect3>
 
-  <sect3>
+  <sect3 id="pgcrypto-pgp-enc-funcs-pgp_sym_decrypt">
    <title><function>pgp_sym_decrypt()</function></title>
 
    <indexterm>
@@ -586,7 +586,7 @@ pgp_sym_decrypt_bytea(msg bytea, psw text [, options text ]) returns bytea
    </para>
   </sect3>
 
-  <sect3>
+  <sect3 id="pgcrypto-pgp-enc-funcs-pgp_pub_encrypt">
    <title><function>pgp_pub_encrypt()</function></title>
 
    <indexterm>
@@ -611,7 +611,7 @@ pgp_pub_encrypt_bytea(data bytea, key bytea [, options text ]) returns bytea
    </para>
   </sect3>
 
-  <sect3>
+  <sect3 id="pgcrypto-pgp-enc-funcs-pgp_pub_decrypt">
    <title><function>pgp_pub_decrypt()</function></title>
 
    <indexterm>
@@ -644,7 +644,7 @@ pgp_pub_decrypt_bytea(msg bytea, key bytea [, psw text [, options text ]]) retur
    </para>
   </sect3>
 
-  <sect3>
+  <sect3 id="pgcrypto-pgp-enc-funcs-pgp_key_id">
    <title><function>pgp_key_id()</function></title>
 
    <indexterm>
@@ -690,7 +690,7 @@ pgp_key_id(bytea) returns text
    </para>
   </sect3>
 
-  <sect3>
+  <sect3 id="pgcrypto-pgp-enc-funcs-armor">
    <title><function>armor()</function>, <function>dearmor()</function></title>
 
    <indexterm>
@@ -719,7 +719,7 @@ dearmor(data text) returns bytea
    </para>
   </sect3>
 
-  <sect3>
+  <sect3 id="pgcrypto-pgp-enc-funcs-pgp_armor_headers">
    <title><function>pgp_armor_headers</function></title>
 
    <indexterm>
@@ -737,7 +737,7 @@ pgp_armor_headers(data text, key out text, value out text) returns setof record
    </para>
   </sect3>
 
-  <sect3>
+  <sect3 id="pgcrypto-pgp-enc-funcs-opts">
    <title>Options for PGP Functions</title>
 
    <para>
@@ -761,7 +761,7 @@ pgp_sym_encrypt(data, psw, 'compress-algo=1, cipher-algo=aes256')
     The rest should have reasonable defaults.
    </para>
 
-  <sect4>
+  <sect4 id="pgcrypto-pgp-enc-funcs-opts-cipher-algo">
    <title>cipher-algo</title>
 
    <para>
@@ -774,7 +774,7 @@ Applies to: pgp_sym_encrypt, pgp_pub_encrypt
 </literallayout>
   </sect4>
 
-  <sect4>
+  <sect4 id="pgcrypto-pgp-enc-funcs-opts-compress-algo">
    <title>compress-algo</title>
 
    <para>
@@ -791,7 +791,7 @@ Applies to: pgp_sym_encrypt, pgp_pub_encrypt
 </literallayout>
   </sect4>
 
-  <sect4>
+  <sect4 id="pgcrypto-pgp-enc-funcs-opts-compress-level">
    <title>compress-level</title>
 
    <para>
@@ -805,7 +805,7 @@ Applies to: pgp_sym_encrypt, pgp_pub_encrypt
 </literallayout>
   </sect4>
 
-  <sect4>
+  <sect4 id="pgcrypto-pgp-enc-funcs-opts-convert-crlf">
    <title>convert-crlf</title>
 
    <para>
@@ -822,7 +822,7 @@ Applies to: pgp_sym_encrypt, pgp_pub_encrypt, pgp_sym_decrypt, pgp_pub_decrypt
 </literallayout>
   </sect4>
 
-  <sect4>
+  <sect4 id="pgcrypto-pgp-enc-funcs-opts-disable-mdc">
    <title>disable-mdc</title>
 
    <para>
@@ -838,7 +838,7 @@ Applies to: pgp_sym_encrypt, pgp_pub_encrypt
 </literallayout>
   </sect4>
 
-  <sect4>
+  <sect4 id="pgcrypto-pgp-enc-funcs-opts-sess-key">
    <title>sess-key</title>
 
    <para>
@@ -853,7 +853,7 @@ Applies to: pgp_sym_encrypt
 </literallayout>
   </sect4>
 
-  <sect4>
+  <sect4 id="pgcrypto-pgp-enc-funcs-opts-s2k-mode">
    <title>s2k-mode</title>
 
    <para>
@@ -869,7 +869,7 @@ Applies to: pgp_sym_encrypt
 </literallayout>
   </sect4>
 
-  <sect4>
+  <sect4 id="pgcrypto-pgp-enc-funcs-opts-s2k-count">
    <title>s2k-count</title>
 
    <para>
@@ -882,7 +882,7 @@ Applies to: pgp_sym_encrypt, only with s2k-mode=3
 </literallayout>
   </sect4>
 
-  <sect4>
+  <sect4 id="pgcrypto-pgp-enc-funcs-opts-s2k-digest-algo">
    <title>s2k-digest-algo</title>
 
    <para>
@@ -895,7 +895,7 @@ Applies to: pgp_sym_encrypt
 </literallayout>
   </sect4>
 
-  <sect4>
+  <sect4 id="pgcrypto-pgp-enc-funcs-opts-s2k-cipher-algo">
    <title>s2k-cipher-algo</title>
 
    <para>
@@ -908,7 +908,7 @@ Applies to: pgp_sym_encrypt
 </literallayout>
   </sect4>
 
-  <sect4>
+  <sect4 id="pgcrypto-pgp-enc-funcs-opts-unicode-mode">
    <title>unicode-mode</title>
 
    <para>
@@ -925,7 +925,7 @@ Applies to: pgp_sym_encrypt, pgp_pub_encrypt
   </sect4>
   </sect3>
 
- <sect3>
+ <sect3 id="pgcrypto-pgp-enc-funcs-gnupg">
   <title>Generating PGP Keys with GnuPG</title>
 
   <para>
@@ -973,7 +973,7 @@ gpg -a --export-secret-keys KEYID > secret.key
   </para>
  </sect3>
 
- <sect3>
+ <sect3 id="pgcrypto-pgp-enc-funcs-limitations">
   <title>Limitations of PGP Code</title>
 
   <itemizedlist>
@@ -1001,7 +1001,7 @@ gpg -a --export-secret-keys KEYID > secret.key
   </sect3>
  </sect2>
 
- <sect2>
+ <sect2 id="pgcrypto-raw-enc-funcs">
   <title>Raw Encryption Functions</title>
 
   <para>
@@ -1119,7 +1119,7 @@ encrypt(data, 'fooz', 'bf-cbc/pad:pkcs')
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="pgcrypto-random-data-funcs">
   <title>Random-Data Functions</title>
 
   <indexterm>
@@ -1148,10 +1148,10 @@ gen_random_uuid() returns uuid
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="pgcrypto-notes">
   <title>Notes</title>
 
-  <sect3>
+  <sect3 id="pgcrypto-notes-config">
    <title>Configuration</title>
 
    <para>
@@ -1179,7 +1179,7 @@ gen_random_uuid() returns uuid
    </para>
   </sect3>
 
-  <sect3>
+  <sect3 id="pgcrypto-notes-null-handling">
    <title>NULL Handling</title>
 
    <para>
@@ -1188,7 +1188,7 @@ gen_random_uuid() returns uuid
    </para>
   </sect3>
 
-  <sect3>
+  <sect3 id="pgcrypto-notes-sec-limits">
    <title>Security Limitations</title>
 
    <para>
@@ -1220,7 +1220,7 @@ gen_random_uuid() returns uuid
    </para>
   </sect3>
 
-  <sect3>
+  <sect3 id="pgcrypto-notes-useful-reading">
    <title>Useful Reading</title>
 
    <itemizedlist>
@@ -1251,7 +1251,7 @@ gen_random_uuid() returns uuid
    </itemizedlist>
   </sect3>
 
-  <sect3>
+  <sect3 id="pgcrypto-notes-tech-ref">
    <title>Technical References</title>
 
    <itemizedlist>
@@ -1287,7 +1287,7 @@ gen_random_uuid() returns uuid
   </sect3>
  </sect2>
 
- <sect2>
+ <sect2 id="pgcrypto-author">
   <title>Author</title>
 
   <para>
diff --git a/doc/src/sgml/pgfreespacemap.sgml b/doc/src/sgml/pgfreespacemap.sgml
index 1f7867d9b9..612eabc075 100644
--- a/doc/src/sgml/pgfreespacemap.sgml
+++ b/doc/src/sgml/pgfreespacemap.sgml
@@ -21,7 +21,7 @@
   using <command>GRANT</command>.
  </para>
 
- <sect2>
+ <sect2 id="pgfreespacemap-funcs">
   <title>Functions</title>
 
   <variablelist>
@@ -71,7 +71,7 @@
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="pgfreespacemap-sample-output">
   <title>Sample Output</title>
 
 <screen>
@@ -108,7 +108,7 @@ postgres=# SELECT * FROM pg_freespace('foo', 7);
 </screen>
  </sect2>
 
- <sect2>
+ <sect2 id="pgfreespacemap-author">
   <title>Author</title>
 
   <para>
diff --git a/doc/src/sgml/pgprewarm.sgml b/doc/src/sgml/pgprewarm.sgml
index 51afc5df3f..cd28daab29 100644
--- a/doc/src/sgml/pgprewarm.sgml
+++ b/doc/src/sgml/pgprewarm.sgml
@@ -19,7 +19,7 @@
   will, using 2 background workers, reload those same blocks after a restart.
  </para>
 
- <sect2>
+ <sect2 id="pgprewarm-funcs">
   <title>Functions</title>
 
 <synopsis>
@@ -84,7 +84,7 @@ autoprewarm_dump_now() RETURNS int8
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="pgprewarm-config-params">
   <title>Configuration Parameters</title>
 
  <variablelist>
@@ -124,7 +124,7 @@ autoprewarm_dump_now() RETURNS int8
 
  </sect2>
 
- <sect2>
+ <sect2 id="pgprewarm-author">
   <title>Author</title>
 
   <para>
diff --git a/doc/src/sgml/pgrowlocks.sgml b/doc/src/sgml/pgrowlocks.sgml
index 392d5f1f9a..e84cb1b95f 100644
--- a/doc/src/sgml/pgrowlocks.sgml
+++ b/doc/src/sgml/pgrowlocks.sgml
@@ -19,7 +19,7 @@
  </para>
 
 
- <sect2>
+ <sect2 id="pgrowlocks-overview">
   <title>Overview</title>
 
   <indexterm>
@@ -124,7 +124,7 @@ SELECT * FROM accounts AS a, pgrowlocks('accounts') AS p
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="pgrowlocks-sample-output">
   <title>Sample Output</title>
 
   <screen>
@@ -139,7 +139,7 @@ SELECT * FROM accounts AS a, pgrowlocks('accounts') AS p
 </screen>
  </sect2>
 
- <sect2>
+ <sect2 id="pgrowlocks-author">
   <title>Author</title>
 
   <para>
diff --git a/doc/src/sgml/pgstatstatements.sgml b/doc/src/sgml/pgstatstatements.sgml
index bc9d5bdbe3..14935b989b 100644
--- a/doc/src/sgml/pgstatstatements.sgml
+++ b/doc/src/sgml/pgstatstatements.sgml
@@ -36,7 +36,7 @@
    <command>CREATE EXTENSION pg_stat_statements</command>.
  </para>
 
- <sect2>
+ <sect2 id="pgstatstatements-pg_stat_statements">
   <title>The <structname>pg_stat_statements</structname> View</title>
 
   <para>
@@ -508,7 +508,7 @@
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="pgstatstatements-pg_stat_statements_info">
   <title>The <structname>pg_stat_statements_info</structname> View</title>
 
   <indexterm>
@@ -564,7 +564,7 @@
   </table>
  </sect2>
 
- <sect2>
+ <sect2 id="pgstatstatements-funcs">
   <title>Functions</title>
 
   <variablelist>
@@ -627,7 +627,7 @@
   </variablelist>
  </sect2>
 
- <sect2>
+ <sect2 id="pgstatstatements-config-params">
   <title>Configuration Parameters</title>
 
   <variablelist>
@@ -762,7 +762,7 @@ pg_stat_statements.track = all
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="pgstatstatements-sample-output">
   <title>Sample Output</title>
 
 <screen>
@@ -867,7 +867,7 @@ hit_percent     |
 </screen>
  </sect2>
 
- <sect2>
+ <sect2 id="pgstatstatements-authors">
   <title>Authors</title>
 
   <para>
diff --git a/doc/src/sgml/pgstattuple.sgml b/doc/src/sgml/pgstattuple.sgml
index b17b3c59e0..581bea2788 100644
--- a/doc/src/sgml/pgstattuple.sgml
+++ b/doc/src/sgml/pgstattuple.sgml
@@ -23,7 +23,7 @@
   the <literal>pg_stat_scan_tables</literal> role instead.
  </para>
 
- <sect2>
+ <sect2 id="pgstattuple-funcs">
   <title>Functions</title>
 
   <variablelist>
@@ -618,7 +618,7 @@ approx_free_percent  | 2.09
   </variablelist>
  </sect2>
 
- <sect2>
+ <sect2 id="pgstattuple-authors">
   <title>Authors</title>
 
   <para>
diff --git a/doc/src/sgml/pgsurgery.sgml b/doc/src/sgml/pgsurgery.sgml
index 134be9bebd..589e6db2d0 100644
--- a/doc/src/sgml/pgsurgery.sgml
+++ b/doc/src/sgml/pgsurgery.sgml
@@ -18,7 +18,7 @@
   They should be used with great caution and only as a last resort.
  </para>
 
- <sect2>
+ <sect2 id="pgsurgery-funcs">
   <title>Functions</title>
 
   <variablelist>
@@ -96,7 +96,7 @@ test=# select ctid from t1 where xmin = 2;
   </variablelist>
  </sect2>
 
- <sect2>
+ <sect2 id="pgsurgery-authors">
   <title>Authors</title>
 
   <para>
diff --git a/doc/src/sgml/pgtrgm.sgml b/doc/src/sgml/pgtrgm.sgml
index 7e29282255..06ea42efd7 100644
--- a/doc/src/sgml/pgtrgm.sgml
+++ b/doc/src/sgml/pgtrgm.sgml
@@ -21,7 +21,7 @@
   on the current database.
  </para>
 
- <sect2>
+ <sect2 id="pgtrgm-concepts">
   <title>Trigram (or Trigraph) Concepts</title>
 
   <para>
@@ -59,7 +59,7 @@
   </note>
  </sect2>
 
- <sect2>
+ <sect2 id="pgtrgm-funcs-ops">
   <title>Functions and Operators</title>
 
   <para>
@@ -355,7 +355,7 @@
   </table>
  </sect2>
 
- <sect2>
+ <sect2 id="pgtrgm-guc">
   <title>GUC Parameters</title>
 
   <variablelist>
@@ -406,7 +406,7 @@
   </variablelist>
  </sect2>
 
- <sect2>
+ <sect2 id="pgtrgm-index">
   <title>Index Support</title>
 
   <para>
@@ -557,7 +557,7 @@ SELECT * FROM test_trgm WHERE t ~ '(foo|bar)';
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="pgtrgm-text-search">
   <title>Text Search Integration</title>
 
   <para>
@@ -606,7 +606,7 @@ CREATE INDEX words_idx ON words USING GIN (word gin_trgm_ops);
   </note>
  </sect2>
 
- <sect2>
+ <sect2 id="pgtrgm-references">
   <title>References</title>
 
   <para>
@@ -619,7 +619,7 @@ CREATE INDEX words_idx ON words USING GIN (word gin_trgm_ops);
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="pgtrgm-authors">
   <title>Authors</title>
 
   <para>
diff --git a/doc/src/sgml/pgvisibility.sgml b/doc/src/sgml/pgvisibility.sgml
index 75336946a6..e6bde081f7 100644
--- a/doc/src/sgml/pgvisibility.sgml
+++ b/doc/src/sgml/pgvisibility.sgml
@@ -41,7 +41,7 @@
   data blocks are similarly expensive.
  </para>
 
- <sect2>
+ <sect2 id="pgvisibility-funcs">
   <title>Functions</title>
 
   <variablelist>
@@ -147,7 +147,7 @@
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="pgvisibility-author">
   <title>Author</title>
 
   <para>
diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml
index e5c1356d8c..fb3c9d3a12 100644
--- a/doc/src/sgml/plpgsql.sgml
+++ b/doc/src/sgml/plpgsql.sgml
@@ -1787,7 +1787,7 @@ END;
      NEXT</command>.
     </para>
 
-    <sect3>
+    <sect3 id="plpgsql-statements-returning-return">
      <title><command>RETURN</command></title>
 
 <synopsis>
@@ -1848,7 +1848,7 @@ RETURN (1, 2, 'three'::text);  -- must cast columns to correct types
      </para>
     </sect3>
 
-    <sect3>
+    <sect3 id="plpgsql-statements-returning-return-next">
      <title><command>RETURN NEXT</command> and <command>RETURN QUERY</command></title>
     <indexterm>
      <primary>RETURN NEXT</primary>
@@ -2080,7 +2080,7 @@ $$;
     </itemizedlist>
     </para>
 
-    <sect3>
+    <sect3 id="plpgsql-conditionals-if-then">
      <title><literal>IF-THEN</literal></title>
 
 <synopsis>
@@ -2107,7 +2107,7 @@ END IF;
        </para>
      </sect3>
 
-     <sect3>
+     <sect3 id="plpgsql-conditionals-if-then-else">
       <title><literal>IF-THEN-ELSE</literal></title>
 
 <synopsis>
@@ -2148,7 +2148,7 @@ END IF;
      </para>
     </sect3>
 
-     <sect3>
+     <sect3 id="plpgsql-conditionals-if-then-elsif">
       <title><literal>IF-THEN-ELSIF</literal></title>
 
 <synopsis>
@@ -2224,7 +2224,7 @@ END IF;
        </para>
      </sect3>
 
-     <sect3>
+     <sect3 id="plpgsql-conditionals-simple-case">
       <title>Simple <literal>CASE</literal></title>
 
 <synopsis>
@@ -2267,7 +2267,7 @@ END CASE;
       </para>
      </sect3>
 
-     <sect3>
+     <sect3 id="plpgsql-conditionals-searched-case">
       <title>Searched <literal>CASE</literal></title>
 
 <synopsis>
@@ -2334,7 +2334,7 @@ END CASE;
      <application>PL/pgSQL</application> function to repeat a series of commands.
     </para>
 
-    <sect3>
+    <sect3 id="plpgsql-control-structures-loops-loop">
      <title><literal>LOOP</literal></title>
 
 <synopsis>
@@ -2354,7 +2354,7 @@ END LOOP <optional> <replaceable>label</replaceable> </optional>;
      </para>
     </sect3>
 
-     <sect3>
+     <sect3 id="plpgsql-control-structures-loops-exit">
       <title><literal>EXIT</literal></title>
 
      <indexterm>
@@ -2426,7 +2426,7 @@ END;
        </para>
      </sect3>
 
-     <sect3>
+     <sect3 id="plpgsql-control-structures-loops-continue">
       <title><literal>CONTINUE</literal></title>
 
      <indexterm>
@@ -2475,7 +2475,7 @@ END LOOP;
      </sect3>
 
 
-     <sect3>
+     <sect3 id="plpgsql-control-structures-loops-while">
       <title><literal>WHILE</literal></title>
 
      <indexterm>
@@ -3189,7 +3189,7 @@ DECLARE
      </para>
     </note>
 
-    <sect3>
+    <sect3 id="plpgsql-cursor-opening-open-for-query">
      <title><command>OPEN FOR</command> <replaceable>query</replaceable></title>
 
 <synopsis>
@@ -3223,7 +3223,7 @@ OPEN curs1 FOR SELECT * FROM foo WHERE key = mykey;
        </para>
      </sect3>
 
-    <sect3>
+    <sect3 id="plpgsql-cursor-opening-open-for-execute">
      <title><command>OPEN FOR EXECUTE</command></title>
 
 <synopsis>
@@ -3348,7 +3348,7 @@ BEGIN
      only until the end of the transaction.
     </para>
 
-    <sect3>
+    <sect3 id="plpgsql-cursor-using-fetch">
      <title><literal>FETCH</literal></title>
 
 <synopsis>
@@ -3405,7 +3405,7 @@ FETCH RELATIVE -2 FROM curs4 INTO x;
        </para>
      </sect3>
 
-    <sect3>
+    <sect3 id="plpgsql-cursor-using-move">
      <title><literal>MOVE</literal></title>
 
 <synopsis>
@@ -3432,7 +3432,7 @@ MOVE FORWARD 2 FROM curs4;
        </para>
      </sect3>
 
-    <sect3>
+    <sect3 id="plpgsql-cursor-using-update-delete">
      <title><literal>UPDATE/DELETE WHERE CURRENT OF</literal></title>
 
 <synopsis>
@@ -3458,7 +3458,7 @@ UPDATE foo SET dataval = myval WHERE CURRENT OF curs1;
        </para>
      </sect3>
 
-    <sect3>
+    <sect3 id="plpgsql-cursor-using-close">
      <title><literal>CLOSE</literal></title>
 
 <synopsis>
@@ -3479,7 +3479,7 @@ CLOSE curs1;
        </para>
      </sect3>
 
-    <sect3>
+    <sect3 id="plpgsql-cursor-using-returning">
      <title>Returning Cursors</title>
 
        <para>
@@ -3808,7 +3808,7 @@ RAISE NOTICE 'Calling cs_create_job(%)', v_job_id;
     class="parameter">option</replaceable> key words are:
 
     <variablelist id="raise-using-options">
-     <varlistentry>
+     <varlistentry id="raise-using-options-message">
       <term><literal>MESSAGE</literal></term>
       <listitem>
        <para>Sets the error message text.  This option can't be used in the
@@ -3817,21 +3817,21 @@ RAISE NOTICE 'Calling cs_create_job(%)', v_job_id;
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="raise-using-options-detail">
       <term><literal>DETAIL</literal></term>
       <listitem>
        <para>Supplies an error detail message.</para>
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="raise-using-options-hint">
       <term><literal>HINT</literal></term>
       <listitem>
        <para>Supplies a hint message.</para>
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="raise-using-options-errcode">
       <term><literal>ERRCODE</literal></term>
       <listitem>
        <para>Specifies the error code (SQLSTATE) to report, either by condition
@@ -3840,7 +3840,7 @@ RAISE NOTICE 'Calling cs_create_job(%)', v_job_id;
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="raise-using-options-column-et-al">
       <term><literal>COLUMN</literal></term>
       <term><literal>CONSTRAINT</literal></term>
       <term><literal>DATATYPE</literal></term>
@@ -4030,7 +4030,7 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl
    top-level block. They are:
 
    <variablelist>
-    <varlistentry>
+    <varlistentry id="plpgsql-dml-trigger-new">
      <term><varname>NEW</varname></term>
      <listitem>
       <para>
@@ -4042,7 +4042,7 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="plpgsql-dml-trigger-old">
      <term><varname>OLD</varname></term>
      <listitem>
       <para>
@@ -4054,7 +4054,7 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="plpgsql-dml-trigger-tg_name">
      <term><varname>TG_NAME</varname></term>
      <listitem>
       <para>
@@ -4064,7 +4064,7 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="plpgsql-dml-trigger-tg_when">
      <term><varname>TG_WHEN</varname></term>
      <listitem>
       <para>
@@ -4075,7 +4075,7 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="plpgsql-dml-trigger-tg_level">
      <term><varname>TG_LEVEL</varname></term>
      <listitem>
       <para>
@@ -4086,7 +4086,7 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="plpgsql-dml-trigger-tg_op">
      <term><varname>TG_OP</varname></term>
      <listitem>
       <para>
@@ -4098,7 +4098,7 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="plpgsql-dml-trigger-tg_relid">
      <term><varname>TG_RELID</varname></term>
      <listitem>
       <para>
@@ -4108,7 +4108,7 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="plpgsql-dml-trigger-tg_relname">
      <term><varname>TG_RELNAME</varname></term>
      <listitem>
       <para>
@@ -4119,7 +4119,7 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="plpgsql-dml-trigger-tg_table_name">
      <term><varname>TG_TABLE_NAME</varname></term>
      <listitem>
       <para>
@@ -4129,7 +4129,7 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="plpgsql-dml-trigger-tg_table_schema">
      <term><varname>TG_TABLE_SCHEMA</varname></term>
      <listitem>
       <para>
@@ -4139,7 +4139,7 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="plpgsql-dml-trigger-tg_nargs">
      <term><varname>TG_NARGS</varname></term>
      <listitem>
       <para>
@@ -4149,7 +4149,7 @@ ASSERT <replaceable class="parameter">condition</replaceable> <optional> , <repl
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="plpgsql-dml-trigger-tg_argv">
      <term><varname>TG_ARGV[]</varname></term>
      <listitem>
       <para>
@@ -4654,7 +4654,7 @@ CREATE TRIGGER emp_audit_del
     in the top-level block. They are:
 
    <variablelist>
-    <varlistentry>
+    <varlistentry id="plpgsql-event-trigger-tg_event">
      <term><varname>TG_EVENT</varname></term>
      <listitem>
       <para>
@@ -4664,7 +4664,7 @@ CREATE TRIGGER emp_audit_del
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="plpgsql-event-trigger-tg_tag">
      <term><varname>TG_TAG</varname></term>
      <listitem>
       <para>
@@ -5119,7 +5119,7 @@ $PROC$ LANGUAGE plpgsql;
   </para>
 
   <variablelist>
-   <varlistentry>
+   <varlistentry id="plpgsql-quote-tips-1-quot">
     <term>1 quotation mark</term>
     <listitem>
      <para>
@@ -5135,7 +5135,7 @@ CREATE FUNCTION foo() RETURNS integer AS '
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="plpgsql-quote-tips-2-quot">
     <term>2 quotation marks</term>
     <listitem>
      <para>
@@ -5155,7 +5155,7 @@ SELECT * FROM users WHERE f_name='foobar';
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="plpgsql-quote-tips-4-quot">
     <term>4 quotation marks</term>
     <listitem>
      <para>
@@ -5178,7 +5178,7 @@ a_output := a_output || $$ AND name LIKE 'foobar' AND xyz$$
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="plpgsql-quote-tips-6-quot">
     <term>6 quotation marks</term>
     <listitem>
      <para>
@@ -5199,7 +5199,7 @@ a_output := a_output || $$ AND name LIKE 'foobar'$$
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="plpgsql-quote-tips-10-quot">
     <term>10 quotation marks</term>
     <listitem>
      <para>
@@ -5264,7 +5264,7 @@ a_output := a_output || $$ if v_$$ || referrer_keys.kind || $$ like '$$
     <literal>"all"</literal>. The default is <literal>"none"</literal>. Currently
     the list of available checks includes:
     <variablelist>
-     <varlistentry>
+     <varlistentry id="plpgsql-extra-checks-shadowed_variables">
       <term><varname>shadowed_variables</varname></term>
       <listitem>
        <para>
@@ -5273,7 +5273,7 @@ a_output := a_output || $$ if v_$$ || referrer_keys.kind || $$ like '$$
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="plpgsql-extra-checks-strict_multi_assignment">
       <term><varname>strict_multi_assignment</varname></term>
       <listitem>
        <para>
@@ -5291,7 +5291,7 @@ a_output := a_output || $$ if v_$$ || referrer_keys.kind || $$ like '$$
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="plpgsql-extra-checks-too_many_rows">
       <term><varname>too_many_rows</varname></term>
       <listitem>
        <para>
@@ -5476,7 +5476,7 @@ HINT:  Make sure the query returns the exact list of columns.
     </itemizedlist>
    </para>
 
-  <sect2>
+  <sect2 id="plpgsql-porting-examples">
    <title>Porting Examples</title>
 
    <para>
@@ -5912,7 +5912,7 @@ END;
     </para>
    </sect3>
 
-   <sect3>
+   <sect3 id="plpgsql-porting-other-execute">
     <title><command>EXECUTE</command></title>
 
     <para>
diff --git a/doc/src/sgml/plpython.sgml b/doc/src/sgml/plpython.sgml
index 54355effd7..e190c90f45 100644
--- a/doc/src/sgml/plpython.sgml
+++ b/doc/src/sgml/plpython.sgml
@@ -153,7 +153,7 @@ $$ LANGUAGE plpython3u;
    below.
   </para>
 
-  <sect2>
+  <sect2 id="plpython-data-type-mapping">
    <title>Data Type Mapping</title>
    <para>
     When a PL/Python function is called, its arguments are converted from
@@ -269,7 +269,7 @@ $$ LANGUAGE plpython3u;
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="plpython-data-null">
    <title>Null, None</title>
   <para>
    If an SQL null value<indexterm><primary>null value</primary><secondary
@@ -369,7 +369,7 @@ SELECT return_str_arr();
   </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="plpython-data-composite-types">
    <title>Composite Types</title>
   <para>
    Composite-type arguments are passed to the function as Python mappings. The
@@ -516,7 +516,7 @@ CALL python_triple(5, 10);
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="plpython-data-set-returning-funcs">
    <title>Set-Returning Functions</title>
   <para>
    A <application>PL/Python</application> function can also return sets of
@@ -779,7 +779,7 @@ $$ LANGUAGE plpython3u;
    <literal>plpy.<replaceable>foo</replaceable></literal>.
   </para>
 
-  <sect2>
+  <sect2 id="plpython-database-access-funcs">
     <title>Database Access Functions</title>
 
   <para>
@@ -1115,7 +1115,7 @@ $$ LANGUAGE plpython3u;
    the form of explicit subtransactions.
   </para>
 
-  <sect2>
+  <sect2 id="plpython-subtransaction-context-managers">
    <title>Subtransaction Context Managers</title>
 
    <para>
diff --git a/doc/src/sgml/postgres-fdw.sgml b/doc/src/sgml/postgres-fdw.sgml
index 8ebf0dc3a0..9d4ffeab0a 100644
--- a/doc/src/sgml/postgres-fdw.sgml
+++ b/doc/src/sgml/postgres-fdw.sgml
@@ -106,10 +106,10 @@
   of columns to the remote table is by name, not position.
  </para>
 
- <sect2>
+ <sect2 id="postgres-fdw-options">
   <title>FDW Options of postgres_fdw</title>
 
-  <sect3>
+  <sect3 id="postgres-fdw-options-connection">
    <title>Connection Options</title>
 
    <para>
@@ -197,7 +197,7 @@ OPTIONS (ADD password_required 'false');
    </para>
   </sect3>
 
-  <sect3>
+  <sect3 id="postgres-fdw-options-object-name">
    <title>Object Name Options</title>
 
    <para>
@@ -246,7 +246,7 @@ OPTIONS (ADD password_required 'false');
 
   </sect3>
 
-  <sect3>
+  <sect3 id="postgres-fdw-options-cost-estimation">
    <title>Cost Estimation Options</title>
 
    <para>
@@ -328,7 +328,7 @@ OPTIONS (ADD password_required 'false');
 
   </sect3>
 
-  <sect3>
+  <sect3 id="postgres-fdw-options-remote-execution">
    <title>Remote Execution Options</title>
 
    <para>
@@ -405,7 +405,7 @@ OPTIONS (ADD password_required 'false');
 
   </sect3>
 
-  <sect3>
+  <sect3 id="postgres-fdw-options-asynchronous-execution">
    <title>Asynchronous Execution Options</title>
 
    <para>
@@ -456,7 +456,7 @@ OPTIONS (ADD password_required 'false');
    </variablelist>
   </sect3>
 
-  <sect3>
+  <sect3 id="postgres-fdw-options-transaction-management">
    <title>Transaction Management Options</title>
 
    <para>
@@ -502,7 +502,7 @@ OPTIONS (ADD password_required 'false');
 
   </sect3>
 
-  <sect3>
+  <sect3 id="postgres-fdw-options-updatability">
    <title>Updatability Options</title>
 
    <para>
@@ -539,7 +539,7 @@ OPTIONS (ADD password_required 'false');
    </variablelist>
   </sect3>
 
-  <sect3>
+  <sect3 id="postgres-fdw-options-truncatability">
    <title>Truncatability Options</title>
 
    <para>
@@ -570,7 +570,7 @@ OPTIONS (ADD password_required 'false');
    </variablelist>
   </sect3>
 
-  <sect3>
+  <sect3 id="postgres-fdw-options-importing">
    <title>Importing Options</title>
 
    <para>
@@ -678,7 +678,7 @@ OPTIONS (ADD password_required 'false');
 
   </sect3>
 
-  <sect3>
+  <sect3 id="postgres-fdw-options-connection-management">
     <title>Connection Management Options</title>
 
     <para>
@@ -707,7 +707,7 @@ OPTIONS (ADD password_required 'false');
    </sect3>
  </sect2>
 
-<sect2>
+<sect2 id="postgres-fdw-functions">
   <title>Functions</title>
 
   <variablelist>
@@ -786,7 +786,7 @@ postgres=# SELECT postgres_fdw_disconnect_all();
 
 </sect2>
 
- <sect2>
+ <sect2 id="postgres-fdw-connection-management">
   <title>Connection Management</title>
 
   <para>
@@ -823,7 +823,7 @@ postgres=# SELECT postgres_fdw_disconnect_all();
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="postgres-fdw-transaction-management">
   <title>Transaction Management</title>
 
   <para>
@@ -858,7 +858,7 @@ postgres=# SELECT postgres_fdw_disconnect_all();
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="postgres-fdw-remote-query-optimization">
   <title>Remote Query Optimization</title>
 
   <para>
@@ -901,7 +901,7 @@ postgres=# SELECT postgres_fdw_disconnect_all();
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="postgres-fdw-remote-query-execution-environment">
   <title>Remote Query Execution Environment</title>
 
   <para>
@@ -957,7 +957,7 @@ postgres=# SELECT postgres_fdw_disconnect_all();
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="postgres-fdw-cross-version-compatibility">
   <title>Cross-Version Compatibility</title>
 
   <para>
@@ -977,7 +977,7 @@ postgres=# SELECT postgres_fdw_disconnect_all();
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="postgres-fdw-configuration-parameters">
   <title>Configuration Parameters</title>
 
   <variablelist>
@@ -1077,7 +1077,7 @@ postgres=# SELECT postgres_fdw_disconnect_all();
   </variablelist>
  </sect2>
 
- <sect2>
+ <sect2 id="postgres-fdw-examples">
   <title>Examples</title>
 
   <para>
@@ -1141,7 +1141,7 @@ CREATE FOREIGN TABLE foreign_table (
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="postgres-fdw-author">
   <title>Author</title>
   <para>
    Shigeru Hanada <email>shigeru.hanada@gmail.com</email>
diff --git a/doc/src/sgml/problems.sgml b/doc/src/sgml/problems.sgml
index cf43262872..4a1cf49f74 100644
--- a/doc/src/sgml/problems.sgml
+++ b/doc/src/sgml/problems.sgml
@@ -28,7 +28,7 @@
   If you need help immediately, consider obtaining a commercial support contract.
  </para>
 
- <sect2>
+ <sect2 id="bug-reporting-identifying-bugs">
   <title>Identifying Bugs</title>
 
   <para>
@@ -96,7 +96,7 @@
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="bug-reporting-what-to-report">
   <title>What to Report</title>
 
   <para>
@@ -291,7 +291,7 @@
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="bug-reporting-where-to-report-bugs">
   <title>Where to Report Bugs</title>
 
   <para>
diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml
index 0695bcd423..2091e2ced2 100644
--- a/doc/src/sgml/protocol.sgml
+++ b/doc/src/sgml/protocol.sgml
@@ -216,7 +216,7 @@
    after the start-up phase.
   </para>
 
-  <sect2>
+  <sect2 id="protocol-flow-start-up">
    <title>Start-up</title>
 
    <para>
@@ -529,7 +529,7 @@
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="protocol-flow-simple-query">
    <title>Simple Query</title>
 
    <para>
@@ -1050,7 +1050,7 @@ SELCT 1/0;<!-- this typo is intentional -->
    </note>
   </sect2>
 
-  <sect2>
+  <sect2 id="protocol-flow-function-call">
    <title>Function Call</title>
 
    <para>
@@ -1327,7 +1327,7 @@ SELCT 1/0;<!-- this typo is intentional -->
    </note>
   </sect2>
 
-  <sect2>
+  <sect2 id="protocol-flow-canceling-requests">
    <title>Canceling Requests in Progress</title>
 
    <para>
@@ -1391,7 +1391,7 @@ SELCT 1/0;<!-- this typo is intentional -->
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="protocol-flow-termination">
    <title>Termination</title>
 
    <para>
@@ -1431,7 +1431,7 @@ SELCT 1/0;<!-- this typo is intentional -->
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="protocol-flow-ssl">
    <title><acronym>SSL</acronym> Session Encryption</title>
 
    <para>
@@ -1504,7 +1504,7 @@ SELCT 1/0;<!-- this typo is intentional -->
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="protocol-flow-gssapi">
    <title><acronym>GSSAPI</acronym> Session Encryption</title>
 
    <para>
diff --git a/doc/src/sgml/queries.sgml b/doc/src/sgml/queries.sgml
index 516fbcbf37..7e92e43934 100644
--- a/doc/src/sgml/queries.sgml
+++ b/doc/src/sgml/queries.sgml
@@ -2487,7 +2487,7 @@ SELECT n FROM t <emphasis>LIMIT 100</emphasis>;
   </sect3>
  </sect2>
 
- <sect2>
+ <sect2 id="queries-with-cte-materialization">
   <title>Common Table Expression Materialization</title>
 
   <para>
diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml
index 5c0735e08a..b546d64dfa 100644
--- a/doc/src/sgml/ref/alter_table.sgml
+++ b/doc/src/sgml/ref/alter_table.sgml
@@ -153,7 +153,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
    lock acquired will be the strictest one required by any subcommand.
 
   <variablelist>
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-add-column">
     <term><literal>ADD COLUMN [ IF NOT EXISTS ]</literal></term>
     <listitem>
      <para>
@@ -165,7 +165,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-drop-column">
     <term><literal>DROP COLUMN [ IF EXISTS ]</literal></term>
     <listitem>
      <para>
@@ -184,7 +184,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-set-data-type">
     <term><literal>SET DATA TYPE</literal></term>
     <listitem>
      <para>
@@ -211,7 +211,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-set-drop-default">
     <term><literal>SET</literal>/<literal>DROP DEFAULT</literal></term>
     <listitem>
      <para>
@@ -224,7 +224,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-set-drop-not-null">
     <term><literal>SET</literal>/<literal>DROP NOT NULL</literal></term>
     <listitem>
      <para>
@@ -255,7 +255,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-drop-expression">
     <term><literal>DROP EXPRESSION [ IF EXISTS ]</literal></term>
     <listitem>
      <para>
@@ -272,7 +272,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-generated-identity">
     <term><literal>ADD GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY</literal></term>
     <term><literal>SET GENERATED { ALWAYS | BY DEFAULT }</literal></term>
     <term><literal>DROP IDENTITY [ IF EXISTS ]</literal></term>
@@ -295,7 +295,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-set-sequence_option">
     <term><literal>SET <replaceable>sequence_option</replaceable></literal></term>
     <term><literal>RESTART</literal></term>
     <listitem>
@@ -308,7 +308,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-set-statistics">
     <term><literal>SET STATISTICS</literal></term>
     <listitem>
      <para>
@@ -329,7 +329,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-set-attribute_option">
     <term><literal>SET ( <replaceable class="parameter">attribute_option</replaceable> = <replaceable class="parameter">value</replaceable> [, ... ] )</literal></term>
     <term><literal>RESET ( <replaceable class="parameter">attribute_option</replaceable> [, ... ] )</literal></term>
     <listitem>
@@ -365,7 +365,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-set-storage">
     <term>
      <literal>SET STORAGE</literal>
      <indexterm>
@@ -395,7 +395,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-set-compression">
     <term>
      <literal>SET COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal>
     </term>
@@ -425,7 +425,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-add-table_constraint">
     <term><literal>ADD <replaceable class="parameter">table_constraint</replaceable> [ NOT VALID ]</literal></term>
     <listitem>
      <para>
@@ -472,7 +472,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-add-table_constraint_using_index">
     <term><literal>ADD <replaceable class="parameter">table_constraint_using_index</replaceable></literal></term>
     <listitem>
      <para>
@@ -527,7 +527,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-alter-constraint">
     <term><literal>ALTER CONSTRAINT</literal></term>
     <listitem>
      <para>
@@ -537,7 +537,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-validate-constraint">
     <term><literal>VALIDATE CONSTRAINT</literal></term>
     <listitem>
      <para>
@@ -554,7 +554,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-drop-constraint">
     <term><literal>DROP CONSTRAINT [ IF EXISTS ]</literal></term>
     <listitem>
      <para>
@@ -566,7 +566,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-disable-enable-trigger">
     <term><literal>DISABLE</literal>/<literal>ENABLE [ REPLICA | ALWAYS ] TRIGGER</literal></term>
     <listitem>
      <para>
@@ -613,7 +613,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-disable-enable-rule">
     <term><literal>DISABLE</literal>/<literal>ENABLE [ REPLICA | ALWAYS ] RULE</literal></term>
     <listitem>
      <para>
@@ -633,7 +633,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-disable-enable-row-level-security">
     <term><literal>DISABLE</literal>/<literal>ENABLE ROW LEVEL SECURITY</literal></term>
     <listitem>
      <para>
@@ -648,7 +648,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-force-row-level-security">
     <term><literal>NO FORCE</literal>/<literal>FORCE ROW LEVEL SECURITY</literal></term>
     <listitem>
      <para>
@@ -663,7 +663,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-cluster-on">
     <term><literal>CLUSTER ON</literal></term>
     <listitem>
      <para>
@@ -677,7 +677,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-set-without-cluster">
     <term><literal>SET WITHOUT CLUSTER</literal></term>
     <listitem>
      <para>
@@ -692,7 +692,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-set-without-oids">
     <term><literal>SET WITHOUT OIDS</literal></term>
     <listitem>
      <para>
@@ -703,7 +703,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-set-access-method">
     <term><literal>SET ACCESS METHOD</literal></term>
     <listitem>
      <para>
@@ -713,7 +713,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-set-tablespace">
     <term><literal>SET TABLESPACE</literal></term>
     <listitem>
      <para>
@@ -745,7 +745,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-set-logged-unlogged">
     <term><literal>SET { LOGGED | UNLOGGED }</literal></term>
     <listitem>
      <para>
@@ -756,7 +756,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-set-storage_parameter">
     <term><literal>SET ( <replaceable class="parameter">storage_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] )</literal></term>
     <listitem>
      <para>
@@ -782,7 +782,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-reset-storage_parameter">
     <term><literal>RESET ( <replaceable class="parameter">storage_parameter</replaceable> [, ... ] )</literal></term>
     <listitem>
      <para>
@@ -793,7 +793,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-inherit">
     <term><literal>INHERIT <replaceable class="parameter">parent_table</replaceable></literal></term>
     <listitem>
      <para>
@@ -821,7 +821,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-no-inherit">
     <term><literal>NO INHERIT <replaceable class="parameter">parent_table</replaceable></literal></term>
     <listitem>
      <para>
@@ -833,7 +833,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-of">
     <term><literal>OF <replaceable class="parameter">type_name</replaceable></literal></term>
     <listitem>
      <para>
@@ -847,7 +847,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-not-of">
     <term><literal>NOT OF</literal></term>
     <listitem>
      <para>
@@ -856,7 +856,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-owner-to">
     <term><literal>OWNER TO</literal></term>
     <listitem>
      <para>
@@ -877,7 +877,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       always logged regardless of whether it changed.
       This option has no effect except when logical replication is in use.
      <variablelist>
-      <varlistentry>
+      <varlistentry id="sql-altertable-replica-identity-default">
        <term><literal>DEFAULT</literal></term>
        <listitem>
         <para>
@@ -887,7 +887,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="sql-altertable-replica-identity-using-index">
        <term><literal>USING INDEX <replaceable class="parameter">index_name</replaceable></literal></term>
        <listitem>
         <para>
@@ -899,7 +899,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="sql-altertable-replica-identity-full">
        <term><literal>FULL</literal></term>
        <listitem>
         <para>
@@ -908,7 +908,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="sql-altertable-replica-identity-nothing">
        <term><literal>NOTHING</literal></term>
        <listitem>
         <para>
@@ -922,7 +922,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-rename">
     <term><literal>RENAME</literal></term>
     <listitem>
      <para>
@@ -936,7 +936,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-altertable-desc-set-schema">
     <term><literal>SET SCHEMA</literal></term>
     <listitem>
      <para>
@@ -1113,7 +1113,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
 
     <variablelist>
 
-     <varlistentry>
+     <varlistentry id="sql-altertable-parms-if-exists">
       <term><literal>IF EXISTS</literal></term>
       <listitem>
        <para>
@@ -1123,7 +1123,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="sql-altertable-parms-name">
       <term><replaceable class="parameter">name</replaceable></term>
       <listitem>
        <para>
@@ -1137,7 +1137,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="sql-altertable-parms-column_name">
       <term><replaceable class="parameter">column_name</replaceable></term>
       <listitem>
        <para>
@@ -1146,7 +1146,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="sql-altertable-parms-new_column_name">
       <term><replaceable class="parameter">new_column_name</replaceable></term>
       <listitem>
        <para>
@@ -1155,7 +1155,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="sql-altertable-parms-new_name">
       <term><replaceable class="parameter">new_name</replaceable></term>
       <listitem>
        <para>
@@ -1164,7 +1164,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="sql-altertable-parms-data_type">
       <term><replaceable class="parameter">data_type</replaceable></term>
       <listitem>
        <para>
@@ -1174,7 +1174,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="sql-altertable-parms-table_constraint">
       <term><replaceable class="parameter">table_constraint</replaceable></term>
       <listitem>
        <para>
@@ -1183,7 +1183,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="sql-altertable-parms-constraint_name">
       <term><replaceable class="parameter">constraint_name</replaceable></term>
       <listitem>
        <para>
@@ -1192,7 +1192,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="sql-altertable-parms-cascade">
       <term><literal>CASCADE</literal></term>
       <listitem>
        <para>
@@ -1204,7 +1204,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="sql-altertable-parms-restrict">
       <term><literal>RESTRICT</literal></term>
       <listitem>
        <para>
@@ -1214,7 +1214,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="sql-altertable-parms-trigger_name">
       <term><replaceable class="parameter">trigger_name</replaceable></term>
       <listitem>
        <para>
@@ -1223,7 +1223,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="sql-altertable-parms-all">
       <term><literal>ALL</literal></term>
       <listitem>
        <para>
@@ -1236,7 +1236,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="sql-altertable-parms-user">
       <term><literal>USER</literal></term>
       <listitem>
        <para>
@@ -1248,7 +1248,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="sql-altertable-parms-index_name">
       <term><replaceable class="parameter">index_name</replaceable></term>
       <listitem>
        <para>
@@ -1257,7 +1257,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="sql-altertable-parms-storage_parameter">
       <term><replaceable class="parameter">storage_parameter</replaceable></term>
       <listitem>
        <para>
@@ -1266,7 +1266,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="sql-altertable-parms-value">
       <term><replaceable class="parameter">value</replaceable></term>
       <listitem>
        <para>
@@ -1276,7 +1276,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="sql-altertable-parms-parent_table">
       <term><replaceable class="parameter">parent_table</replaceable></term>
       <listitem>
        <para>
@@ -1285,7 +1285,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="sql-altertable-parms-new_owner">
       <term><replaceable class="parameter">new_owner</replaceable></term>
       <listitem>
        <para>
@@ -1294,7 +1294,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="sql-altertable-parms-new_access_method">
       <term><replaceable class="parameter">new_access_method</replaceable></term>
       <listitem>
        <para>
@@ -1303,7 +1303,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="sql-altertable-parms-new_tablespace">
       <term><replaceable class="parameter">new_tablespace</replaceable></term>
       <listitem>
        <para>
@@ -1312,7 +1312,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="sql-altertable-parms-new_schema">
       <term><replaceable class="parameter">new_schema</replaceable></term>
       <listitem>
        <para>
@@ -1321,7 +1321,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="sql-altertable-parms-partition_name">
       <term><replaceable class="parameter">partition_name</replaceable></term>
       <listitem>
        <para>
@@ -1330,7 +1330,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="sql-altertable-parms-partition_bound_spec">
       <term><replaceable class="parameter">partition_bound_spec</replaceable></term>
       <listitem>
        <para>
diff --git a/doc/src/sgml/ref/commit.sgml b/doc/src/sgml/ref/commit.sgml
index 5f244cdd3c..7e2dcac5a3 100644
--- a/doc/src/sgml/ref/commit.sgml
+++ b/doc/src/sgml/ref/commit.sgml
@@ -43,7 +43,7 @@ COMMIT [ WORK | TRANSACTION ] [ AND [ NO ] CHAIN ]
   </indexterm>
 
   <variablelist>
-   <varlistentry>
+   <varlistentry id="sql-commit-transaction">
     <term><literal>WORK</literal></term>
     <term><literal>TRANSACTION</literal></term>
     <listitem>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 7e4ef312c0..6463522c1a 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -218,7 +218,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-if-not-exists">
     <term><literal>IF NOT EXISTS</literal></term>
     <listitem>
      <para>
@@ -230,7 +230,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-table_name">
     <term><replaceable class="parameter">table_name</replaceable></term>
     <listitem>
      <para>
@@ -239,7 +239,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-type_name">
     <term><literal>OF <replaceable class="parameter">type_name</replaceable></literal></term>
     <listitem>
      <para>
@@ -260,7 +260,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-column_name">
     <term><replaceable class="parameter">column_name</replaceable></term>
     <listitem>
      <para>
@@ -269,7 +269,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-data_type">
     <term><replaceable class="parameter">data_type</replaceable></term>
     <listitem>
      <para>
@@ -281,7 +281,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-collate">
     <term><literal>COLLATE <replaceable>collation</replaceable></literal></term>
     <listitem>
      <para>
@@ -292,7 +292,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-compression">
     <term><literal>COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal></term>
     <listitem>
      <para>
@@ -317,7 +317,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-inherits">
     <term><literal>INHERITS ( <replaceable>parent_table</replaceable> [, ... ] )</literal></term>
     <listitem>
      <para>
@@ -374,7 +374,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-partition-by">
     <term><literal>PARTITION BY { RANGE | LIST | HASH } ( { <replaceable class="parameter">column_name</replaceable> | ( <replaceable class="parameter">expression</replaceable> ) } [ <replaceable class="parameter">opclass</replaceable> ] [, ...] ) </literal></term>
     <listitem>
      <para>
@@ -590,7 +590,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-like">
     <term><literal>LIKE <replaceable>source_table</replaceable> [ <replaceable>like_option</replaceable> ... ]</literal></term>
     <listitem>
      <para>
@@ -622,7 +622,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       available options are:
 
       <variablelist>
-       <varlistentry>
+       <varlistentry id="sql-createtable-parms-like-opt-comments">
         <term><literal>INCLUDING COMMENTS</literal></term>
         <listitem>
          <para>
@@ -634,7 +634,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
         </listitem>
        </varlistentry>
 
-       <varlistentry>
+       <varlistentry id="sql-createtable-parms-like-opt-compression">
         <term><literal>INCLUDING COMPRESSION</literal></term>
         <listitem>
          <para>
@@ -645,7 +645,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
         </listitem>
        </varlistentry>
 
-       <varlistentry>
+       <varlistentry id="sql-createtable-parms-like-opt-constraints">
         <term><literal>INCLUDING CONSTRAINTS</literal></term>
         <listitem>
          <para>
@@ -656,7 +656,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
         </listitem>
        </varlistentry>
 
-       <varlistentry>
+       <varlistentry id="sql-createtable-parms-like-opt-defaults">
         <term><literal>INCLUDING DEFAULTS</literal></term>
         <listitem>
          <para>
@@ -670,7 +670,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
         </listitem>
        </varlistentry>
 
-       <varlistentry>
+       <varlistentry id="sql-createtable-parms-like-opt-generated">
         <term><literal>INCLUDING GENERATED</literal></term>
         <listitem>
          <para>
@@ -680,7 +680,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
         </listitem>
        </varlistentry>
 
-       <varlistentry>
+       <varlistentry id="sql-createtable-parms-like-opt-identity">
         <term><literal>INCLUDING IDENTITY</literal></term>
         <listitem>
          <para>
@@ -692,7 +692,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
         </listitem>
        </varlistentry>
 
-       <varlistentry>
+       <varlistentry id="sql-createtable-parms-like-opt-indexes">
         <term><literal>INCLUDING INDEXES</literal></term>
         <listitem>
          <para>
@@ -706,7 +706,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
         </listitem>
        </varlistentry>
 
-       <varlistentry>
+       <varlistentry id="sql-createtable-parms-like-opt-statistics">
         <term><literal>INCLUDING STATISTICS</literal></term>
         <listitem>
          <para>
@@ -715,7 +715,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
         </listitem>
        </varlistentry>
 
-       <varlistentry>
+       <varlistentry id="sql-createtable-parms-like-opt-storage">
         <term><literal>INCLUDING STORAGE</literal></term>
         <listitem>
          <para>
@@ -729,7 +729,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
         </listitem>
        </varlistentry>
 
-       <varlistentry>
+       <varlistentry id="sql-createtable-parms-like-opt-all">
         <term><literal>INCLUDING ALL</literal></term>
         <listitem>
          <para>
@@ -753,7 +753,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-constraint">
     <term><literal>CONSTRAINT <replaceable class="parameter">constraint_name</replaceable></literal></term>
     <listitem>
      <para>
@@ -767,7 +767,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-not-null">
     <term><literal>NOT NULL</literal></term>
     <listitem>
      <para>
@@ -776,7 +776,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-null">
     <term><literal>NULL</literal></term>
     <listitem>
      <para>
@@ -791,7 +791,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-check">
     <term><literal>CHECK ( <replaceable class="parameter">expression</replaceable> ) [ NO INHERIT ] </literal></term>
     <listitem>
      <para>
@@ -829,7 +829,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-default">
     <term><literal>DEFAULT
     <replaceable>default_expr</replaceable></literal></term>
     <listitem>
@@ -850,7 +850,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-generated-stored">
     <term><literal>GENERATED ALWAYS AS ( <replaceable>generation_expr</replaceable> ) STORED</literal><indexterm><primary>generated column</primary></indexterm></term>
     <listitem>
      <para>
@@ -872,7 +872,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-generated-identity">
     <term><literal>GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY [ ( <replaceable>sequence_options</replaceable> ) ]</literal></term>
     <listitem>
      <para>
@@ -916,7 +916,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-unique">
     <term><literal>UNIQUE [ NULLS [ NOT ] DISTINCT ]</literal> (column constraint)</term>
     <term><literal>UNIQUE [ NULLS [ NOT ] DISTINCT ] ( <replaceable class="parameter">column_name</replaceable> [, ... ] )</literal>
     <optional> <literal>INCLUDE ( <replaceable class="parameter">column_name</replaceable> [, ...])</literal> </optional> (table constraint)</term>
@@ -970,7 +970,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-primary-key">
     <term><literal>PRIMARY KEY</literal> (column constraint)</term>
     <term><literal>PRIMARY KEY ( <replaceable class="parameter">column_name</replaceable> [, ... ] )</literal>
     <optional> <literal>INCLUDE ( <replaceable class="parameter">column_name</replaceable> [, ...])</literal> </optional> (table constraint)</term>
@@ -1073,7 +1073,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-references">
     <term><literal>REFERENCES <replaceable class="parameter">reftable</replaceable> [ ( <replaceable class="parameter">refcolumn</replaceable> ) ] [ MATCH <replaceable class="parameter">matchtype</replaceable> ] [ ON DELETE <replaceable class="parameter">referential_action</replaceable> ] [ ON UPDATE <replaceable class="parameter">referential_action</replaceable> ]</literal> (column constraint)</term>
 
    <term><literal>FOREIGN KEY ( <replaceable class="parameter">column_name</replaceable> [, ... ] )
@@ -1133,7 +1133,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       actions for each clause:
 
       <variablelist>
-       <varlistentry>
+       <varlistentry id="sql-createtable-parms-references-refact-no-action">
         <term><literal>NO ACTION</literal></term>
         <listitem>
          <para>
@@ -1146,7 +1146,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
         </listitem>
        </varlistentry>
 
-       <varlistentry>
+       <varlistentry id="sql-createtable-parms-references-refact-restrict">
         <term><literal>RESTRICT</literal></term>
         <listitem>
          <para>
@@ -1158,7 +1158,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
         </listitem>
        </varlistentry>
 
-       <varlistentry>
+       <varlistentry id="sql-createtable-parms-references-refact-cascade">
         <term><literal>CASCADE</literal></term>
         <listitem>
          <para>
@@ -1169,7 +1169,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
         </listitem>
        </varlistentry>
 
-       <varlistentry>
+       <varlistentry id="sql-createtable-parms-references-refact-set-null">
         <term><literal>SET NULL [ ( <replaceable>column_name</replaceable> [, ... ] ) ]</literal></term>
         <listitem>
          <para>
@@ -1180,7 +1180,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
         </listitem>
        </varlistentry>
 
-       <varlistentry>
+       <varlistentry id="sql-createtable-parms-references-refact-set-default">
         <term><literal>SET DEFAULT [ ( <replaceable>column_name</replaceable> [, ... ] ) ]</literal></term>
         <listitem>
          <para>
@@ -1204,7 +1204,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-deferrable">
     <term><literal>DEFERRABLE</literal></term>
     <term><literal>NOT DEFERRABLE</literal></term>
     <listitem>
@@ -1226,7 +1226,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-initially">
     <term><literal>INITIALLY IMMEDIATE</literal></term>
     <term><literal>INITIALLY DEFERRED</literal></term>
     <listitem>
@@ -1256,7 +1256,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-with">
     <term><literal>WITH ( <replaceable class="parameter">storage_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] )</literal></term>
     <listitem>
      <para>
@@ -1270,7 +1270,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-without-oids">
     <term><literal>WITHOUT OIDS</literal></term>
     <listitem>
      <para>
@@ -1281,7 +1281,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-on-commit">
     <term><literal>ON COMMIT</literal></term>
     <listitem>
      <para>
@@ -1290,7 +1290,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
       The three options are:
 
       <variablelist>
-       <varlistentry>
+       <varlistentry id="sql-createtable-parms-on-commit-preserve-rows">
         <term><literal>PRESERVE ROWS</literal></term>
         <listitem>
          <para>
@@ -1300,7 +1300,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
         </listitem>
        </varlistentry>
 
-       <varlistentry>
+       <varlistentry id="sql-createtable-parms-on-commit-delete-rows">
         <term><literal>DELETE ROWS</literal></term>
         <listitem>
          <para>
@@ -1313,7 +1313,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
         </listitem>
        </varlistentry>
 
-       <varlistentry>
+       <varlistentry id="sql-createtable-parms-on-commit-drop">
         <term><literal>DROP</literal></term>
         <listitem>
          <para>
@@ -1345,7 +1345,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="sql-createtable-parms-using-index-tablespace">
     <term><literal>USING INDEX TABLESPACE <replaceable class="parameter">tablespace_name</replaceable></literal></term>
     <listitem>
      <para>
diff --git a/doc/src/sgml/ref/initdb.sgml b/doc/src/sgml/ref/initdb.sgml
index 8f71c7c962..927ee72973 100644
--- a/doc/src/sgml/ref/initdb.sgml
+++ b/doc/src/sgml/ref/initdb.sgml
@@ -124,7 +124,7 @@ PostgreSQL documentation
 
    <para>
     <variablelist>
-     <varlistentry>
+     <varlistentry id="app-initdb-options-auth">
       <term><option>-A <replaceable class="parameter">authmethod</replaceable></option></term>
       <term><option>--auth=<replaceable class="parameter">authmethod</replaceable></option></term>
       <listitem>
@@ -144,7 +144,7 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="app-initdb-options-auth-host">
       <term><option>--auth-host=<replaceable class="parameter">authmethod</replaceable></option></term>
       <listitem>
        <para>
@@ -155,7 +155,7 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="app-initdb-options-auth-local">
       <term><option>--auth-local=<replaceable class="parameter">authmethod</replaceable></option></term>
       <listitem>
        <para>
@@ -166,7 +166,7 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="app-initdb-options-pgdata">
       <term><option>-D <replaceable class="parameter">directory</replaceable></option></term>
       <term><option>--pgdata=<replaceable class="parameter">directory</replaceable></option></term>
       <listitem>
@@ -182,7 +182,7 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="app-initdb-options-encoding">
       <term><option>-E <replaceable class="parameter">encoding</replaceable></option></term>
       <term><option>--encoding=<replaceable class="parameter">encoding</replaceable></option></term>
       <listitem>
@@ -227,7 +227,7 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="app-initdb-options-locale">
       <term><option>--locale=<replaceable>locale</replaceable></option></term>
       <listitem>
        <para>
@@ -239,7 +239,7 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="app-initdb-options-lc-collate-et-al">
       <term><option>--lc-collate=<replaceable>locale</replaceable></option></term>
       <term><option>--lc-ctype=<replaceable>locale</replaceable></option></term>
       <term><option>--lc-messages=<replaceable>locale</replaceable></option></term>
@@ -255,7 +255,7 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="app-initdb-options-no-locale">
       <term><option>--no-locale</option></term>
       <listitem>
        <para>
@@ -264,7 +264,7 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="app-initdb-options-no-sync">
       <term><option>-N</option></term>
       <term><option>--no-sync</option></term>
       <listitem>
@@ -279,7 +279,7 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="app-initdb-options-no-instructions">
       <term><option>--no-instructions</option></term>
       <listitem>
        <para>
@@ -292,7 +292,7 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="app-initdb-options-pwfile">
       <term><option>--pwfile=<replaceable>filename</replaceable></option></term>
       <listitem>
        <para>
@@ -302,7 +302,7 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="app-initdb-options-sync-only">
       <term><option>-S</option></term>
       <term><option>--sync-only</option></term>
       <listitem>
@@ -316,7 +316,7 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="app-initdb-options-text-search-config">
       <term><option>-T <replaceable>config</replaceable></option></term>
       <term><option>--text-search-config=<replaceable>config</replaceable></option></term>
       <listitem>
@@ -327,7 +327,7 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="app-initdb-options-username">
       <term><option>-U <replaceable class="parameter">username</replaceable></option></term>
       <term><option>--username=<replaceable class="parameter">username</replaceable></option></term>
       <listitem>
@@ -342,7 +342,7 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="app-initdb-options-pwprompt">
       <term><option>-W</option></term>
       <term><option>--pwprompt</option></term>
       <listitem>
@@ -356,7 +356,7 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-initdb-options-waldir">
       <term><option>-X <replaceable class="parameter">directory</replaceable></option></term>
       <term><option>--waldir=<replaceable class="parameter">directory</replaceable></option></term>
       <listitem>
@@ -367,7 +367,7 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="app-initdb-options-wal-segsize">
       <term><option>--wal-segsize=<replaceable>size</replaceable></option></term>
       <listitem>
        <para>
@@ -394,7 +394,7 @@ PostgreSQL documentation
     Other, less commonly used, options are also available:
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="app-initdb-options-debug">
       <term><option>-d</option></term>
       <term><option>--debug</option></term>
       <listitem>
@@ -408,7 +408,7 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="app-initdb-options-discard-caches">
       <term><option>--discard-caches</option></term>
       <listitem>
        <para>
@@ -419,7 +419,7 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="app-initdb-options-l">
       <term><option>-L <replaceable class="parameter">directory</replaceable></option></term>
       <listitem>
        <para>
@@ -431,7 +431,7 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="app-initdb-options-no-clean">
       <term><option>-n</option></term>
       <term><option>--no-clean</option></term>
       <listitem>
@@ -451,7 +451,7 @@ PostgreSQL documentation
     Other options:
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="app-initdb-options-version">
        <term><option>-V</option></term>
        <term><option>--version</option></term>
        <listitem>
@@ -461,7 +461,7 @@ PostgreSQL documentation
        </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="app-initdb-options-help">
        <term><option>-?</option></term>
        <term><option>--help</option></term>
        <listitem>
@@ -481,7 +481,7 @@ PostgreSQL documentation
   <title>Environment</title>
 
   <variablelist>
-   <varlistentry>
+   <varlistentry id="app-initdb-environment-pgdata">
     <term><envar>PGDATA</envar></term>
 
     <listitem>
@@ -492,7 +492,7 @@ PostgreSQL documentation
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="app-initdb-environment-pg_color">
     <term><envar>PG_COLOR</envar></term>
     <listitem>
      <para>
@@ -503,7 +503,7 @@ PostgreSQL documentation
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="app-initdb-environment-tz">
     <term><envar>TZ</envar></term>
 
     <listitem>
diff --git a/doc/src/sgml/ref/pgbench.sgml b/doc/src/sgml/ref/pgbench.sgml
index be1896fa99..6cb64d9ffb 100644
--- a/doc/src/sgml/ref/pgbench.sgml
+++ b/doc/src/sgml/ref/pgbench.sgml
@@ -152,7 +152,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
 
     <variablelist>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-dbname">
       <term><replaceable class="parameter">dbname</replaceable></term>
       <listitem>
        <para>
@@ -164,7 +164,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-initialize">
       <term><option>-i</option></term>
       <term><option>--initialize</option></term>
       <listitem>
@@ -174,7 +174,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-init-steps">
       <term><option>-I <replaceable>init_steps</replaceable></option></term>
       <term><option>--init-steps=<replaceable>init_steps</replaceable></option></term>
       <listitem>
@@ -187,7 +187,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
         The available steps are:
 
         <variablelist>
-         <varlistentry>
+         <varlistentry id="pgbench-options-init-steps-d">
           <term><literal>d</literal> (Drop)</term>
           <listitem>
            <para>
@@ -195,7 +195,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
            </para>
           </listitem>
          </varlistentry>
-         <varlistentry>
+         <varlistentry id="pgbench-options-init-steps-t">
           <term><literal>t</literal> (create Tables)</term>
           <listitem>
            <para>
@@ -208,7 +208,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
            </para>
           </listitem>
          </varlistentry>
-         <varlistentry>
+         <varlistentry id="pgbench-options-init-steps-g">
           <term><literal>g</literal> or <literal>G</literal> (Generate data, client-side or server-side)</term>
           <listitem>
            <para>
@@ -242,7 +242,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
            </para>
           </listitem>
          </varlistentry>
-         <varlistentry>
+         <varlistentry id="pgbench-options-init-steps-v">
           <term><literal>v</literal> (Vacuum)</term>
           <listitem>
            <para>
@@ -250,7 +250,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
            </para>
           </listitem>
          </varlistentry>
-         <varlistentry>
+         <varlistentry id="pgbench-options-init-steps-p">
           <term><literal>p</literal> (create Primary keys)</term>
           <listitem>
            <para>
@@ -258,7 +258,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
            </para>
           </listitem>
          </varlistentry>
-         <varlistentry>
+         <varlistentry id="pgbench-options-init-steps-f">
          <term><literal>f</literal> (create Foreign keys)</term>
           <listitem>
            <para>
@@ -271,7 +271,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-fillfactor">
       <term><option>-F</option> <replaceable>fillfactor</replaceable></term>
       <term><option>--fillfactor=</option><replaceable>fillfactor</replaceable></term>
       <listitem>
@@ -284,7 +284,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-no-vacuum-init">
       <term><option>-n</option></term>
       <term><option>--no-vacuum</option></term>
       <listitem>
@@ -296,7 +296,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-quiet">
       <term><option>-q</option></term>
       <term><option>--quiet</option></term>
       <listitem>
@@ -312,7 +312,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-scale-init">
       <term><option>-s</option> <replaceable>scale_factor</replaceable></term>
       <term><option>--scale=</option><replaceable>scale_factor</replaceable></term>
       <listitem>
@@ -329,7 +329,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-foreign-keys">
       <term><option>--foreign-keys</option></term>
       <listitem>
        <para>
@@ -340,7 +340,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-index-tablespace">
       <term><option>--index-tablespace=<replaceable>index_tablespace</replaceable></option></term>
       <listitem>
        <para>
@@ -350,7 +350,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-partition-method">
       <term><option>--partition-method=<replaceable>NAME</replaceable></option></term>
       <listitem>
        <para>
@@ -363,7 +363,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-partitions">
       <term><option>--partitions=<replaceable>NUM</replaceable></option></term>
       <listitem>
        <para>
@@ -375,7 +375,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-tablespace">
       <term><option>--tablespace=<replaceable>tablespace</replaceable></option></term>
       <listitem>
        <para>
@@ -385,7 +385,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-unlogged-tables">
       <term><option>--unlogged-tables</option></term>
       <listitem>
        <para>
@@ -407,7 +407,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
     benchmarking arguments:
 
     <variablelist>
-     <varlistentry>
+     <varlistentry id="pgbench-options-builtin">
       <term><option>-b</option> <replaceable>scriptname[@weight]</replaceable></term>
       <term><option>--builtin</option>=<replaceable>scriptname[@weight]</replaceable></term>
       <listitem>
@@ -428,7 +428,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-client">
       <term><option>-c</option> <replaceable>clients</replaceable></term>
       <term><option>--client=</option><replaceable>clients</replaceable></term>
       <listitem>
@@ -439,7 +439,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-connect">
       <term><option>-C</option></term>
       <term><option>--connect</option></term>
       <listitem>
@@ -451,7 +451,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-debug">
       <term><option>-d</option></term>
       <term><option>--debug</option></term>
       <listitem>
@@ -461,7 +461,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-define">
       <term><option>-D</option> <replaceable>varname</replaceable><literal>=</literal><replaceable>value</replaceable></term>
       <term><option>--define=</option><replaceable>varname</replaceable><literal>=</literal><replaceable>value</replaceable></term>
       <listitem>
@@ -472,7 +472,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-file">
       <term><option>-f</option> <replaceable>filename[@weight]</replaceable></term>
       <term><option>--file=</option><replaceable>filename[@weight]</replaceable></term>
       <listitem>
@@ -492,7 +492,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-jobs">
       <term><option>-j</option> <replaceable>threads</replaceable></term>
       <term><option>--jobs=</option><replaceable>threads</replaceable></term>
       <listitem>
@@ -505,7 +505,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-log">
       <term><option>-l</option></term>
       <term><option>--log</option></term>
       <listitem>
@@ -516,7 +516,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-latency-limit">
       <term><option>-L</option> <replaceable>limit</replaceable></term>
       <term><option>--latency-limit=</option><replaceable>limit</replaceable></term>
       <listitem>
@@ -534,7 +534,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
        </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-protocol">
       <term><option>-M</option> <replaceable>querymode</replaceable></term>
       <term><option>--protocol=</option><replaceable>querymode</replaceable></term>
       <listitem>
@@ -564,7 +564,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-no-vacuum-run">
       <term><option>-n</option></term>
       <term><option>--no-vacuum</option></term>
       <listitem>
@@ -579,7 +579,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-skip-some-updates">
       <term><option>-N</option></term>
       <term><option>--skip-some-updates</option></term>
       <listitem>
@@ -590,7 +590,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-progress">
       <term><option>-P</option> <replaceable>sec</replaceable></term>
       <term><option>--progress=</option><replaceable>sec</replaceable></term>
       <listitem>
@@ -606,7 +606,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-report-latencies">
       <term><option>-r</option></term>
       <term><option>--report-latencies</option></term>
       <listitem>
@@ -618,7 +618,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-rate">
       <term><option>-R</option> <replaceable>rate</replaceable></term>
       <term><option>--rate=</option><replaceable>rate</replaceable></term>
       <listitem>
@@ -669,7 +669,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-scale-run">
       <term><option>-s</option> <replaceable>scale_factor</replaceable></term>
       <term><option>--scale=</option><replaceable>scale_factor</replaceable></term>
       <listitem>
@@ -684,7 +684,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-select-only">
       <term><option>-S</option></term>
       <term><option>--select-only</option></term>
       <listitem>
@@ -695,7 +695,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-transactions">
       <term><option>-t</option> <replaceable>transactions</replaceable></term>
       <term><option>--transactions=</option><replaceable>transactions</replaceable></term>
       <listitem>
@@ -705,7 +705,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-time">
       <term><option>-T</option> <replaceable>seconds</replaceable></term>
       <term><option>--time=</option><replaceable>seconds</replaceable></term>
       <listitem>
@@ -717,7 +717,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-vacuum-all">
       <term><option>-v</option></term>
       <term><option>--vacuum-all</option></term>
       <listitem>
@@ -730,7 +730,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-aggregate-interval">
       <term><option>--aggregate-interval=<replaceable>seconds</replaceable></option></term>
       <listitem>
        <para>
@@ -741,7 +741,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-log-prefix">
       <term><option>--log-prefix=<replaceable>prefix</replaceable></option></term>
       <listitem>
        <para>
@@ -751,7 +751,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-progress-timestamp">
       <term><option>--progress-timestamp</option></term>
       <listitem>
        <para>
@@ -764,7 +764,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-random-seed">
       <term><option>--random-seed=</option><replaceable>seed</replaceable></term>
       <listitem>
        <para>
@@ -801,7 +801,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-sampling-rate">
       <term><option>--sampling-rate=<replaceable>rate</replaceable></option></term>
       <listitem>
        <para>
@@ -819,7 +819,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-show-script">
       <term><option>--show-script=</option><replaceable>scriptname</replaceable></term>
       <listitem>
        <para>
@@ -843,7 +843,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
 
     <variablelist>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-host">
       <term><option>-h</option> <replaceable>hostname</replaceable></term>
       <term><option>--host=</option><replaceable>hostname</replaceable></term>
       <listitem>
@@ -853,7 +853,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-port">
       <term><option>-p</option> <replaceable>port</replaceable></term>
       <term><option>--port=</option><replaceable>port</replaceable></term>
       <listitem>
@@ -863,7 +863,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-username">
       <term><option>-U</option> <replaceable>login</replaceable></term>
       <term><option>--username=</option><replaceable>login</replaceable></term>
       <listitem>
@@ -873,7 +873,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-version">
       <term><option>-V</option></term>
       <term><option>--version</option></term>
       <listitem>
@@ -883,7 +883,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
       </listitem>
      </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="pgbench-options-help">
       <term><option>-?</option></term>
       <term><option>--help</option></term>
       <listitem>
@@ -917,7 +917,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
   <title>Environment</title>
 
   <variablelist>
-   <varlistentry>
+   <varlistentry id="pgbench-environment-pgdatabase-et-al">
     <term><envar>PGDATABASE</envar></term>
     <term><envar>PGHOST</envar></term>
     <term><envar>PGPORT</envar></term>
@@ -1142,7 +1142,7 @@ SELECT 4 AS four \; SELECT 5 AS five \aset
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="pgbench-metacommand-if-else">
     <term><literal>\if</literal> <replaceable class="parameter">expression</replaceable></term>
     <term><literal>\elif</literal> <replaceable class="parameter">expression</replaceable></term>
     <term><literal>\else</literal></term>
@@ -1212,7 +1212,7 @@ SELECT 4 AS four \; SELECT 5 AS five \aset
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="pgbench-metacommand-sleep">
     <term>
      <literal>\sleep <replaceable>number</replaceable> [ us | ms | s ]</literal>
     </term>
@@ -1235,7 +1235,7 @@ SELECT 4 AS four \; SELECT 5 AS five \aset
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="pgbench-metacommand-setshell">
     <term>
      <literal>\setshell <replaceable>varname</replaceable> <replaceable>command</replaceable> [ <replaceable>argument</replaceable> ... ]</literal>
     </term>
@@ -1263,7 +1263,7 @@ SELECT 4 AS four \; SELECT 5 AS five \aset
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="pgbench-metacommand-shell">
     <term>
      <literal>\shell <replaceable>command</replaceable> [ <replaceable>argument</replaceable> ... ]</literal>
     </term>
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index caabb06c53..d0caaa6532 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -49,7 +49,7 @@ PostgreSQL documentation
   <title>Options</title>
 
   <variablelist>
-    <varlistentry>
+    <varlistentry id="app-psql-options-echo-all">
       <term><option>-a</option></term>
       <term><option>--echo-all</option></term>
       <listitem>
@@ -62,7 +62,7 @@ PostgreSQL documentation
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-no-align">
       <term><option>-A</option></term>
       <term><option>--no-align</option></term>
       <listitem>
@@ -74,7 +74,7 @@ PostgreSQL documentation
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-echo-errors">
       <term><option>-b</option></term>
       <term><option>--echo-errors</option></term>
       <listitem>
@@ -86,7 +86,7 @@ PostgreSQL documentation
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-command">
       <term><option>-c <replaceable class="parameter">command</replaceable></option></term>
       <term><option>--command=<replaceable class="parameter">command</replaceable></option></term>
       <listitem>
@@ -150,7 +150,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-csv">
       <term><option>--csv</option></term>
       <listitem>
       <para>
@@ -160,7 +160,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-dbname">
       <term><option>-d <replaceable class="parameter">dbname</replaceable></option></term>
       <term><option>--dbname=<replaceable class="parameter">dbname</replaceable></option></term>
       <listitem>
@@ -176,7 +176,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-echo-queries">
       <term><option>-e</option></term>
       <term><option>--echo-queries</option></term>
       <listitem>
@@ -189,7 +189,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-echo-hidden">
       <term><option>-E</option></term>
       <term><option>--echo-hidden</option></term>
       <listitem>
@@ -202,7 +202,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-file">
       <term><option>-f <replaceable class="parameter">filename</replaceable></option></term>
       <term><option>--file=<replaceable class="parameter">filename</replaceable></option></term>
       <listitem>
@@ -244,7 +244,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-field-separator">
       <term><option>-F <replaceable class="parameter">separator</replaceable></option></term>
       <term><option>--field-separator=<replaceable class="parameter">separator</replaceable></option></term>
       <listitem>
@@ -256,7 +256,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-field-host">
       <term><option>-h <replaceable class="parameter">hostname</replaceable></option></term>
       <term><option>--host=<replaceable class="parameter">hostname</replaceable></option></term>
       <listitem>
@@ -269,7 +269,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-html">
       <term><option>-H</option></term>
       <term><option>--html</option></term>
       <listitem>
@@ -281,7 +281,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-list">
       <term><option>-l</option></term>
       <term><option>--list</option></term>
       <listitem>
@@ -301,7 +301,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-log-file">
       <term><option>-L <replaceable class="parameter">filename</replaceable></option></term>
       <term><option>--log-file=<replaceable class="parameter">filename</replaceable></option></term>
       <listitem>
@@ -313,7 +313,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-no-readline">
       <term><option>-n</option></term>
       <term><option>--no-readline</option></term>
       <listitem>
@@ -325,7 +325,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-output">
       <term><option>-o <replaceable class="parameter">filename</replaceable></option></term>
       <term><option>--output=<replaceable class="parameter">filename</replaceable></option></term>
       <listitem>
@@ -337,7 +337,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-port">
       <term><option>-p <replaceable class="parameter">port</replaceable></option></term>
       <term><option>--port=<replaceable class="parameter">port</replaceable></option></term>
       <listitem>
@@ -351,7 +351,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-pset">
       <term><option>-P <replaceable class="parameter">assignment</replaceable></option></term>
       <term><option>--pset=<replaceable class="parameter">assignment</replaceable></option></term>
       <listitem>
@@ -365,7 +365,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-quiet">
       <term><option>-q</option></term>
       <term><option>--quiet</option></term>
       <listitem>
@@ -380,7 +380,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-record-separator">
       <term><option>-R <replaceable class="parameter">separator</replaceable></option></term>
       <term><option>--record-separator=<replaceable class="parameter">separator</replaceable></option></term>
       <listitem>
@@ -392,7 +392,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-single-step">
       <term><option>-s</option></term>
       <term><option>--single-step</option></term>
       <listitem>
@@ -404,7 +404,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-single-line">
       <term><option>-S</option></term>
       <term><option>--single-line</option></term>
       <listitem>
@@ -424,7 +424,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-tuples-only">
       <term><option>-t</option></term>
       <term><option>--tuples-only</option></term>
       <listitem>
@@ -436,7 +436,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-table-attr">
       <term><option>-T <replaceable class="parameter">table_options</replaceable></option></term>
       <term><option>--table-attr=<replaceable class="parameter">table_options</replaceable></option></term>
       <listitem>
@@ -448,7 +448,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-username">
       <term><option>-U <replaceable class="parameter">username</replaceable></option></term>
       <term><option>--username=<replaceable class="parameter">username</replaceable></option></term>
       <listitem>
@@ -460,7 +460,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-variable">
       <term><option>-v <replaceable class="parameter">assignment</replaceable></option></term>
       <term><option>--set=<replaceable class="parameter">assignment</replaceable></option></term>
       <term><option>--variable=<replaceable class="parameter">assignment</replaceable></option></term>
@@ -477,7 +477,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-version">
       <term><option>-V</option></term>
       <term><option>--version</option></term>
       <listitem>
@@ -487,7 +487,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-no-password">
      <term><option>-w</option></term>
      <term><option>--no-password</option></term>
      <listitem>
@@ -507,7 +507,7 @@ EOF
      </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-password">
       <term><option>-W</option></term>
       <term><option>--password</option></term>
       <listitem>
@@ -535,7 +535,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-expanded">
       <term><option>-x</option></term>
       <term><option>--expanded</option></term>
       <listitem>
@@ -546,7 +546,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-no-psqlrc">
       <term><option>-X,</option></term>
       <term><option>--no-psqlrc</option></term>
       <listitem>
@@ -558,7 +558,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-field-separator-zero">
       <term><option>-z</option></term>
       <term><option>--field-separator-zero</option></term>
       <listitem>
@@ -569,7 +569,7 @@ EOF
       </listitem>
     </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-record-separator-zero">
       <term><option>-0</option></term>
       <term><option>--record-separator-zero</option></term>
       <listitem>
@@ -581,7 +581,7 @@ EOF
       </listitem>
     </varlistentry>
 
-     <varlistentry>
+     <varlistentry id="app-psql-options-single-transaction">
       <term><option>-1</option></term>
       <term><option>--single-transaction</option></term>
       <listitem>
@@ -606,7 +606,7 @@ EOF
       </listitem>
      </varlistentry>
 
-    <varlistentry>
+    <varlistentry id="app-psql-options-help">
       <term><option>-?</option></term>
       <term><option>--help[=<replaceable class="parameter">topic</replaceable>]</option></term>
       <listitem>
@@ -871,7 +871,7 @@ testdb=&gt;
     The following meta-commands are defined:
 
     <variablelist>
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-a">
         <term><literal>\a</literal></term>
         <listitem>
         <para>
@@ -883,7 +883,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-c-lc">
         <term><literal>\c</literal> or <literal>\connect [ -reuse-previous=<replaceable class="parameter">on|off</replaceable> ] [ <replaceable class="parameter">dbname</replaceable> [ <replaceable class="parameter">username</replaceable> ] [ <replaceable class="parameter">host</replaceable> ] [ <replaceable class="parameter">port</replaceable> ] | <replaceable class="parameter">conninfo</replaceable> ]</literal></term>
         <listitem>
         <para>
@@ -963,7 +963,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-c-uc">
         <term><literal>\C [ <replaceable class="parameter">title</replaceable> ]</literal></term>
         <listitem>
         <para>
@@ -978,7 +978,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-cd">
        <term><literal>\cd [ <replaceable>directory</replaceable> ]</literal></term>
        <listitem>
         <para>
@@ -995,7 +995,7 @@ testdb=&gt;
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-conninfo">
         <term><literal>\conninfo</literal></term>
         <listitem>
         <para>
@@ -1092,7 +1092,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-copyright">
         <term><literal>\copyright</literal></term>
         <listitem>
         <para>
@@ -1176,7 +1176,7 @@ testdb=&gt;
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-d">
         <term><literal>\d[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
 
         <listitem>
@@ -1230,7 +1230,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-da-lc">
         <term><literal>\da[S] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
 
         <listitem>
@@ -1246,7 +1246,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-da-uc">
         <term><literal>\dA[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
 
         <listitem>
@@ -1260,7 +1260,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-dac">
         <term>
           <literal>\dAc[+]
             [<link linkend="app-psql-patterns"><replaceable class="parameter">access-method-pattern</replaceable></link>
@@ -1283,7 +1283,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-daf">
         <term>
           <literal>\dAf[+]
             [<link linkend="app-psql-patterns"><replaceable class="parameter">access-method-pattern</replaceable></link>
@@ -1306,7 +1306,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-dao">
         <term>
           <literal>\dAo[+]
             [<link linkend="app-psql-patterns"><replaceable class="parameter">access-method-pattern</replaceable></link>
@@ -1330,7 +1330,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-dap">
         <term>
           <literal>\dAp[+]
             [<link linkend="app-psql-patterns"><replaceable class="parameter">access-method-pattern</replaceable></link>
@@ -1353,7 +1353,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-db">
         <term><literal>\db[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
 
         <listitem>
@@ -1369,7 +1369,7 @@ testdb=&gt;
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-dc-lc">
         <term><literal>\dc[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1387,7 +1387,7 @@ testdb=&gt;
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-dc-uc">
         <term><literal>\dC[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1402,7 +1402,7 @@ testdb=&gt;
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-dd-lc">
         <term><literal>\dd[S] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1431,7 +1431,7 @@ testdb=&gt;
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-dd-uc">
         <term><literal>\dD[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1448,7 +1448,7 @@ testdb=&gt;
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-ddp">
         <term><literal>\ddp [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1470,7 +1470,7 @@ testdb=&gt;
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-de-et-al">
         <term><literal>\dE[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <term><literal>\di[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <term><literal>\dm[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
@@ -1503,7 +1503,7 @@ testdb=&gt;
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-des">
         <term><literal>\des[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1519,7 +1519,7 @@ testdb=&gt;
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-det">
         <term><literal>\det[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1534,7 +1534,7 @@ testdb=&gt;
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-deu">
         <term><literal>\deu[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1557,7 +1557,7 @@ testdb=&gt;
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-dew">
         <term><literal>\dew[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1573,7 +1573,7 @@ testdb=&gt;
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-df-lc">
         <term><literal>\df[anptwS+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> [ <replaceable class="parameter">arg_pattern</replaceable> ... ] ]</literal></term>
 
         <listitem>
@@ -1604,7 +1604,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-df-uc">
         <term><literal>\dF[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1618,7 +1618,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-dfd">
         <term><literal>\dFd[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1632,7 +1632,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-dfp">
         <term><literal>\dFp[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1646,7 +1646,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-dft">
         <term><literal>\dFt[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1660,7 +1660,7 @@ testdb=&gt;
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-dg">
         <term><literal>\dg[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1680,7 +1680,7 @@ testdb=&gt;
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-dl-lc">
         <term><literal>\dl[+]</literal></term>
         <listitem>
         <para>
@@ -1693,7 +1693,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-dl-uc">
         <term><literal>\dL[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1710,7 +1710,7 @@ testdb=&gt;
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-dn">
         <term><literal>\dn[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
 
         <listitem>
@@ -1727,7 +1727,7 @@ testdb=&gt;
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-do-lc">
         <term><literal>\do[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> [ <replaceable class="parameter">arg_pattern</replaceable> [ <replaceable class="parameter">arg_pattern</replaceable> ] ] ]</literal></term>
         <listitem>
         <para>
@@ -1752,7 +1752,7 @@ testdb=&gt;
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-do-uc">
         <term><literal>\dO[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1772,7 +1772,7 @@ testdb=&gt;
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-dp-lc">
         <term><literal>\dp [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1794,7 +1794,7 @@ testdb=&gt;
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-dp-uc">
         <term><literal>\dP[itn+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1826,7 +1826,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-drds">
         <term><literal>\drds [ <link linkend="app-psql-patterns"><replaceable class="parameter">role-pattern</replaceable></link> [ <link linkend="app-psql-patterns"><replaceable class="parameter">database-pattern</replaceable></link> ] ]</literal></term>
         <listitem>
         <para>
@@ -1848,7 +1848,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-drp">
         <term><literal>\dRp[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1862,7 +1862,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-drs">
         <term><literal>\dRs[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1876,7 +1876,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-dt">
         <term><literal>\dT[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1893,7 +1893,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-du">
         <term><literal>\du[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1912,7 +1912,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-dx-lc">
         <term><literal>\dx[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1926,7 +1926,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-dx-uc">
         <term><literal>\dX [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1948,7 +1948,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-dy">
         <term><literal>\dy[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -1962,7 +1962,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-edit">
         <term><literal>\e</literal> or <literal>\edit</literal> <literal> <optional> <replaceable class="parameter">filename</replaceable> </optional> <optional> <replaceable class="parameter">line_number</replaceable> </optional> </literal></term>
 
         <listitem>
@@ -2015,7 +2015,7 @@ testdb=&gt;
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-echo">
         <term><literal>\echo <replaceable class="parameter">text</replaceable> [ ... ]</literal></term>
         <listitem>
         <para>
@@ -2040,7 +2040,7 @@ Tue Oct 26 21:40:57 CEST 1999
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-ef">
         <term><literal>\ef <optional> <replaceable class="parameter">function_description</replaceable> <optional>  <replaceable class="parameter">line_number</replaceable> </optional> </optional> </literal></term>
 
         <listitem>
@@ -2092,7 +2092,7 @@ Tue Oct 26 21:40:57 CEST 1999
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-encoding">
         <term><literal>\encoding [ <replaceable class="parameter">encoding</replaceable> ]</literal></term>
 
         <listitem>
@@ -2104,7 +2104,7 @@ Tue Oct 26 21:40:57 CEST 1999
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-errverbose">
         <term><literal>\errverbose</literal></term>
 
         <listitem>
@@ -2118,7 +2118,7 @@ Tue Oct 26 21:40:57 CEST 1999
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-ev">
         <term><literal>\ev <optional> <replaceable class="parameter">view_name</replaceable> <optional>  <replaceable class="parameter">line_number</replaceable> </optional> </optional> </literal></term>
 
         <listitem>
@@ -2153,7 +2153,7 @@ Tue Oct 26 21:40:57 CEST 1999
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-f">
         <term><literal>\f [ <replaceable class="parameter">string</replaceable> ]</literal></term>
 
         <listitem>
@@ -2166,7 +2166,7 @@ Tue Oct 26 21:40:57 CEST 1999
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-g">
         <term><literal>\g [ (<replaceable class="parameter">option</replaceable>=<replaceable class="parameter">value</replaceable> [...]) ] [ <replaceable class="parameter">filename</replaceable> ]</literal></term>
         <term><literal>\g [ (<replaceable class="parameter">option</replaceable>=<replaceable class="parameter">value</replaceable> [...]) ] [ |<replaceable class="parameter">command</replaceable> ]</literal></term>
         <listitem>
@@ -2221,7 +2221,7 @@ Tue Oct 26 21:40:57 CEST 1999
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-gdesc">
         <term><literal>\gdesc</literal></term>
 
         <listitem>
@@ -2240,7 +2240,7 @@ Tue Oct 26 21:40:57 CEST 1999
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-getenv">
         <term><literal>\getenv <replaceable class="parameter">psql_var</replaceable> <replaceable class="parameter">env_var</replaceable></literal></term>
 
         <listitem>
@@ -2262,7 +2262,7 @@ Tue Oct 26 21:40:57 CEST 1999
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-gexec">
         <term><literal>\gexec</literal></term>
 
         <listitem>
@@ -2308,7 +2308,7 @@ CREATE INDEX
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-gset">
         <term><literal>\gset [ <replaceable class="parameter">prefix</replaceable> ]</literal></term>
 
         <listitem>
@@ -2353,7 +2353,7 @@ hello 10
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-gx">
         <term><literal>\gx [ (<replaceable class="parameter">option</replaceable>=<replaceable class="parameter">value</replaceable> [...]) ] [ <replaceable class="parameter">filename</replaceable> ]</literal></term>
         <term><literal>\gx [ (<replaceable class="parameter">option</replaceable>=<replaceable class="parameter">value</replaceable> [...]) ] [ |<replaceable class="parameter">command</replaceable> ]</literal></term>
         <listitem>
@@ -2367,7 +2367,7 @@ hello 10
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-help">
         <term><literal>\h</literal> or <literal>\help</literal> <literal>[ <replaceable class="parameter">command</replaceable> ]</literal></term>
         <listitem>
         <para>
@@ -2398,7 +2398,7 @@ hello 10
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-html">
         <term><literal>\H</literal> or <literal>\html</literal></term>
         <listitem>
         <para>
@@ -2412,7 +2412,7 @@ hello 10
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-include">
         <term><literal>\i</literal> or <literal>\include</literal> <replaceable class="parameter">filename</replaceable></term>
         <listitem>
         <para>
@@ -2527,7 +2527,7 @@ SELECT
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-include_relative">
         <term><literal>\ir</literal> or <literal>\include_relative</literal> <replaceable class="parameter">filename</replaceable></term>
         <listitem>
         <para>
@@ -2542,7 +2542,7 @@ SELECT
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-list">
         <term><literal>\l[+]</literal> or <literal>\list[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -2559,7 +2559,7 @@ SELECT
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-lo_export">
         <term><literal>\lo_export <replaceable class="parameter">loid</replaceable> <replaceable class="parameter">filename</replaceable></literal></term>
 
         <listitem>
@@ -2583,7 +2583,7 @@ SELECT
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-lo_import">
         <term><literal>\lo_import <replaceable class="parameter">filename</replaceable> [ <replaceable class="parameter">comment</replaceable> ]</literal></term>
 
         <listitem>
@@ -2612,7 +2612,7 @@ lo_import 152801
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-lo_list">
         <term><literal>\lo_list[+]</literal></term>
         <listitem>
         <para>
@@ -2626,7 +2626,7 @@ lo_import 152801
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-lo_unlink">
         <term><literal>\lo_unlink <replaceable class="parameter">loid</replaceable></literal></term>
 
         <listitem>
@@ -2646,7 +2646,7 @@ lo_import 152801
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-out">
         <term><literal>\o</literal> or <literal>\out [ <replaceable class="parameter">filename</replaceable> ]</literal></term>
         <term><literal>\o</literal> or <literal>\out [ |<replaceable class="parameter">command</replaceable> ]</literal></term>
         <listitem>
@@ -2685,7 +2685,7 @@ lo_import 152801
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-print">
         <term><literal>\p</literal> or <literal>\print</literal></term>
         <listitem>
         <para>
@@ -2696,7 +2696,7 @@ lo_import 152801
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-password">
         <term><literal>\password [ <replaceable class="parameter">username</replaceable> ]</literal></term>
         <listitem>
         <para>
@@ -2709,7 +2709,7 @@ lo_import 152801
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-prompt">
         <term><literal>\prompt [ <replaceable class="parameter">text</replaceable> ] <replaceable class="parameter">name</replaceable></literal></term>
         <listitem>
         <para>
@@ -2728,7 +2728,7 @@ lo_import 152801
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-pset">
         <term><literal>\pset [ <replaceable class="parameter">option</replaceable> [ <replaceable class="parameter">value</replaceable> ] ]</literal></term>
 
         <listitem>
@@ -2753,7 +2753,7 @@ lo_import 152801
         <para>
         Adjustable printing options are:
         <variablelist>
-          <varlistentry>
+          <varlistentry id="app-psql-meta-commands-pset-border">
           <term><literal>border</literal></term>
           <listitem>
           <para>
@@ -2773,7 +2773,7 @@ lo_import 152801
           </listitem>
           </varlistentry>
 
-          <varlistentry>
+          <varlistentry id="app-psql-meta-commands-pset-columns">
           <term><literal>columns</literal></term>
           <listitem>
           <para>
@@ -2792,7 +2792,7 @@ lo_import 152801
           </listitem>
           </varlistentry>
 
-          <varlistentry>
+          <varlistentry id="app-psql-meta-commands-pset-csv_fieldsep">
           <term><literal>csv_fieldsep</literal></term>
           <listitem>
           <para>
@@ -2805,7 +2805,7 @@ lo_import 152801
           </listitem>
           </varlistentry>
 
-          <varlistentry>
+          <varlistentry id="app-psql-meta-commands-pset-expanded">
           <term><literal>expanded</literal> (or <literal>x</literal>)</term>
           <listitem>
           <para>
@@ -2827,7 +2827,7 @@ lo_import 152801
           </listitem>
           </varlistentry>
 
-          <varlistentry>
+          <varlistentry id="app-psql-meta-commands-pset-fieldsep">
           <term><literal>fieldsep</literal></term>
           <listitem>
           <para>
@@ -2841,7 +2841,7 @@ lo_import 152801
           </listitem>
           </varlistentry>
 
-          <varlistentry>
+          <varlistentry id="app-psql-meta-commands-pset-fieldsep_zero">
           <term><literal>fieldsep_zero</literal></term>
           <listitem>
           <para>
@@ -2851,7 +2851,7 @@ lo_import 152801
           </listitem>
           </varlistentry>
 
-          <varlistentry>
+          <varlistentry id="app-psql-meta-commands-pset-footer">
           <term><literal>footer</literal></term>
           <listitem>
           <para>
@@ -2865,7 +2865,7 @@ lo_import 152801
           </listitem>
           </varlistentry>
 
-          <varlistentry>
+          <varlistentry id="app-psql-meta-commands-pset-format">
           <term><literal>format</literal></term>
           <listitem>
           <para>
@@ -2942,7 +2942,7 @@ lo_import 152801
           </listitem>
           </varlistentry>
 
-          <varlistentry>
+          <varlistentry id="app-psql-meta-commands-pset-linestyle">
           <term><literal>linestyle</literal></term>
           <listitem>
           <para>
@@ -2993,7 +2993,7 @@ lo_import 152801
           </listitem>
           </varlistentry>
 
-          <varlistentry>
+          <varlistentry id="app-psql-meta-commands-pset-null">
           <term><literal>null</literal></term>
           <listitem>
           <para>
@@ -3005,7 +3005,7 @@ lo_import 152801
           </listitem>
           </varlistentry>
 
-          <varlistentry>
+          <varlistentry id="app-psql-meta-commands-pset-numericlocale">
           <term><literal>numericlocale</literal></term>
           <listitem>
           <para>
@@ -3019,7 +3019,7 @@ lo_import 152801
           </listitem>
           </varlistentry>
 
-          <varlistentry>
+          <varlistentry id="app-psql-meta-commands-pset-pager">
           <term><literal>pager</literal></term>
           <listitem>
           <para>
@@ -3054,7 +3054,7 @@ lo_import 152801
           </listitem>
           </varlistentry>
 
-          <varlistentry>
+          <varlistentry id="app-psql-meta-commands-pset-pager_min_lines">
           <term><literal>pager_min_lines</literal></term>
           <listitem>
           <para>
@@ -3066,7 +3066,7 @@ lo_import 152801
           </listitem>
           </varlistentry>
 
-          <varlistentry>
+          <varlistentry id="app-psql-meta-commands-pset-recordsep">
           <term><literal>recordsep</literal></term>
           <listitem>
           <para>
@@ -3076,7 +3076,7 @@ lo_import 152801
           </listitem>
           </varlistentry>
 
-          <varlistentry>
+          <varlistentry id="app-psql-meta-commands-pset-recordsep_zero">
           <term><literal>recordsep_zero</literal></term>
           <listitem>
           <para>
@@ -3086,7 +3086,7 @@ lo_import 152801
           </listitem>
           </varlistentry>
 
-          <varlistentry>
+          <varlistentry id="app-psql-meta-commands-pset-tableattr">
           <term><literal>tableattr</literal> (or <literal>T</literal>)</term>
           <listitem>
           <para>
@@ -3110,7 +3110,7 @@ lo_import 152801
           </listitem>
           </varlistentry>
 
-          <varlistentry>
+          <varlistentry id="app-psql-meta-commands-pset-title">
           <term><literal>title</literal> (or <literal>C</literal>)</term>
           <listitem>
           <para>
@@ -3122,7 +3122,7 @@ lo_import 152801
           </listitem>
           </varlistentry>
 
-          <varlistentry>
+          <varlistentry id="app-psql-meta-commands-pset-tuples_only">
           <term><literal>tuples_only</literal> (or <literal>t</literal>)</term>
           <listitem>
           <para>
@@ -3138,7 +3138,7 @@ lo_import 152801
           </listitem>
           </varlistentry>
 
-          <varlistentry>
+          <varlistentry id="app-psql-meta-commands-pset-unicode_border_linestyle">
           <term><literal>unicode_border_linestyle</literal></term>
           <listitem>
           <para>
@@ -3149,7 +3149,7 @@ lo_import 152801
           </listitem>
           </varlistentry>
 
-          <varlistentry>
+          <varlistentry id="app-psql-meta-commands-pset-unicode_column_linestyle">
           <term><literal>unicode_column_linestyle</literal></term>
           <listitem>
           <para>
@@ -3160,7 +3160,7 @@ lo_import 152801
           </listitem>
           </varlistentry>
 
-          <varlistentry>
+          <varlistentry id="app-psql-meta-commands-pset-unicode_header_linestyle">
           <term><literal>unicode_header_linestyle</literal></term>
           <listitem>
           <para>
@@ -3191,7 +3191,7 @@ lo_import 152801
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-quit">
         <term><literal>\q</literal> or <literal>\quit</literal></term>
         <listitem>
         <para>
@@ -3202,7 +3202,7 @@ lo_import 152801
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-qecho">
         <term><literal>\qecho <replaceable class="parameter">text</replaceable> [ ... ] </literal></term>
         <listitem>
         <para>
@@ -3214,7 +3214,7 @@ lo_import 152801
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-reset">
         <term><literal>\r</literal> or <literal>\reset</literal></term>
         <listitem>
         <para>
@@ -3224,7 +3224,7 @@ lo_import 152801
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-s">
         <term><literal>\s [ <replaceable class="parameter">filename</replaceable> ]</literal></term>
         <listitem>
         <para>
@@ -3240,7 +3240,7 @@ lo_import 152801
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-set">
         <term><literal>\set [ <replaceable class="parameter">name</replaceable> [ <replaceable class="parameter">value</replaceable> [ ... ] ] ]</literal></term>
 
         <listitem>
@@ -3280,7 +3280,7 @@ lo_import 152801
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-setenv">
         <term><literal>\setenv <replaceable class="parameter">name</replaceable> [ <replaceable class="parameter">value</replaceable> ]</literal></term>
 
         <listitem>
@@ -3297,7 +3297,7 @@ testdb=&gt; <userinput>\setenv LESS -imx4F</userinput>
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-sf">
         <term><literal>\sf[+] <replaceable class="parameter">function_description</replaceable> </literal></term>
 
         <listitem>
@@ -3332,7 +3332,7 @@ testdb=&gt; <userinput>\setenv LESS -imx4F</userinput>
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-sv">
         <term><literal>\sv[+] <replaceable class="parameter">view_name</replaceable> </literal></term>
 
         <listitem>
@@ -3358,7 +3358,7 @@ testdb=&gt; <userinput>\setenv LESS -imx4F</userinput>
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-t-lc">
         <term><literal>\t</literal></term>
         <listitem>
         <para>
@@ -3370,7 +3370,7 @@ testdb=&gt; <userinput>\setenv LESS -imx4F</userinput>
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-t-uc">
         <term><literal>\T <replaceable class="parameter">table_options</replaceable></literal></term>
         <listitem>
         <para>
@@ -3384,7 +3384,7 @@ testdb=&gt; <userinput>\setenv LESS -imx4F</userinput>
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-timing">
        <term><literal>\timing [ <replaceable class="parameter">on</replaceable> | <replaceable class="parameter">off</replaceable> ]</literal></term>
         <listitem>
         <para>
@@ -3398,7 +3398,7 @@ testdb=&gt; <userinput>\setenv LESS -imx4F</userinput>
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-unset">
         <term><literal>\unset <replaceable class="parameter">name</replaceable></literal></term>
 
         <listitem>
@@ -3417,7 +3417,7 @@ testdb=&gt; <userinput>\setenv LESS -imx4F</userinput>
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-write">
         <term><literal>\w</literal> or <literal>\write</literal> <replaceable class="parameter">filename</replaceable></term>
         <term><literal>\w</literal> or <literal>\write</literal> <literal>|</literal><replaceable class="parameter">command</replaceable></term>
         <listitem>
@@ -3441,7 +3441,7 @@ testdb=&gt; <userinput>\setenv LESS -imx4F</userinput>
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-warn">
         <term><literal>\warn <replaceable class="parameter">text</replaceable> [ ... ]</literal></term>
         <listitem>
         <para>
@@ -3453,7 +3453,7 @@ testdb=&gt; <userinput>\setenv LESS -imx4F</userinput>
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-watch">
         <term><literal>\watch [ <replaceable class="parameter">seconds</replaceable> ]</literal></term>
         <listitem>
         <para>
@@ -3471,7 +3471,7 @@ testdb=&gt; <userinput>\setenv LESS -imx4F</userinput>
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-x">
         <term><literal>\x [ <replaceable class="parameter">on</replaceable> | <replaceable class="parameter">off</replaceable> | <replaceable class="parameter">auto</replaceable> ]</literal></term>
         <listitem>
         <para>
@@ -3482,7 +3482,7 @@ testdb=&gt; <userinput>\setenv LESS -imx4F</userinput>
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-z">
         <term><literal>\z [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
@@ -3501,7 +3501,7 @@ testdb=&gt; <userinput>\setenv LESS -imx4F</userinput>
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-exclamation_mark">
         <term><literal>\! [ <replaceable class="parameter">command</replaceable> ]</literal></term>
         <listitem>
         <para>
@@ -3521,7 +3521,7 @@ testdb=&gt; <userinput>\setenv LESS -imx4F</userinput>
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-question_mark">
         <term><literal>\? [ <replaceable class="parameter">topic</replaceable> ]</literal></term>
         <listitem>
         <para>
@@ -3538,7 +3538,7 @@ testdb=&gt; <userinput>\setenv LESS -imx4F</userinput>
       </varlistentry>
 
 
-      <varlistentry>
+      <varlistentry id="app-psql-meta-commands-semicolon">
         <term><literal>\;</literal></term>
         <listitem>
         <para>
@@ -3753,7 +3753,7 @@ bar
    </para>
 
     <variablelist>
-      <varlistentry>
+      <varlistentry id="app-psql-variables-autocommit">
       <term>
        <varname>AUTOCOMMIT</varname>
        <indexterm>
@@ -3797,7 +3797,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-comp_keyword_case">
         <term><varname>COMP_KEYWORD_CASE</varname></term>
         <listitem>
         <para>
@@ -3813,7 +3813,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-dbname">
         <term><varname>DBNAME</varname></term>
         <listitem>
         <para>
@@ -3824,7 +3824,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-echo">
         <term><varname>ECHO</varname></term>
         <listitem>
         <para>
@@ -3843,7 +3843,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-echo_hidden">
         <term><varname>ECHO_HIDDEN</varname></term>
         <listitem>
         <para>
@@ -3860,7 +3860,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-encoding">
         <term><varname>ENCODING</varname></term>
         <listitem>
         <para>
@@ -3872,7 +3872,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-error">
        <term><varname>ERROR</varname></term>
        <listitem>
         <para>
@@ -3882,7 +3882,7 @@ bar
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-fetch_count">
         <term><varname>FETCH_COUNT</varname></term>
         <listitem>
         <para>
@@ -3910,7 +3910,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-hide_tableam">
         <term><varname>HIDE_TABLEAM</varname></term>
         <listitem>
         <para>
@@ -3921,7 +3921,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-hide_toast_compression">
         <term><varname>HIDE_TOAST_COMPRESSION</varname></term>
         <listitem>
         <para>
@@ -3932,7 +3932,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-histcontrol">
         <term><varname>HISTCONTROL</varname></term>
         <listitem>
         <para>
@@ -3953,7 +3953,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-histfile">
         <term><varname>HISTFILE</varname></term>
         <listitem>
         <para>
@@ -3979,7 +3979,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-histsize">
         <term><varname>HISTSIZE</varname></term>
         <listitem>
         <para>
@@ -3995,7 +3995,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-host">
         <term><varname>HOST</varname></term>
         <listitem>
         <para>
@@ -4006,7 +4006,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-ignoreeof">
         <term><varname>IGNOREEOF</varname></term>
         <listitem>
         <para>
@@ -4027,7 +4027,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-lastoid">
         <term><varname>LASTOID</varname></term>
         <listitem>
         <para>
@@ -4043,7 +4043,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-last_error_message">
        <term><varname>LAST_ERROR_MESSAGE</varname></term>
        <term><varname>LAST_ERROR_SQLSTATE</varname></term>
        <listitem>
@@ -4056,7 +4056,7 @@ bar
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-on_error_rollback">
       <term>
        <varname>ON_ERROR_ROLLBACK</varname>
        <indexterm>
@@ -4080,7 +4080,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-on_error_stop">
         <term><varname>ON_ERROR_STOP</varname></term>
         <listitem>
         <para>
@@ -4099,7 +4099,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-port">
         <term><varname>PORT</varname></term>
         <listitem>
         <para>
@@ -4110,7 +4110,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-prompt">
         <term><varname>PROMPT1</varname></term>
         <term><varname>PROMPT2</varname></term>
         <term><varname>PROMPT3</varname></term>
@@ -4123,7 +4123,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-quiet">
         <term><varname>QUIET</varname></term>
         <listitem>
         <para>
@@ -4134,7 +4134,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-row_count">
        <term><varname>ROW_COUNT</varname></term>
        <listitem>
         <para>
@@ -4144,7 +4144,7 @@ bar
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-server_version_name">
         <term><varname>SERVER_VERSION_NAME</varname></term>
         <term><varname>SERVER_VERSION_NUM</varname></term>
         <listitem>
@@ -4159,7 +4159,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-show_context">
         <term><varname>SHOW_CONTEXT</varname></term>
         <listitem>
         <para>
@@ -4177,7 +4177,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-singleline">
         <term><varname>SINGLELINE</varname></term>
         <listitem>
         <para>
@@ -4187,7 +4187,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-singlestep">
         <term><varname>SINGLESTEP</varname></term>
         <listitem>
         <para>
@@ -4197,7 +4197,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-sqlstate">
        <term><varname>SQLSTATE</varname></term>
        <listitem>
         <para>
@@ -4208,7 +4208,7 @@ bar
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-user">
         <term><varname>USER</varname></term>
         <listitem>
         <para>
@@ -4219,7 +4219,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-verbosity">
         <term><varname>VERBOSITY</varname></term>
         <listitem>
         <para>
@@ -4233,7 +4233,7 @@ bar
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-variables-version">
         <term><varname>VERSION</varname></term>
         <term><varname>VERSION_NAME</varname></term>
         <term><varname>VERSION_NUM</varname></term>
@@ -4362,7 +4362,7 @@ testdb=&gt; <userinput>INSERT INTO my_table VALUES (:'content');</userinput>
     instead. Defined substitutions are:
 
     <variablelist>
-      <varlistentry>
+      <varlistentry id="app-psql-prompting-m-uc">
         <term><literal>%M</literal></term>
         <listitem>
          <para>
@@ -4376,7 +4376,7 @@ testdb=&gt; <userinput>INSERT INTO my_table VALUES (:'content');</userinput>
        </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-prompting-m-lc">
         <term><literal>%m</literal></term>
         <listitem>
          <para>
@@ -4387,12 +4387,12 @@ testdb=&gt; <userinput>INSERT INTO my_table VALUES (:'content');</userinput>
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-prompting-gt">
         <term><literal>%&gt;</literal></term>
         <listitem><para>The port number at which the database server is listening.</para></listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-prompting-n">
         <term><literal>%n</literal></term>
         <listitem>
          <para>
@@ -4404,18 +4404,18 @@ testdb=&gt; <userinput>INSERT INTO my_table VALUES (:'content');</userinput>
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-prompting-slash">
         <term><literal>%/</literal></term>
         <listitem><para>The name of the current database.</para></listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-prompting-tilde">
         <term><literal>%~</literal></term>
         <listitem><para>Like <literal>%/</literal>, but the output is <literal>~</literal>
          (tilde) if the database is your default database.</para></listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-prompting-numbersign">
         <term><literal>%#</literal></term>
         <listitem>
          <para>
@@ -4428,14 +4428,14 @@ testdb=&gt; <userinput>INSERT INTO my_table VALUES (:'content');</userinput>
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-prompting-p">
         <term><literal>%p</literal></term>
         <listitem>
          <para>The process ID of the backend currently connected to.</para>
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-prompting-r">
         <term><literal>%R</literal></term>
         <listitem>
         <para>
@@ -4458,7 +4458,7 @@ testdb=&gt; <userinput>INSERT INTO my_table VALUES (:'content');</userinput>
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-prompting-x">
         <term><literal>%x</literal></term>
         <listitem>
         <para>
@@ -4471,7 +4471,7 @@ testdb=&gt; <userinput>INSERT INTO my_table VALUES (:'content');</userinput>
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-prompting-l">
         <term><literal>%l</literal></term>
         <listitem>
          <para>
@@ -4480,7 +4480,7 @@ testdb=&gt; <userinput>INSERT INTO my_table VALUES (:'content');</userinput>
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-prompting-digits">
         <term><literal>%</literal><replaceable class="parameter">digits</replaceable></term>
         <listitem>
         <para>
@@ -4489,7 +4489,7 @@ testdb=&gt; <userinput>INSERT INTO my_table VALUES (:'content');</userinput>
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-prompting-name">
         <term><literal>%:</literal><replaceable class="parameter">name</replaceable><literal>:</literal></term>
         <listitem>
         <para>
@@ -4500,7 +4500,7 @@ testdb=&gt; <userinput>INSERT INTO my_table VALUES (:'content');</userinput>
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-prompting-command">
         <term><literal>%`</literal><replaceable class="parameter">command</replaceable><literal>`</literal></term>
         <listitem>
         <para>
@@ -4511,7 +4511,7 @@ testdb=&gt; <userinput>INSERT INTO my_table VALUES (:'content');</userinput>
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-prompting-square_brackets">
         <term><literal>%[</literal> ... <literal>%]</literal></term>
         <listitem>
          <para>
@@ -4533,7 +4533,7 @@ testdb=&gt; \set PROMPT1 '%[%033[1;33;40m%]%n@%/%R%[%033[0m%]%# '
         </listitem>
       </varlistentry>
 
-      <varlistentry>
+      <varlistentry id="app-psql-prompting-w">
         <term><literal>%w</literal></term>
         <listitem>
         <para>
@@ -4633,7 +4633,7 @@ $endif
 
   <variablelist>
 
-   <varlistentry>
+   <varlistentry id="app-psql-environment-columns">
     <term><envar>COLUMNS</envar></term>
 
     <listitem>
@@ -4646,7 +4646,7 @@ $endif
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="app-psql-environment-pgdatabase-et-al">
     <term><envar>PGDATABASE</envar></term>
     <term><envar>PGHOST</envar></term>
     <term><envar>PGPORT</envar></term>
@@ -4659,7 +4659,7 @@ $endif
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="app-psql-environment-pg_color">
     <term><envar>PG_COLOR</envar></term>
     <listitem>
      <para>
@@ -4670,7 +4670,7 @@ $endif
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="app-psql-environment-psql_editor-et-al">
     <term><envar>PSQL_EDITOR</envar></term>
     <term><envar>EDITOR</envar></term>
     <term><envar>VISUAL</envar></term>
@@ -4687,7 +4687,7 @@ $endif
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="app-psql-environment-psql_editor_linenumber_arg">
     <term><envar>PSQL_EDITOR_LINENUMBER_ARG</envar></term>
 
     <listitem>
@@ -4715,7 +4715,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="app-psql-environment-psql_history">
     <term><envar>PSQL_HISTORY</envar></term>
 
     <listitem>
@@ -4725,7 +4725,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="app-psql-environment-pager">
     <term><envar>PSQL_PAGER</envar></term>
     <term><envar>PAGER</envar></term>
 
@@ -4746,7 +4746,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="app-psql-environment-psql_watch_pager">
     <term><envar>PSQL_WATCH_PAGER</envar></term>
 
     <listitem>
@@ -4764,7 +4764,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="app-psql-environment-psqlrc">
     <term><envar>PSQLRC</envar></term>
 
     <listitem>
@@ -4774,7 +4774,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="app-psql-environment-shell">
     <term><envar>SHELL</envar></term>
 
     <listitem>
@@ -4784,7 +4784,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
     </listitem>
    </varlistentry>
 
-   <varlistentry>
+   <varlistentry id="app-psql-environment-tmpdir">
     <term><envar>TMPDIR</envar></term>
 
     <listitem>
@@ -4809,7 +4809,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
   <title>Files</title>
 
  <variablelist>
-  <varlistentry>
+  <varlistentry id="app-psql-files-psqlrc">
    <term><filename>psqlrc</filename> and <filename>~/.psqlrc</filename></term>
    <listitem>
     <para>
@@ -4853,7 +4853,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
    </listitem>
   </varlistentry>
 
-  <varlistentry>
+  <varlistentry id="app-psql-files-psql_history">
    <term><filename>.psql_history</filename></term>
    <listitem>
     <para>
diff --git a/doc/src/sgml/ref/rollback.sgml b/doc/src/sgml/ref/rollback.sgml
index 142f71e774..833e8697a4 100644
--- a/doc/src/sgml/ref/rollback.sgml
+++ b/doc/src/sgml/ref/rollback.sgml
@@ -42,7 +42,7 @@ ROLLBACK [ WORK | TRANSACTION ] [ AND [ NO ] CHAIN ]
   </indexterm>
 
   <variablelist>
-   <varlistentry>
+   <varlistentry id="sql-rollback-transaction">
     <term><literal>WORK</literal></term>
     <term><literal>TRANSACTION</literal></term>
     <listitem>
diff --git a/doc/src/sgml/regress.sgml b/doc/src/sgml/regress.sgml
index 952139fc60..b1db526451 100644
--- a/doc/src/sgml/regress.sgml
+++ b/doc/src/sgml/regress.sgml
@@ -32,7 +32,7 @@
    interprocess communication and locking are working correctly.
   </para>
 
-  <sect2>
+  <sect2 id="regress-run-temp-inst">
    <title>Running the Tests Against a Temporary Installation</title>
 
   <para>
@@ -93,7 +93,7 @@ make MAX_CONNECTIONS=10 check
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="regress-run-existing-inst">
    <title>Running the Tests Against an Existing Installation</title>
 
   <para>
@@ -123,7 +123,7 @@ make installcheck-parallel
   </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="regress-run-additional-suites">
    <title>Additional Test Suites</title>
 
   <para>
@@ -319,7 +319,7 @@ make check-world PG_TEST_EXTRA='kerberos ldap ssl'
   </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="regress-run-locale">
    <title>Locale and Encoding</title>
 
    <para>
@@ -362,7 +362,7 @@ make check LANG=C ENCODING=EUC_JP
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="regress-run-custom-settings">
    <title>Custom Server Settings</title>
 
    <para>
@@ -388,7 +388,7 @@ make check EXTRA_REGRESS_OPTS="--temp-config=test_postgresql.conf"
    </para>
   </sect2>
 
-  <sect2>
+  <sect2 id="regress-run-extra-tests">
    <title>Extra Tests</title>
 
    <para>
@@ -452,7 +452,7 @@ make check EXTRA_TESTS=numeric_big
     <xref linkend="regress-variant"/> for details.
    </para>
 
-   <sect2>
+   <sect2 id="regress-evaluation-message-differences">
     <title>Error Message Differences</title>
 
     <para>
@@ -467,7 +467,7 @@ make check EXTRA_TESTS=numeric_big
     </para>
    </sect2>
 
-   <sect2>
+   <sect2 id="regress-evaluation-locale-differences">
     <title>Locale Differences</title>
 
     <para>
@@ -514,7 +514,7 @@ make check NO_LOCALE=1
     </para>
    </sect2>
 
-   <sect2>
+   <sect2 id="regress-evaluation-date-time-differences">
     <title>Date and Time Differences</title>
 
     <para>
@@ -528,7 +528,7 @@ make check NO_LOCALE=1
     </para>
    </sect2>
 
-   <sect2>
+   <sect2 id="regress-evaluation-float-differences">
     <title>Floating-Point Differences</title>
 
     <para>
@@ -556,7 +556,7 @@ make check NO_LOCALE=1
     </para>
    </sect2>
 
-   <sect2>
+   <sect2 id="regress-evaluation-ordering-differences">
     <title>Row Ordering Differences</title>
 
     <para>
@@ -592,7 +592,7 @@ exclusion of those that don't.
     </para>
    </sect2>
 
-   <sect2>
+   <sect2 id="regress-evaluation-stack-depth">
     <title>Insufficient Stack Depth</title>
 
     <para>
@@ -614,7 +614,7 @@ exclusion of those that don't.
     </para>
    </sect2>
 
-   <sect2>
+   <sect2 id="regress-evaluation-random-test">
     <title>The <quote>random</quote> Test</title>
 
     <para>
@@ -629,7 +629,7 @@ diff results/random.out expected/random.out
     </para>
    </sect2>
 
-   <sect2>
+   <sect2 id="regress-evaluation-config-params">
     <title>Configuration Parameters</title>
 
     <para>
diff --git a/doc/src/sgml/rowtypes.sgml b/doc/src/sgml/rowtypes.sgml
index 417ccb00de..4d86f97c03 100644
--- a/doc/src/sgml/rowtypes.sgml
+++ b/doc/src/sgml/rowtypes.sgml
@@ -91,7 +91,7 @@ CREATE TABLE inventory_item (
  </para>
  </sect2>
 
- <sect2>
+ <sect2 id="rowtypes-constructing">
   <title>Constructing Composite Values</title>
 
   <indexterm>
@@ -209,7 +209,7 @@ SELECT (my_func(...)).field FROM ...
  </para>
  </sect2>
 
- <sect2>
+ <sect2 id="rowtypes-modifying">
   <title>Modifying Composite Types</title>
 
  <para>
diff --git a/doc/src/sgml/rules.sgml b/doc/src/sgml/rules.sgml
index 4aa4e00e01..f688fbebbf 100644
--- a/doc/src/sgml/rules.sgml
+++ b/doc/src/sgml/rules.sgml
@@ -637,7 +637,7 @@ SELECT shoe_ready.shoename, shoe_ready.sh_avail,
    </para>
 </sect2>
 
-<sect2>
+<sect2 id="rules-views-non-select">
 <title>View Rules in Non-<command>SELECT</command> Statements</title>
 
 <para>
@@ -757,7 +757,7 @@ SELECT t1.a, t2.b, t1.ctid FROM t1, t2 WHERE t1.a = t2.a;
 </para>
 </sect2>
 
-<sect2>
+<sect2 id="rules-views-power">
 <title>The Power of Views in <productname>PostgreSQL</productname></title>
 
 <para>
@@ -1172,7 +1172,7 @@ SELECT word FROM words ORDER BY word &lt;-&gt; 'caterpiler' LIMIT 10;
  </para>
 </caution>
 
-<sect2>
+<sect2 id="rules-update-how">
 <title>How Update Rules Work</title>
 
 <para>
@@ -1296,7 +1296,7 @@ CREATE [ OR REPLACE ] RULE <replaceable class="parameter">name</replaceable> AS
     there is no need to apply update rules to the output of view rewriting.
 </para>
 
-<sect3>
+<sect3 id="rules-update-how-first">
 <title>A First Rule Step by Step</title>
 
 <para>
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index f77ed24204..bf4dc6a593 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -1237,7 +1237,7 @@ RemoveIPC=no
    </caution>
   </sect2>
 
-  <sect2>
+  <sect2 id="kernel-resources-limits">
    <title>Resource Limits</title>
 
    <para>
diff --git a/doc/src/sgml/seg.sgml b/doc/src/sgml/seg.sgml
index 9be69e3609..72387c7d45 100644
--- a/doc/src/sgml/seg.sgml
+++ b/doc/src/sgml/seg.sgml
@@ -20,7 +20,7 @@
   on the current database.
  </para>
 
- <sect2>
+ <sect2 id="seg-rationale">
   <title>Rationale</title>
 
   <para>
@@ -81,7 +81,7 @@ test=&gt; select '6.25 .. 6.50'::seg as "pH";
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="seg-syntax">
   <title>Syntax</title>
 
   <para>
@@ -220,7 +220,7 @@ test=&gt; select '6.25 .. 6.50'::seg as "pH";
 
  </sect2>
 
- <sect2>
+ <sect2 id="seg-precision">
   <title>Precision</title>
 
   <para>
@@ -239,7 +239,7 @@ test=&gt; select '6.25 .. 6.50'::seg as "pH";
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="seg-usage">
   <title>Usage</title>
 
   <para>
@@ -363,7 +363,7 @@ test=&gt; select '6.25 .. 6.50'::seg as "pH";
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="seg-notes">
   <title>Notes</title>
 
   <para>
@@ -392,7 +392,7 @@ postgres=&gt; select '10(+-)1'::seg as seg;
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="seg-credits">
   <title>Credits</title>
 
   <para>
diff --git a/doc/src/sgml/sepgsql.sgml b/doc/src/sgml/sepgsql.sgml
index 620d0636e8..fd4bb83cbf 100644
--- a/doc/src/sgml/sepgsql.sgml
+++ b/doc/src/sgml/sepgsql.sgml
@@ -315,7 +315,7 @@ $ sudo semodule -r sepgsql-regtest
 
  <sect2 id="sepgsql-features">
   <title>Features</title>
-  <sect3>
+  <sect3 id="sepgsql-features-controlled-obj-classes">
    <title>Controlled Object Classes</title>
    <para>
     The security model of <productname>SELinux</productname> describes all the access
@@ -348,7 +348,7 @@ $ sudo semodule -r sepgsql-regtest
    </para>
   </sect3>
 
-  <sect3>
+  <sect3 id="sepgsql-features-dml-permissions">
    <title>DML Permissions</title>
 
    <para>
@@ -432,7 +432,7 @@ UPDATE t1 SET x = 2, y = func1(y) WHERE z = 100;
    </para>
   </sect3>
 
-  <sect3>
+  <sect3 id="sepgsql-features-ddl-permissions">
    <title>DDL Permissions</title>
    <para>
     <productname>SELinux</productname> defines several permissions to control common
@@ -523,7 +523,7 @@ UPDATE t1 SET x = 2, y = func1(y) WHERE z = 100;
 
   </sect3>
 
-  <sect3>
+  <sect3 id="sepgsql-features-trusted-procedures">
    <title>Trusted Procedures</title>
    <para>
     Trusted procedures are similar to security definer functions or setuid
@@ -579,7 +579,7 @@ postgres=# SELECT cid, cname, show_credit(cid) FROM customer;
    </para>
   </sect3>
 
-  <sect3>
+  <sect3 id="sepgsql-features-dynamic-domain-transitions">
    <title>Dynamic Domain Transitions</title>
    <para>
     It is possible to use SELinux's dynamic domain transition feature
@@ -641,7 +641,7 @@ ERROR:  SELinux: security policy violation
    </para>
   </sect3>
 
-  <sect3>
+  <sect3 id="sepgsql-features-misc">
    <title>Miscellaneous</title>
    <para>
     We reject the <link linkend="sql-load"><command>LOAD</command></link> command across the board, because
diff --git a/doc/src/sgml/sources.sgml b/doc/src/sgml/sources.sgml
index 1b77efb087..c9a435e926 100644
--- a/doc/src/sgml/sources.sgml
+++ b/doc/src/sgml/sources.sgml
@@ -445,7 +445,7 @@ ereport(level, errmsg_internal("format string", ...));
     <productname>PostgreSQL</productname>.
    </para>
 
-  <simplesect>
+  <simplesect id="error-style-guide-what-goes-where">
    <title>What Goes Where</title>
 
    <para>
@@ -486,7 +486,7 @@ Hint:       the addendum
 
   </simplesect>
 
-  <simplesect>
+  <simplesect id="error-style-guide-formatting">
    <title>Formatting</title>
 
    <para>
@@ -507,7 +507,7 @@ Hint:       the addendum
 
   </simplesect>
 
-  <simplesect>
+  <simplesect id="error-style-guide-quotation-marks">
    <title>Quotation Marks</title>
 
    <para>
@@ -528,7 +528,7 @@ Hint:       the addendum
 
   </simplesect>
 
-  <simplesect>
+  <simplesect id="error-style-guide-quotes">
    <title>Use of Quotes</title>
 
    <para>
@@ -552,7 +552,7 @@ Hint:       the addendum
 
   </simplesect>
 
-  <simplesect>
+  <simplesect id="error-style-guide-grammar-punctuation">
    <title>Grammar and Punctuation</title>
 
    <para>
@@ -591,7 +591,7 @@ Hint:       the addendum
 
   </simplesect>
 
-  <simplesect>
+  <simplesect id="error-style-guide-case">
    <title>Upper Case vs. Lower Case</title>
 
    <para>
@@ -607,7 +607,7 @@ Hint:       the addendum
 
   </simplesect>
 
-  <simplesect>
+  <simplesect id="error-style-guide-passive-voice">
    <title>Avoid Passive Voice</title>
 
    <para>
@@ -623,7 +623,7 @@ Hint:       the addendum
 
   </simplesect>
 
-  <simplesect>
+  <simplesect id="error-style-guide-tense">
    <title>Present vs. Past Tense</title>
 
    <para>
@@ -663,7 +663,7 @@ cannot open file "%s"
 
   </simplesect>
 
-  <simplesect>
+  <simplesect id="error-style-guide-object-type">
    <title>Type of the Object</title>
 
    <para>
@@ -677,7 +677,7 @@ cannot open file "%s"
 
   </simplesect>
 
-  <simplesect>
+  <simplesect id="error-style-guide-brackets">
    <title>Brackets</title>
 
    <para>
@@ -692,7 +692,7 @@ cannot open file "%s"
 
   </simplesect>
 
-  <simplesect>
+  <simplesect id="error-style-guide-error-messages">
    <title>Assembling Error Messages</title>
 
    <para>
@@ -713,7 +713,7 @@ could not open file %s: %m
 
   </simplesect>
 
-  <simplesect>
+  <simplesect id="error-style-guide-error-reasons">
    <title>Reasons for Errors</title>
 
    <para>
@@ -728,7 +728,7 @@ BETTER: could not open file %s (I/O failure)
 
   </simplesect>
 
-  <simplesect>
+  <simplesect id="error-style-guide-function-names">
    <title>Function Names</title>
 
    <para>
@@ -760,7 +760,7 @@ BETTER: could not open file %s: %m
 
   </simplesect>
 
-  <simplesect>
+  <simplesect id="error-style-guide-tricky-words">
    <title>Tricky Words to Avoid</title>
 
   <formalpara>
@@ -846,7 +846,7 @@ BETTER: unrecognized node type: 42
 
   </simplesect>
 
-  <simplesect>
+  <simplesect id="error-style-guide-spelling">
    <title>Proper Spelling</title>
 
    <para>
@@ -886,7 +886,7 @@ BETTER: unrecognized node type: 42
 
   </simplesect>
 
-  <simplesect>
+  <simplesect id="error-style-guide-localization">
    <title>Localization</title>
 
    <para>
@@ -901,7 +901,7 @@ BETTER: unrecognized node type: 42
   <sect1 id="source-conventions">
    <title>Miscellaneous Coding Conventions</title>
 
-   <simplesect>
+   <simplesect id="source-conventions-c-standard">
     <title>C Standard</title>
     <para>
      Code in <productname>PostgreSQL</productname> should only rely on language
@@ -932,7 +932,7 @@ BETTER: unrecognized node type: 42
     </para>
    </simplesect>
 
-   <simplesect>
+   <simplesect id="source-conventions-macros-inline">
     <title>Function-Like Macros and Inline Functions</title>
     <para>
      Both, macros with arguments and <literal>static inline</literal>
@@ -971,7 +971,7 @@ MemoryContextSwitchTo(MemoryContext context)
     </para>
    </simplesect>
 
-   <simplesect>
+   <simplesect id="source-conventions-signal-handlers">
     <title>Writing Signal Handlers</title>
     <para>
      To be suitable to run inside a signal handler code has to be
@@ -1013,7 +1013,7 @@ handle_sighup(SIGNAL_ARGS)
     </para>
    </simplesect>
 
-   <simplesect>
+   <simplesect id="source-conventions-function-pointers">
     <title>Calling Function Pointers</title>
 
     <para>
diff --git a/doc/src/sgml/sslinfo.sgml b/doc/src/sgml/sslinfo.sgml
index 2a9c45a111..786f113072 100644
--- a/doc/src/sgml/sslinfo.sgml
+++ b/doc/src/sgml/sslinfo.sgml
@@ -25,7 +25,7 @@
   configured with <literal>--with-ssl=openssl</literal>.
  </para>
 
- <sect2>
+ <sect2 id="sslinfo-functions">
   <title>Functions Provided</title>
 
   <variablelist>
@@ -243,7 +243,7 @@ emailAddress
   </variablelist>
  </sect2>
 
- <sect2>
+ <sect2 id="sslinfo-author">
   <title>Author</title>
 
   <para>
diff --git a/doc/src/sgml/stylesheet-html-common.xsl b/doc/src/sgml/stylesheet-html-common.xsl
index 9df2782ce4..111b03d6fc 100644
--- a/doc/src/sgml/stylesheet-html-common.xsl
+++ b/doc/src/sgml/stylesheet-html-common.xsl
@@ -301,4 +301,115 @@ set       toc,title
   </xsl:choose>
 </xsl:template>
 
+
+<!-- Overridden template to add links to ids in varlists -->
+<xsl:template match="varlistentry">
+  <dt>
+    <xsl:call-template name="id.attribute"/>
+    <xsl:call-template name="anchor"/>
+    <xsl:apply-templates select="term"/>
+    <xsl:call-template name="pg.id.link"/>
+  </dt>
+  <dd>
+    <xsl:apply-templates select="listitem"/>
+  </dd>
+</xsl:template>
+
+<!-- Overridden template to add links to ids in sections -->
+<xsl:template name="section.heading">
+  <xsl:param name="section" select="."/>
+  <xsl:param name="level" select="1"/>
+  <xsl:param name="allow-anchors" select="1"/>
+  <xsl:param name="title"/>
+  <xsl:param name="class" select="'title'"/>
+
+  <xsl:variable name="id">
+    <xsl:choose>
+      <!-- Make sure the subtitle doesn't get the same id as the title -->
+      <xsl:when test="self::subtitle">
+        <xsl:call-template name="object.id">
+          <xsl:with-param name="object" select="."/>
+        </xsl:call-template>
+      </xsl:when>
+      <!-- if title is in an *info wrapper, get the grandparent -->
+      <xsl:when test="contains(local-name(..), 'info')">
+        <xsl:call-template name="object.id">
+          <xsl:with-param name="object" select="../.."/>
+        </xsl:call-template>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:call-template name="object.id">
+          <xsl:with-param name="object" select=".."/>
+        </xsl:call-template>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <!-- HTML H level is one higher than section level -->
+  <xsl:variable name="hlevel">
+    <xsl:choose>
+      <!-- highest valid HTML H level is H6; so anything nested deeper
+           than 5 levels down just becomes H6 -->
+      <xsl:when test="$level &gt; 5">6</xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$level + 1"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:element name="h{$hlevel}" namespace="http://www.w3.org/1999/xhtml">
+    <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+    <xsl:if test="$css.decoration != '0'">
+      <xsl:if test="$hlevel&lt;3">
+        <xsl:attribute name="style">clear: both</xsl:attribute>
+      </xsl:if>
+    </xsl:if>
+    <xsl:if test="$allow-anchors != 0">
+      <xsl:call-template name="anchor">
+        <xsl:with-param name="node" select="$section"/>
+        <xsl:with-param name="conditional" select="0"/>
+      </xsl:call-template>
+    </xsl:if>
+    <xsl:copy-of select="$title"/>
+    <xsl:call-template name="pg.id.link">
+      <xsl:with-param name="object" select="$section"/>
+    </xsl:call-template>
+  </xsl:element>
+</xsl:template>
+
+<!-- Creates a link pointing to an id within the document -->
+<xsl:template name="pg.id.link">
+  <xsl:param name="object" select="."/>
+  <xsl:choose>
+    <xsl:when test="$object/@id or $object/@xml:id">
+      <a>
+        <xsl:attribute name="href">
+          <xsl:text>#</xsl:text>
+          <xsl:call-template name="object.id">
+            <xsl:with-param name="object" select="$object"/>
+          </xsl:call-template>
+        </xsl:attribute>
+        <xsl:attribute name="class">
+          <xsl:text>id_link</xsl:text>
+        </xsl:attribute>
+        <xsl:text> #</xsl:text>
+      </a>
+    </xsl:when>
+    <xsl:otherwise>
+      <!-- Only complain about varlistentries if at least one entry in the list has an id -->
+      <xsl:if test="name($object) != 'varlistentry' or $object/parent::variablelist/varlistentry[@id]">
+        <xsl:message terminate="no">
+          <xsl:value-of select ="name($object)"/>
+          <xsl:text> element without id. Please add an id to make it usable</xsl:text>
+          <xsl:text> as stable anchor in the public HTML documentation.</xsl:text>
+        </xsl:message>
+        <xsl:comment>
+          <xsl:text>Please add an id to the </xsl:text>
+          <xsl:value-of select ="name($object)"/>
+          <xsl:text> element in the sgml source code.</xsl:text>
+        </xsl:comment>
+      </xsl:if>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
 </xsl:stylesheet>
diff --git a/doc/src/sgml/stylesheet.css b/doc/src/sgml/stylesheet.css
index 6410a47958..e4174e0613 100644
--- a/doc/src/sgml/stylesheet.css
+++ b/doc/src/sgml/stylesheet.css
@@ -163,3 +163,13 @@ acronym		{ font-style: inherit; }
     width: 75%;
   }
 }
+
+/* Links to ids of headers and definition terms */
+a.id_link {
+        color: inherit;
+        visibility: hidden;
+}
+
+*:hover > a.id_link {
+        visibility: visible;
+}
diff --git a/doc/src/sgml/tablefunc.sgml b/doc/src/sgml/tablefunc.sgml
index 808162b89b..acc9236a48 100644
--- a/doc/src/sgml/tablefunc.sgml
+++ b/doc/src/sgml/tablefunc.sgml
@@ -20,7 +20,7 @@
   on the current database.
  </para>
 
- <sect2>
+ <sect2 id="tablefunc-functions-sect">
   <title>Functions Provided</title>
 
   <para>
@@ -119,7 +119,7 @@
     </tgroup>
   </table>
 
-  <sect3>
+  <sect3 id="tablefunc-functions-normal_rand">
    <title><function>normal_rand</function></title>
 
    <indexterm>
@@ -166,7 +166,7 @@ test=# SELECT * FROM normal_rand(1000, 5, 3);
 </screen>
   </sect3>
 
-  <sect3>
+  <sect3 id="tablefunc-functions-crosstab-text">
    <title><function>crosstab(text)</function></title>
 
    <indexterm>
@@ -325,7 +325,7 @@ AS ct(row_name text, category_1 text, category_2 text, category_3 text);
 
   </sect3>
 
-  <sect3>
+  <sect3 id="tablefunc-functions-crosstab-n-text">
    <title><function>crosstab<replaceable>N</replaceable>(text)</function></title>
 
    <indexterm>
@@ -436,7 +436,7 @@ CREATE OR REPLACE FUNCTION crosstab_float8_5_cols(
 
   </sect3>
 
-  <sect3>
+  <sect3 id="tablefunc-functions-crosstab-text-2">
    <title><function>crosstab(text, text)</function></title>
 
    <indexterm>
@@ -646,7 +646,7 @@ AS
 
   </sect3>
 
-  <sect3>
+  <sect3 id="tablefunc-functions-connectby">
    <title><function>connectby</function></title>
 
    <indexterm>
@@ -853,7 +853,7 @@ SELECT * FROM connectby('connectby_tree', 'keyid', 'parent_keyid', 'pos', 'row2'
 
  </sect2>
 
- <sect2>
+ <sect2 id="tablefunc-author">
   <title>Author</title>
 
   <para>
diff --git a/doc/src/sgml/tsm-system-rows.sgml b/doc/src/sgml/tsm-system-rows.sgml
index d960aa3e0f..f5357791c0 100644
--- a/doc/src/sgml/tsm-system-rows.sgml
+++ b/doc/src/sgml/tsm-system-rows.sgml
@@ -39,7 +39,7 @@
   on the current database.
  </para>
 
- <sect2>
+ <sect2 id="tsm-system-rows-examples">
   <title>Examples</title>
 
   <para>
diff --git a/doc/src/sgml/tsm-system-time.sgml b/doc/src/sgml/tsm-system-time.sgml
index df6e83a923..0de15ae7e8 100644
--- a/doc/src/sgml/tsm-system-time.sgml
+++ b/doc/src/sgml/tsm-system-time.sgml
@@ -41,7 +41,7 @@
   on the current database.
  </para>
 
- <sect2>
+ <sect2 id="tsm-system-time-examples">
   <title>Examples</title>
 
   <para>
diff --git a/doc/src/sgml/unaccent.sgml b/doc/src/sgml/unaccent.sgml
index 5cd716a2aa..139a87d4ff 100644
--- a/doc/src/sgml/unaccent.sgml
+++ b/doc/src/sgml/unaccent.sgml
@@ -27,7 +27,7 @@
   on the current database.
  </para>
 
- <sect2>
+ <sect2 id="unaccent-configuration">
   <title>Configuration</title>
 
   <para>
@@ -107,7 +107,7 @@
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="unaccent-usage">
   <title>Usage</title>
 
   <para>
@@ -165,7 +165,7 @@ mydb=# select ts_headline('fr','H&ocirc;tel de la Mer',to_tsquery('fr','Hotels')
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="unaccent-functions">
  <title>Functions</title>
 
  <para>
diff --git a/doc/src/sgml/uuid-ossp.sgml b/doc/src/sgml/uuid-ossp.sgml
index 359d3c0128..b2fdc5291f 100644
--- a/doc/src/sgml/uuid-ossp.sgml
+++ b/doc/src/sgml/uuid-ossp.sgml
@@ -22,7 +22,7 @@
   on the current database.
  </para>
 
- <sect2>
+ <sect2 id="uuid-ossp-functions-sect">
   <title><literal>uuid-ossp</literal> Functions</title>
 
   <para>
@@ -205,7 +205,7 @@ SELECT uuid_generate_v3(uuid_ns_url(), 'http://www.postgresql.org');
   </table>
  </sect2>
 
- <sect2>
+ <sect2 id="uuid-ossp-building">
   <title>Building <filename>uuid-ossp</filename></title>
 
   <para>
@@ -230,7 +230,7 @@ SELECT uuid_generate_v3(uuid_ns_url(), 'http://www.postgresql.org');
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="uuid-ossp-author">
   <title>Author</title>
 
   <para>
diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml
index a34723030b..32dfaa6d5f 100644
--- a/doc/src/sgml/xfunc.sgml
+++ b/doc/src/sgml/xfunc.sgml
@@ -1464,7 +1464,7 @@ SELECT concat_values('|', 1, 4, 2);
     </para>
    </sect2>
 
-   <sect2>
+   <sect2 id="xfunc-sql-collations">
     <title><acronym>SQL</acronym> Functions with Collations</title>
 
     <indexterm>
@@ -2355,7 +2355,7 @@ memcpy(destination->data, buffer, 40);
     </para>
    </sect2>
 
-   <sect2>
+   <sect2 id="xfunc-c-v1-call-conv">
     <title>Version 1 Calling Conventions</title>
 
     <para>
@@ -2605,7 +2605,7 @@ CREATE FUNCTION concat_text(text, text) RETURNS text
     </para>
    </sect2>
 
-   <sect2>
+   <sect2 id="xfunc-c-code">
     <title>Writing Code</title>
 
     <para>
@@ -2712,7 +2712,7 @@ CREATE FUNCTION concat_text(text, text) RETURNS text
 
 &dfunc;
 
-   <sect2>
+   <sect2 id="xfunc-c-composite-type-args">
     <title>Composite-Type Arguments</title>
 
     <para>
@@ -2800,7 +2800,7 @@ CREATE FUNCTION c_overpaid(emp, integer) RETURNS boolean
     </para>
    </sect2>
 
-   <sect2>
+   <sect2 id="xfunc-c-returning-rows">
     <title>Returning Rows (Composite Types)</title>
 
     <para>
@@ -3295,7 +3295,7 @@ CREATE OR REPLACE FUNCTION retcomposite(IN integer, IN integer,
     </para>
    </sect2>
 
-   <sect2>
+   <sect2 id="xfunc-c-polymorphic">
     <title>Polymorphic Arguments and Return Types</title>
 
     <para>
diff --git a/doc/src/sgml/xml2.sgml b/doc/src/sgml/xml2.sgml
index 584bb3e923..e450accb0f 100644
--- a/doc/src/sgml/xml2.sgml
+++ b/doc/src/sgml/xml2.sgml
@@ -12,7 +12,7 @@
   XSLT functionality.
  </para>
 
- <sect2>
+ <sect2 id="xml2-deprecation">
   <title>Deprecation Notice</title>
 
   <para>
@@ -30,7 +30,7 @@
   </para>
  </sect2>
 
- <sect2>
+ <sect2 id="xml2-functions">
   <title>Description of Functions</title>
 
   <para>
@@ -168,7 +168,7 @@
   </table>
  </sect2>
 
- <sect2>
+ <sect2 id="xml2-xpath_table-">
   <title><literal>xpath_table</literal></title>
 
   <indexterm>
@@ -318,7 +318,7 @@ WHERE t.author_id = p.person_id;
    of this in a view for convenience.
   </para>
 
-  <sect3>
+  <sect3 id="xml2-xpath_table-multivalued-results">
    <title>Multivalued Results</title>
 
    <para>
@@ -393,14 +393,14 @@ ORDER BY doc_num, line_num;
   </sect3>
  </sect2>
 
- <sect2>
+ <sect2 id="xml2-xslt">
   <title>XSLT Functions</title>
 
   <para>
    The following functions are available if libxslt is installed:
   </para>
 
-  <sect3>
+  <sect3 id="xml2-xslt-xslt_process">
    <title><literal>xslt_process</literal></title>
 
   <indexterm>
@@ -427,7 +427,7 @@ xslt_process(text document, text stylesheet, text paramlist) returns text
   </sect3>
  </sect2>
 
- <sect2>
+ <sect2 id="xml2-author">
   <title>Author</title>
 
   <para>
diff --git a/doc/src/sgml/xoper.sgml b/doc/src/sgml/xoper.sgml
index 98f4c5c4aa..a929ced07d 100644
--- a/doc/src/sgml/xoper.sgml
+++ b/doc/src/sgml/xoper.sgml
@@ -109,7 +109,7 @@ SELECT (a + b) AS c FROM test_complex;
     See <xref linkend="xfunc-optimization"/> for more information.
    </para>
 
-   <sect2>
+   <sect2 id="xoper-commutator">
     <title><literal>COMMUTATOR</literal></title>
 
     <para>
@@ -186,7 +186,7 @@ SELECT (a + b) AS c FROM test_complex;
     </para>
    </sect2>
 
-   <sect2>
+   <sect2 id="xoper-negator">
     <title><literal>NEGATOR</literal></title>
 
     <para>
@@ -225,7 +225,7 @@ SELECT (a + b) AS c FROM test_complex;
 
   </sect2>
 
-  <sect2>
+  <sect2 id="xoper-restrict">
    <title><literal>RESTRICT</literal></title>
 
    <para>
@@ -302,7 +302,7 @@ column OP constant
    </para>
    </sect2>
 
-   <sect2>
+   <sect2 id="xoper-join">
     <title><literal>JOIN</literal></title>
 
     <para>
@@ -339,7 +339,7 @@ table1.column1 OP table2.column2
     </para>
    </sect2>
 
-   <sect2>
+   <sect2 id="xoper-hashes">
     <title><literal>HASHES</literal></title>
 
     <para>
@@ -427,7 +427,7 @@ table1.column1 OP table2.column2
 
    </sect2>
 
-   <sect2>
+   <sect2 id="xoper-merges">
     <title><literal>MERGES</literal></title>
 
     <para>
#35Brar Piening
brar@gmx.de
In reply to: Brar Piening (#34)
Re: Add id's to various elements in protocol.sgml

On 09.03.2022 at 20:43, Brar Piening wrote:

Attached is a pretty huge patch that adds ids to all sections and all
the varlistentries where the containing variablelist already had at
least one id (plus a few additional ones that I stumbled upon and
deemed useful). It also adds html links next to the respective heading
in the html documentation and emits a build message and a comment when
a section or a relevant (see before) varlistentry doesn't have an id.

I have uploaded a doc build with the patch applied to
https://pgdocs.piening.info/ to make it easier for you all to review the
results and see what is there and what isn't and how it feels UI-wise.

You may want to look at https://pgdocs.piening.info/app-psql.html where
the patch adds ids and links to all varlistentries but doesn't do so for
the headings (because they are refsect1 headings not sect1 headings).

https://pgdocs.piening.info/protocol-flow.html is pretty much the
opposite. The patch adds ids and links to the headings (they are sect2
headings) but doesn't add them to the varlistentries (yet - because I
mostly sticked to the algorithm suggested at
/messages/by-id/621FAF40.5070507@anastigmatix.net
to contain the workload).