Add comment explaining why queryid is int64 in pg_stat_statements

From: Shaik Mohammad Mujeeb <mujeeb(dot)sk(at)zohocorp(dot)com>
To: "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org>
Cc: "mujeebskdev" <mujeeb(dot)sk(dot)dev(at)gmail(dot)com>, "pgsql-hackers" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Add comment explaining why queryid is int64 in pg_stat_statements
Date: 2025-05-15 07:08:10
Message-ID: 196d2c5a3b2.3ca51b1d13056.5169656769048887404@zohocorp.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Attachment Content-Type Size
add_comment_for_why_queryid_is_int64.patch application/octet-stream 593 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrei Lepikhov 2025-05-15 07:54:35 Re: Should we optimize the `ORDER BY random() LIMIT x` case?
Previous Message Peter Smith 2025-05-15 06:57:00 Re: Logical Replication of sequences