aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tcop
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/tcop')
-rw-r--r--src/backend/tcop/postgres.c10
-rw-r--r--src/backend/tcop/pquery.c101
-rw-r--r--src/backend/tcop/utility.c10
3 files changed, 20 insertions, 101 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index b4f064d0e1b..ec717d8c122 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.316 2003/03/06 00:04:27 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.317 2003/03/10 03:53:51 tgl Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
@@ -483,7 +483,7 @@ pg_plan_query(Query *querytree)
ResetUsage();
/* call the optimizer */
- plan = planner(querytree);
+ plan = planner(querytree, false, 0);
if (log_planner_stats)
ShowUsage("PLANNER STATISTICS");
@@ -1789,7 +1789,7 @@ PostgresMain(int argc, char *argv[], const char *username)
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
- puts("$Revision: 1.316 $ $Date: 2003/03/06 00:04:27 $\n");
+ puts("$Revision: 1.317 $ $Date: 2003/03/10 03:53:51 $\n");
}
/*
@@ -2245,6 +2245,10 @@ CreateCommandTag(Node *parsetree)
}
break;
+ case T_DeclareCursorStmt:
+ tag = "DECLARE CURSOR";
+ break;
+
case T_ClosePortalStmt:
tag = "CLOSE CURSOR";
break;
diff --git a/src/backend/tcop/pquery.c b/src/backend/tcop/pquery.c
index 1e02e42193d..29d5018440d 100644
--- a/src/backend/tcop/pquery.c
+++ b/src/backend/tcop/pquery.c
@@ -8,19 +8,15 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.58 2002/12/15 16:17:52 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.59 2003/03/10 03:53:51 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
-#include "commands/portalcmds.h"
-#include "executor/execdefs.h"
#include "executor/executor.h"
#include "tcop/pquery.h"
-#include "utils/memutils.h"
-#include "utils/ps_status.h"
/*
@@ -64,38 +60,6 @@ FreeQueryDesc(QueryDesc *qdesc)
pfree(qdesc);
}
-/* ----------------
- * PreparePortal
- * ----------------
- */
-Portal
-PreparePortal(char *portalName)
-{
- Portal portal;
-
- /*
- * Check for already-in-use portal name.
- */
- portal = GetPortalByName(portalName);
- if (PortalIsValid(portal))
- {
- /*
- * XXX Should we raise an error rather than closing the old
- * portal?
- */
- elog(WARNING, "Closing pre-existing portal \"%s\"",
- portalName);
- PortalDrop(portal);
- }
-
- /*
- * Create the new portal.
- */
- portal = CreatePortal(portalName);
-
- return portal;
-}
-
/*
* ProcessQuery
@@ -116,10 +80,6 @@ ProcessQuery(Query *parsetree,
char *completionTag)
{
int operation = parsetree->commandType;
- bool isRetrieveIntoPortal = false;
- char *intoName = NULL;
- Portal portal = NULL;
- MemoryContext oldContext = NULL;
QueryDesc *queryDesc;
/*
@@ -127,16 +87,7 @@ ProcessQuery(Query *parsetree,
*/
if (operation == CMD_SELECT)
{
- if (parsetree->isPortal)
- {
- isRetrieveIntoPortal = true;
- /* If binary portal, switch to alternate output format */
- if (dest == Remote && parsetree->isBinary)
- dest = RemoteInternal;
- /* Check for invalid context (must be in transaction block) */
- RequireTransactionChain((void *) parsetree, "DECLARE CURSOR");
- }
- else if (parsetree->into != NULL)
+ if (parsetree->into != NULL)
{
/*
* SELECT INTO table (a/k/a CREATE AS ... SELECT).
@@ -150,57 +101,17 @@ ProcessQuery(Query *parsetree,
}
/*
- * If retrieving into a portal, set up the portal and copy the
- * parsetree and plan into its memory context.
+ * Create the QueryDesc object
*/
- if (isRetrieveIntoPortal)
- {
- intoName = parsetree->into->relname;
- portal = PreparePortal(intoName);
- oldContext = MemoryContextSwitchTo(PortalGetHeapMemory(portal));
- parsetree = copyObject(parsetree);
- plan = copyObject(plan);
- intoName = parsetree->into->relname; /* use copied name in
- * QueryDesc */
-
- /*
- * We stay in portal's memory context for now, so that query desc
- * is also allocated in the portal context.
- */
- }
+ queryDesc = CreateQueryDesc(parsetree, plan, dest, NULL, NULL, false);
/*
- * Now we can create the QueryDesc object.
- */
- queryDesc = CreateQueryDesc(parsetree, plan, dest, intoName, NULL, false);
-
- /*
- * call ExecStart to prepare the plan for execution
+ * Call ExecStart to prepare the plan for execution
*/
ExecutorStart(queryDesc);
/*
- * If retrieve into portal, stop now; we do not run the plan until a
- * FETCH command is received.
- */
- if (isRetrieveIntoPortal)
- {
- /* Arrange to shut down the executor if portal is dropped */
- PortalSetQuery(portal, queryDesc, PortalCleanup);
-
- /* Now we can return to caller's memory context. */
- MemoryContextSwitchTo(oldContext);
-
- /* Set completion tag. SQL calls this operation DECLARE CURSOR */
- if (completionTag)
- strcpy(completionTag, "DECLARE CURSOR");
-
- return;
- }
-
- /*
- * Now we get to the important call to ExecutorRun() where we actually
- * run the plan..
+ * And run the plan.
*/
ExecutorRun(queryDesc, ForwardScanDirection, 0L);
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index db7dc0945cd..0fae711a2c3 100644
--- a/src/backend/tcop/utility.c
+++ b/src/backend/tcop/utility.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.193 2003/02/19 03:59:02 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.194 2003/03/10 03:53:51 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -306,13 +306,17 @@ ProcessUtility(Node *parsetree,
break;
/*
- * ************************* portal manipulation ***************************
+ * Portal (cursor) manipulation
*/
+ case T_DeclareCursorStmt:
+ PerformCursorOpen((DeclareCursorStmt *) parsetree, dest);
+ break;
+
case T_ClosePortalStmt:
{
ClosePortalStmt *stmt = (ClosePortalStmt *) parsetree;
- PerformPortalClose(stmt->portalname, dest);
+ PerformPortalClose(stmt->portalname);
}
break;