mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
Rearrange snapshot handling to make rule expansion more consistent.
With this patch, portals, SQL functions, and SPI all agree that there should be only a CommandCounterIncrement between the queries that are generated from a single SQL command by rule expansion. Fetching a whole new snapshot now happens only between original queries. This is equivalent to the existing behavior of EXPLAIN ANALYZE, and it was judged to be the best choice since it eliminates one source of concurrency hazards for rules. The patch should also make things marginally faster by reducing the number of snapshot push/pop operations. The patch removes pg_parse_and_rewrite(), which is no longer used anywhere. There was considerable discussion about more aggressive refactoring of the query-processing functions exported by postgres.c, but for the moment nothing more has been done there. I also took the opportunity to refactor snapmgr.c's API slightly: the former PushUpdatedSnapshot() has been split into two functions. Marko Tiikkaja, reviewed by Steve Singer and Tom Lane
This commit is contained in:
@ -513,47 +513,6 @@ client_read_ended(void)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Parse a query string and pass it through the rewriter.
|
||||
*
|
||||
* A list of Query nodes is returned, since the string might contain
|
||||
* multiple queries and/or the rewriter might expand one query to several.
|
||||
*
|
||||
* NOTE: this routine is no longer used for processing interactive queries,
|
||||
* but it is still needed for parsing of SQL function bodies.
|
||||
*/
|
||||
List *
|
||||
pg_parse_and_rewrite(const char *query_string, /* string to execute */
|
||||
Oid *paramTypes, /* parameter types */
|
||||
int numParams) /* number of parameters */
|
||||
{
|
||||
List *raw_parsetree_list;
|
||||
List *querytree_list;
|
||||
ListCell *list_item;
|
||||
|
||||
/*
|
||||
* (1) parse the request string into a list of raw parse trees.
|
||||
*/
|
||||
raw_parsetree_list = pg_parse_query(query_string);
|
||||
|
||||
/*
|
||||
* (2) Do parse analysis and rule rewrite.
|
||||
*/
|
||||
querytree_list = NIL;
|
||||
foreach(list_item, raw_parsetree_list)
|
||||
{
|
||||
Node *parsetree = (Node *) lfirst(list_item);
|
||||
|
||||
querytree_list = list_concat(querytree_list,
|
||||
pg_analyze_and_rewrite(parsetree,
|
||||
query_string,
|
||||
paramTypes,
|
||||
numParams));
|
||||
}
|
||||
|
||||
return querytree_list;
|
||||
}
|
||||
|
||||
/*
|
||||
* Do raw parsing (only).
|
||||
*
|
||||
|
Reference in New Issue
Block a user