Use ExplainPropertyInteger for queryid in EXPLAIN
authorDavid Rowley <drowley@postgresql.org>
Mon, 9 Aug 2021 03:47:00 +0000 (15:47 +1200)
committerDavid Rowley <drowley@postgresql.org>
Mon, 9 Aug 2021 03:47:23 +0000 (15:47 +1200)
This saves a few lines of code.  Also add a comment to mention why we use
ExplainPropertyInteger instead of ExplainPropertyUInteger given that
queryid is a uint64 type.

Author: David Rowley
Reviewed-by: Julien Rouhaud
Discussion: https://postgr.es/m/CAApHDvqhSLYpSU_EqUdN39w9Uvb8ogmHV7_3YhJ0S3aScGBjsg@mail.gmail.com
Backpatch-through: 14, where this code was originally added

src/backend/commands/explain.c

index 36fbe129cf47b8bbed4d13e95f93560421bdd183..10644dfac44ef0aa65706747ebab024daf9dc056 100644 (file)
@@ -606,10 +606,12 @@ ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es,
 
    if (es->verbose && plannedstmt->queryId != UINT64CONST(0))
    {
-       char        buf[MAXINT8LEN + 1];
-
-       pg_lltoa(plannedstmt->queryId, buf);
-       ExplainPropertyText("Query Identifier", buf, es);
+       /*
+        * Output the queryid as an int64 rather than a uint64 so we match
+        * what would be seen in the BIGINT pg_stat_statements.queryid column.
+        */
+       ExplainPropertyInteger("Query Identifier", NULL, (int64)
+                              plannedstmt->queryId, es);
    }
 
    /* Show buffer usage in planning */