mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
Restructure command destination handling so that we pass around
DestReceiver pointers instead of just CommandDest values. The DestReceiver is made at the point where the destination is selected, rather than deep inside the executor. This cleans up the original kluge implementation of tstoreReceiver.c, and makes it easy to support retrieving results from utility statements inside portals. Thus, you can now do fun things like Bind and Execute a FETCH or EXPLAIN command, and it'll all work as expected (e.g., you can Describe the portal, or use Execute's count parameter to suspend the output partway through). Implementation involves stuffing the utility command's output into a Tuplestore, which would be kind of annoying for huge output sets, but should be quite acceptable for typical uses of utility commands.
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
* Copyright (c) 2002-2003, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/prepare.c,v 1.15 2003/05/05 00:44:55 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/prepare.c,v 1.16 2003/05/06 20:26:26 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -102,7 +102,7 @@ PrepareQuery(PrepareStmt *stmt)
|
||||
* Implements the 'EXECUTE' utility statement.
|
||||
*/
|
||||
void
|
||||
ExecuteQuery(ExecuteStmt *stmt, CommandDest outputDest)
|
||||
ExecuteQuery(ExecuteStmt *stmt, DestReceiver *dest)
|
||||
{
|
||||
PreparedStatement *entry;
|
||||
char *query_string;
|
||||
@@ -180,7 +180,7 @@ ExecuteQuery(ExecuteStmt *stmt, CommandDest outputDest)
|
||||
*/
|
||||
PortalStart(portal, paramLI);
|
||||
|
||||
(void) PortalRun(portal, FETCH_ALL, outputDest, outputDest, NULL);
|
||||
(void) PortalRun(portal, FETCH_ALL, dest, dest, NULL);
|
||||
|
||||
PortalDrop(portal, false);
|
||||
|
||||
@@ -488,19 +488,21 @@ ExplainExecuteQuery(ExplainStmt *stmt, TupOutputState *tstate)
|
||||
{
|
||||
QueryDesc *qdesc;
|
||||
|
||||
/* Create a QueryDesc requesting no output */
|
||||
qdesc = CreateQueryDesc(query, plan, None, NULL,
|
||||
paramLI, stmt->analyze);
|
||||
|
||||
if (execstmt->into)
|
||||
{
|
||||
if (qdesc->operation != CMD_SELECT)
|
||||
if (query->commandType != CMD_SELECT)
|
||||
elog(ERROR, "INTO clause specified for non-SELECT query");
|
||||
|
||||
/* Copy the query so we can modify it */
|
||||
query = copyObject(query);
|
||||
|
||||
query->into = execstmt->into;
|
||||
qdesc->dest = None;
|
||||
}
|
||||
|
||||
/* Create a QueryDesc requesting no output */
|
||||
qdesc = CreateQueryDesc(query, plan, None_Receiver, NULL,
|
||||
paramLI, stmt->analyze);
|
||||
|
||||
ExplainOnePlan(qdesc, stmt, tstate);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user