Skip to content

Commit c33e55a

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 8bd92fc commit c33e55a

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
@@ -11247,10 +11247,10 @@ now()
1124711247
statement (more specifically, the time of receipt of the latest command
1124811248
message from the client).
1124911249
<function>statement_timestamp()</function> and <function>transaction_timestamp()</function>
11250-
return the same value during the first command of a transaction, but might
11251-
differ during subsequent commands.
11250+
return the same value during the first statement of a transaction, but might
11251+
differ during subsequent statements.
1125211252
<function>clock_timestamp()</function> returns the actual current time, and
11253-
therefore its value changes even within a single SQL command.
11253+
therefore its value changes even within a single SQL statement.
1125411254
<function>timeofday()</function> is a historical
1125511255
<productname>PostgreSQL</productname> function. Like
1125611256
<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
@@ -886,6 +886,16 @@ SELCT 1/0;<!-- this typo is intentional -->
886886
Errors detected at semantic analysis or later, such as a misspelled
887887
table or column name, do not have this effect.
888888
</para>
889+
890+
<para>
891+
Lastly, note that all the statements within the Query message will
892+
observe the same value of <function>statement_timestamp()</function>,
893+
since that timestamp is updated only upon receipt of the Query
894+
message. This will result in them all observing the same
895+
value of <function>transaction_timestamp()</function> as well,
896+
except in cases where the query string ends a previously-started
897+
transaction and begins a new one.
898+
</para>
889899
</sect3>
890900
</sect2>
891901

0 commit comments

Comments
 (0)