Add comment explaining why queryid is int64 in pg_stat_statements
Shaik Mohammad Mujeeb <mujeeb.sk@zohocorp.com>
From: Shaik Mohammad Mujeeb <mujeeb.sk@zohocorp.com>
To: "pgsql-hackers" <pgsql-hackers@postgresql.org>
Cc: "mujeebskdev" <mujeeb.sk.dev@gmail.com>, "pgsql-hackers" <pgsql-hackers@lists.postgresql.org>
Date: 2025-05-15T07:08:10Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Change internal plan ID type from uint64 to int64
- e050af28686e 18.0 landed
-
Change internal queryid type from uint64 to int64
- c3eda50b0648 18.0 landed
-
pg_stat_statements: Widen query IDs from 32 bits to 64 bits.
- cff440d36869 11.0 cited
Attachments
- add_comment_for_why_queryid_is_int64.patch (application/octet-stream) patch
Hi Developers, In pg_stat_statements.c, the function pg_stat_statements_internal() declares the queryid variable as int64, but assigns it a value of type uint64. At first glance, this might appear to be an overflow issue. However, I think this is intentional - the queryid is cast to int64 to match the bigint type of the queryid column in the pg_stat_statements view. Please find the attached patch, which adds a clarifying comment to make the rationale explicit and avoid potential confusion for future readers. Thanks and Regards, Shaik Mohammad Mujeeb Member Technical Staff Zoho Corp