Strange code in EXPLAIN for queryid

Started by David Rowleyover 5 years ago3 messageshackers
Jump to latest
#1David Rowley
dgrowleyml@gmail.com

I was wondering about the following code in explain.c

char buf[MAXINT8LEN + 1];

pg_lltoa(plannedstmt->queryId, buf);
ExplainPropertyText("Query Identifier", buf, es);

I thought it was a bit strange that we don't just use
ExplainPropertyInteger() instead of going to the trouble of building
the string with pg_lltoa().

On looking a little closer I also saw that plannedstmt->queryId is a
uint64. I guess that we're showing this as an int64 so that it
matches the queryid column in the pg_stat_statements view? If so, I
think it's worth a comment to mention why we're not using
ExplainPropertyUInteger.

Any objection to applying the attached to pg14 and master?

David

Attachments:

clarify_why_queryid_is_signed_rather_than_unsigned.patchapplication/octet-stream; name=clarify_why_queryid_is_signed_rather_than_unsigned.patchDownload+6-4
#2Julien Rouhaud
rjuju123@gmail.com
In reply to: David Rowley (#1)
Re: Strange code in EXPLAIN for queryid

On Sun, Aug 08, 2021 at 11:56:41PM +1200, David Rowley wrote:

On looking a little closer I also saw that plannedstmt->queryId is a
uint64. I guess that we're showing this as an int64 so that it
matches the queryid column in the pg_stat_statements view?

The only reason we display it as an int64 rather than a uint64 is because
the SQL standard doesn't define such a type, and using numeric would add
useless overhead.

Any objection to applying the attached to pg14 and master?

No objection.

#3David Rowley
dgrowleyml@gmail.com
In reply to: Julien Rouhaud (#2)
Re: Strange code in EXPLAIN for queryid

On Mon, 9 Aug 2021 at 02:06, Julien Rouhaud <rjuju123@gmail.com> wrote:

Any objection to applying the attached to pg14 and master?

No objection.

Thanks for looking. I've now pushed this to master and pg14.

David