aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/functions.c
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2024-07-19 10:21:01 +0900
committerMichael Paquier <michael@paquier.xyz>2024-07-19 10:21:01 +0900
commitc145f321b681ab6c3636849071ff30d5c6f6353c (patch)
treea74d5f2251ef8822ca15b7993891ab9395907f38 /src/backend/executor/functions.c
parentcd85ae1114fedcce8602bca77b4557fe75165637 (diff)
downloadpostgresql-c145f321b681ab6c3636849071ff30d5c6f6353c.tar.gz
postgresql-c145f321b681ab6c3636849071ff30d5c6f6353c.zip
Propagate query IDs of utility statements in functions
For utility statements defined within a function, the query tree is copied to a PlannedStmt as utility commands do not require planning. However, the query ID was missing from the information passed down. This leads to plugins relying on the query ID like pg_stat_statements to not be able to track utility statements within function calls. Tests are added to check this behavior, depending on pg_stat_statements.track. This is an old bug. Now, query IDs for utilities are compiled using their parsed trees rather than the query string since v16 (3db72ebcbe20), leading to less bloat with utilities, so backpatch down only to this version. Author: Anthonin Bonnefoy Discussion: https://postgr.es/m/CAO6_XqrGp-uwBqi3vBPLuRULKkddjC7R5QZCgsFren=8E+m2Sg@mail.gmail.com Backpatch-through: 16
Diffstat (limited to 'src/backend/executor/functions.c')
-rw-r--r--src/backend/executor/functions.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c
index 539cd0a9991..692854e2b3e 100644
--- a/src/backend/executor/functions.c
+++ b/src/backend/executor/functions.c
@@ -492,6 +492,7 @@ init_execution_state(List *queryTree_list,
stmt->utilityStmt = queryTree->utilityStmt;
stmt->stmt_location = queryTree->stmt_location;
stmt->stmt_len = queryTree->stmt_len;
+ stmt->queryId = queryTree->queryId;
}
else
stmt = pg_plan_query(queryTree,