aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tcop/postgres.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2022-09-26 16:32:16 +0200
committerPeter Eisentraut <peter@eisentraut.org>2022-09-26 16:32:16 +0200
commit787102b5637389b10c220b08992a6a064ac319c6 (patch)
treed346f5af86389b764f408aba18328a24354a4605 /src/backend/tcop/postgres.c
parent40ad8f9deed21f02b23eb034bfca87f7acc7562b (diff)
downloadpostgresql-787102b5637389b10c220b08992a6a064ac319c6.tar.gz
postgresql-787102b5637389b10c220b08992a6a064ac319c6.zip
Enable WRITE_READ_PARSE_PLAN_TREES of rewritten utility statements
This was previously disabled because we lacked outfuncs/readfuncs support for most utility statement types. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/flat/4159834.1657405226@sss.pgh.pa.us
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r--src/backend/tcop/postgres.c32
1 files changed, 11 insertions, 21 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 4952d011836..5352d5f4c6b 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -801,7 +801,7 @@ pg_rewrite_query(Query *query)
new_list = copyObject(querytree_list);
/* This checks both copyObject() and the equal() routines... */
if (!equal(new_list, querytree_list))
- elog(WARNING, "copyObject() failed to produce equal parse tree");
+ elog(WARNING, "copyObject() failed to produce an equal rewritten parse tree");
else
querytree_list = new_list;
}
@@ -813,35 +813,25 @@ pg_rewrite_query(Query *query)
List *new_list = NIL;
ListCell *lc;
- /*
- * We currently lack outfuncs/readfuncs support for most utility
- * statement types, so only attempt to write/read non-utility queries.
- */
foreach(lc, querytree_list)
{
Query *query = lfirst_node(Query, lc);
+ char *str = nodeToString(query);
+ Query *new_query = stringToNodeWithLocations(str);
- if (query->commandType != CMD_UTILITY)
- {
- char *str = nodeToString(query);
- Query *new_query = stringToNodeWithLocations(str);
-
- /*
- * queryId is not saved in stored rules, but we must preserve
- * it here to avoid breaking pg_stat_statements.
- */
- new_query->queryId = query->queryId;
+ /*
+ * queryId is not saved in stored rules, but we must preserve it
+ * here to avoid breaking pg_stat_statements.
+ */
+ new_query->queryId = query->queryId;
- new_list = lappend(new_list, new_query);
- pfree(str);
- }
- else
- new_list = lappend(new_list, query);
+ new_list = lappend(new_list, new_query);
+ pfree(str);
}
/* This checks both outfuncs/readfuncs and the equal() routines... */
if (!equal(new_list, querytree_list))
- elog(WARNING, "outfuncs/readfuncs failed to produce equal parse tree");
+ elog(WARNING, "outfuncs/readfuncs failed to produce an equal rewritten parse tree");
else
querytree_list = new_list;
}