pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: theshallow27@gmail.com
Subject: BUG #19739: Parameterized first autocommit statement can have different `transaction_timestamp()` and `statement
Date: Fri, 02 Oct 2026 22:37:31 +0000
Message-ID: <19739-bdca3e8fd9b496fa@postgresql.org> (raw)

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.







view thread (2+ messages)  latest in thread

Message-ID: <19739-bdca3e8fd9b496fa@postgresql.org>
Permalink:  ../19739-bdca3e8fd9b496fa@postgresql.org/
Also on:    postgresql.org/message-id/19739-bdca3e8fd9b496fa@postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, theshallow27@gmail.com
  Subject: Re: BUG #19739: Parameterized first autocommit statement can have different `transaction_timestamp()` and `statement
  In-Reply-To: <19739-bdca3e8fd9b496fa@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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