Skip to content

Commit bdb052f

Browse files
committed
Doc: clarify description of current-date/time functions.
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: https://postgr.es/m/175223006802.3157505.14764328206246105568@wrigleys.postgresql.org Backpatch-through: 13
1 parent 50959f9 commit bdb052f

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

doc/src/sgml/func.sgml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11024,10 +11024,10 @@ now()
1102411024
statement (more specifically, the time of receipt of the latest command
1102511025
message from the client).
1102611026
<function>statement_timestamp()</function> and <function>transaction_timestamp()</function>
11027-
return the same value during the first command of a transaction, but might
11028-
differ during subsequent commands.
11027+
return the same value during the first statement of a transaction, but might
11028+
differ during subsequent statements.
1102911029
<function>clock_timestamp()</function> returns the actual current time, and
11030-
therefore its value changes even within a single SQL command.
11030+
therefore its value changes even within a single SQL statement.
1103111031
<function>timeofday()</function> is a historical
1103211032
<productname>PostgreSQL</productname> function. Like
1103311033
<function>clock_timestamp()</function>, it returns the actual current time,

doc/src/sgml/protocol.sgml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,16 @@ SELCT 1/0;<!-- this typo is intentional -->
800800
Errors detected at semantic analysis or later, such as a misspelled
801801
table or column name, do not have this effect.
802802
</para>
803+
804+
<para>
805+
Lastly, note that all the statements within the Query message will
806+
observe the same value of <function>statement_timestamp()</function>,
807+
since that timestamp is updated only upon receipt of the Query
808+
message. This will result in them all observing the same
809+
value of <function>transaction_timestamp()</function> as well,
810+
except in cases where the query string ends a previously-started
811+
transaction and begins a new one.
812+
</para>
803813
</sect3>
804814
</sect2>
805815

0 commit comments

Comments
 (0)