aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tcop/utility.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/tcop/utility.c')
-rw-r--r--src/backend/tcop/utility.c1052
1 files changed, 528 insertions, 524 deletions
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index d309ac69a27..33fe08c4551 100644
--- a/src/backend/tcop/utility.c
+++ b/src/backend/tcop/utility.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.22 1997/09/07 04:49:36 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.23 1997/09/08 02:29:50 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -78,648 +78,652 @@ void
ProcessUtility(Node * parsetree,
CommandDest dest)
{
- char *commandTag = NULL;
- char *relname;
- char *relationName;
- char *userName;
+ char *commandTag = NULL;
+ char *relname;
+ char *relationName;
+ char *userName;
userName = GetPgUserName();
switch (nodeTag(parsetree))
{
- /*
- * ******************************** transactions ********************************
- *
- */
- case T_TransactionStmt:
- {
- TransactionStmt *stmt = (TransactionStmt *) parsetree;
+ /*
+ * ******************************** transactions ********************************
+ *
+ */
+ case T_TransactionStmt:
+ {
+ TransactionStmt *stmt = (TransactionStmt *) parsetree;
- switch (stmt->command)
+ switch (stmt->command)
+ {
+ case BEGIN_TRANS:
+ commandTag = "BEGIN";
+ CHECK_IF_ABORTED();
+ BeginTransactionBlock();
+ break;
+
+ case END_TRANS:
+ commandTag = "END";
+ EndTransactionBlock();
+ break;
+
+ case ABORT_TRANS:
+ commandTag = "ABORT";
+ UserAbortTransactionBlock();
+ break;
+ }
+ }
+ break;
+
+ /*
+ * ******************************** portal manipulation ********************************
+ *
+ */
+ case T_ClosePortalStmt:
{
- case BEGIN_TRANS:
- commandTag = "BEGIN";
- CHECK_IF_ABORTED();
- BeginTransactionBlock();
- break;
+ ClosePortalStmt *stmt = (ClosePortalStmt *) parsetree;
- case END_TRANS:
- commandTag = "END";
- EndTransactionBlock();
- break;
+ commandTag = "CLOSE";
+ CHECK_IF_ABORTED();
- case ABORT_TRANS:
- commandTag = "ABORT";
- UserAbortTransactionBlock();
- break;
+ PerformPortalClose(stmt->portalname, dest);
}
- }
- break;
-
- /*
- * ******************************** portal manipulation ********************************
- *
- */
- case T_ClosePortalStmt:
- {
- ClosePortalStmt *stmt = (ClosePortalStmt *) parsetree;
-
- commandTag = "CLOSE";
- CHECK_IF_ABORTED();
+ break;
- PerformPortalClose(stmt->portalname, dest);
- }
- break;
+ case T_FetchStmt:
+ {
+ FetchStmt *stmt = (FetchStmt *) parsetree;
+ char *portalName = stmt->portalname;
+ bool forward;
+ int count;
+
+ commandTag = "FETCH";
+ CHECK_IF_ABORTED();
- case T_FetchStmt:
- {
- FetchStmt *stmt = (FetchStmt *) parsetree;
- char *portalName = stmt->portalname;
- bool forward;
- int count;
+ forward = (bool) (stmt->direction == FORWARD);
- commandTag = "FETCH";
- CHECK_IF_ABORTED();
+ /*
+ * parser ensures that count is >= 0 and 'fetch ALL' -> 0
+ */
- forward = (bool) (stmt->direction == FORWARD);
+ count = stmt->howMany;
+ PerformPortalFetch(portalName, forward, count, commandTag, dest);
+ }
+ break;
/*
- * parser ensures that count is >= 0 and 'fetch ALL' -> 0
+ * ******************************** relation and attribute
+ * manipulation ********************************
+ *
*/
-
- count = stmt->howMany;
- PerformPortalFetch(portalName, forward, count, commandTag, dest);
- }
- break;
-
- /*
- * ******************************** relation and attribute
- * manipulation ********************************
- *
- */
- case T_CreateStmt:
- commandTag = "CREATE";
- CHECK_IF_ABORTED();
-
- DefineRelation((CreateStmt *) parsetree);
- break;
-
- case T_DestroyStmt:
- {
- DestroyStmt *stmt = (DestroyStmt *) parsetree;
- List *arg;
- List *args = stmt->relNames;
- Relation rel;
-
- commandTag = "DROP";
+ case T_CreateStmt:
+ commandTag = "CREATE";
CHECK_IF_ABORTED();
- foreach(arg, args)
+ DefineRelation((CreateStmt *) parsetree);
+ break;
+
+ case T_DestroyStmt:
{
- relname = strVal(lfirst(arg));
- if (IsSystemRelationName(relname))
- elog(WARN, "class \"%s\" is a system catalog",
- relname);
- rel = heap_openr(relname);
- if (RelationIsValid(rel))
+ DestroyStmt *stmt = (DestroyStmt *) parsetree;
+ List *arg;
+ List *args = stmt->relNames;
+ Relation rel;
+
+ commandTag = "DROP";
+ CHECK_IF_ABORTED();
+
+ foreach(arg, args)
{
- if (stmt->sequence &&
- rel->rd_rel->relkind != RELKIND_SEQUENCE)
- elog(WARN, "Use DROP TABLE to drop table '%s'",
+ relname = strVal(lfirst(arg));
+ if (IsSystemRelationName(relname))
+ elog(WARN, "class \"%s\" is a system catalog",
relname);
- if (!(stmt->sequence) &&
- rel->rd_rel->relkind == RELKIND_SEQUENCE)
- elog(WARN, "Use DROP SEQUENCE to drop sequence '%s'",
- relname);
- heap_close(rel);
- }
+ rel = heap_openr(relname);
+ if (RelationIsValid(rel))
+ {
+ if (stmt->sequence &&
+ rel->rd_rel->relkind != RELKIND_SEQUENCE)
+ elog(WARN, "Use DROP TABLE to drop table '%s'",
+ relname);
+ if (!(stmt->sequence) &&
+ rel->rd_rel->relkind == RELKIND_SEQUENCE)
+ elog(WARN, "Use DROP SEQUENCE to drop sequence '%s'",
+ relname);
+ heap_close(rel);
+ }
#ifndef NO_SECURITY
- if (!pg_ownercheck(userName, relname, RELNAME))
- elog(WARN, "you do not own class \"%s\"",
- relname);
+ if (!pg_ownercheck(userName, relname, RELNAME))
+ elog(WARN, "you do not own class \"%s\"",
+ relname);
#endif
+ }
+ foreach(arg, args)
+ {
+ relname = strVal(lfirst(arg));
+ RemoveRelation(relname);
+ }
}
- foreach(arg, args)
+ break;
+
+ case T_PurgeStmt:
{
- relname = strVal(lfirst(arg));
- RemoveRelation(relname);
+ PurgeStmt *stmt = (PurgeStmt *) parsetree;
+
+ commandTag = "PURGE";
+ CHECK_IF_ABORTED();
+
+ RelationPurge(stmt->relname,
+ stmt->beforeDate, /* absolute time string */
+ stmt->afterDate); /* relative time string */
}
- }
- break;
+ break;
+
+ case T_CopyStmt:
+ {
+ CopyStmt *stmt = (CopyStmt *) parsetree;
- case T_PurgeStmt:
- {
- PurgeStmt *stmt = (PurgeStmt *) parsetree;
+ commandTag = "COPY";
+ CHECK_IF_ABORTED();
- commandTag = "PURGE";
- CHECK_IF_ABORTED();
+ DoCopy(stmt->relname,
+ stmt->binary,
+ stmt->oids,
+ (bool) (stmt->direction == FROM),
+ (bool) (stmt->filename == NULL),
- RelationPurge(stmt->relname,
- stmt->beforeDate, /* absolute time string */
- stmt->afterDate); /* relative time string */
- }
- break;
+ /*
+ * null filename means copy to/from stdout/stdin, rather
+ * than to/from a file.
+ */
+ stmt->filename,
+ stmt->delimiter);
+ }
+ break;
- case T_CopyStmt:
- {
- CopyStmt *stmt = (CopyStmt *) parsetree;
+ case T_AddAttrStmt:
+ {
+ AddAttrStmt *stmt = (AddAttrStmt *) parsetree;
- commandTag = "COPY";
- CHECK_IF_ABORTED();
+ commandTag = "ADD";
+ CHECK_IF_ABORTED();
- DoCopy(stmt->relname,
- stmt->binary,
- stmt->oids,
- (bool) (stmt->direction == FROM),
- (bool) (stmt->filename == NULL),
+ /*
+ * owner checking done in PerformAddAttribute (now
+ * recursive)
+ */
+ PerformAddAttribute(stmt->relname,
+ userName,
+ stmt->inh,
+ stmt->colDef);
+ }
+ break;
/*
- * null filename means copy to/from stdout/stdin, rather than
- * to/from a file.
+ * schema
*/
- stmt->filename,
- stmt->delimiter);
- }
- break;
-
- case T_AddAttrStmt:
- {
- AddAttrStmt *stmt = (AddAttrStmt *) parsetree;
-
- commandTag = "ADD";
- CHECK_IF_ABORTED();
+ case T_RenameStmt:
+ {
+ RenameStmt *stmt = (RenameStmt *) parsetree;
- /* owner checking done in PerformAddAttribute (now recursive) */
- PerformAddAttribute(stmt->relname,
- userName,
- stmt->inh,
- stmt->colDef);
- }
- break;
-
- /*
- * schema
- */
- case T_RenameStmt:
- {
- RenameStmt *stmt = (RenameStmt *) parsetree;
-
- commandTag = "RENAME";
- CHECK_IF_ABORTED();
+ commandTag = "RENAME";
+ CHECK_IF_ABORTED();
- relname = stmt->relname;
- if (IsSystemRelationName(relname))
- elog(WARN, "class \"%s\" is a system catalog",
- relname);
+ relname = stmt->relname;
+ if (IsSystemRelationName(relname))
+ elog(WARN, "class \"%s\" is a system catalog",
+ relname);
#ifndef NO_SECURITY
- if (!pg_ownercheck(userName, relname, RELNAME))
- elog(WARN, "you do not own class \"%s\"",
- relname);
+ if (!pg_ownercheck(userName, relname, RELNAME))
+ elog(WARN, "you do not own class \"%s\"",
+ relname);
#endif
- /* ----------------
- * XXX using len == 3 to tell the difference
- * between "rename rel to newrel" and
- * "rename att in rel to newatt" will not
- * work soon because "rename type/operator/rule"
- * stuff is being added. - cim 10/24/90
- * ----------------
- * [another piece of amuzing but useless anecdote -- ay]
- */
- if (stmt->column == NULL)
- {
/* ----------------
- * rename relation
- *
- * Note: we also rename the "type" tuple
- * corresponding to the relation.
+ * XXX using len == 3 to tell the difference
+ * between "rename rel to newrel" and
+ * "rename att in rel to newatt" will not
+ * work soon because "rename type/operator/rule"
+ * stuff is being added. - cim 10/24/90
* ----------------
+ * [another piece of amuzing but useless anecdote -- ay]
*/
- renamerel(relname, /* old name */
- stmt->newname); /* new name */
- TypeRename(relname, /* old name */
- stmt->newname); /* new name */
- }
- else
- {
- /* ----------------
- * rename attribute
- * ----------------
- */
- renameatt(relname, /* relname */
- stmt->column, /* old att name */
- stmt->newname, /* new att name */
- userName,
- stmt->inh); /* recursive? */
+ if (stmt->column == NULL)
+ {
+ /* ----------------
+ * rename relation
+ *
+ * Note: we also rename the "type" tuple
+ * corresponding to the relation.
+ * ----------------
+ */
+ renamerel(relname, /* old name */
+ stmt->newname); /* new name */
+ TypeRename(relname, /* old name */
+ stmt->newname); /* new name */
+ }
+ else
+ {
+ /* ----------------
+ * rename attribute
+ * ----------------
+ */
+ renameatt(relname, /* relname */
+ stmt->column, /* old att name */
+ stmt->newname, /* new att name */
+ userName,
+ stmt->inh); /* recursive? */
+ }
}
- }
- break;
+ break;
- case T_ChangeACLStmt:
- {
- ChangeACLStmt *stmt = (ChangeACLStmt *) parsetree;
- List *i;
- AclItem *aip;
- unsigned modechg;
+ case T_ChangeACLStmt:
+ {
+ ChangeACLStmt *stmt = (ChangeACLStmt *) parsetree;
+ List *i;
+ AclItem *aip;
+ unsigned modechg;
- commandTag = "CHANGE";
- CHECK_IF_ABORTED();
+ commandTag = "CHANGE";
+ CHECK_IF_ABORTED();
- aip = stmt->aclitem;
- modechg = stmt->modechg;
+ aip = stmt->aclitem;
+ modechg = stmt->modechg;
#ifndef NO_SECURITY
- foreach(i, stmt->relNames)
- {
- relname = strVal(lfirst(i));
- if (!pg_ownercheck(userName, relname, RELNAME))
- elog(WARN, "you do not own class \"%s\"",
- relname);
- }
+ foreach(i, stmt->relNames)
+ {
+ relname = strVal(lfirst(i));
+ if (!pg_ownercheck(userName, relname, RELNAME))
+ elog(WARN, "you do not own class \"%s\"",
+ relname);
+ }
#endif
- foreach(i, stmt->relNames)
- {
- relname = strVal(lfirst(i));
- ChangeAcl(relname, aip, modechg);
- }
+ foreach(i, stmt->relNames)
+ {
+ relname = strVal(lfirst(i));
+ ChangeAcl(relname, aip, modechg);
+ }
- }
- break;
+ }
+ break;
- /*
- * ******************************** object creation / destruction ********************************
- *
- */
- case T_DefineStmt:
- {
- DefineStmt *stmt = (DefineStmt *) parsetree;
+ /*
+ * ******************************** object creation /
+ * destruction ********************************
+ *
+ */
+ case T_DefineStmt:
+ {
+ DefineStmt *stmt = (DefineStmt *) parsetree;
- commandTag = "CREATE";
- CHECK_IF_ABORTED();
+ commandTag = "CREATE";
+ CHECK_IF_ABORTED();
- switch (stmt->defType)
- {
- case OPERATOR:
- DefineOperator(stmt->defname, /* operator name */
- stmt->definition); /* rest */
- break;
- case P_TYPE:
+ switch (stmt->defType)
{
- DefineType(stmt->defname, stmt->definition);
+ case OPERATOR:
+ DefineOperator(stmt->defname, /* operator name */
+ stmt->definition); /* rest */
+ break;
+ case P_TYPE:
+ {
+ DefineType(stmt->defname, stmt->definition);
+ }
+ break;
+ case AGGREGATE:
+ DefineAggregate(stmt->defname, /* aggregate name */
+ stmt->definition); /* rest */
+ break;
}
- break;
- case AGGREGATE:
- DefineAggregate(stmt->defname, /* aggregate name */
- stmt->definition); /* rest */
- break;
}
- }
- break;
+ break;
+
+ case T_ViewStmt: /* CREATE VIEW */
+ {
+ ViewStmt *stmt = (ViewStmt *) parsetree;
- case T_ViewStmt: /* CREATE VIEW */
- {
- ViewStmt *stmt = (ViewStmt *) parsetree;
+ commandTag = "CREATE";
+ CHECK_IF_ABORTED();
+ DefineView(stmt->viewname, stmt->query); /* retrieve parsetree */
+ }
+ break;
+ case T_ProcedureStmt: /* CREATE FUNCTION */
commandTag = "CREATE";
CHECK_IF_ABORTED();
- DefineView(stmt->viewname, stmt->query); /* retrieve parsetree */
- }
- break;
+ CreateFunction((ProcedureStmt *) parsetree, dest); /* everything */
+ break;
- case T_ProcedureStmt: /* CREATE FUNCTION */
- commandTag = "CREATE";
- CHECK_IF_ABORTED();
- CreateFunction((ProcedureStmt *) parsetree, dest); /* everything */
- break;
+ case T_IndexStmt: /* CREATE INDEX */
+ {
+ IndexStmt *stmt = (IndexStmt *) parsetree;
- case T_IndexStmt: /* CREATE INDEX */
- {
- IndexStmt *stmt = (IndexStmt *) parsetree;
+ commandTag = "CREATE";
+ CHECK_IF_ABORTED();
+ /* XXX no support for ARCHIVE indices, yet */
+ DefineIndex(stmt->relname, /* relation name */
+ stmt->idxname, /* index name */
+ stmt->accessMethod, /* am name */
+ stmt->indexParams, /* parameters */
+ stmt->withClause,
+ stmt->unique,
+ (Expr *) stmt->whereClause,
+ stmt->rangetable);
+ }
+ break;
- commandTag = "CREATE";
- CHECK_IF_ABORTED();
- /* XXX no support for ARCHIVE indices, yet */
- DefineIndex(stmt->relname, /* relation name */
- stmt->idxname, /* index name */
- stmt->accessMethod, /* am name */
- stmt->indexParams, /* parameters */
- stmt->withClause,
- stmt->unique,
- (Expr *) stmt->whereClause,
- stmt->rangetable);
- }
- break;
-
- case T_RuleStmt: /* CREATE RULE */
- {
- RuleStmt *stmt = (RuleStmt *) parsetree;
- int aclcheck_result;
+ case T_RuleStmt: /* CREATE RULE */
+ {
+ RuleStmt *stmt = (RuleStmt *) parsetree;
+ int aclcheck_result;
#ifndef NO_SECURITY
- relname = stmt->object->relname;
- aclcheck_result = pg_aclcheck(relname, userName, ACL_RU);
- if (aclcheck_result != ACLCHECK_OK)
- elog(WARN, "%s: %s", relname, aclcheck_error_strings[aclcheck_result]);
+ relname = stmt->object->relname;
+ aclcheck_result = pg_aclcheck(relname, userName, ACL_RU);
+ if (aclcheck_result != ACLCHECK_OK)
+ elog(WARN, "%s: %s", relname, aclcheck_error_strings[aclcheck_result]);
#endif
+ commandTag = "CREATE";
+ CHECK_IF_ABORTED();
+ DefineQueryRewrite(stmt);
+ }
+ break;
+
+ case T_CreateSeqStmt:
commandTag = "CREATE";
CHECK_IF_ABORTED();
- DefineQueryRewrite(stmt);
- }
- break;
-
- case T_CreateSeqStmt:
- commandTag = "CREATE";
- CHECK_IF_ABORTED();
- DefineSequence((CreateSeqStmt *) parsetree);
- break;
+ DefineSequence((CreateSeqStmt *) parsetree);
+ break;
- case T_ExtendStmt:
- {
- ExtendStmt *stmt = (ExtendStmt *) parsetree;
+ case T_ExtendStmt:
+ {
+ ExtendStmt *stmt = (ExtendStmt *) parsetree;
- commandTag = "EXTEND";
- CHECK_IF_ABORTED();
+ commandTag = "EXTEND";
+ CHECK_IF_ABORTED();
- ExtendIndex(stmt->idxname, /* index name */
- (Expr *) stmt->whereClause, /* where */
- stmt->rangetable);
- }
- break;
+ ExtendIndex(stmt->idxname, /* index name */
+ (Expr *) stmt->whereClause, /* where */
+ stmt->rangetable);
+ }
+ break;
- case T_RemoveStmt:
- {
- RemoveStmt *stmt = (RemoveStmt *) parsetree;
+ case T_RemoveStmt:
+ {
+ RemoveStmt *stmt = (RemoveStmt *) parsetree;
- commandTag = "DROP";
- CHECK_IF_ABORTED();
+ commandTag = "DROP";
+ CHECK_IF_ABORTED();
- switch (stmt->removeType)
- {
- case INDEX:
- relname = stmt->name;
- if (IsSystemRelationName(relname))
- elog(WARN, "class \"%s\" is a system catalog index",
- relname);
+ switch (stmt->removeType)
+ {
+ case INDEX:
+ relname = stmt->name;
+ if (IsSystemRelationName(relname))
+ elog(WARN, "class \"%s\" is a system catalog index",
+ relname);
#ifndef NO_SECURITY
- if (!pg_ownercheck(userName, relname, RELNAME))
- elog(WARN, "%s: %s", relname, aclcheck_error_strings[ACLCHECK_NOT_OWNER]);
+ if (!pg_ownercheck(userName, relname, RELNAME))
+ elog(WARN, "%s: %s", relname, aclcheck_error_strings[ACLCHECK_NOT_OWNER]);
#endif
- RemoveIndex(relname);
- break;
- case RULE:
- {
- char *rulename = stmt->name;
- int aclcheck_result;
+ RemoveIndex(relname);
+ break;
+ case RULE:
+ {
+ char *rulename = stmt->name;
+ int aclcheck_result;
#ifndef NO_SECURITY
- relationName = RewriteGetRuleEventRel(rulename);
- aclcheck_result = pg_aclcheck(relationName, userName, ACL_RU);
- if (aclcheck_result != ACLCHECK_OK)
- {
- elog(WARN, "%s: %s", relationName, aclcheck_error_strings[aclcheck_result]);
- }
+ relationName = RewriteGetRuleEventRel(rulename);
+ aclcheck_result = pg_aclcheck(relationName, userName, ACL_RU);
+ if (aclcheck_result != ACLCHECK_OK)
+ {
+ elog(WARN, "%s: %s", relationName, aclcheck_error_strings[aclcheck_result]);
+ }
#endif
- RemoveRewriteRule(rulename);
- }
- break;
- case P_TYPE:
+ RemoveRewriteRule(rulename);
+ }
+ break;
+ case P_TYPE:
#ifndef NO_SECURITY
- /* XXX moved to remove.c */
+ /* XXX moved to remove.c */
#endif
- RemoveType(stmt->name);
- break;
- case VIEW:
- {
- char *viewName = stmt->name;
- char *ruleName;
+ RemoveType(stmt->name);
+ break;
+ case VIEW:
+ {
+ char *viewName = stmt->name;
+ char *ruleName;
#ifndef NO_SECURITY
- ruleName = MakeRetrieveViewRuleName(viewName);
- relationName = RewriteGetRuleEventRel(ruleName);
- if (!pg_ownercheck(userName, relationName, RELNAME))
- elog(WARN, "%s: %s", relationName, aclcheck_error_strings[ACLCHECK_NOT_OWNER]);
- pfree(ruleName);
+ ruleName = MakeRetrieveViewRuleName(viewName);
+ relationName = RewriteGetRuleEventRel(ruleName);
+ if (!pg_ownercheck(userName, relationName, RELNAME))
+ elog(WARN, "%s: %s", relationName, aclcheck_error_strings[ACLCHECK_NOT_OWNER]);
+ pfree(ruleName);
#endif
- RemoveView(viewName);
+ RemoveView(viewName);
+ }
+ break;
}
break;
}
break;
- }
- break;
- case T_RemoveAggrStmt:
- {
- RemoveAggrStmt *stmt = (RemoveAggrStmt *) parsetree;
+ case T_RemoveAggrStmt:
+ {
+ RemoveAggrStmt *stmt = (RemoveAggrStmt *) parsetree;
- commandTag = "DROP";
- CHECK_IF_ABORTED();
- RemoveAggregate(stmt->aggname, stmt->aggtype);
- }
- break;
+ commandTag = "DROP";
+ CHECK_IF_ABORTED();
+ RemoveAggregate(stmt->aggname, stmt->aggtype);
+ }
+ break;
- case T_RemoveFuncStmt:
- {
- RemoveFuncStmt *stmt = (RemoveFuncStmt *) parsetree;
+ case T_RemoveFuncStmt:
+ {
+ RemoveFuncStmt *stmt = (RemoveFuncStmt *) parsetree;
- commandTag = "DROP";
- CHECK_IF_ABORTED();
- RemoveFunction(stmt->funcname,
- length(stmt->args),
- stmt->args);
- }
- break;
-
- case T_RemoveOperStmt:
- {
- RemoveOperStmt *stmt = (RemoveOperStmt *) parsetree;
- char *type1 = (char *) NULL;
- char *type2 = (char *) NULL;
+ commandTag = "DROP";
+ CHECK_IF_ABORTED();
+ RemoveFunction(stmt->funcname,
+ length(stmt->args),
+ stmt->args);
+ }
+ break;
- commandTag = "DROP";
- CHECK_IF_ABORTED();
+ case T_RemoveOperStmt:
+ {
+ RemoveOperStmt *stmt = (RemoveOperStmt *) parsetree;
+ char *type1 = (char *) NULL;
+ char *type2 = (char *) NULL;
- if (lfirst(stmt->args) != NULL)
- type1 = strVal(lfirst(stmt->args));
- if (lsecond(stmt->args) != NULL)
- type2 = strVal(lsecond(stmt->args));
- RemoveOperator(stmt->opname, type1, type2);
- }
- break;
-
- case T_VersionStmt:
- {
- elog(WARN, "CREATE VERSION is not currently implemented");
- }
- break;
-
- case T_CreatedbStmt:
- {
- CreatedbStmt *stmt = (CreatedbStmt *) parsetree;
-
- commandTag = "CREATEDB";
- CHECK_IF_ABORTED();
- createdb(stmt->dbname);
- }
- break;
+ commandTag = "DROP";
+ CHECK_IF_ABORTED();
- case T_DestroydbStmt:
- {
- DestroydbStmt *stmt = (DestroydbStmt *) parsetree;
+ if (lfirst(stmt->args) != NULL)
+ type1 = strVal(lfirst(stmt->args));
+ if (lsecond(stmt->args) != NULL)
+ type2 = strVal(lsecond(stmt->args));
+ RemoveOperator(stmt->opname, type1, type2);
+ }
+ break;
- commandTag = "DESTROYDB";
- CHECK_IF_ABORTED();
- destroydb(stmt->dbname);
- }
- break;
+ case T_VersionStmt:
+ {
+ elog(WARN, "CREATE VERSION is not currently implemented");
+ }
+ break;
- /* Query-level asynchronous notification */
- case T_NotifyStmt:
- {
- NotifyStmt *stmt = (NotifyStmt *) parsetree;
+ case T_CreatedbStmt:
+ {
+ CreatedbStmt *stmt = (CreatedbStmt *) parsetree;
- commandTag = "NOTIFY";
- CHECK_IF_ABORTED();
+ commandTag = "CREATEDB";
+ CHECK_IF_ABORTED();
+ createdb(stmt->dbname);
+ }
+ break;
+
+ case T_DestroydbStmt:
+ {
+ DestroydbStmt *stmt = (DestroydbStmt *) parsetree;
- Async_Notify(stmt->relname);
- }
- break;
+ commandTag = "DESTROYDB";
+ CHECK_IF_ABORTED();
+ destroydb(stmt->dbname);
+ }
+ break;
- case T_ListenStmt:
- {
- ListenStmt *stmt = (ListenStmt *) parsetree;
+ /* Query-level asynchronous notification */
+ case T_NotifyStmt:
+ {
+ NotifyStmt *stmt = (NotifyStmt *) parsetree;
- commandTag = "LISTEN";
- CHECK_IF_ABORTED();
+ commandTag = "NOTIFY";
+ CHECK_IF_ABORTED();
- Async_Listen(stmt->relname, MasterPid);
- }
- break;
-
- /*
- * ******************************** dynamic loader ********************************
- *
- */
- case T_LoadStmt:
- {
- LoadStmt *stmt = (LoadStmt *) parsetree;
- FILE *fp;
- char *filename;
-
- commandTag = "LOAD";
- CHECK_IF_ABORTED();
+ Async_Notify(stmt->relname);
+ }
+ break;
- filename = stmt->filename;
- closeAllVfds();
- if ((fp = AllocateFile(filename, "r")) == NULL)
- elog(WARN, "LOAD: could not open file %s", filename);
- FreeFile(fp);
- load_file(filename);
- }
- break;
+ case T_ListenStmt:
+ {
+ ListenStmt *stmt = (ListenStmt *) parsetree;
- case T_ClusterStmt:
- {
- ClusterStmt *stmt = (ClusterStmt *) parsetree;
+ commandTag = "LISTEN";
+ CHECK_IF_ABORTED();
- commandTag = "CLUSTER";
- CHECK_IF_ABORTED();
+ Async_Listen(stmt->relname, MasterPid);
+ }
+ break;
- cluster(stmt->relname, stmt->indexname);
- }
- break;
+ /*
+ * ******************************** dynamic loader ********************************
+ *
+ */
+ case T_LoadStmt:
+ {
+ LoadStmt *stmt = (LoadStmt *) parsetree;
+ FILE *fp;
+ char *filename;
+
+ commandTag = "LOAD";
+ CHECK_IF_ABORTED();
+
+ filename = stmt->filename;
+ closeAllVfds();
+ if ((fp = AllocateFile(filename, "r")) == NULL)
+ elog(WARN, "LOAD: could not open file %s", filename);
+ FreeFile(fp);
+ load_file(filename);
+ }
+ break;
- case T_VacuumStmt:
- commandTag = "VACUUM";
- CHECK_IF_ABORTED();
- vacuum(((VacuumStmt *) parsetree)->vacrel,
- ((VacuumStmt *) parsetree)->verbose,
- ((VacuumStmt *) parsetree)->analyze,
- ((VacuumStmt *) parsetree)->va_spec);
- break;
+ case T_ClusterStmt:
+ {
+ ClusterStmt *stmt = (ClusterStmt *) parsetree;
- case T_ExplainStmt:
- {
- ExplainStmt *stmt = (ExplainStmt *) parsetree;
+ commandTag = "CLUSTER";
+ CHECK_IF_ABORTED();
- commandTag = "EXPLAIN";
+ cluster(stmt->relname, stmt->indexname);
+ }
+ break;
+
+ case T_VacuumStmt:
+ commandTag = "VACUUM";
CHECK_IF_ABORTED();
+ vacuum(((VacuumStmt *) parsetree)->vacrel,
+ ((VacuumStmt *) parsetree)->verbose,
+ ((VacuumStmt *) parsetree)->analyze,
+ ((VacuumStmt *) parsetree)->va_spec);
+ break;
+
+ case T_ExplainStmt:
+ {
+ ExplainStmt *stmt = (ExplainStmt *) parsetree;
+
+ commandTag = "EXPLAIN";
+ CHECK_IF_ABORTED();
- ExplainQuery(stmt->query, stmt->verbose, dest);
- }
- break;
+ ExplainQuery(stmt->query, stmt->verbose, dest);
+ }
+ break;
- /*
- * ******************************** Tioga-related statements *******************************
- */
- case T_RecipeStmt:
- {
- RecipeStmt *stmt = (RecipeStmt *) parsetree;
+ /*
+ * ******************************** Tioga-related statements *******************************
+ */
+ case T_RecipeStmt:
+ {
+ RecipeStmt *stmt = (RecipeStmt *) parsetree;
- commandTag = "EXECUTE RECIPE";
+ commandTag = "EXECUTE RECIPE";
+ CHECK_IF_ABORTED();
+ beginRecipe(stmt);
+ }
+ break;
+
+ /*
+ * ******************************** set variable statements *******************************
+ */
+ case T_VariableSetStmt:
+ {
+ VariableSetStmt *n = (VariableSetStmt *) parsetree;
+
+ SetPGVariable(n->name, n->value);
+ commandTag = "SET VARIABLE";
+ }
+ break;
+
+ case T_VariableShowStmt:
+ {
+ VariableShowStmt *n = (VariableShowStmt *) parsetree;
+
+ GetPGVariable(n->name);
+ commandTag = "SHOW VARIABLE";
+ }
+ break;
+
+ case T_VariableResetStmt:
+ {
+ VariableResetStmt *n = (VariableResetStmt *) parsetree;
+
+ ResetPGVariable(n->name);
+ commandTag = "RESET VARIABLE";
+ }
+ break;
+
+ /*
+ * ******************************** TRIGGER statements *******************************
+ */
+ case T_CreateTrigStmt:
+ commandTag = "CREATE";
+ CHECK_IF_ABORTED();
+
+ CreateTrigger((CreateTrigStmt *) parsetree);
+ break;
+
+ case T_DropTrigStmt:
+ commandTag = "DROP";
CHECK_IF_ABORTED();
- beginRecipe(stmt);
- }
- break;
-
- /*
- * ******************************** set variable statements *******************************
- */
- case T_VariableSetStmt:
- {
- VariableSetStmt *n = (VariableSetStmt *) parsetree;
-
- SetPGVariable(n->name, n->value);
- commandTag = "SET VARIABLE";
- }
- break;
-
- case T_VariableShowStmt:
- {
- VariableShowStmt *n = (VariableShowStmt *) parsetree;
-
- GetPGVariable(n->name);
- commandTag = "SHOW VARIABLE";
- }
- break;
-
- case T_VariableResetStmt:
- {
- VariableResetStmt *n = (VariableResetStmt *) parsetree;
-
- ResetPGVariable(n->name);
- commandTag = "RESET VARIABLE";
- }
- break;
-
- /*
- * ******************************** TRIGGER statements *******************************
- */
- case T_CreateTrigStmt:
- commandTag = "CREATE";
- CHECK_IF_ABORTED();
-
- CreateTrigger((CreateTrigStmt *) parsetree);
- break;
-
- case T_DropTrigStmt:
- commandTag = "DROP";
- CHECK_IF_ABORTED();
-
- DropTrigger((DropTrigStmt *) parsetree);
- break;
-
- /*
- * ******************************** default ********************************
- *
- */
- default:
- elog(WARN, "ProcessUtility: command #%d unsupported",
- nodeTag(parsetree));
- break;
+
+ DropTrigger((DropTrigStmt *) parsetree);
+ break;
+
+ /*
+ * ******************************** default ********************************
+ *
+ */
+ default:
+ elog(WARN, "ProcessUtility: command #%d unsupported",
+ nodeTag(parsetree));
+ break;
}
/* ----------------