diff options
Diffstat (limited to 'src/backend/tcop')
-rw-r--r-- | src/backend/tcop/fastpath.c | 10 | ||||
-rw-r--r-- | src/backend/tcop/postgres.c | 111 | ||||
-rw-r--r-- | src/backend/tcop/utility.c | 155 |
3 files changed, 140 insertions, 136 deletions
diff --git a/src/backend/tcop/fastpath.c b/src/backend/tcop/fastpath.c index 213e54af684..1b38fe7ed08 100644 --- a/src/backend/tcop/fastpath.c +++ b/src/backend/tcop/fastpath.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.37 2000/01/26 05:57:07 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.38 2000/04/12 17:15:43 momjian Exp $ * * NOTES * This cruft is the server side of PQfn. @@ -302,10 +302,10 @@ HandleFunctionRequest() update_fp_info(fid, fip); /* - * XXX FIXME: elog() here means we lose sync with the frontend, - * since we have not swallowed all of its input message. What - * should happen is we absorb all of the input message per protocol - * syntax, and *then* do error checking and elog if appropriate. + * XXX FIXME: elog() here means we lose sync with the frontend, since + * we have not swallowed all of its input message. What should happen + * is we absorb all of the input message per protocol syntax, and + * *then* do error checking and elog if appropriate. */ if (fip->nargs != nargs) diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 402725efb51..c9bfcad00d8 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.150 2000/04/04 23:52:50 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.151 2000/04/12 17:15:43 momjian Exp $ * * NOTES * this is the "main" module of the postgres backend and @@ -101,14 +101,14 @@ CommandDest whereToSendOutput = Debug; PS_DEFINE_BUFFER; #endif -extern void BaseInit(void); -extern void StartupXLOG(void); -extern void ShutdownXLOG(void); +extern void BaseInit(void); +extern void StartupXLOG(void); +extern void ShutdownXLOG(void); -extern void HandleDeadLock(SIGNAL_ARGS); +extern void HandleDeadLock(SIGNAL_ARGS); -extern char XLogDir[]; -extern char ControlFilePath[]; +extern char XLogDir[]; +extern char ControlFilePath[]; extern int lockingOff; extern int NBuffers; @@ -126,7 +126,7 @@ bool ExitAfterAbort = false; extern int NBuffers; -static bool EchoQuery = false; /* default don't echo */ +static bool EchoQuery = false; /* default don't echo */ time_t tim; char pg_pathname[MAXPGPATH]; FILE *StatFp; @@ -154,9 +154,9 @@ int XfuncMode = 0; * decls for routines only used in this file * ---------------------------------------------------------------- */ -static int InteractiveBackend(StringInfo inBuf); -static int SocketBackend(StringInfo inBuf); -static int ReadCommand(StringInfo inBuf); +static int InteractiveBackend(StringInfo inBuf); +static int SocketBackend(StringInfo inBuf); +static int ReadCommand(StringInfo inBuf); static void pg_exec_query(char *query_string); @@ -169,7 +169,7 @@ static void pg_exec_query(char *query_string); * InteractiveBackend() is called for user interactive connections * the string entered by the user is placed in its parameter inBuf. * - * EOF is returned if end-of-file input is seen; time to shut down. + * EOF is returned if end-of-file input is seen; time to shut down. * ---------------- */ @@ -277,7 +277,7 @@ InteractiveBackend(StringInfo inBuf) * the function call is processed in HandleFunctionRequest() * (now called from PostgresMain()). * - * EOF is returned if the connection is lost. + * EOF is returned if the connection is lost. * ---------------- */ @@ -349,11 +349,12 @@ SocketBackend(StringInfo inBuf) static int ReadCommand(StringInfo inBuf) { - MemoryContext oldcontext; - int result; + MemoryContext oldcontext; + int result; - /* Make sure any expansion of inBuf happens in permanent memory context, - * so that we can keep using it for future command cycles. + /* + * Make sure any expansion of inBuf happens in permanent memory + * context, so that we can keep using it for future command cycles. */ oldcontext = MemoryContextSwitchTo(TopMemoryContext); if (IsUnderPostmaster) @@ -372,9 +373,9 @@ ReadCommand(StringInfo inBuf) * multiple queries and/or the rewriter might expand one query to several. */ List * -pg_parse_and_rewrite(char *query_string, /* string to execute */ - Oid *typev, /* argument types */ - int nargs, /* number of arguments */ +pg_parse_and_rewrite(char *query_string, /* string to execute */ + Oid *typev,/* argument types */ + int nargs, /* number of arguments */ bool aclOverride) { List *querytree_list; @@ -383,9 +384,7 @@ pg_parse_and_rewrite(char *query_string, /* string to execute */ List *new_list; if (DebugPrintQuery) - { TPRINTF(TRACE_QUERY, "query: %s", query_string); - } /* ---------------- * (1) parse the request string into a list of parse trees @@ -436,7 +435,8 @@ pg_parse_and_rewrite(char *query_string, /* string to execute */ else { /* rewrite regular queries */ - List *rewritten = QueryRewrite(querytree); + List *rewritten = QueryRewrite(querytree); + new_list = nconc(new_list, rewritten); } } @@ -586,11 +586,10 @@ pg_exec_query_dest(char *query_string, /* string to execute */ * list pointer has been advanced before the query is executed. We * need to do that because VACUUM has a nasty little habit of doing * CommitTransactionCommand at startup, and that will release the - * memory holding our parse list :-(. This needs a better - * solution --- currently, the code will crash if someone submits - * "vacuum; something-else" in a single query string. But memory - * allocation needs redesigned anyway, so this will have to do for - * now. + * memory holding our parse list :-(. This needs a better solution + * --- currently, the code will crash if someone submits "vacuum; + * something-else" in a single query string. But memory allocation + * needs redesigned anyway, so this will have to do for now. */ while (querytree_list) { @@ -637,7 +636,8 @@ pg_exec_query_dest(char *query_string, /* string to execute */ EndCommand(tag, dest); - /* We continue in the loop, on the off chance that there + /* + * We continue in the loop, on the off chance that there * is a COMMIT or ROLLBACK utility command later in the * query string. */ @@ -735,6 +735,7 @@ void die(SIGNAL_ARGS) { PG_SETMASK(&BlockSig); + /* * If ERROR/FATAL is in progress... */ @@ -840,7 +841,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) extern int optind; extern char *optarg; - extern int DebugLvl; + extern int DebugLvl; /* * Set default values for command-line options. @@ -1210,16 +1211,15 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) fprintf(stderr, "%s does not know where to find the database system " "data. You must specify the directory that contains the " "database system either by specifying the -D invocation " - "option or by setting the PGDATA environment variable.\n\n", + "option or by setting the PGDATA environment variable.\n\n", argv[0]); proc_exit(1); } /* - * 1. Set BlockSig and UnBlockSig masks. - * 2. Set up signal handlers. - * 3. Allow only SIGUSR1 signal (we never block it) - * during initialization. + * 1. Set BlockSig and UnBlockSig masks. 2. Set up signal handlers. 3. + * Allow only SIGUSR1 signal (we never block it) during + * initialization. * * Note that postmaster already blocked ALL signals to make us happy. */ @@ -1235,22 +1235,23 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) BlockSig &= ~(sigmask(SIGUSR1)); #endif - pqsignal(SIGHUP, read_pg_options); /* update pg_options from file */ - pqsignal(SIGINT, QueryCancelHandler); /* cancel current query */ - pqsignal(SIGQUIT, handle_warn); /* handle error */ + pqsignal(SIGHUP, read_pg_options); /* update pg_options from file */ + pqsignal(SIGINT, QueryCancelHandler); /* cancel current query */ + pqsignal(SIGQUIT, handle_warn); /* handle error */ pqsignal(SIGTERM, die); pqsignal(SIGALRM, HandleDeadLock); - /* - * Ignore failure to write to frontend. Note: if frontend closes - * connection, we will notice it and exit cleanly when control next - * returns to outer loop. This seems safer than forcing exit in the + + /* + * Ignore failure to write to frontend. Note: if frontend closes + * connection, we will notice it and exit cleanly when control next + * returns to outer loop. This seems safer than forcing exit in the * midst of output during who-knows-what operation... */ pqsignal(SIGPIPE, SIG_IGN); pqsignal(SIGUSR1, quickdie); - pqsignal(SIGUSR2, Async_NotifyHandler); /* flush also sinval cache */ + pqsignal(SIGUSR2, Async_NotifyHandler); /* flush also sinval cache */ pqsignal(SIGFPE, FloatExceptionHandler); - pqsignal(SIGCHLD, SIG_IGN); /* ignored, sent by LockOwners */ + pqsignal(SIGCHLD, SIG_IGN); /* ignored, sent by LockOwners */ pqsignal(SIGTTIN, SIG_DFL); pqsignal(SIGTTOU, SIG_DFL); pqsignal(SIGCONT, SIG_DFL); @@ -1298,9 +1299,9 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) * Try to create pid file. */ SetPidFname(DataDir); - if (SetPidFile(-getpid())) { + if (SetPidFile(-getpid())) proc_exit(0); - } + /* * Register clean up proc. */ @@ -1365,6 +1366,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) remote_info = remote_host = "unknown"; break; } + /* * Set process params for ps */ @@ -1425,13 +1427,14 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) on_shmem_exit(remove_all_temp_relations, NULL); { - MemoryContext oldcontext = MemoryContextSwitchTo(TopMemoryContext); - parser_input = makeStringInfo(); /* initialize input buffer */ + MemoryContext oldcontext = MemoryContextSwitchTo(TopMemoryContext); + + parser_input = makeStringInfo(); /* initialize input buffer */ MemoryContextSwitchTo(oldcontext); } - /* - * Send this backend's cancellation info to the frontend. + /* + * Send this backend's cancellation info to the frontend. */ if (whereToSendOutput == Remote && PG_PROTOCOL_MAJOR(FrontendProtocol) >= 2) @@ -1449,7 +1452,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) if (!IsUnderPostmaster) { puts("\nPOSTGRES backend interactive interface "); - puts("$Revision: 1.150 $ $Date: 2000/04/04 23:52:50 $\n"); + puts("$Revision: 1.151 $ $Date: 2000/04/12 17:15:43 $\n"); } /* @@ -1463,8 +1466,8 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) /* * POSTGRES main processing loop begins here * - * If an exception is encountered, processing resumes here - * so we abort the current transaction and start a new one. + * If an exception is encountered, processing resumes here so we abort + * the current transaction and start a new one. */ if (sigsetjmp(Warn_restart, 1) != 0) @@ -1478,7 +1481,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) InError = false; if (ExitAfterAbort) { - ProcReleaseLocks(); /* Just to be sure... */ + ProcReleaseLocks(); /* Just to be sure... */ proc_exit(0); } } diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index d3ba5b319dd..2cc10fe1cd9 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.85 2000/04/04 21:44:40 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.86 2000/04/12 17:15:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -164,7 +164,7 @@ ProcessUtility(Node *parsetree, case T_DropStmt: { - DropStmt *stmt = (DropStmt *) parsetree; + DropStmt *stmt = (DropStmt *) parsetree; List *args = stmt->relNames; List *arg; @@ -213,17 +213,17 @@ ProcessUtility(Node *parsetree, PS_SET_STATUS(commandTag = "TRUNCATE"); CHECK_IF_ABORTED(); - relname = ((TruncateStmt *) parsetree)->relName; + relname = ((TruncateStmt *) parsetree)->relName; if (!allowSystemTableMods && IsSystemRelationName(relname)) elog(ERROR, "TRUNCATE cannot be used on system tables. '%s' is a system table", relname); /* Grab exclusive lock in preparation for truncate... */ rel = heap_openr(relname, AccessExclusiveLock); - if (rel->rd_rel->relkind == RELKIND_SEQUENCE) + if (rel->rd_rel->relkind == RELKIND_SEQUENCE) elog(ERROR, "TRUNCATE cannot be used on sequences. '%s' is a sequence", relname); - heap_close(rel, NoLock); + heap_close(rel, NoLock); #ifndef NO_SECURITY if (!pg_ownercheck(userName, relname, RELNAME)) @@ -233,21 +233,21 @@ ProcessUtility(Node *parsetree, } break; - case T_CommentStmt: - { - - CommentStmt *statement; - - statement = ((CommentStmt *) parsetree); - - PS_SET_STATUS(commandTag = "COMMENT"); - CHECK_IF_ABORTED(); - CommentObject(statement->objtype, statement->objname, - statement->objproperty, statement->objlist, - statement->comment); - } - break; - + case T_CommentStmt: + { + + CommentStmt *statement; + + statement = ((CommentStmt *) parsetree); + + PS_SET_STATUS(commandTag = "COMMENT"); + CHECK_IF_ABORTED(); + CommentObject(statement->objtype, statement->objname, + statement->objproperty, statement->objlist, + statement->comment); + } + break; + case T_CopyStmt: @@ -272,7 +272,7 @@ ProcessUtility(Node *parsetree, */ stmt->filename, stmt->delimiter, - stmt->null_print); + stmt->null_print); } break; @@ -333,42 +333,42 @@ ProcessUtility(Node *parsetree, } break; - /* various Alter Table forms */ + /* various Alter Table forms */ case T_AlterTableStmt: - { - AlterTableStmt *stmt = (AlterTableStmt *) parsetree; - - PS_SET_STATUS(commandTag = "ALTER"); - CHECK_IF_ABORTED(); - - /* - * Some or all of these functions are recursive to cover inherited things, - * so permission checks are done there. - */ - switch(stmt->subtype) - { - case 'A': /* ADD COLUMN */ - AlterTableAddColumn(stmt->relname, stmt->inh, (ColumnDef *) stmt->def); - break; - case 'T': /* ALTER COLUMN */ - AlterTableAlterColumn(stmt->relname, stmt->inh, stmt->name, stmt->def); - break; - case 'D': /* ALTER DROP */ - AlterTableDropColumn(stmt->relname, stmt->inh, stmt->name, stmt->behavior); - break; - case 'C': /* ADD CONSTRAINT */ - AlterTableAddConstraint(stmt->relname, stmt->inh, stmt->def); - break; - case 'X': /* DROP CONSTRAINT */ - AlterTableDropConstraint(stmt->relname, stmt->inh, stmt->name, stmt->behavior); - break; - default: /* oops */ - elog(ERROR, "T_AlterTableStmt: unknown subtype"); - break; - } - } - break; + { + AlterTableStmt *stmt = (AlterTableStmt *) parsetree; + + PS_SET_STATUS(commandTag = "ALTER"); + CHECK_IF_ABORTED(); + + /* + * Some or all of these functions are recursive to cover + * inherited things, so permission checks are done there. + */ + switch (stmt->subtype) + { + case 'A': /* ADD COLUMN */ + AlterTableAddColumn(stmt->relname, stmt->inh, (ColumnDef *) stmt->def); + break; + case 'T': /* ALTER COLUMN */ + AlterTableAlterColumn(stmt->relname, stmt->inh, stmt->name, stmt->def); + break; + case 'D': /* ALTER DROP */ + AlterTableDropColumn(stmt->relname, stmt->inh, stmt->name, stmt->behavior); + break; + case 'C': /* ADD CONSTRAINT */ + AlterTableAddConstraint(stmt->relname, stmt->inh, stmt->def); + break; + case 'X': /* DROP CONSTRAINT */ + AlterTableDropConstraint(stmt->relname, stmt->inh, stmt->name, stmt->behavior); + break; + default: /* oops */ + elog(ERROR, "T_AlterTableStmt: unknown subtype"); + break; + } + } + break; case T_ChangeACLStmt: @@ -385,7 +385,7 @@ ProcessUtility(Node *parsetree, modechg = stmt->modechg; foreach(i, stmt->relNames) - { + { Relation rel; relname = strVal(lfirst(i)); @@ -830,26 +830,26 @@ ProcessUtility(Node *parsetree, DeferredTriggerSetState((ConstraintsSetStmt *) parsetree); break; - case T_CreateGroupStmt: - PS_SET_STATUS(commandTag = "CREATE GROUP"); + case T_CreateGroupStmt: + PS_SET_STATUS(commandTag = "CREATE GROUP"); CHECK_IF_ABORTED(); - CreateGroup((CreateGroupStmt *) parsetree); - break; + CreateGroup((CreateGroupStmt *) parsetree); + break; - case T_AlterGroupStmt: - PS_SET_STATUS(commandTag = "ALTER GROUP"); + case T_AlterGroupStmt: + PS_SET_STATUS(commandTag = "ALTER GROUP"); CHECK_IF_ABORTED(); - AlterGroup((AlterGroupStmt *) parsetree, "ALTER GROUP"); - break; + AlterGroup((AlterGroupStmt *) parsetree, "ALTER GROUP"); + break; - case T_DropGroupStmt: - PS_SET_STATUS(commandTag = "DROP GROUP"); + case T_DropGroupStmt: + PS_SET_STATUS(commandTag = "DROP GROUP"); CHECK_IF_ABORTED(); - DropGroup((DropGroupStmt *) parsetree); - break; + DropGroup((DropGroupStmt *) parsetree); + break; case T_ReindexStmt: { @@ -861,15 +861,15 @@ ProcessUtility(Node *parsetree, switch (stmt->reindexType) { case INDEX: - relname = (char*) stmt->name; + relname = (char *) stmt->name; if (IsSystemRelationName(relname)) { if (!allowSystemTableMods && IsSystemRelationName(relname)) - elog(ERROR, "class \"%s\" is a system catalog index", - relname); + elog(ERROR, "class \"%s\" is a system catalog index", + relname); if (!IsIgnoringSystemIndexes()) elog(ERROR, "class \"%s\" is a system catalog index", - relname); + relname); } #ifndef NO_SECURITY if (!pg_ownercheck(userName, relname, RELNAME)) @@ -878,15 +878,15 @@ ProcessUtility(Node *parsetree, ReindexIndex(relname, stmt->force); break; case TABLE: - relname = (char*) stmt->name; + relname = (char *) stmt->name; if (IsSystemRelationName(relname)) { if (!allowSystemTableMods && IsSystemRelationName(relname)) - elog(ERROR, "class \"%s\" is a system catalog index", - relname); + elog(ERROR, "class \"%s\" is a system catalog index", + relname); if (!IsIgnoringSystemIndexes()) elog(ERROR, "class \"%s\" is a system catalog index", - relname); + relname); } #ifndef NO_SECURITY if (!pg_ownercheck(userName, relname, RELNAME)) @@ -895,7 +895,7 @@ ProcessUtility(Node *parsetree, ReindexTable(relname, stmt->force); break; case DATABASE: - relname = (char*) stmt->name; + relname = (char *) stmt->name; if (!allowSystemTableMods) elog(ERROR, "-O option is needed"); if (!IsIgnoringSystemIndexes()) @@ -906,6 +906,7 @@ ProcessUtility(Node *parsetree, break; } break; + /* * ******************************** default ******************************** * |