Thread: Strange code in EXPLAIN for queryid

Strange code in EXPLAIN for queryid

From
David Rowley
Date:
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

Attachment

Re: Strange code in EXPLAIN for queryid

From
Julien Rouhaud
Date:
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.



Re: Strange code in EXPLAIN for queryid

From
David Rowley
Date:
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