mirror of
https://github.com/postgres/postgres.git
synced 2025-04-29 13:56:47 +03:00
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
This commit is contained in:
parent
40ad8f9dee
commit
787102b563
@ -801,7 +801,7 @@ pg_rewrite_query(Query *query)
|
|||||||
new_list = copyObject(querytree_list);
|
new_list = copyObject(querytree_list);
|
||||||
/* This checks both copyObject() and the equal() routines... */
|
/* This checks both copyObject() and the equal() routines... */
|
||||||
if (!equal(new_list, querytree_list))
|
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
|
else
|
||||||
querytree_list = new_list;
|
querytree_list = new_list;
|
||||||
}
|
}
|
||||||
@ -813,35 +813,25 @@ pg_rewrite_query(Query *query)
|
|||||||
List *new_list = NIL;
|
List *new_list = NIL;
|
||||||
ListCell *lc;
|
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)
|
foreach(lc, querytree_list)
|
||||||
{
|
{
|
||||||
Query *query = lfirst_node(Query, lc);
|
Query *query = lfirst_node(Query, lc);
|
||||||
|
char *str = nodeToString(query);
|
||||||
|
Query *new_query = stringToNodeWithLocations(str);
|
||||||
|
|
||||||
if (query->commandType != CMD_UTILITY)
|
/*
|
||||||
{
|
* queryId is not saved in stored rules, but we must preserve it
|
||||||
char *str = nodeToString(query);
|
* here to avoid breaking pg_stat_statements.
|
||||||
Query *new_query = stringToNodeWithLocations(str);
|
*/
|
||||||
|
new_query->queryId = query->queryId;
|
||||||
|
|
||||||
/*
|
new_list = lappend(new_list, new_query);
|
||||||
* queryId is not saved in stored rules, but we must preserve
|
pfree(str);
|
||||||
* 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This checks both outfuncs/readfuncs and the equal() routines... */
|
/* This checks both outfuncs/readfuncs and the equal() routines... */
|
||||||
if (!equal(new_list, querytree_list))
|
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
|
else
|
||||||
querytree_list = new_list;
|
querytree_list = new_list;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user