OSDN Git Service

Return null in queryid/planid when privilege insifficiency
authorKyotaro Horiguchi <horikyota.ntt@gmail.com>
Wed, 12 Jan 2022 07:58:35 +0000 (16:58 +0900)
committerKyotaro Horiguchi <horikyota.ntt@gmail.com>
Mon, 17 Jan 2022 02:47:26 +0000 (11:47 +0900)
The fields returned zeroes but null is appropriate.  I think
compatibility won't be issue since that field anyway cannot match
meaningful pg_stat_statements field.

pg_store_plans.c

index 629eb7e..71297b6 100644 (file)
@@ -1471,15 +1471,19 @@ pg_store_plans_internal(FunctionCallInfo fcinfo,
                {
                        values[i++] = Int64GetDatumFast(queryid);
                        values[i++] = Int64GetDatumFast(planid);
+
+                       /* fill queryid_stat_statements with the same value with queryid */
                        if (api_version == PGSP_V1_5)
-                               values[i++] = ObjectIdGetDatum(queryid);
+                               values[i++] = Int64GetDatumFast(queryid);
                }
                else
                {
-                       values[i++] = Int64GetDatumFast(0);
-                       values[i++] = Int64GetDatumFast(0);
+                       nulls[i++] = true;      /* queryid */
+                       nulls[i++] = true;      /* planid */
+
+                       /* queryid_stat_statemetns*/
                        if (api_version == PGSP_V1_5)
-                               values[i++] = Int64GetDatumFast(0);
+                               nulls[i++] = true;
                }
 
                if (is_allowed_role || entry->key.userid == userid)