diff options
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r-- | src/backend/tcop/postgres.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 0ec7fcf71d8..a7dd5cb904a 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.335 2003/05/06 05:15:45 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.336 2003/05/06 20:26:27 tgl Exp $ * * NOTES * this is the "main" module of the postgres backend and @@ -656,6 +656,8 @@ pg_plan_queries(List *querytrees, bool needSnapshot) static void exec_simple_query(const char *query_string) { + CommandDest dest = whereToSendOutput; + DestReceiver *receiver; MemoryContext oldcontext; List *parsetree_list, *parsetree_item; @@ -683,6 +685,12 @@ exec_simple_query(const char *query_string) ResetUsage(); /* + * Create destination receiver object --- we can reuse it for all + * queries in the string. Note it is created in MessageContext. + */ + receiver = CreateDestReceiver(dest); + + /* * Start up a transaction command. All queries generated by the * query_string will be in this same command block, *unless* we find a * BEGIN/COMMIT/ABORT statement; we have to force a new xact command @@ -745,7 +753,7 @@ exec_simple_query(const char *query_string) set_ps_display(commandTag); - BeginCommand(commandTag, whereToSendOutput); + BeginCommand(commandTag, dest); /* * If we are in an aborted transaction, reject all commands except @@ -819,8 +827,8 @@ exec_simple_query(const char *query_string) (void) PortalRun(portal, FETCH_ALL, - whereToSendOutput, - whereToSendOutput, + receiver, + receiver, completionTag); PortalDrop(portal, false); @@ -868,14 +876,16 @@ exec_simple_query(const char *query_string) * (But a command aborted by error will not send an EndCommand * report at all.) */ - EndCommand(completionTag, whereToSendOutput); + EndCommand(completionTag, dest); } /* end loop over parsetrees */ /* * If there were no parsetrees, return EmptyQueryResponse message. */ if (!parsetree_list) - NullCommand(whereToSendOutput); + NullCommand(dest); + + (*receiver->destroy) (receiver); QueryContext = NULL; @@ -1282,6 +1292,7 @@ static void exec_execute_message(const char *portal_name, int is_binary, long max_rows) { CommandDest dest; + DestReceiver *receiver; Portal portal; bool is_trans_stmt = false; bool is_trans_exit = false; @@ -1363,15 +1374,19 @@ exec_execute_message(const char *portal_name, int is_binary, long max_rows) /* * Okay to run the portal. */ + receiver = CreateDestReceiver(dest); + if (max_rows <= 0) max_rows = FETCH_ALL; completed = PortalRun(portal, max_rows, - dest, - dest, + receiver, + receiver, completionTag); + (*receiver->destroy) (receiver); + if (completed) { if (is_trans_stmt) @@ -2344,7 +2359,7 @@ PostgresMain(int argc, char *argv[], const char *username) if (!IsUnderPostmaster) { puts("\nPOSTGRES backend interactive interface "); - puts("$Revision: 1.335 $ $Date: 2003/05/06 05:15:45 $\n"); + puts("$Revision: 1.336 $ $Date: 2003/05/06 20:26:27 $\n"); } /* @@ -2412,7 +2427,6 @@ PostgresMain(int argc, char *argv[], const char *username) */ MemoryContextSwitchTo(TopMemoryContext); MemoryContextResetAndDeleteChildren(ErrorContext); - CurrentPortal = NULL; PortalContext = NULL; QueryContext = NULL; |