aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2023-08-27 17:27:44 +0900
committerMichael Paquier <michael@paquier.xyz>2023-08-27 17:27:44 +0900
commitbb45156f342c2cdb88cdd7f9efdc4541e910ec86 (patch)
tree630d2e17fc3afab41b7c5ddcda653628a7f2fddd /src
parente48b19c5db3185e1868391176fc040df08a149fb (diff)
downloadpostgresql-bb45156f342c2cdb88cdd7f9efdc4541e910ec86.tar.gz
postgresql-bb45156f342c2cdb88cdd7f9efdc4541e910ec86.zip
Show names of DEALLOCATE as constants in pg_stat_statements
This commit switches query jumbling so as prepared statement names are treated as constants in DeallocateStmt. A boolean field is added to DeallocateStmt to make a distinction between ALL and named prepared statements, as "name" was used to make this difference before, NULL meaning DEALLOCATE ALL. Prior to this commit, DEALLOCATE was not tracked in pg_stat_statements, for the reason that it was not possible to treat its name parameter as a constant. Now that query jumbling applies to all the utility nodes, this reason does not apply anymore. Like 638d42a3c520, this can be a huge advantage for monitoring where prepared statement names are randomly generated, preventing bloat in pg_stat_statements. A couple of tests are added to track the new behavior. Author: Dagfinn Ilmari Mannsåker, Michael Paquier Reviewed-by: Julien Rouhaud Discussion: https://postgr.es/m/ZMhT9kNtJJsHw6jK@paquier.xyz
Diffstat (limited to 'src')
-rw-r--r--src/backend/parser/gram.y8
-rw-r--r--src/include/nodes/parsenodes.h8
2 files changed, 14 insertions, 2 deletions
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 1b0e9e58195..7d2032885ed 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -11953,6 +11953,8 @@ DeallocateStmt: DEALLOCATE name
DeallocateStmt *n = makeNode(DeallocateStmt);
n->name = $2;
+ n->isall = false;
+ n->location = @2;
$$ = (Node *) n;
}
| DEALLOCATE PREPARE name
@@ -11960,6 +11962,8 @@ DeallocateStmt: DEALLOCATE name
DeallocateStmt *n = makeNode(DeallocateStmt);
n->name = $3;
+ n->isall = false;
+ n->location = @3;
$$ = (Node *) n;
}
| DEALLOCATE ALL
@@ -11967,6 +11971,8 @@ DeallocateStmt: DEALLOCATE name
DeallocateStmt *n = makeNode(DeallocateStmt);
n->name = NULL;
+ n->isall = true;
+ n->location = -1;
$$ = (Node *) n;
}
| DEALLOCATE PREPARE ALL
@@ -11974,6 +11980,8 @@ DeallocateStmt: DEALLOCATE name
DeallocateStmt *n = makeNode(DeallocateStmt);
n->name = NULL;
+ n->isall = true;
+ n->location = -1;
$$ = (Node *) n;
}
;
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 5217132331f..fef4c714b8e 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -3929,8 +3929,12 @@ typedef struct ExecuteStmt
typedef struct DeallocateStmt
{
NodeTag type;
- char *name; /* The name of the plan to remove */
- /* NULL means DEALLOCATE ALL */
+ /* The name of the plan to remove, NULL if DEALLOCATE ALL */
+ char *name pg_node_attr(query_jumble_ignore);
+ /* true if DEALLOCATE ALL */
+ bool isall;
+ /* token location, or -1 if unknown */
+ int location pg_node_attr(query_jumble_location);
} DeallocateStmt;
/*