Doc: clarify description of current-date/time functions.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 15 Jul 2025 20:35:42 +0000 (16:35 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 15 Jul 2025 20:36:18 +0000 (16:36 -0400)
Minor wordsmithing of the func.sgml paragraph describing
statement_timestamp() and allied functions: don't switch between
"statement" and "command" when those are being used to mean about
the same thing.

Also, add some text to protocol.sgml describing the perhaps-surprising
behavior these functions have in a multi-statement Query message.

Reported-by: P M <petermittere@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Laurenz Albe <laurenz.albe@cybertec.at>
Reviewed-by: David G. Johnston <david.g.johnston@gmail.com>
Discussion: http://postgr.es/m/175223006802.3157505.14764328206246105568@wrigleys.postgresql.org
Backpatch-through: 13

doc/src/sgml/func.sgml
doc/src/sgml/protocol.sgml

index e2bc769e50ba1a665383a6d86487146f91c33a61..db22327ac12611df03b492b5557c5aa5407b8fd3 100644 (file)
@@ -10689,10 +10689,10 @@ now()
     statement (more specifically, the time of receipt of the latest command
     message from the client).
     <function>statement_timestamp()</function> and <function>transaction_timestamp()</function>
-    return the same value during the first command of a transaction, but might
-    differ during subsequent commands.
+    return the same value during the first statement of a transaction, but might
+    differ during subsequent statements.
     <function>clock_timestamp()</function> returns the actual current time, and
-    therefore its value changes even within a single SQL command.
+    therefore its value changes even within a single SQL statement.
     <function>timeofday()</function> is a historical
     <productname>PostgreSQL</productname> function.  Like
     <function>clock_timestamp()</function>, it returns the actual current time,
index fdf34eba10cd396aaa4df05c0c9e2ad0aa6fd91f..e030b55186cb44f2e5d443fce6ea467c8ae8f020 100644 (file)
@@ -818,6 +818,16 @@ SELCT 1/0;<!-- this typo is intentional -->
      Errors detected at semantic analysis or later, such as a misspelled
      table or column name, do not have this effect.
     </para>
+
+    <para>
+     Lastly, note that all the statements within the Query message will
+     observe the same value of <function>statement_timestamp()</function>,
+     since that timestamp is updated only upon receipt of the Query
+     message.  This will result in them all observing the same
+     value of <function>transaction_timestamp()</function> as well,
+     except in cases where the query string ends a previously-started
+     transaction and begins a new one.
+    </para>
    </sect3>
   </sect2>