BUG #19739: Parameterized first autocommit statement can have different `transaction_timestamp()` and `statement

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: theshallow27(at)gmail(dot)com
Subject: BUG #19739: Parameterized first autocommit statement can have different `transaction_timestamp()` and `statement
Date: 2026-10-02 22:37:31
Message-ID: 19739-bdca3e8fd9b496fa@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 19739
Logged by: Shallow
Email address: theshallow27(at)gmail(dot)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.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2026-10-02 22:38:00 BUG #19740: `has_language_privilege` returns TRUE for a nonexistent language OID when the user is a superuser
Previous Message PG Bug reporting form 2026-10-02 22:36:49 BUG #19738: `uuidv7(interval)` rejects sub-millisecond timestamps within the final 48-bit millisecond