pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #19739: Parameterized first autocommit statement can have different `transaction_timestamp()` and `statement
2+ messages / 2 participants
[nested] [flat]

* BUG #19739: Parameterized first autocommit statement can have different `transaction_timestamp()` and `statement
@ 2026-10-02 22:37 PG Bug reporting form <noreply@postgresql.org>
  2026-10-03 21:58 ` Re: BUG #19739: Parameterized first autocommit statement can have different `transaction_timestamp()` and `statement Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2026-10-02 22:37 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: theshallow27@gmail.com

The following bug has been logged on the website:

Bug reference:      19739
Logged by:          Shallow
Email address:      theshallow27@gmail.com
PostgreSQL version: 18.6
Operating system:   Linux
Description:        

The documentation says `transaction_timestamp()` and
`statement_timestamp()` return the same value during the first statement of
a
transaction. With a parameterized query executed as the first command on a
fresh autocommit connection, they differ. The same query without parameters
returns equality. Parameterized execution uses the extended query protocol,
so
this may expose a distinction between Parse/Bind/Execute message timing and
the documented “first statement” guarantee.

**Reproduction:** Using Psycopg with autocommit enabled on a fresh
connection:

```python
cur.execute(
    "SELECT transaction_timestamp() = statement_timestamp() WHERE %s::int =
0",
    (0,),
)
print(cur.fetchone())  # (False,)
```

Control query on a fresh autocommit connection:

```sql
SELECT transaction_timestamp() = statement_timestamp(); -- true
```

**Expected result:** The parameterized query, as the first SQL statement in
an
implicit transaction, should return `true`; alternatively, the documentation
should clarify how extended-protocol messages affect the guarantee.







^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #19739: Parameterized first autocommit statement can have different `transaction_timestamp()` and `statement
  2026-10-02 22:37 BUG #19739: Parameterized first autocommit statement can have different `transaction_timestamp()` and `statement PG Bug reporting form <noreply@postgresql.org>
@ 2026-10-03 21:58 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2026-10-03 21:58 UTC (permalink / raw)
  To: theshallow27@gmail.com; +Cc: pgsql-bugs@lists.postgresql.org

PG Bug reporting form <noreply@postgresql.org> writes:
> The documentation says `transaction_timestamp()` and
> `statement_timestamp()` return the same value during the first statement of
> a
> transaction. With a parameterized query executed as the first command on a
> fresh autocommit connection, they differ.

Strictly speaking, that depends on which steps of an extended-protocol
query count as separate statements.  But I don't think we're going to
modify this documentation to dive into details as abstruse as that;
it would merely confuse the same people the comment is meant to help.

			regards, tom lane






^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-10-03 21:58 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-10-02 22:37 BUG #19739: Parameterized first autocommit statement can have different `transaction_timestamp()` and `statement PG Bug reporting form <noreply@postgresql.org>
2026-10-03 21:58 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox