diff options
author | Tom Lane | 2002-02-26 22:47:12 +0000 |
---|---|---|
committer | Tom Lane | 2002-02-26 22:47:12 +0000 |
commit | 56ee2ecba96a742bb6e18dfe8ee48054e90ebaa9 (patch) | |
tree | 905c72dc3db475d47d04472a1de7ab715b5725c7 /src/backend/tcop | |
parent | f71dc6d0e28a855f2d782ec48f950ffeaca1307d (diff) |
Restructure command-completion-report code so that there is just one
report for each received SQL command, regardless of rewriting activity.
Also ensure that this report comes from the 'original' command, not the
last command generated by rewrite; this fixes 7.2 breakage for INSERT
commands that have actions added by rules. Fernando Nasser and Tom Lane.
Diffstat (limited to 'src/backend/tcop')
-rw-r--r-- | src/backend/tcop/dest.c | 43 | ||||
-rw-r--r-- | src/backend/tcop/postgres.c | 365 | ||||
-rw-r--r-- | src/backend/tcop/pquery.c | 110 | ||||
-rw-r--r-- | src/backend/tcop/utility.c | 130 |
4 files changed, 424 insertions, 224 deletions
diff --git a/src/backend/tcop/dest.c b/src/backend/tcop/dest.c index 5ed8896938a..f055bc3137b 100644 --- a/src/backend/tcop/dest.c +++ b/src/backend/tcop/dest.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/dest.c,v 1.46 2001/10/28 06:25:51 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/dest.c,v 1.47 2002/02/26 22:47:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -41,8 +41,6 @@ #include "libpq/pqformat.h" -static char CommandInfo[32] = {0}; - /* ---------------- * dummy DestReceiver functions * ---------------- @@ -102,7 +100,6 @@ BeginCommand(char *pname, * if this is a "retrieve into portal" query, done because * nothing needs to be sent to the fe. */ - CommandInfo[0] = '\0'; if (isIntoPortal) break; @@ -198,30 +195,22 @@ DestToFunction(CommandDest dest) } /* ---------------- - * EndCommand - tell destination that no more tuples will arrive + * EndCommand - tell destination that query is complete * ---------------- */ void -EndCommand(char *commandTag, CommandDest dest) +EndCommand(const char *commandTag, CommandDest dest) { - char buf[64]; - switch (dest) { case Remote: case RemoteInternal: - - /* - * tell the fe that the query is over - */ - sprintf(buf, "%s%s", commandTag, CommandInfo); - pq_puttextmessage('C', buf); - CommandInfo[0] = '\0'; + pq_puttextmessage('C', commandTag); break; - case Debug: case None: - default: + case Debug: + case SPI: break; } } @@ -317,23 +306,3 @@ ReadyForQuery(CommandDest dest) break; } } - -void -UpdateCommandInfo(int operation, Oid lastoid, uint32 tuples) -{ - switch (operation) - { - case CMD_INSERT: - if (tuples > 1) - lastoid = InvalidOid; - sprintf(CommandInfo, " %u %u", lastoid, tuples); - break; - case CMD_DELETE: - case CMD_UPDATE: - sprintf(CommandInfo, " %u", tuples); - break; - default: - CommandInfo[0] = '\0'; - break; - } -} diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 976b434655f..61fdf9c5acf 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.247 2002/02/23 01:31:36 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.248 2002/02/26 22:47:08 tgl Exp $ * * NOTES * this is the "main" module of the postgres backend and @@ -64,6 +64,7 @@ #include "pgstat.h" + /* ---------------- * global variables * ---------------- @@ -87,6 +88,13 @@ bool InError = false; static bool EchoQuery = false; /* default don't echo */ +/* + * Flag to mark SIGHUP. Whenever the main loop comes around it + * will reread the configuration file. (Better than doing the + * reading in the signal handler, ey?) + */ +static volatile bool got_SIGHUP = false; + /* ---------------- * people who want to use EOF should #define DONTUSENEWLINE in * tcop/tcopdebug.h @@ -118,13 +126,7 @@ static void start_xact_command(void); static void finish_xact_command(void); static void SigHupHandler(SIGNAL_ARGS); static void FloatExceptionHandler(SIGNAL_ARGS); - -/* - * Flag to mark SIGHUP. Whenever the main loop comes around it - * will reread the configuration file. (Better than doing the - * reading in the signal handler, ey?) - */ -static volatile bool got_SIGHUP = false; +static const char *CreateCommandTag(Node *parsetree); /* ---------------------------------------------------------------- @@ -635,6 +637,8 @@ pg_exec_query_string(char *query_string, /* string to execute */ { Node *parsetree = (Node *) lfirst(parsetree_item); bool isTransactionStmt; + const char *commandTag; + char completionTag[COMPLETION_TAG_BUFSIZE]; List *querytree_list, *querytree_item; @@ -670,16 +674,17 @@ pg_exec_query_string(char *query_string, /* string to execute */ if (!allowit) { - /* - * the EndCommand() stuff is to tell the frontend that the - * command ended. -cim 6/1/90 - */ - char *tag = "*ABORT STATE*"; - elog(NOTICE, "current transaction is aborted, " "queries ignored until end of transaction block"); - EndCommand(tag, dest); + /* + * We need to emit a command-complete report to the client, + * even though we didn't process the query. + * - cim 6/1/90 + */ + commandTag = "*ABORT STATE*"; + + EndCommand(commandTag, dest); /* * We continue in the loop, on the off chance that there @@ -702,7 +707,18 @@ pg_exec_query_string(char *query_string, /* string to execute */ /* * OK to analyze and rewrite this query. - * + */ + + /* + * First we set the command-completion tag to the main query + * (as opposed to each of the others that may be generated by + * analyze and rewrite). Also set ps_status to the main query tag. + */ + commandTag = CreateCommandTag(parsetree); + + set_ps_display(commandTag); + + /* * Switch to appropriate context for constructing querytrees (again, * these must outlive the execution context). */ @@ -746,7 +762,19 @@ pg_exec_query_string(char *query_string, /* string to execute */ else if (DebugLvl > 1) elog(DEBUG, "ProcessUtility"); - ProcessUtility(querytree->utilityStmt, dest); + if (querytree->originalQuery) + { + /* utility statement can override default tag string */ + ProcessUtility(querytree->utilityStmt, dest, + completionTag); + if (completionTag[0]) + commandTag = completionTag; + } + else + { + /* utility added by rewrite cannot override tag */ + ProcessUtility(querytree->utilityStmt, dest, NULL); + } } else { @@ -778,7 +806,18 @@ pg_exec_query_string(char *query_string, /* string to execute */ { if (DebugLvl > 1) elog(DEBUG, "ProcessQuery"); - ProcessQuery(querytree, plan, dest); + + if (querytree->originalQuery) + { + /* original stmt can override default tag string */ + ProcessQuery(querytree, plan, dest, completionTag); + commandTag = completionTag; + } + else + { + /* stmt added by rewrite cannot override tag */ + ProcessQuery(querytree, plan, dest, NULL); + } } if (Show_executor_stats) @@ -818,6 +857,29 @@ pg_exec_query_string(char *query_string, /* string to execute */ } /* end loop over queries generated from a * parsetree */ + + /* + * It is possible that the original query was removed due to + * a DO INSTEAD rewrite rule. In that case we will still have + * the default completion tag, which is fine for most purposes, + * but it may confuse clients if it's INSERT/UPDATE/DELETE. + * Clients expect those tags to have counts after them (cf. + * ProcessQuery). + */ + if (strcmp(commandTag, "INSERT") == 0) + commandTag = "INSERT 0 0"; + else if (strcmp(commandTag, "UPDATE") == 0) + commandTag = "UPDATE 0"; + else if (strcmp(commandTag, "DELETE") == 0) + commandTag = "DELETE 0"; + + /* + * Tell client that we're done with this query. Note we emit + * exactly one EndCommand report for each raw parsetree, thus + * one for each SQL command the client sent, regardless of + * rewriting. + */ + EndCommand(commandTag, dest); } /* end loop over parsetrees */ /* @@ -1626,7 +1688,7 @@ PostgresMain(int argc, char *argv[], const char *username) if (!IsUnderPostmaster) { puts("\nPOSTGRES backend interactive interface "); - puts("$Revision: 1.247 $ $Date: 2002/02/23 01:31:36 $\n"); + puts("$Revision: 1.248 $ $Date: 2002/02/26 22:47:08 $\n"); } /* @@ -2037,3 +2099,268 @@ assertTest(int val) #endif #endif + + +/* ---------------------------------------------------------------- + * CreateCommandTag + * + * utility to get a string representation of the + * command operation. + * ---------------------------------------------------------------- + */ +static const char * +CreateCommandTag(Node *parsetree) +{ + const char *tag; + + switch (nodeTag(parsetree)) + { + case T_InsertStmt: + tag = "INSERT"; + break; + + case T_DeleteStmt: + tag = "DELETE"; + break; + + case T_UpdateStmt: + tag = "UPDATE"; + break; + + case T_SelectStmt: + tag = "SELECT"; + break; + + case T_TransactionStmt: + { + TransactionStmt *stmt = (TransactionStmt *) parsetree; + + switch (stmt->command) + { + case BEGIN_TRANS: + tag = "BEGIN"; + break; + + case COMMIT: + tag = "COMMIT"; + break; + + case ROLLBACK: + tag = "ROLLBACK"; + break; + + default: + tag = "???"; + break; + } + } + break; + + case T_ClosePortalStmt: + tag = "CLOSE"; + break; + + case T_FetchStmt: + { + FetchStmt *stmt = (FetchStmt *) parsetree; + tag = (stmt->ismove) ? "MOVE" : "FETCH"; + } + break; + + case T_CreateStmt: + tag = "CREATE"; + break; + + case T_DropStmt: + tag = "DROP"; + break; + + case T_TruncateStmt: + tag = "TRUNCATE"; + break; + + case T_CommentStmt: + tag = "COMMENT"; + break; + + case T_CopyStmt: + tag = "COPY"; + break; + + case T_RenameStmt: + tag = "ALTER"; + break; + + case T_AlterTableStmt: + tag = "ALTER"; + break; + + case T_GrantStmt: + { + GrantStmt *stmt = (GrantStmt *) parsetree; + tag = (stmt->is_grant) ? "GRANT" : "REVOKE"; + } + break; + + case T_DefineStmt: + tag = "CREATE"; + break; + + case T_ViewStmt: /* CREATE VIEW */ + tag = "CREATE"; + break; + + case T_ProcedureStmt: /* CREATE FUNCTION */ + tag = "CREATE"; + break; + + case T_IndexStmt: /* CREATE INDEX */ + tag = "CREATE"; + break; + + case T_RuleStmt: /* CREATE RULE */ + tag = "CREATE"; + break; + + case T_CreateSeqStmt: + tag = "CREATE"; + break; + + case T_RemoveAggrStmt: + tag = "DROP"; + break; + + case T_RemoveFuncStmt: + tag = "DROP"; + break; + + case T_RemoveOperStmt: + tag = "DROP"; + break; + + case T_VersionStmt: + tag = "CREATE VERSION"; + break; + + case T_CreatedbStmt: + tag = "CREATE DATABASE"; + break; + + case T_DropdbStmt: + tag = "DROP DATABASE"; + break; + + case T_NotifyStmt: + tag = "NOTIFY"; + break; + + case T_ListenStmt: + tag = "LISTEN"; + break; + + case T_UnlistenStmt: + tag = "UNLISTEN"; + break; + + case T_LoadStmt: + tag = "LOAD"; + break; + + case T_ClusterStmt: + tag = "CLUSTER"; + break; + + case T_VacuumStmt: + if (((VacuumStmt *) parsetree)->vacuum) + tag = "VACUUM"; + else + tag = "ANALYZE"; + break; + + case T_ExplainStmt: + tag = "EXPLAIN"; + break; + +#ifdef NOT_USED + case T_RecipeStmt: + tag = "EXECUTE RECIPE"; + break; +#endif + + case T_VariableSetStmt: + tag = "SET VARIABLE"; + break; + + case T_VariableShowStmt: + tag = "SHOW VARIABLE"; + break; + + case T_VariableResetStmt: + tag = "RESET VARIABLE"; + break; + + case T_CreateTrigStmt: + tag = "CREATE"; + break; + + case T_DropTrigStmt: + tag = "DROP"; + break; + + case T_CreatePLangStmt: + tag = "CREATE"; + break; + + case T_DropPLangStmt: + tag = "DROP"; + break; + + case T_CreateUserStmt: + tag = "CREATE USER"; + break; + + case T_AlterUserStmt: + tag = "ALTER USER"; + break; + + case T_DropUserStmt: + tag = "DROP USER"; + break; + + case T_LockStmt: + tag = "LOCK TABLE"; + break; + + case T_ConstraintsSetStmt: + tag = "SET CONSTRAINTS"; + break; + + case T_CreateGroupStmt: + tag = "CREATE GROUP"; + break; + + case T_AlterGroupStmt: + tag = "ALTER GROUP"; + break; + + case T_DropGroupStmt: + tag = "DROP GROUP"; + break; + + case T_CheckPointStmt: + tag = "CHECKPOINT"; + break; + + case T_ReindexStmt: + tag = "REINDEX"; + break; + + default: + elog(DEBUG, "CreateCommandTag: unknown parse node type %d", + nodeTag(parsetree)); + tag = "???"; + break; + } + + return tag; +} diff --git a/src/backend/tcop/pquery.c b/src/backend/tcop/pquery.c index 91d98a2d50d..75b99c21fab 100644 --- a/src/backend/tcop/pquery.c +++ b/src/backend/tcop/pquery.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.46 2001/10/25 05:49:43 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.47 2002/02/26 22:47:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -23,9 +23,6 @@ #include "utils/ps_status.h" -static char *CreateOperationTag(int operationType); - - /* ---------------------------------------------------------------- * CreateQueryDesc * ---------------------------------------------------------------- @@ -89,42 +86,6 @@ CreateExecutorState(void) return state; } -/* ---------------------------------------------------------------- - * CreateOperationTag - * - * utility to get a string representation of the - * query operation. - * ---------------------------------------------------------------- - */ -static char * -CreateOperationTag(int operationType) -{ - char *tag; - - switch (operationType) - { - case CMD_SELECT: - tag = "SELECT"; - break; - case CMD_INSERT: - tag = "INSERT"; - break; - case CMD_DELETE: - tag = "DELETE"; - break; - case CMD_UPDATE: - tag = "UPDATE"; - break; - default: - elog(DEBUG, "CreateOperationTag: unknown operation type %d", - operationType); - tag = "???"; - break; - } - - return tag; -} - /* ---------------- * PreparePortal * ---------------- @@ -158,19 +119,25 @@ PreparePortal(char *portalName) } -/* ---------------------------------------------------------------- - * ProcessQuery +/* + * ProcessQuery + * Execute a query * - * Execute a plan, the non-parallel version - * ---------------------------------------------------------------- + * parsetree: the query tree + * plan: the plan tree for the query + * dest: where to send results + * completionTag: points to a buffer of size COMPLETION_TAG_BUFSIZE + * in which to store a command completion status string. + * + * completionTag may be NULL if caller doesn't want a status string. */ void ProcessQuery(Query *parsetree, Plan *plan, - CommandDest dest) + CommandDest dest, + char *completionTag) { int operation = parsetree->commandType; - char *tag; bool isRetrieveIntoPortal; bool isRetrieveIntoRelation; char *intoName = NULL; @@ -180,8 +147,6 @@ ProcessQuery(Query *parsetree, EState *state; TupleDesc attinfo; - set_ps_display(tag = CreateOperationTag(operation)); - /* * initialize portal/into relation status */ @@ -238,8 +203,7 @@ ProcessQuery(Query *parsetree, * When performing a retrieve into, we override the normal * communication destination during the processing of the the query. * This only affects the tuple-output function - the correct - * destination will still see BeginCommand() and EndCommand() - * messages. + * destination will still see the BeginCommand() call. */ if (isRetrieveIntoRelation) queryDesc->dest = None; @@ -263,7 +227,7 @@ ProcessQuery(Query *parsetree, attinfo, isRetrieveIntoRelation, isRetrieveIntoPortal, - tag, + NULL, /* not used */ dest); /* @@ -281,7 +245,9 @@ ProcessQuery(Query *parsetree, /* Now we can return to caller's memory context. */ MemoryContextSwitchTo(oldContext); - EndCommand(tag, dest); + /* Set completion tag. SQL calls this operation DECLARE CURSOR */ + if (completionTag) + strcpy(completionTag, "DECLARE"); return; } @@ -292,16 +258,42 @@ ProcessQuery(Query *parsetree, */ ExecutorRun(queryDesc, state, EXEC_RUN, 0L); - /* save infos for EndCommand */ - UpdateCommandInfo(operation, state->es_lastoid, state->es_processed); - /* - * Now, we close down all the scans and free allocated resources. + * Build command completion status string, if caller wants one. */ - ExecutorEnd(queryDesc, state); + if (completionTag) + { + Oid lastOid; + + switch (operation) + { + case CMD_SELECT: + strcpy(completionTag, "SELECT"); + break; + case CMD_INSERT: + if (state->es_processed == 1) + lastOid = state->es_lastoid; + else + lastOid = InvalidOid; + snprintf(completionTag, COMPLETION_TAG_BUFSIZE, + "INSERT %u %u", lastOid, state->es_processed); + break; + case CMD_UPDATE: + snprintf(completionTag, COMPLETION_TAG_BUFSIZE, + "UPDATE %u", state->es_processed); + break; + case CMD_DELETE: + snprintf(completionTag, COMPLETION_TAG_BUFSIZE, + "DELETE %u", state->es_processed); + break; + default: + strcpy(completionTag, "???"); + break; + } + } /* - * Notify the destination of end of processing. + * Now, we close down all the scans and free allocated resources. */ - EndCommand(tag, dest); + ExecutorEnd(queryDesc, state); } diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index f80a6bdca44..a6a8b561e02 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.126 2002/02/24 20:20:20 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.127 2002/02/26 22:47:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -44,7 +44,6 @@ #include "rewrite/rewriteRemove.h" #include "tcop/utility.h" #include "utils/acl.h" -#include "utils/ps_status.h" #include "utils/syscache.h" #include "utils/temprel.h" #include "access/xlog.h" @@ -130,18 +129,31 @@ CheckDropPermissions(char *name, char rightkind) } -/* ---------------- +/* + * ProcessUtility * general utility function invoker - * ---------------- + * + * parsetree: the parse tree for the utility statement + * dest: where to send results + * completionTag: points to a buffer of size COMPLETION_TAG_BUFSIZE + * in which to store a command completion status string. + * + * completionTag is only set nonempty if we want to return a nondefault + * status (currently, only used for MOVE/FETCH). + * + * completionTag may be NULL if caller doesn't want a status string. */ void ProcessUtility(Node *parsetree, - CommandDest dest) + CommandDest dest, + char *completionTag) { - char *commandTag = NULL; char *relname; char *relationName; + if (completionTag) + completionTag[0] = '\0'; + switch (nodeTag(parsetree)) { /* @@ -155,17 +167,14 @@ ProcessUtility(Node *parsetree, switch (stmt->command) { case BEGIN_TRANS: - set_ps_display(commandTag = "BEGIN"); BeginTransactionBlock(); break; case COMMIT: - set_ps_display(commandTag = "COMMIT"); EndTransactionBlock(); break; case ROLLBACK: - set_ps_display(commandTag = "ROLLBACK"); UserAbortTransactionBlock(); break; } @@ -180,8 +189,6 @@ ProcessUtility(Node *parsetree, { ClosePortalStmt *stmt = (ClosePortalStmt *) parsetree; - set_ps_display(commandTag = "CLOSE"); - PerformPortalClose(stmt->portalname, dest); } break; @@ -193,8 +200,6 @@ ProcessUtility(Node *parsetree, bool forward; int count; - set_ps_display(commandTag = (stmt->ismove) ? "MOVE" : "FETCH"); - SetQuerySnapshot(); forward = (bool) (stmt->direction == FORWARD); @@ -204,8 +209,9 @@ ProcessUtility(Node *parsetree, */ count = stmt->howMany; - PerformPortalFetch(portalName, forward, count, commandTag, - (stmt->ismove) ? None : dest); /* /dev/null for MOVE */ + PerformPortalFetch(portalName, forward, count, + (stmt->ismove) ? None : dest, + completionTag); } break; @@ -215,8 +221,6 @@ ProcessUtility(Node *parsetree, * */ case T_CreateStmt: - set_ps_display(commandTag = "CREATE"); - DefineRelation((CreateStmt *) parsetree, RELKIND_RELATION); /* @@ -234,8 +238,6 @@ ProcessUtility(Node *parsetree, List *args = stmt->names; List *arg; - set_ps_display(commandTag = "DROP"); - foreach(arg, args) { relname = strVal(lfirst(arg)); @@ -296,8 +298,6 @@ ProcessUtility(Node *parsetree, { Relation rel; - set_ps_display(commandTag = "TRUNCATE"); - relname = ((TruncateStmt *) parsetree)->relName; if (!allowSystemTableMods && IsSystemRelationName(relname)) elog(ERROR, "TRUNCATE cannot be used on system tables. '%s' is a system table", @@ -325,8 +325,6 @@ ProcessUtility(Node *parsetree, statement = ((CommentStmt *) parsetree); - set_ps_display(commandTag = "COMMENT"); - CommentObject(statement->objtype, statement->objname, statement->objproperty, statement->objlist, statement->comment); @@ -337,8 +335,6 @@ ProcessUtility(Node *parsetree, { CopyStmt *stmt = (CopyStmt *) parsetree; - set_ps_display(commandTag = "COPY"); - if (stmt->direction != FROM) SetQuerySnapshot(); @@ -365,8 +361,6 @@ ProcessUtility(Node *parsetree, { RenameStmt *stmt = (RenameStmt *) parsetree; - set_ps_display(commandTag = "ALTER"); - relname = stmt->relname; if (!allowSystemTableMods && IsSystemRelationName(relname)) elog(ERROR, "ALTER TABLE: relation \"%s\" is a system catalog", @@ -413,8 +407,6 @@ ProcessUtility(Node *parsetree, { AlterTableStmt *stmt = (AlterTableStmt *) parsetree; - set_ps_display(commandTag = "ALTER"); - /* * Some or all of these functions are recursive to cover * inherited things, so permission checks are done there. @@ -475,9 +467,6 @@ ProcessUtility(Node *parsetree, { GrantStmt *stmt = (GrantStmt *) parsetree; - commandTag = stmt->is_grant ? "GRANT" : "REVOKE"; - set_ps_display(commandTag); - ExecuteGrantStmt(stmt); } break; @@ -491,8 +480,6 @@ ProcessUtility(Node *parsetree, { DefineStmt *stmt = (DefineStmt *) parsetree; - set_ps_display(commandTag = "CREATE"); - switch (stmt->defType) { case OPERATOR: @@ -514,15 +501,11 @@ ProcessUtility(Node *parsetree, { ViewStmt *stmt = (ViewStmt *) parsetree; - set_ps_display(commandTag = "CREATE"); - DefineView(stmt->viewname, stmt->query); /* retrieve parsetree */ } break; case T_ProcedureStmt: /* CREATE FUNCTION */ - set_ps_display(commandTag = "CREATE"); - CreateFunction((ProcedureStmt *) parsetree); break; @@ -530,8 +513,6 @@ ProcessUtility(Node *parsetree, { IndexStmt *stmt = (IndexStmt *) parsetree; - set_ps_display(commandTag = "CREATE"); - relname = stmt->relname; if (!allowSystemTableMods && IsSystemRelationName(relname)) elog(ERROR, "CREATE INDEX: relation \"%s\" is a system catalog", @@ -559,15 +540,12 @@ ProcessUtility(Node *parsetree, aclcheck_result = pg_aclcheck(relname, GetUserId(), ACL_RULE); if (aclcheck_result != ACLCHECK_OK) elog(ERROR, "%s: %s", relname, aclcheck_error_strings[aclcheck_result]); - set_ps_display(commandTag = "CREATE"); DefineQueryRewrite(stmt); } break; case T_CreateSeqStmt: - set_ps_display(commandTag = "CREATE"); - DefineSequence((CreateSeqStmt *) parsetree); break; @@ -576,8 +554,6 @@ ProcessUtility(Node *parsetree, RemoveAggrStmt *stmt = (RemoveAggrStmt *) parsetree; char *typename = (char *) NULL; - set_ps_display(commandTag = "DROP"); - if (stmt->aggtype != NULL) typename = TypeNameToInternalName((TypeName *) stmt->aggtype); @@ -589,8 +565,6 @@ ProcessUtility(Node *parsetree, { RemoveFuncStmt *stmt = (RemoveFuncStmt *) parsetree; - set_ps_display(commandTag = "DROP"); - RemoveFunction(stmt->funcname, stmt->args); } break; @@ -603,8 +577,6 @@ ProcessUtility(Node *parsetree, char *typename1 = (char *) NULL; char *typename2 = (char *) NULL; - set_ps_display(commandTag = "DROP"); - if (typenode1 != NULL) typename1 = TypeNameToInternalName(typenode1); if (typenode2 != NULL) @@ -622,8 +594,6 @@ ProcessUtility(Node *parsetree, { CreatedbStmt *stmt = (CreatedbStmt *) parsetree; - set_ps_display(commandTag = "CREATE DATABASE"); - createdb(stmt->dbname, stmt->dbowner, stmt->dbpath, stmt->dbtemplate, stmt->encoding); @@ -634,8 +604,6 @@ ProcessUtility(Node *parsetree, { DropdbStmt *stmt = (DropdbStmt *) parsetree; - set_ps_display(commandTag = "DROP DATABASE"); - dropdb(stmt->dbname); } break; @@ -645,8 +613,6 @@ ProcessUtility(Node *parsetree, { NotifyStmt *stmt = (NotifyStmt *) parsetree; - set_ps_display(commandTag = "NOTIFY"); - Async_Notify(stmt->relname); } break; @@ -655,8 +621,6 @@ ProcessUtility(Node *parsetree, { ListenStmt *stmt = (ListenStmt *) parsetree; - set_ps_display(commandTag = "LISTEN"); - Async_Listen(stmt->relname, MyProcPid); } break; @@ -665,8 +629,6 @@ ProcessUtility(Node *parsetree, { UnlistenStmt *stmt = (UnlistenStmt *) parsetree; - set_ps_display(commandTag = "UNLISTEN"); - Async_Unlisten(stmt->relname, MyProcPid); } break; @@ -679,8 +641,6 @@ ProcessUtility(Node *parsetree, { LoadStmt *stmt = (LoadStmt *) parsetree; - set_ps_display(commandTag = "LOAD"); - closeAllVfds(); /* probably not necessary... */ load_file(stmt->filename); } @@ -690,8 +650,6 @@ ProcessUtility(Node *parsetree, { ClusterStmt *stmt = (ClusterStmt *) parsetree; - set_ps_display(commandTag = "CLUSTER"); - relname = stmt->relname; if (IsSystemRelationName(relname)) elog(ERROR, "CLUSTER: relation \"%s\" is a system catalog", @@ -704,12 +662,6 @@ ProcessUtility(Node *parsetree, break; case T_VacuumStmt: - if (((VacuumStmt *) parsetree)->vacuum) - commandTag = "VACUUM"; - else - commandTag = "ANALYZE"; - set_ps_display(commandTag); - vacuum((VacuumStmt *) parsetree); break; @@ -717,8 +669,6 @@ ProcessUtility(Node *parsetree, { ExplainStmt *stmt = (ExplainStmt *) parsetree; - set_ps_display(commandTag = "EXPLAIN"); - ExplainQuery(stmt->query, stmt->verbose, stmt->analyze, dest); } break; @@ -732,8 +682,6 @@ ProcessUtility(Node *parsetree, { RecipeStmt *stmt = (RecipeStmt *) parsetree; - set_ps_display(commandTag = "EXECUTE RECIPE"); - beginRecipe(stmt); } break; @@ -747,7 +695,6 @@ ProcessUtility(Node *parsetree, VariableSetStmt *n = (VariableSetStmt *) parsetree; SetPGVariable(n->name, n->args); - set_ps_display(commandTag = "SET VARIABLE"); } break; @@ -756,7 +703,6 @@ ProcessUtility(Node *parsetree, VariableShowStmt *n = (VariableShowStmt *) parsetree; GetPGVariable(n->name); - set_ps_display(commandTag = "SHOW VARIABLE"); } break; @@ -765,7 +711,6 @@ ProcessUtility(Node *parsetree, VariableResetStmt *n = (VariableResetStmt *) parsetree; ResetPGVariable(n->name); - set_ps_display(commandTag = "RESET VARIABLE"); } break; @@ -773,14 +718,10 @@ ProcessUtility(Node *parsetree, * ******************************** TRIGGER statements ******************************* */ case T_CreateTrigStmt: - set_ps_display(commandTag = "CREATE"); - CreateTrigger((CreateTrigStmt *) parsetree); break; case T_DropTrigStmt: - set_ps_display(commandTag = "DROP"); - DropTrigger((DropTrigStmt *) parsetree); break; @@ -788,14 +729,10 @@ ProcessUtility(Node *parsetree, * ************* PROCEDURAL LANGUAGE statements ***************** */ case T_CreatePLangStmt: - set_ps_display(commandTag = "CREATE"); - CreateProceduralLanguage((CreatePLangStmt *) parsetree); break; case T_DropPLangStmt: - set_ps_display(commandTag = "DROP"); - DropProceduralLanguage((DropPLangStmt *) parsetree); break; @@ -804,57 +741,39 @@ ProcessUtility(Node *parsetree, * */ case T_CreateUserStmt: - set_ps_display(commandTag = "CREATE USER"); - CreateUser((CreateUserStmt *) parsetree); break; case T_AlterUserStmt: - set_ps_display(commandTag = "ALTER USER"); - AlterUser((AlterUserStmt *) parsetree); break; case T_DropUserStmt: - set_ps_display(commandTag = "DROP USER"); - DropUser((DropUserStmt *) parsetree); break; case T_LockStmt: - set_ps_display(commandTag = "LOCK TABLE"); - LockTableCommand((LockStmt *) parsetree); break; case T_ConstraintsSetStmt: - set_ps_display(commandTag = "SET CONSTRAINTS"); - DeferredTriggerSetState((ConstraintsSetStmt *) parsetree); break; case T_CreateGroupStmt: - set_ps_display(commandTag = "CREATE GROUP"); - CreateGroup((CreateGroupStmt *) parsetree); break; case T_AlterGroupStmt: - set_ps_display(commandTag = "ALTER GROUP"); - AlterGroup((AlterGroupStmt *) parsetree, "ALTER GROUP"); break; case T_DropGroupStmt: - set_ps_display(commandTag = "DROP GROUP"); - DropGroup((DropGroupStmt *) parsetree); break; case T_CheckPointStmt: { - set_ps_display(commandTag = "CHECKPOINT"); - if (!superuser()) elog(ERROR, "permission denied"); CreateCheckPoint(false); @@ -865,8 +784,6 @@ ProcessUtility(Node *parsetree, { ReindexStmt *stmt = (ReindexStmt *) parsetree; - set_ps_display(commandTag = "REINDEX"); - switch (stmt->reindexType) { case INDEX: @@ -912,9 +829,4 @@ ProcessUtility(Node *parsetree, nodeTag(parsetree)); break; } - - /* - * tell fe/be or whatever that we're done. - */ - EndCommand(commandTag, dest); } |