diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-04-16 01:14:58 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-04-16 01:14:58 +0000 |
commit | 66888f7424f7d6c7cea2c26e181054d1455d4e7a (patch) | |
tree | d7224be67b7a912f5d65315afb1c121622373a0a /src/backend/tcop/postgres.c | |
parent | fa92d21a486de868b21bbc03944649af3e1ac90f (diff) | |
download | postgresql-66888f7424f7d6c7cea2c26e181054d1455d4e7a.tar.gz postgresql-66888f7424f7d6c7cea2c26e181054d1455d4e7a.zip |
Expose more cursor-related functionality in SPI: specifically, allow
access to the planner's cursor-related planning options, and provide new
FETCH/MOVE routines that allow access to the full power of those commands.
Small refactoring of planner(), pg_plan_query(), and pg_plan_queries()
APIs to make it convenient to pass the planning options down from SPI.
This is the core-code portion of Pavel Stehule's patch for scrollable
cursor support in plpgsql; I'll review and apply the plpgsql changes
separately.
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r-- | src/backend/tcop/postgres.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index bfcc271996e..7722eddf347 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.530 2007/03/29 19:10:10 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.531 2007/04/16 01:14:57 tgl Exp $ * * NOTES * this is the "main" module of the postgres backend and @@ -656,9 +656,12 @@ pg_rewrite_queries(List *querytree_list) } -/* Generate a plan for a single already-rewritten query. */ +/* + * Generate a plan for a single already-rewritten query. + * This is a thin wrapper around planner() and takes the same parameters. + */ PlannedStmt * -pg_plan_query(Query *querytree, ParamListInfo boundParams) +pg_plan_query(Query *querytree, int cursorOptions, ParamListInfo boundParams) { PlannedStmt *plan; @@ -670,7 +673,7 @@ pg_plan_query(Query *querytree, ParamListInfo boundParams) ResetUsage(); /* call the optimizer */ - plan = planner(querytree, false, 0, boundParams); + plan = planner(querytree, cursorOptions, boundParams); if (log_planner_stats) ShowUsage("PLANNER STATISTICS"); @@ -718,7 +721,7 @@ pg_plan_query(Query *querytree, ParamListInfo boundParams) * list. Utility statements are simply represented by their statement nodes. */ List * -pg_plan_queries(List *querytrees, ParamListInfo boundParams, +pg_plan_queries(List *querytrees, int cursorOptions, ParamListInfo boundParams, bool needSnapshot) { List *stmt_list = NIL; @@ -741,7 +744,7 @@ pg_plan_queries(List *querytrees, ParamListInfo boundParams, ActiveSnapshot = CopySnapshot(GetTransactionSnapshot()); needSnapshot = false; } - stmt = (Node *) pg_plan_query(query, boundParams); + stmt = (Node *) pg_plan_query(query, cursorOptions, boundParams); } stmt_list = lappend(stmt_list, stmt); @@ -892,7 +895,7 @@ exec_simple_query(const char *query_string) querytree_list = pg_analyze_and_rewrite(parsetree, query_string, NULL, 0); - plantree_list = pg_plan_queries(querytree_list, NULL, true); + plantree_list = pg_plan_queries(querytree_list, 0, NULL, true); /* If we got a cancel signal in analysis or planning, quit */ CHECK_FOR_INTERRUPTS(); @@ -1207,7 +1210,7 @@ exec_parse_message(const char *query_string, /* string to execute */ } else { - stmt_list = pg_plan_queries(querytree_list, NULL, true); + stmt_list = pg_plan_queries(querytree_list, 0, NULL, true); fully_planned = true; } } @@ -1621,7 +1624,7 @@ exec_bind_message(StringInfo input_message) */ oldContext = MemoryContextSwitchTo(PortalGetHeapMemory(portal)); query_list = copyObject(cplan->stmt_list); - plan_list = pg_plan_queries(query_list, params, true); + plan_list = pg_plan_queries(query_list, 0, params, true); MemoryContextSwitchTo(oldContext); /* We no longer need the cached plan refcount ... */ |