Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/tcop')
-rw-r--r--src/backend/tcop/dest.c9
-rw-r--r--src/backend/tcop/fastpath.c56
-rw-r--r--src/backend/tcop/postgres.c406
-rw-r--r--src/backend/tcop/pquery.c229
-rw-r--r--src/backend/tcop/utility.c145
5 files changed, 447 insertions, 398 deletions
diff --git a/src/backend/tcop/dest.c b/src/backend/tcop/dest.c
index 76990d34f7c..7ea881e84a6 100644
--- a/src/backend/tcop/dest.c
+++ b/src/backend/tcop/dest.c
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/dest.c,v 1.59 2003/07/22 19:00:11 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/dest.c,v 1.60 2003/08/04 00:43:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -93,7 +93,7 @@ BeginCommand(const char *commandTag, CommandDest dest)
* CreateDestReceiver - return appropriate receiver function set for dest
*
* Note: a Portal must be specified for destinations Remote, RemoteExecute,
- * and Tuplestore. It can be NULL for the others.
+ * and Tuplestore. It can be NULL for the others.
* ----------------
*/
DestReceiver *
@@ -173,8 +173,9 @@ NullCommand(CommandDest dest)
case RemoteExecute:
/*
- * tell the fe that we saw an empty query string. In protocols
- * before 3.0 this has a useless empty-string message body.
+ * tell the fe that we saw an empty query string. In
+ * protocols before 3.0 this has a useless empty-string
+ * message body.
*/
if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 3)
pq_putemptymessage('I');
diff --git a/src/backend/tcop/fastpath.c b/src/backend/tcop/fastpath.c
index b86d657ea25..7ccc3f80c6b 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.66 2003/08/01 00:15:22 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.67 2003/08/04 00:43:25 momjian Exp $
*
* NOTES
* This cruft is the server side of PQfn.
@@ -53,10 +53,10 @@ struct fp_info
};
-static int16 parse_fcall_arguments(StringInfo msgBuf, struct fp_info *fip,
- FunctionCallInfo fcinfo);
-static int16 parse_fcall_arguments_20(StringInfo msgBuf, struct fp_info *fip,
- FunctionCallInfo fcinfo);
+static int16 parse_fcall_arguments(StringInfo msgBuf, struct fp_info * fip,
+ FunctionCallInfo fcinfo);
+static int16 parse_fcall_arguments_20(StringInfo msgBuf, struct fp_info * fip,
+ FunctionCallInfo fcinfo);
/* ----------------
@@ -103,8 +103,8 @@ GetOldFunctionMessage(StringInfo buf)
/* FATAL here since no hope of regaining message sync */
ereport(FATAL,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("invalid argument size %d in function call message",
- argsize)));
+ errmsg("invalid argument size %d in function call message",
+ argsize)));
}
/* and arg contents */
if (argsize > 0)
@@ -158,8 +158,8 @@ SendFunctionResult(Datum retval, bool isnull, Oid rettype, int16 format)
&typoutput, &typelem, &typisvarlena);
outputstr = DatumGetCString(OidFunctionCall3(typoutput,
retval,
- ObjectIdGetDatum(typelem),
- Int32GetDatum(-1)));
+ ObjectIdGetDatum(typelem),
+ Int32GetDatum(-1)));
pq_sendcountedtext(&buf, outputstr, strlen(outputstr), false);
pfree(outputstr);
}
@@ -174,7 +174,7 @@ SendFunctionResult(Datum retval, bool isnull, Oid rettype, int16 format)
&typsend, &typelem, &typisvarlena);
outputbytes = DatumGetByteaP(OidFunctionCall2(typsend,
retval,
- ObjectIdGetDatum(typelem)));
+ ObjectIdGetDatum(typelem)));
/* We assume the result will not have been toasted */
pq_sendint(&buf, VARSIZE(outputbytes) - VARHDRSZ, 4);
pq_sendbytes(&buf, VARDATA(outputbytes),
@@ -255,11 +255,11 @@ fetch_fp_info(Oid func_id, struct fp_info * fip)
* and will pass it in msgBuf.
* In old protocol, the passed msgBuf is empty and we must read the
* message here.
- *
+ *
* RETURNS:
* 0 if successful completion, EOF if frontend connection lost.
*
- * Note: All ordinary errors result in ereport(ERROR,...). However,
+ * Note: All ordinary errors result in ereport(ERROR,...). However,
* if we lose the frontend connection there is no one to ereport to,
* and no use in proceeding...
*
@@ -303,15 +303,15 @@ HandleFunctionRequest(StringInfo msgBuf)
ereport(ERROR,
(errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
errmsg("current transaction is aborted, "
- "queries ignored until end of transaction block")));
+ "queries ignored until end of transaction block")));
/*
* Begin parsing the buffer contents.
*/
if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3)
- (void) pq_getmsgstring(msgBuf); /* dummy string */
+ (void) pq_getmsgstring(msgBuf); /* dummy string */
- fid = (Oid) pq_getmsgint(msgBuf, 4); /* function oid */
+ fid = (Oid) pq_getmsgint(msgBuf, 4); /* function oid */
/*
* There used to be a lame attempt at caching lookup info here. Now we
@@ -359,7 +359,7 @@ HandleFunctionRequest(StringInfo msgBuf)
callit = true;
if (fip->flinfo.fn_strict)
{
- int i;
+ int i;
for (i = 0; i < fcinfo.nargs; i++)
{
@@ -394,7 +394,7 @@ HandleFunctionRequest(StringInfo msgBuf)
* is returned.
*/
static int16
-parse_fcall_arguments(StringInfo msgBuf, struct fp_info *fip,
+parse_fcall_arguments(StringInfo msgBuf, struct fp_info * fip,
FunctionCallInfo fcinfo)
{
int nargs;
@@ -447,8 +447,8 @@ parse_fcall_arguments(StringInfo msgBuf, struct fp_info *fip,
if (argsize < 0)
ereport(ERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("invalid argument size %d in function call message",
- argsize)));
+ errmsg("invalid argument size %d in function call message",
+ argsize)));
/* Reset abuf to empty, and insert raw data into it */
abuf.len = 0;
@@ -473,11 +473,11 @@ parse_fcall_arguments(StringInfo msgBuf, struct fp_info *fip,
char *pstring;
getTypeInputInfo(fip->argtypes[i], &typInput, &typElem);
+
/*
- * Since stringinfo.c keeps a trailing null in
- * place even for binary data, the contents of
- * abuf are a valid C string. We have to do
- * encoding conversion before calling the typinput
+ * Since stringinfo.c keeps a trailing null in place even for
+ * binary data, the contents of abuf are a valid C string. We
+ * have to do encoding conversion before calling the typinput
* routine, though.
*/
pstring = (char *)
@@ -528,7 +528,7 @@ parse_fcall_arguments(StringInfo msgBuf, struct fp_info *fip,
* is returned.
*/
static int16
-parse_fcall_arguments_20(StringInfo msgBuf, struct fp_info *fip,
+parse_fcall_arguments_20(StringInfo msgBuf, struct fp_info * fip,
FunctionCallInfo fcinfo)
{
int nargs;
@@ -570,8 +570,8 @@ parse_fcall_arguments_20(StringInfo msgBuf, struct fp_info *fip,
if (argsize < 0)
ereport(ERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("invalid argument size %d in function call message",
- argsize)));
+ errmsg("invalid argument size %d in function call message",
+ argsize)));
/* Reset abuf to empty, and insert raw data into it */
abuf.len = 0;
@@ -593,8 +593,8 @@ parse_fcall_arguments_20(StringInfo msgBuf, struct fp_info *fip,
if (abuf.cursor != abuf.len)
ereport(ERROR,
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
- errmsg("incorrect binary data format in function argument %d",
- i + 1)));
+ errmsg("incorrect binary data format in function argument %d",
+ i + 1)));
}
/* Desired result format is always binary in protocol 2.0 */
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 80f2be70ed6..cb835469a0f 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.353 2003/07/29 00:03:18 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.354 2003/08/04 00:43:25 momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
@@ -133,6 +133,7 @@ static bool EchoQuery = false; /* default don't echo */
#ifndef TCOP_DONTUSENEWLINE
static int UseNewLine = 1; /* Use newlines query delimiters (the
* default) */
+
#else
static int UseNewLine = 0; /* Use EOF as query delimiters */
#endif /* TCOP_DONTUSENEWLINE */
@@ -283,8 +284,8 @@ SocketBackend(StringInfo inBuf)
/*
* Validate message type code before trying to read body; if we have
- * lost sync, better to say "command unknown" than to run out of memory
- * because we used garbage as a length word.
+ * lost sync, better to say "command unknown" than to run out of
+ * memory because we used garbage as a length word.
*
* This also gives us a place to set the doing_extended_query_message
* flag as soon as possible.
@@ -300,7 +301,7 @@ SocketBackend(StringInfo inBuf)
{
ereport(COMMERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("unexpected EOF on client connection")));
+ errmsg("unexpected EOF on client connection")));
return EOF;
}
}
@@ -327,7 +328,7 @@ SocketBackend(StringInfo inBuf)
if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3)
ereport(FATAL,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("invalid frontend message type %d", qtype)));
+ errmsg("invalid frontend message type %d", qtype)));
break;
case 'S': /* sync */
@@ -339,7 +340,7 @@ SocketBackend(StringInfo inBuf)
if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3)
ereport(FATAL,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("invalid frontend message type %d", qtype)));
+ errmsg("invalid frontend message type %d", qtype)));
break;
case 'd': /* copy data */
@@ -350,14 +351,15 @@ SocketBackend(StringInfo inBuf)
if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3)
ereport(FATAL,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("invalid frontend message type %d", qtype)));
+ errmsg("invalid frontend message type %d", qtype)));
break;
default:
+
/*
- * Otherwise we got garbage from the frontend. We treat this
- * as fatal because we have probably lost message boundary sync,
- * and there's no good way to recover.
+ * Otherwise we got garbage from the frontend. We treat this
+ * as fatal because we have probably lost message boundary
+ * sync, and there's no good way to recover.
*/
ereport(FATAL,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
@@ -409,9 +411,9 @@ ReadCommand(StringInfo inBuf)
* but it is still needed for parsing of SQL function bodies.
*/
List *
-pg_parse_and_rewrite(const char *query_string, /* string to execute */
+pg_parse_and_rewrite(const char *query_string, /* string to execute */
Oid *paramTypes, /* parameter types */
- int numParams) /* number of parameters */
+ int numParams) /* number of parameters */
{
List *raw_parsetree_list;
List *querytree_list;
@@ -518,8 +520,8 @@ pg_rewrite_queries(List *querytree_list)
ResetUsage();
/*
- * rewritten queries are collected in new_list. Note there may be more
- * or fewer than in the original list.
+ * rewritten queries are collected in new_list. Note there may be
+ * more or fewer than in the original list.
*/
foreach(list_item, querytree_list)
{
@@ -558,7 +560,7 @@ pg_rewrite_queries(List *querytree_list)
/* This checks both copyObject() and the equal() routines... */
if (!equal(new_list, querytree_list))
ereport(WARNING,
- (errmsg("copyObject failed to produce an equal parse tree")));
+ (errmsg("copyObject failed to produce an equal parse tree")));
else
querytree_list = new_list;
#endif
@@ -603,7 +605,7 @@ pg_plan_query(Query *querytree)
/* This checks both copyObject() and the equal() routines... */
if (!equal(new_plan, plan))
ereport(WARNING,
- (errmsg("copyObject failed to produce an equal plan tree")));
+ (errmsg("copyObject failed to produce an equal plan tree")));
else
#endif
plan = new_plan;
@@ -671,7 +673,7 @@ pg_plan_queries(List *querytrees, bool needSnapshot)
static void
exec_simple_query(const char *query_string)
{
- CommandDest dest = whereToSendOutput;
+ CommandDest dest = whereToSendOutput;
MemoryContext oldcontext;
List *parsetree_list,
*parsetree_item;
@@ -689,10 +691,10 @@ exec_simple_query(const char *query_string)
pgstat_report_activity(query_string);
/*
- * We use save_log_* so "SET log_duration = true" and
- * "SET log_min_duration_statement = true" don't report incorrect
- * time because gettimeofday() wasn't called.
- * Similarly, log_statement_stats has to be captured once.
+ * We use save_log_* so "SET log_duration = true" and "SET
+ * log_min_duration_statement = true" don't report incorrect time
+ * because gettimeofday() wasn't called. Similarly,
+ * log_statement_stats has to be captured once.
*/
if (save_log_duration || save_log_min_duration_statement > 0)
gettimeofday(&start_t, NULL);
@@ -710,10 +712,10 @@ exec_simple_query(const char *query_string)
start_xact_command();
/*
- * Zap any pre-existing unnamed statement. (While not strictly
- * necessary, it seems best to define simple-Query mode as if it
- * used the unnamed statement and portal; this ensures we recover
- * any storage used by prior unnamed operations.)
+ * Zap any pre-existing unnamed statement. (While not strictly
+ * necessary, it seems best to define simple-Query mode as if it used
+ * the unnamed statement and portal; this ensures we recover any
+ * storage used by prior unnamed operations.)
*/
unnamed_stmt_pstmt = NULL;
if (unnamed_stmt_context)
@@ -756,10 +758,10 @@ exec_simple_query(const char *query_string)
int16 format;
/*
- * Get the command name for use in status display (it also becomes the
- * default completion tag, down inside PortalRun). Set ps_status and
- * do any special start-of-SQL-command processing needed by the
- * destination.
+ * Get the command name for use in status display (it also becomes
+ * the default completion tag, down inside PortalRun). Set
+ * ps_status and do any special start-of-SQL-command processing
+ * needed by the destination.
*/
commandTag = CreateCommandTag(parsetree);
@@ -817,8 +819,8 @@ exec_simple_query(const char *query_string)
CHECK_FOR_INTERRUPTS();
/*
- * Create unnamed portal to run the query or queries in.
- * If there already is one, silently drop it.
+ * Create unnamed portal to run the query or queries in. If there
+ * already is one, silently drop it.
*/
portal = CreatePortal("", true, true);
@@ -836,9 +838,9 @@ exec_simple_query(const char *query_string)
/*
* Select the appropriate output format: text unless we are doing
- * a FETCH from a binary cursor. (Pretty grotty to have to do this
- * here --- but it avoids grottiness in other places. Ah, the joys
- * of backward compatibility...)
+ * a FETCH from a binary cursor. (Pretty grotty to have to do
+ * this here --- but it avoids grottiness in other places. Ah,
+ * the joys of backward compatibility...)
*/
format = 0; /* TEXT is default */
if (IsA(parsetree, FetchStmt))
@@ -851,7 +853,7 @@ exec_simple_query(const char *query_string)
if (PortalIsValid(fportal) &&
(fportal->cursorOptions & CURSOR_OPT_BINARY))
- format = 1; /* BINARY */
+ format = 1; /* BINARY */
}
}
PortalSetResultFormat(portal, 1, &format);
@@ -867,7 +869,8 @@ exec_simple_query(const char *query_string)
MemoryContextSwitchTo(oldcontext);
/*
- * Run the portal to completion, and then drop it (and the receiver).
+ * Run the portal to completion, and then drop it (and the
+ * receiver).
*/
(void) PortalRun(portal,
FETCH_ALL,
@@ -882,30 +885,32 @@ exec_simple_query(const char *query_string)
if (IsA(parsetree, TransactionStmt))
{
/*
- * If this was a transaction control statement, commit it.
- * We will start a new xact command for the next command (if any).
+ * If this was a transaction control statement, commit it. We
+ * will start a new xact command for the next command (if
+ * any).
*/
finish_xact_command();
}
else if (lnext(parsetree_item) == NIL)
{
/*
- * If this is the last parsetree of the query string, close down
- * transaction statement before reporting command-complete. This
- * is so that any end-of-transaction errors are reported before
- * the command-complete message is issued, to avoid confusing
- * clients who will expect either a command-complete message or an
- * error, not one and then the other. But for compatibility with
- * historical Postgres behavior, we do not force a transaction
- * boundary between queries appearing in a single query string.
+ * If this is the last parsetree of the query string, close
+ * down transaction statement before reporting
+ * command-complete. This is so that any end-of-transaction
+ * errors are reported before the command-complete message is
+ * issued, to avoid confusing clients who will expect either a
+ * command-complete message or an error, not one and then the
+ * other. But for compatibility with historical Postgres
+ * behavior, we do not force a transaction boundary between
+ * queries appearing in a single query string.
*/
finish_xact_command();
}
else
{
/*
- * We need a CommandCounterIncrement after every query,
- * except those that start or end a transaction block.
+ * We need a CommandCounterIncrement after every query, except
+ * those that start or end a transaction block.
*/
CommandCounterIncrement();
}
@@ -934,12 +939,13 @@ exec_simple_query(const char *query_string)
QueryContext = NULL;
/*
- * Combine processing here as we need to calculate the query
- * duration in both instances.
+ * Combine processing here as we need to calculate the query duration
+ * in both instances.
*/
if (save_log_duration || save_log_min_duration_statement > 0)
{
- long usecs;
+ long usecs;
+
gettimeofday(&stop_t, NULL);
if (stop_t.tv_usec < start_t.tv_usec)
{
@@ -948,9 +954,9 @@ exec_simple_query(const char *query_string)
}
usecs = (long) (stop_t.tv_sec - start_t.tv_sec) * 1000000 + (long) (stop_t.tv_usec - start_t.tv_usec);
- /*
- * Output a duration_query to the log if the query has exceeded the
- * min duration.
+ /*
+ * Output a duration_query to the log if the query has exceeded
+ * the min duration.
*/
if (usecs >= save_log_min_duration_statement * 1000)
ereport(LOG,
@@ -959,7 +965,7 @@ exec_simple_query(const char *query_string)
(long) (stop_t.tv_usec - start_t.tv_usec),
query_string)));
- /*
+ /*
* If the user is requesting logging of all durations, then log
* that as well.
*/
@@ -984,8 +990,8 @@ exec_simple_query(const char *query_string)
static void
exec_parse_message(const char *query_string, /* string to execute */
const char *stmt_name, /* name for prepared stmt */
- Oid *paramTypes, /* parameter types */
- int numParams) /* number of parameters */
+ Oid *paramTypes, /* parameter types */
+ int numParams) /* number of parameters */
{
MemoryContext oldcontext;
List *parsetree_list;
@@ -1018,16 +1024,16 @@ exec_parse_message(const char *query_string, /* string to execute */
/*
* Switch to appropriate context for constructing parsetrees.
*
- * We have two strategies depending on whether the prepared statement
- * is named or not. For a named prepared statement, we do parsing
- * in MessageContext and copy the finished trees into the prepared
- * statement's private context; then the reset of MessageContext releases
- * temporary space used by parsing and planning. For an unnamed prepared
- * statement, we assume the statement isn't going to hang around long,
- * so getting rid of temp space quickly is probably not worth the costs
- * of copying parse/plan trees. So in this case, we set up a special
- * context for the unnamed statement, and do all the parsing/planning
- * therein.
+ * We have two strategies depending on whether the prepared statement is
+ * named or not. For a named prepared statement, we do parsing in
+ * MessageContext and copy the finished trees into the prepared
+ * statement's private context; then the reset of MessageContext
+ * releases temporary space used by parsing and planning. For an
+ * unnamed prepared statement, we assume the statement isn't going to
+ * hang around long, so getting rid of temp space quickly is probably
+ * not worth the costs of copying parse/plan trees. So in this case,
+ * we set up a special context for the unnamed statement, and do all
+ * the parsing/planning therein.
*/
is_named = (stmt_name[0] != '\0');
if (is_named)
@@ -1064,9 +1070,9 @@ exec_parse_message(const char *query_string, /* string to execute */
parsetree_list = pg_parse_query(query_string);
/*
- * We only allow a single user statement in a prepared statement.
- * This is mainly to keep the protocol simple --- otherwise we'd need
- * to worry about multiple result tupdescs and things like that.
+ * We only allow a single user statement in a prepared statement. This
+ * is mainly to keep the protocol simple --- otherwise we'd need to
+ * worry about multiple result tupdescs and things like that.
*/
if (length(parsetree_list) > 1)
ereport(ERROR,
@@ -1075,8 +1081,8 @@ exec_parse_message(const char *query_string, /* string to execute */
if (parsetree_list != NIL)
{
- Node *parsetree = (Node *) lfirst(parsetree_list);
- int i;
+ Node *parsetree = (Node *) lfirst(parsetree_list);
+ int i;
/*
* Get the command name for possible use in status display.
@@ -1085,10 +1091,10 @@ exec_parse_message(const char *query_string, /* string to execute */
/*
* If we are in an aborted transaction, reject all commands except
- * COMMIT/ROLLBACK. It is important that this test occur before we
- * try to do parse analysis, rewrite, or planning, since all those
- * phases try to do database accesses, which may fail in abort
- * state. (It might be safe to allow some additional utility
+ * COMMIT/ROLLBACK. It is important that this test occur before
+ * we try to do parse analysis, rewrite, or planning, since all
+ * those phases try to do database accesses, which may fail in
+ * abort state. (It might be safe to allow some additional utility
* commands in this state, but not many...)
*/
if (IsAbortedTransactionBlockState())
@@ -1130,13 +1136,13 @@ exec_parse_message(const char *query_string, /* string to execute */
param_list = NIL;
for (i = 0; i < numParams; i++)
{
- Oid ptype = paramTypes[i];
+ Oid ptype = paramTypes[i];
if (ptype == InvalidOid || ptype == UNKNOWNOID)
ereport(ERROR,
(errcode(ERRCODE_INDETERMINATE_DATATYPE),
- errmsg("could not determine datatype of parameter $%d",
- i + 1)));
+ errmsg("could not determine datatype of parameter $%d",
+ i + 1)));
param_list = lappendo(param_list, ptype);
}
@@ -1149,7 +1155,7 @@ exec_parse_message(const char *query_string, /* string to execute */
}
else
{
- /* Empty input string. This is legal. */
+ /* Empty input string. This is legal. */
commandTag = NULL;
querytree_list = NIL;
plantree_list = NIL;
@@ -1193,9 +1199,10 @@ exec_parse_message(const char *query_string, /* string to execute */
QueryContext = NULL;
/*
- * We do NOT close the open transaction command here; that only happens
- * when the client sends Sync. Instead, do CommandCounterIncrement just
- * in case something happened during parse/plan.
+ * We do NOT close the open transaction command here; that only
+ * happens when the client sends Sync. Instead, do
+ * CommandCounterIncrement just in case something happened during
+ * parse/plan.
*/
CommandCounterIncrement();
@@ -1236,9 +1243,9 @@ exec_bind_message(StringInfo input_message)
set_ps_display("BIND");
/*
- * Start up a transaction command so we can call functions etc.
- * (Note that this will normally change current memory context.)
- * Nothing happens if we are already in one.
+ * Start up a transaction command so we can call functions etc. (Note
+ * that this will normally change current memory context.) Nothing
+ * happens if we are already in one.
*/
start_xact_command();
@@ -1264,8 +1271,8 @@ exec_bind_message(StringInfo input_message)
if (numPFormats > 1 && numPFormats != numParams)
ereport(ERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("bind message has %d parameter formats but %d parameters",
- numPFormats, numParams)));
+ errmsg("bind message has %d parameter formats but %d parameters",
+ numPFormats, numParams)));
/* Find prepared statement */
if (stmt_name[0] != '\0')
@@ -1277,14 +1284,14 @@ exec_bind_message(StringInfo input_message)
if (!pstmt)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_PSTATEMENT),
- errmsg("unnamed prepared statement does not exist")));
+ errmsg("unnamed prepared statement does not exist")));
}
if (numParams != length(pstmt->argtype_list))
ereport(ERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
errmsg("bind message supplies %d parameters, but prepared statement \"%s\" requires %d",
- numParams, stmt_name, length(pstmt->argtype_list))));
+ numParams, stmt_name, length(pstmt->argtype_list))));
/*
* Create the portal. Allow silent replacement of an existing portal
@@ -1305,13 +1312,14 @@ exec_bind_message(StringInfo input_message)
/*
* Fetch parameters, if any, and store in the portal's memory context.
*
- * In an aborted transaction, we can't risk calling user-defined functions,
- * but we can't fail to Bind either, so bind all parameters to null values.
+ * In an aborted transaction, we can't risk calling user-defined
+ * functions, but we can't fail to Bind either, so bind all parameters
+ * to null values.
*/
if (numParams > 0)
{
- bool isaborted = IsAbortedTransactionBlockState();
- List *l;
+ bool isaborted = IsAbortedTransactionBlockState();
+ List *l;
MemoryContext oldContext;
oldContext = MemoryContextSwitchTo(PortalGetHeapMemory(portal));
@@ -1340,25 +1348,25 @@ exec_bind_message(StringInfo input_message)
}
else
{
- int16 pformat;
+ int16 pformat;
StringInfoData pbuf;
- char csave;
+ char csave;
if (numPFormats > 1)
pformat = pformats[i];
else if (numPFormats > 0)
pformat = pformats[0];
else
- pformat = 0; /* default = text */
+ pformat = 0; /* default = text */
/*
- * Rather than copying data around, we just set up a phony
- * StringInfo pointing to the correct portion of the
- * message buffer. We assume we can scribble on the
- * message buffer so as to maintain the convention that
- * StringInfos have a trailing null. This is grotty but
- * is a big win when dealing with very large parameter
- * strings.
+ * Rather than copying data around, we just set up a
+ * phony StringInfo pointing to the correct portion of
+ * the message buffer. We assume we can scribble on
+ * the message buffer so as to maintain the convention
+ * that StringInfos have a trailing null. This is
+ * grotty but is a big win when dealing with very
+ * large parameter strings.
*/
pbuf.data = (char *) pvalue;
pbuf.maxlen = plength + 1;
@@ -1375,9 +1383,10 @@ exec_bind_message(StringInfo input_message)
char *pstring;
getTypeInputInfo(ptype, &typInput, &typElem);
+
/*
- * We have to do encoding conversion before calling
- * the typinput routine.
+ * We have to do encoding conversion before
+ * calling the typinput routine.
*/
pstring = (char *)
pg_client_to_server((unsigned char *) pbuf.data,
@@ -1396,7 +1405,10 @@ exec_bind_message(StringInfo input_message)
Oid typReceive;
Oid typElem;
- /* Call the parameter type's binary input converter */
+ /*
+ * Call the parameter type's binary input
+ * converter
+ */
getTypeBinaryInputInfo(ptype, &typReceive, &typElem);
params[i].value =
@@ -1409,7 +1421,7 @@ exec_bind_message(StringInfo input_message)
ereport(ERROR,
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
errmsg("incorrect binary data format in bind parameter %d",
- i + 1)));
+ i + 1)));
}
else
{
@@ -1474,7 +1486,7 @@ exec_bind_message(StringInfo input_message)
static void
exec_execute_message(const char *portal_name, long max_rows)
{
- CommandDest dest;
+ CommandDest dest;
DestReceiver *receiver;
Portal portal;
bool is_trans_stmt = false;
@@ -1494,7 +1506,8 @@ exec_execute_message(const char *portal_name, long max_rows)
errmsg("portal \"%s\" does not exist", portal_name)));
/*
- * If the original query was a null string, just return EmptyQueryResponse.
+ * If the original query was a null string, just return
+ * EmptyQueryResponse.
*/
if (portal->commandTag == NULL)
{
@@ -1521,7 +1534,7 @@ exec_execute_message(const char *portal_name, long max_rows)
/* Check for transaction-control commands */
if (length(portal->parseTrees) == 1)
{
- Query *query = (Query *) lfirst(portal->parseTrees);
+ Query *query = (Query *) lfirst(portal->parseTrees);
if (query->commandType == CMD_UTILITY &&
query->utilityStmt != NULL &&
@@ -1537,14 +1550,15 @@ exec_execute_message(const char *portal_name, long max_rows)
}
/*
- * Create dest receiver in MessageContext (we don't want it in transaction
- * context, because that may get deleted if portal contains VACUUM).
+ * Create dest receiver in MessageContext (we don't want it in
+ * transaction context, because that may get deleted if portal
+ * contains VACUUM).
*/
receiver = CreateDestReceiver(dest, portal);
/*
- * Ensure we are in a transaction command (this should normally be
- * the case already due to prior BIND).
+ * Ensure we are in a transaction command (this should normally be the
+ * case already due to prior BIND).
*/
start_xact_command();
@@ -1558,7 +1572,7 @@ exec_execute_message(const char *portal_name, long max_rows)
ereport(ERROR,
(errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
errmsg("current transaction is aborted, "
- "queries ignored until end of transaction block")));
+ "queries ignored until end of transaction block")));
}
/* Check for cancel signal before we start execution */
@@ -1583,16 +1597,17 @@ exec_execute_message(const char *portal_name, long max_rows)
if (is_trans_stmt)
{
/*
- * If this was a transaction control statement, commit it. We will
- * start a new xact command for the next command (if any).
+ * If this was a transaction control statement, commit it. We
+ * will start a new xact command for the next command (if
+ * any).
*/
finish_xact_command();
}
else
{
/*
- * We need a CommandCounterIncrement after every query,
- * except those that start or end a transaction block.
+ * We need a CommandCounterIncrement after every query, except
+ * those that start or end a transaction block.
*/
CommandCounterIncrement();
}
@@ -1633,7 +1648,7 @@ exec_describe_statement_message(const char *stmt_name)
if (!pstmt)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_PSTATEMENT),
- errmsg("unnamed prepared statement does not exist")));
+ errmsg("unnamed prepared statement does not exist")));
}
if (whereToSendOutput != Remote)
@@ -1642,7 +1657,7 @@ exec_describe_statement_message(const char *stmt_name)
/*
* First describe the parameters...
*/
- pq_beginmessage(&buf, 't'); /* parameter description message type */
+ pq_beginmessage(&buf, 't'); /* parameter description message type */
pq_sendint(&buf, length(pstmt->argtype_list), 2);
foreach(l, pstmt->argtype_list)
@@ -1659,7 +1674,7 @@ exec_describe_statement_message(const char *stmt_name)
tupdesc = FetchPreparedStatementResultDesc(pstmt);
if (tupdesc)
{
- List *targetlist;
+ List *targetlist;
if (ChoosePortalStrategy(pstmt->query_list) == PORTAL_ONE_SELECT)
targetlist = ((Query *) lfirst(pstmt->query_list))->targetList;
@@ -1693,7 +1708,7 @@ exec_describe_portal_message(const char *portal_name)
if (portal->tupDesc)
{
- List *targetlist;
+ List *targetlist;
if (portal->strategy == PORTAL_ONE_SELECT)
targetlist = ((Query *) lfirst(portal->parseTrees))->targetList;
@@ -1768,19 +1783,21 @@ void
quickdie(SIGNAL_ARGS)
{
PG_SETMASK(&BlockSig);
+
/*
- * Ideally this should be ereport(FATAL), but then we'd not get control
- * back (perhaps could fix by doing local sigsetjmp?)
+ * Ideally this should be ereport(FATAL), but then we'd not get
+ * control back (perhaps could fix by doing local sigsetjmp?)
*/
ereport(WARNING,
(errcode(ERRCODE_CRASH_SHUTDOWN),
- errmsg("terminating connection due to crash of another backend"),
- errdetail("The postmaster has commanded this backend to roll back"
- " the current transaction and exit, because another"
- " backend exited abnormally and possibly corrupted"
- " shared memory."),
+ errmsg("terminating connection due to crash of another backend"),
+ errdetail("The postmaster has commanded this backend to roll back"
+ " the current transaction and exit, because another"
+ " backend exited abnormally and possibly corrupted"
+ " shared memory."),
errhint("In a moment you should be able to reconnect to the"
" database and repeat your query.")));
+
/*
* DO NOT proc_exit() -- we're here because shared memory may be
* corrupted, so we don't want to try to clean up our transaction.
@@ -1894,9 +1911,9 @@ FloatExceptionHandler(SIGNAL_ARGS)
ereport(ERROR,
(errcode(ERRCODE_FLOATING_POINT_EXCEPTION),
errmsg("floating-point exception"),
- errdetail("An invalid floating-point operation was signaled. "
- "This probably means an out-of-range result or an "
- "invalid operation, such as division by zero.")));
+ errdetail("An invalid floating-point operation was signaled. "
+ "This probably means an out-of-range result or an "
+ "invalid operation, such as division by zero.")));
}
/* SIGHUP: set flag to re-read config file at next convenient time */
@@ -1929,7 +1946,7 @@ ProcessInterrupts(void)
DisableNotifyInterrupt();
ereport(FATAL,
(errcode(ERRCODE_ADMIN_SHUTDOWN),
- errmsg("terminating connection due to administrator command")));
+ errmsg("terminating connection due to administrator command")));
}
if (QueryCancelPending)
{
@@ -1999,7 +2016,8 @@ PostgresMain(int argc, char *argv[], const char *username)
bool secure;
int errs = 0;
int debug_flag = 0;
- GucContext ctx, debug_context;
+ GucContext ctx,
+ debug_context;
GucSource gucsource;
char *tmp;
int firstchar;
@@ -2049,7 +2067,7 @@ PostgresMain(int argc, char *argv[], const char *username)
Noversion = false;
EchoQuery = false;
- if (!IsUnderPostmaster /* when exec || ExecBackend*/)
+ if (!IsUnderPostmaster /* when exec || ExecBackend */ )
{
InitializeGUCOptions();
potential_DataDir = getenv("PGDATA");
@@ -2114,29 +2132,33 @@ PostgresMain(int argc, char *argv[], const char *username)
case 'd': /* debug level */
{
/*
- * Client option can't decrease debug level.
- * We have to do the test here because we group priv and client
- * set GUC calls below, after we know the final debug value.
- */
+ * Client option can't decrease debug level. We have
+ * to do the test here because we group priv and
+ * client set GUC calls below, after we know the final
+ * debug value.
+ */
if (ctx != PGC_BACKEND || atoi(optarg) > debug_flag)
{
debug_flag = atoi(optarg);
- debug_context = ctx; /* save context for use below */
+ debug_context = ctx; /* save context for use
+ * below */
/* Set server debugging level. */
if (debug_flag != 0)
{
char *debugstr = palloc(strlen("debug") + strlen(optarg) + 1);
-
+
sprintf(debugstr, "debug%s", optarg);
SetConfigOption("log_min_messages", debugstr, ctx, gucsource);
pfree(debugstr);
-
+
}
else
+
/*
* -d0 allows user to prevent postmaster debug
- * from propagating to backend. It would be nice
- * to set it to the postgresql.conf value here.
+ * from propagating to backend. It would be
+ * nice to set it to the postgresql.conf value
+ * here.
*/
SetConfigOption("log_min_messages", "notice",
ctx, gucsource);
@@ -2245,17 +2267,19 @@ PostgresMain(int argc, char *argv[], const char *username)
if (secure)
{
#ifdef EXEC_BACKEND
- char *p;
- int i;
- int PMcanAcceptConnections; /* will eventually be global or static, when fork */
-
+ char *p;
+ int i;
+ int PMcanAcceptConnections; /* will eventually be
+ * global or static,
+ * when fork */
+
sscanf(optarg, "%d,%d,%d,%p,", &MyProcPort->sock, &PMcanAcceptConnections,
- &UsedShmemSegID, &UsedShmemSegAddr);
+ &UsedShmemSegID, &UsedShmemSegAddr);
/* Grab dbname as last param */
- for (i = 0, p = optarg-1; i < 4 && p; i++)
- p = strchr(p+1, ',');
+ for (i = 0, p = optarg - 1; i < 4 && p; i++)
+ p = strchr(p + 1, ',');
if (i == 4 && p)
- dbname = strdup(p+1);
+ dbname = strdup(p + 1);
#else
dbname = strdup(optarg);
#endif
@@ -2411,11 +2435,12 @@ PostgresMain(int argc, char *argv[], const char *username)
SetConfigOption("debug_print_rewritten", "true", debug_context, gucsource);
/*
- * Process any additional GUC variable settings passed in startup packet.
+ * Process any additional GUC variable settings passed in startup
+ * packet.
*/
if (MyProcPort != NULL)
{
- List *gucopts = MyProcPort->guc_options;
+ List *gucopts = MyProcPort->guc_options;
while (gucopts)
{
@@ -2481,7 +2506,7 @@ PostgresMain(int argc, char *argv[], const char *username)
pqsignal(SIGINT, StatementCancelHandler); /* cancel current query */
pqsignal(SIGTERM, die); /* cancel current query and exit */
pqsignal(SIGQUIT, quickdie); /* hard crash time */
- pqsignal(SIGALRM, handle_sig_alarm); /* timeout conditions */
+ pqsignal(SIGALRM, handle_sig_alarm); /* timeout conditions */
/*
* Ignore failure to write to frontend. Note: if frontend closes
@@ -2626,7 +2651,7 @@ PostgresMain(int argc, char *argv[], const char *username)
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
- puts("$Revision: 1.353 $ $Date: 2003/07/29 00:03:18 $\n");
+ puts("$Revision: 1.354 $ $Date: 2003/08/04 00:43:25 $\n");
}
/*
@@ -2664,15 +2689,15 @@ PostgresMain(int argc, char *argv[], const char *username)
*
* Make sure we're not interrupted while cleaning up. Also forget
* any pending QueryCancel request, since we're aborting anyway.
- * Force InterruptHoldoffCount to a known state in case we ereport'd
- * from inside a holdoff section.
+ * Force InterruptHoldoffCount to a known state in case we
+ * ereport'd from inside a holdoff section.
*/
ImmediateInterruptOK = false;
QueryCancelPending = false;
InterruptHoldoffCount = 1;
CritSectionCount = 0; /* should be unnecessary, but... */
disable_sig_alarm(true);
- QueryCancelPending = false; /* again in case timeout occurred */
+ QueryCancelPending = false; /* again in case timeout occurred */
DisableNotifyInterrupt();
debug_query_string = NULL;
@@ -2706,8 +2731,8 @@ PostgresMain(int argc, char *argv[], const char *username)
/*
* If we were handling an extended-query-protocol message,
- * initiate skip till next Sync. This also causes us not
- * to issue ReadyForQuery (until we get Sync).
+ * initiate skip till next Sync. This also causes us not to issue
+ * ReadyForQuery (until we get Sync).
*/
if (doing_extended_query_message)
ignore_till_sync = true;
@@ -2732,8 +2757,8 @@ PostgresMain(int argc, char *argv[], const char *username)
for (;;)
{
/*
- * At top of loop, reset extended-query-message flag, so that
- * any errors encountered in "idle" state don't provoke skip.
+ * At top of loop, reset extended-query-message flag, so that any
+ * errors encountered in "idle" state don't provoke skip.
*/
doing_extended_query_message = false;
@@ -2815,7 +2840,8 @@ PostgresMain(int argc, char *argv[], const char *username)
}
/*
- * (6) process the command. But ignore it if we're skipping till Sync.
+ * (6) process the command. But ignore it if we're skipping till
+ * Sync.
*/
if (ignore_till_sync && firstchar != EOF)
continue;
@@ -2847,7 +2873,7 @@ PostgresMain(int argc, char *argv[], const char *username)
numParams = pq_getmsgint(input_message, 2);
if (numParams > 0)
{
- int i;
+ int i;
paramTypes = (Oid *) palloc(numParams * sizeof(Oid));
for (i = 0; i < numParams; i++)
@@ -2861,9 +2887,10 @@ PostgresMain(int argc, char *argv[], const char *username)
break;
case 'B': /* bind */
+
/*
- * this message is complex enough that it seems best to put
- * the field extraction out-of-line
+ * this message is complex enough that it seems best to
+ * put the field extraction out-of-line
*/
exec_bind_message(input_message);
break;
@@ -2871,7 +2898,7 @@ PostgresMain(int argc, char *argv[], const char *username)
case 'E': /* execute */
{
const char *portal_name;
- int max_rows;
+ int max_rows;
portal_name = pq_getmsgstring(input_message);
max_rows = pq_getmsgint(input_message, 4);
@@ -2911,9 +2938,9 @@ PostgresMain(int argc, char *argv[], const char *username)
send_rfq = true;
break;
- case 'C': /* close */
+ case 'C': /* close */
{
- int close_type;
+ int close_type;
const char *close_target;
close_type = pq_getmsgbyte(input_message);
@@ -2949,19 +2976,19 @@ PostgresMain(int argc, char *argv[], const char *username)
default:
ereport(ERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("invalid CLOSE message subtype %d",
- close_type)));
+ errmsg("invalid CLOSE message subtype %d",
+ close_type)));
break;
}
if (whereToSendOutput == Remote)
- pq_putemptymessage('3'); /* CloseComplete */
+ pq_putemptymessage('3'); /* CloseComplete */
}
break;
case 'D': /* describe */
{
- int describe_type;
+ int describe_type;
const char *describe_target;
describe_type = pq_getmsgbyte(input_message);
@@ -2979,20 +3006,20 @@ PostgresMain(int argc, char *argv[], const char *username)
default:
ereport(ERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("invalid DESCRIBE message subtype %d",
- describe_type)));
+ errmsg("invalid DESCRIBE message subtype %d",
+ describe_type)));
break;
}
}
break;
- case 'H': /* flush */
+ case 'H': /* flush */
pq_getmsgend(input_message);
if (whereToSendOutput == Remote)
pq_flush();
break;
- case 'S': /* sync */
+ case 'S': /* sync */
pq_getmsgend(input_message);
finish_xact_command();
send_rfq = true;
@@ -3007,8 +3034,8 @@ PostgresMain(int argc, char *argv[], const char *username)
case EOF:
/*
- * Reset whereToSendOutput to prevent ereport from attempting
- * to send any more messages to client.
+ * Reset whereToSendOutput to prevent ereport from
+ * attempting to send any more messages to client.
*/
if (whereToSendOutput == Remote)
whereToSendOutput = None;
@@ -3022,12 +3049,13 @@ PostgresMain(int argc, char *argv[], const char *username)
*/
proc_exit(0);
- case 'd': /* copy data */
- case 'c': /* copy done */
- case 'f': /* copy fail */
+ case 'd': /* copy data */
+ case 'c': /* copy done */
+ case 'f': /* copy fail */
+
/*
- * Accept but ignore these messages, per protocol spec;
- * we probably got here because a COPY failed, and the
+ * Accept but ignore these messages, per protocol spec; we
+ * probably got here because a COPY failed, and the
* frontend is still sending data.
*/
break;
@@ -3119,9 +3147,9 @@ ShowUsage(const char *title)
(long) (elapse_t.tv_sec - Save_t.tv_sec),
(long) (elapse_t.tv_usec - Save_t.tv_usec),
(long) (r.ru_utime.tv_sec - Save_r.ru_utime.tv_sec),
- (long) (r.ru_utime.tv_usec - Save_r.ru_utime.tv_usec),
+ (long) (r.ru_utime.tv_usec - Save_r.ru_utime.tv_usec),
(long) (r.ru_stime.tv_sec - Save_r.ru_stime.tv_sec),
- (long) (r.ru_stime.tv_usec - Save_r.ru_stime.tv_usec));
+ (long) (r.ru_stime.tv_usec - Save_r.ru_stime.tv_usec));
appendStringInfo(&str,
"!\t[%ld.%06ld user %ld.%06ld sys total]\n",
(long) user.tv_sec,
diff --git a/src/backend/tcop/pquery.c b/src/backend/tcop/pquery.c
index 2f6ed0eda1d..0626ac5e8f4 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.68 2003/08/01 17:57:42 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.69 2003/08/04 00:43:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -24,18 +24,18 @@
static uint32 RunFromStore(Portal portal, ScanDirection direction, long count,
- DestReceiver *dest);
+ DestReceiver *dest);
static long PortalRunSelect(Portal portal, bool forward, long count,
- DestReceiver *dest);
+ DestReceiver *dest);
static void PortalRunUtility(Portal portal, Query *query,
- DestReceiver *dest, char *completionTag);
+ DestReceiver *dest, char *completionTag);
static void PortalRunMulti(Portal portal,
- DestReceiver *dest, DestReceiver *altdest,
- char *completionTag);
+ DestReceiver *dest, DestReceiver *altdest,
+ char *completionTag);
static long DoPortalRunFetch(Portal portal,
- FetchDirection fdirection,
- long count,
- DestReceiver *dest);
+ FetchDirection fdirection,
+ long count,
+ DestReceiver *dest);
static void DoPortalRewind(Portal portal);
@@ -56,7 +56,7 @@ CreateQueryDesc(Query *parsetree,
qd->plantree = plantree; /* plan */
qd->dest = dest; /* output dest */
qd->params = params; /* parameter values passed into query */
- qd->doInstrument = doInstrument; /* instrumentation wanted? */
+ qd->doInstrument = doInstrument; /* instrumentation wanted? */
/* null these fields until set by ExecutorStart */
qd->tupDesc = NULL;
@@ -156,7 +156,7 @@ ProcessQuery(Query *parsetree,
else
lastOid = InvalidOid;
snprintf(completionTag, COMPLETION_TAG_BUFSIZE,
- "INSERT %u %u", lastOid, queryDesc->estate->es_processed);
+ "INSERT %u %u", lastOid, queryDesc->estate->es_processed);
break;
case CMD_UPDATE:
snprintf(completionTag, COMPLETION_TAG_BUFSIZE,
@@ -195,14 +195,12 @@ ChoosePortalStrategy(List *parseTrees)
if (length(parseTrees) == 1)
{
- Query *query = (Query *) lfirst(parseTrees);
+ Query *query = (Query *) lfirst(parseTrees);
if (query->commandType == CMD_SELECT &&
query->canSetTag &&
query->into == NULL)
- {
strategy = PORTAL_ONE_SELECT;
- }
else if (query->commandType == CMD_UTILITY &&
query->canSetTag &&
query->utilityStmt != NULL)
@@ -233,8 +231,8 @@ PortalStart(Portal portal, ParamListInfo params)
QueryDesc *queryDesc;
AssertArg(PortalIsValid(portal));
- AssertState(portal->queryContext != NULL); /* query defined? */
- AssertState(!portal->portalReady); /* else extra PortalStart */
+ AssertState(portal->queryContext != NULL); /* query defined? */
+ AssertState(!portal->portalReady); /* else extra PortalStart */
oldContext = MemoryContextSwitchTo(PortalGetHeapMemory(portal));
@@ -252,31 +250,37 @@ PortalStart(Portal portal, ParamListInfo params)
switch (portal->strategy)
{
case PORTAL_ONE_SELECT:
+
/*
* Must set query snapshot before starting executor.
*/
SetQuerySnapshot();
+
/*
* Create QueryDesc in portal's context; for the moment, set
* the destination to None.
*/
queryDesc = CreateQueryDesc((Query *) lfirst(portal->parseTrees),
- (Plan *) lfirst(portal->planTrees),
+ (Plan *) lfirst(portal->planTrees),
None_Receiver,
params,
false);
+
/*
* Call ExecStart to prepare the plan for execution
*/
ExecutorStart(queryDesc, false);
+
/*
* This tells PortalCleanup to shut down the executor
*/
portal->queryDesc = queryDesc;
+
/*
* Remember tuple descriptor (computed by ExecutorStart)
*/
portal->tupDesc = queryDesc->tupDesc;
+
/*
* Reset cursor position data to "start of query"
*/
@@ -287,12 +291,14 @@ PortalStart(Portal portal, ParamListInfo params)
break;
case PORTAL_UTIL_SELECT:
+
/*
* We don't set query snapshot here, because PortalRunUtility
* will take care of it.
*/
portal->tupDesc =
UtilityTupleDescriptor(((Query *) lfirst(portal->parseTrees))->utilityStmt);
+
/*
* Reset cursor position data to "start of query"
*/
@@ -346,7 +352,8 @@ PortalSetResultFormat(Portal portal, int nFormats, int16 *formats)
errmsg("bind message has %d result formats but query has %d columns",
nFormats, natts)));
memcpy(portal->formats, formats, natts * sizeof(int16));
- } else if (nFormats > 0)
+ }
+ else if (nFormats > 0)
{
/* single format specified, use for all columns */
int16 format1 = formats[0];
@@ -393,7 +400,7 @@ PortalRun(Portal portal, long count,
MemoryContext oldContext;
AssertArg(PortalIsValid(portal));
- AssertState(portal->portalReady); /* else no PortalStart */
+ AssertState(portal->portalReady); /* else no PortalStart */
/* Initialize completion tag to empty string */
if (completionTag)
@@ -405,7 +412,7 @@ PortalRun(Portal portal, long count,
if (portal->portalDone)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("portal \"%s\" cannot be run anymore", portal->name)));
+ errmsg("portal \"%s\" cannot be run anymore", portal->name)));
if (portal->portalActive)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
@@ -429,6 +436,7 @@ PortalRun(Portal portal, long count,
/* we know the query is supposed to set the tag */
if (completionTag && portal->commandTag)
strcpy(completionTag, portal->commandTag);
+
/*
* Since it's a forward fetch, say DONE iff atEnd is now true.
*/
@@ -436,6 +444,7 @@ PortalRun(Portal portal, long count,
break;
case PORTAL_UTIL_SELECT:
+
/*
* If we have not yet run the utility statement, do so,
* storing its results in the portal's tuplestore.
@@ -451,16 +460,19 @@ PortalRun(Portal portal, long count,
(*treceiver->destroy) (treceiver);
portal->portalUtilReady = true;
}
+
/*
* Now fetch desired portion of results.
*/
(void) PortalRunSelect(portal, true, count, dest);
+
/*
* We know the query is supposed to set the tag; we assume
* only the default tag is needed.
*/
if (completionTag && portal->commandTag)
strcpy(completionTag, portal->commandTag);
+
/*
* Since it's a forward fetch, say DONE iff atEnd is now true.
*/
@@ -518,8 +530,8 @@ PortalRunSelect(Portal portal,
uint32 nprocessed;
/*
- * NB: queryDesc will be NULL if we are fetching from a held cursor
- * or a completed utility query; can't use it in that path.
+ * NB: queryDesc will be NULL if we are fetching from a held cursor or
+ * a completed utility query; can't use it in that path.
*/
queryDesc = PortalGetQueryDesc(portal);
@@ -527,7 +539,7 @@ PortalRunSelect(Portal portal,
Assert(queryDesc || portal->holdStore);
/*
- * Force the queryDesc destination to the right thing. This supports
+ * Force the queryDesc destination to the right thing. This supports
* MOVE, for example, which will pass in dest = None. This is okay to
* change as long as we do it on every fetch. (The Executor must not
* assume that dest never changes.)
@@ -567,13 +579,13 @@ PortalRunSelect(Portal portal,
if (direction != NoMovementScanDirection)
{
- long oldPos;
+ long oldPos;
if (nprocessed > 0)
- portal->atStart = false; /* OK to go backward now */
+ portal->atStart = false; /* OK to go backward now */
if (count == 0 ||
(unsigned long) nprocessed < (unsigned long) count)
- portal->atEnd = true; /* we retrieved 'em all */
+ portal->atEnd = true; /* we retrieved 'em all */
oldPos = portal->portalPos;
portal->portalPos += nprocessed;
/* portalPos doesn't advance when we fall off the end */
@@ -610,19 +622,19 @@ PortalRunSelect(Portal portal,
{
if (nprocessed > 0 && portal->atEnd)
{
- portal->atEnd = false; /* OK to go forward now */
- portal->portalPos++; /* adjust for endpoint case */
+ portal->atEnd = false; /* OK to go forward now */
+ portal->portalPos++; /* adjust for endpoint case */
}
if (count == 0 ||
(unsigned long) nprocessed < (unsigned long) count)
{
- portal->atStart = true; /* we retrieved 'em all */
+ portal->atStart = true; /* we retrieved 'em all */
portal->portalPos = 0;
portal->posOverflow = false;
}
else
{
- long oldPos;
+ long oldPos;
oldPos = portal->portalPos;
portal->portalPos -= nprocessed;
@@ -662,13 +674,13 @@ RunFromStore(Portal portal, ScanDirection direction, long count,
}
else
{
- bool forward = (direction == ForwardScanDirection);
+ bool forward = (direction == ForwardScanDirection);
for (;;)
{
MemoryContext oldcontext;
- HeapTuple tup;
- bool should_free;
+ HeapTuple tup;
+ bool should_free;
oldcontext = MemoryContextSwitchTo(portal->holdContext);
@@ -686,9 +698,9 @@ RunFromStore(Portal portal, ScanDirection direction, long count,
pfree(tup);
/*
- * check our tuple count.. if we've processed the proper number
- * then quit, else loop again and process more tuples. Zero
- * count means no limit.
+ * check our tuple count.. if we've processed the proper
+ * number then quit, else loop again and process more tuples.
+ * Zero count means no limit.
*/
current_tuple_count++;
if (count && count == current_tuple_count)
@@ -709,35 +721,34 @@ static void
PortalRunUtility(Portal portal, Query *query,
DestReceiver *dest, char *completionTag)
{
- Node *utilityStmt = query->utilityStmt;
+ Node *utilityStmt = query->utilityStmt;
elog(DEBUG3, "ProcessUtility");
/*
- * Set snapshot if utility stmt needs one. Most reliable
- * way to do this seems to be to enumerate those that do not
- * need one; this is a short list. Transaction control,
- * LOCK, and SET must *not* set a snapshot since they need
- * to be executable at the start of a serializable transaction
- * without freezing a snapshot. By extension we allow SHOW
- * not to set a snapshot. The other stmts listed are just
- * efficiency hacks. Beware of listing anything that can
- * modify the database --- if, say, it has to update an
- * index with expressions that invoke user-defined functions,
- * then it had better have a snapshot.
+ * Set snapshot if utility stmt needs one. Most reliable way to do
+ * this seems to be to enumerate those that do not need one; this is a
+ * short list. Transaction control, LOCK, and SET must *not* set a
+ * snapshot since they need to be executable at the start of a
+ * serializable transaction without freezing a snapshot. By extension
+ * we allow SHOW not to set a snapshot. The other stmts listed are
+ * just efficiency hacks. Beware of listing anything that can modify
+ * the database --- if, say, it has to update an index with
+ * expressions that invoke user-defined functions, then it had better
+ * have a snapshot.
*/
- if (! (IsA(utilityStmt, TransactionStmt) ||
- IsA(utilityStmt, LockStmt) ||
- IsA(utilityStmt, VariableSetStmt) ||
- IsA(utilityStmt, VariableShowStmt) ||
- IsA(utilityStmt, VariableResetStmt) ||
- IsA(utilityStmt, ConstraintsSetStmt) ||
- /* efficiency hacks from here down */
- IsA(utilityStmt, FetchStmt) ||
- IsA(utilityStmt, ListenStmt) ||
- IsA(utilityStmt, NotifyStmt) ||
- IsA(utilityStmt, UnlistenStmt) ||
- IsA(utilityStmt, CheckPointStmt)))
+ if (!(IsA(utilityStmt, TransactionStmt) ||
+ IsA(utilityStmt, LockStmt) ||
+ IsA(utilityStmt, VariableSetStmt) ||
+ IsA(utilityStmt, VariableShowStmt) ||
+ IsA(utilityStmt, VariableResetStmt) ||
+ IsA(utilityStmt, ConstraintsSetStmt) ||
+ /* efficiency hacks from here down */
+ IsA(utilityStmt, FetchStmt) ||
+ IsA(utilityStmt, ListenStmt) ||
+ IsA(utilityStmt, NotifyStmt) ||
+ IsA(utilityStmt, UnlistenStmt) ||
+ IsA(utilityStmt, CheckPointStmt)))
SetQuerySnapshot();
if (query->canSetTag)
@@ -745,7 +756,7 @@ PortalRunUtility(Portal portal, Query *query,
/* utility statement can override default tag string */
ProcessUtility(utilityStmt, dest, completionTag);
if (completionTag && completionTag[0] == '\0' && portal->commandTag)
- strcpy(completionTag, portal->commandTag); /* use the default */
+ strcpy(completionTag, portal->commandTag); /* use the default */
}
else
{
@@ -770,14 +781,14 @@ PortalRunMulti(Portal portal,
List *querylist_item;
/*
- * If the destination is RemoteExecute, change to None. The reason
- * is that the client won't be expecting any tuples, and indeed has no
+ * If the destination is RemoteExecute, change to None. The reason is
+ * that the client won't be expecting any tuples, and indeed has no
* way to know what they are, since there is no provision for Describe
- * to send a RowDescription message when this portal execution strategy
- * is in effect. This presently will only affect SELECT commands added
- * to non-SELECT queries by rewrite rules: such commands will be executed,
- * but the results will be discarded unless you use "simple Query"
- * protocol.
+ * to send a RowDescription message when this portal execution
+ * strategy is in effect. This presently will only affect SELECT
+ * commands added to non-SELECT queries by rewrite rules: such
+ * commands will be executed, but the results will be discarded unless
+ * you use "simple Query" protocol.
*/
if (dest->mydest == RemoteExecute)
dest = None_Receiver;
@@ -785,8 +796,8 @@ PortalRunMulti(Portal portal,
altdest = None_Receiver;
/*
- * Loop to handle the individual queries generated from a
- * single parsetree by analysis and rewrite.
+ * Loop to handle the individual queries generated from a single
+ * parsetree by analysis and rewrite.
*/
foreach(querylist_item, portal->parseTrees)
{
@@ -862,12 +873,12 @@ PortalRunMulti(Portal portal,
}
/*
- * If a command completion tag was supplied, use it. Otherwise
- * use the portal's commandTag as the default completion tag.
+ * If a command completion tag was supplied, use it. Otherwise use
+ * the portal's commandTag as the default completion tag.
*
- * Exception: clients will expect INSERT/UPDATE/DELETE tags to
- * have counts, so fake something up if necessary. (This could
- * happen if the original query was replaced by a DO INSTEAD rule.)
+ * Exception: clients will expect INSERT/UPDATE/DELETE tags to have
+ * counts, so fake something up if necessary. (This could happen if
+ * the original query was replaced by a DO INSTEAD rule.)
*/
if (completionTag && completionTag[0] == '\0')
{
@@ -903,7 +914,7 @@ PortalRunFetch(Portal portal,
MemoryContext oldContext;
AssertArg(PortalIsValid(portal));
- AssertState(portal->portalReady); /* else no PortalStart */
+ AssertState(portal->portalReady); /* else no PortalStart */
/*
* Check for improper portal use, and mark portal active.
@@ -911,7 +922,7 @@ PortalRunFetch(Portal portal,
if (portal->portalDone)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("portal \"%s\" cannot be run anymore", portal->name)));
+ errmsg("portal \"%s\" cannot be run anymore", portal->name)));
if (portal->portalActive)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
@@ -989,18 +1000,18 @@ DoPortalRunFetch(Portal portal,
if (count > 0)
{
/*
- * Definition: Rewind to start, advance count-1 rows, return
- * next row (if any). In practice, if the goal is less than
- * halfway back to the start, it's better to scan from where
- * we are. In any case, we arrange to fetch the target row
- * going forwards.
+ * Definition: Rewind to start, advance count-1 rows,
+ * return next row (if any). In practice, if the goal is
+ * less than halfway back to the start, it's better to
+ * scan from where we are. In any case, we arrange to
+ * fetch the target row going forwards.
*/
if (portal->posOverflow || portal->portalPos == LONG_MAX ||
- count-1 <= portal->portalPos / 2)
+ count - 1 <= portal->portalPos / 2)
{
DoPortalRewind(portal);
if (count > 1)
- PortalRunSelect(portal, true, count-1,
+ PortalRunSelect(portal, true, count - 1,
None_Receiver);
}
else
@@ -1010,10 +1021,10 @@ DoPortalRunFetch(Portal portal,
if (portal->atEnd)
pos++; /* need one extra fetch if off end */
if (count <= pos)
- PortalRunSelect(portal, false, pos-count+1,
+ PortalRunSelect(portal, false, pos - count + 1,
None_Receiver);
- else if (count > pos+1)
- PortalRunSelect(portal, true, count-pos-1,
+ else if (count > pos + 1)
+ PortalRunSelect(portal, true, count - pos - 1,
None_Receiver);
}
return PortalRunSelect(portal, true, 1L, dest);
@@ -1022,17 +1033,19 @@ DoPortalRunFetch(Portal portal,
{
/*
* Definition: Advance to end, back up abs(count)-1 rows,
- * return prior row (if any). We could optimize this if we
- * knew in advance where the end was, but typically we won't.
- * (Is it worth considering case where count > half of size
- * of query? We could rewind once we know the size ...)
+ * return prior row (if any). We could optimize this if
+ * we knew in advance where the end was, but typically we
+ * won't. (Is it worth considering case where count > half
+ * of size of query? We could rewind once we know the
+ * size ...)
*/
PortalRunSelect(portal, true, FETCH_ALL, None_Receiver);
if (count < -1)
- PortalRunSelect(portal, false, -count-1, None_Receiver);
+ PortalRunSelect(portal, false, -count - 1, None_Receiver);
return PortalRunSelect(portal, false, 1L, dest);
}
- else /* count == 0 */
+ else
+/* count == 0 */
{
/* Rewind to start, return zero rows */
DoPortalRewind(portal);
@@ -1043,10 +1056,11 @@ DoPortalRunFetch(Portal portal,
if (count > 0)
{
/*
- * Definition: advance count-1 rows, return next row (if any).
+ * Definition: advance count-1 rows, return next row (if
+ * any).
*/
if (count > 1)
- PortalRunSelect(portal, true, count-1, None_Receiver);
+ PortalRunSelect(portal, true, count - 1, None_Receiver);
return PortalRunSelect(portal, true, 1L, dest);
}
else if (count < 0)
@@ -1056,10 +1070,11 @@ DoPortalRunFetch(Portal portal,
* (if any).
*/
if (count < -1)
- PortalRunSelect(portal, false, -count-1, None_Receiver);
+ PortalRunSelect(portal, false, -count - 1, None_Receiver);
return PortalRunSelect(portal, false, 1L, dest);
}
- else /* count == 0 */
+ else
+/* count == 0 */
{
/* Same as FETCH FORWARD 0, so fall out of switch */
fdirection = FETCH_FORWARD;
@@ -1071,8 +1086,8 @@ DoPortalRunFetch(Portal portal,
}
/*
- * Get here with fdirection == FETCH_FORWARD or FETCH_BACKWARD,
- * and count >= 0.
+ * Get here with fdirection == FETCH_FORWARD or FETCH_BACKWARD, and
+ * count >= 0.
*/
forward = (fdirection == FETCH_FORWARD);
@@ -1081,7 +1096,7 @@ DoPortalRunFetch(Portal portal,
*/
if (count == 0)
{
- bool on_row;
+ bool on_row;
/* Are we sitting on a row? */
on_row = (!portal->atStart && !portal->atEnd);
@@ -1094,11 +1109,11 @@ DoPortalRunFetch(Portal portal,
else
{
/*
- * If we are sitting on a row, back up one so we can re-fetch it.
- * If we are not sitting on a row, we still have to start up and
- * shut down the executor so that the destination is initialized
- * and shut down correctly; so keep going. To PortalRunSelect,
- * count == 0 means we will retrieve no row.
+ * If we are sitting on a row, back up one so we can re-fetch
+ * it. If we are not sitting on a row, we still have to start
+ * up and shut down the executor so that the destination is
+ * initialized and shut down correctly; so keep going. To
+ * PortalRunSelect, count == 0 means we will retrieve no row.
*/
if (on_row)
{
@@ -1115,7 +1130,7 @@ DoPortalRunFetch(Portal portal,
*/
if (!forward && count == FETCH_ALL && dest->mydest == None)
{
- long result = portal->portalPos;
+ long result = portal->portalPos;
if (result > 0 && !portal->atEnd)
result--;
@@ -1142,9 +1157,7 @@ DoPortalRewind(Portal portal)
MemoryContextSwitchTo(oldcontext);
}
if (PortalGetQueryDesc(portal))
- {
ExecutorRewind(PortalGetQueryDesc(portal));
- }
portal->atStart = true;
portal->atEnd = false;
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index ec9e7a4cecb..f0206bd14f7 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.203 2003/08/01 00:15:23 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.204 2003/08/04 00:43:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -70,32 +70,32 @@ struct msgstrings
};
static const struct msgstrings msgstringarray[] = {
- { RELKIND_RELATION,
- ERRCODE_UNDEFINED_TABLE,
- gettext_noop("table \"%s\" does not exist"),
- gettext_noop("\"%s\" is not a table"),
- gettext_noop("Use DROP TABLE to remove a table.") },
- { RELKIND_SEQUENCE,
- ERRCODE_UNDEFINED_TABLE,
- gettext_noop("sequence \"%s\" does not exist"),
- gettext_noop("\"%s\" is not a sequence"),
- gettext_noop("Use DROP SEQUENCE to remove a sequence.") },
- { RELKIND_VIEW,
- ERRCODE_UNDEFINED_TABLE,
- gettext_noop("view \"%s\" does not exist"),
- gettext_noop("\"%s\" is not a view"),
- gettext_noop("Use DROP VIEW to remove a view.") },
- { RELKIND_INDEX,
- ERRCODE_UNDEFINED_OBJECT,
- gettext_noop("index \"%s\" does not exist"),
- gettext_noop("\"%s\" is not an index"),
- gettext_noop("Use DROP INDEX to remove an index.") },
- { RELKIND_COMPOSITE_TYPE,
- ERRCODE_UNDEFINED_OBJECT,
- gettext_noop("type \"%s\" does not exist"),
- gettext_noop("\"%s\" is not a type"),
- gettext_noop("Use DROP TYPE to remove a type.") },
- { '\0', 0, NULL, NULL, NULL }
+ {RELKIND_RELATION,
+ ERRCODE_UNDEFINED_TABLE,
+ gettext_noop("table \"%s\" does not exist"),
+ gettext_noop("\"%s\" is not a table"),
+ gettext_noop("Use DROP TABLE to remove a table.")},
+ {RELKIND_SEQUENCE,
+ ERRCODE_UNDEFINED_TABLE,
+ gettext_noop("sequence \"%s\" does not exist"),
+ gettext_noop("\"%s\" is not a sequence"),
+ gettext_noop("Use DROP SEQUENCE to remove a sequence.")},
+ {RELKIND_VIEW,
+ ERRCODE_UNDEFINED_TABLE,
+ gettext_noop("view \"%s\" does not exist"),
+ gettext_noop("\"%s\" is not a view"),
+ gettext_noop("Use DROP VIEW to remove a view.")},
+ {RELKIND_INDEX,
+ ERRCODE_UNDEFINED_OBJECT,
+ gettext_noop("index \"%s\" does not exist"),
+ gettext_noop("\"%s\" is not an index"),
+ gettext_noop("Use DROP INDEX to remove an index.")},
+ {RELKIND_COMPOSITE_TYPE,
+ ERRCODE_UNDEFINED_OBJECT,
+ gettext_noop("type \"%s\" does not exist"),
+ gettext_noop("\"%s\" is not a type"),
+ gettext_noop("Use DROP TYPE to remove a type.")},
+ {'\0', 0, NULL, NULL, NULL}
};
@@ -181,7 +181,7 @@ CheckRelationOwnership(RangeVar *rel, bool noCatalogs)
tuple = SearchSysCache(RELOID,
ObjectIdGetDatum(relOid),
0, 0, 0);
- if (!HeapTupleIsValid(tuple)) /* should not happen */
+ if (!HeapTupleIsValid(tuple)) /* should not happen */
elog(ERROR, "cache lookup failed for relation %u", relOid);
if (!pg_class_ownercheck(relOid, GetUserId()))
@@ -194,8 +194,8 @@ CheckRelationOwnership(RangeVar *rel, bool noCatalogs)
IsSystemClass((Form_pg_class) GETSTRUCT(tuple)))
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("permission denied: \"%s\" is a system catalog",
- rel->relname)));
+ errmsg("permission denied: \"%s\" is a system catalog",
+ rel->relname)));
}
ReleaseSysCache(tuple);
@@ -316,18 +316,18 @@ ProcessUtility(Node *parsetree,
if (stmt->options)
{
- List *head;
+ List *head;
foreach(head, stmt->options)
{
- DefElem *item = (DefElem *) lfirst(head);
+ DefElem *item = (DefElem *) lfirst(head);
- if (strcmp(item->defname, "transaction_isolation")==0)
+ if (strcmp(item->defname, "transaction_isolation") == 0)
SetPGVariable("transaction_isolation",
- makeList1(item->arg), false);
- else if (strcmp(item->defname, "transaction_read_only")==0)
+ makeList1(item->arg), false);
+ else if (strcmp(item->defname, "transaction_read_only") == 0)
SetPGVariable("transaction_read_only",
- makeList1(item->arg), false);
+ makeList1(item->arg), false);
}
}
}
@@ -429,7 +429,11 @@ ProcessUtility(Node *parsetree,
break;
case OBJECT_DOMAIN:
- /* RemoveDomain does its own permissions checks */
+
+ /*
+ * RemoveDomain does its own permissions
+ * checks
+ */
RemoveDomain(names, stmt->behavior);
break;
@@ -438,7 +442,11 @@ ProcessUtility(Node *parsetree,
break;
case OBJECT_SCHEMA:
- /* RemoveSchema does its own permissions checks */
+
+ /*
+ * RemoveSchema does its own permissions
+ * checks
+ */
RemoveSchema(names, stmt->behavior);
break;
@@ -590,8 +598,8 @@ ProcessUtility(Node *parsetree,
/* check that we are the superuser */
if (!superuser())
ereport(ERROR,
- (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("must be superuser to alter owner")));
+ (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+ errmsg("must be superuser to alter owner")));
/* get_usesysid raises an error if no such user */
AlterTableOwner(relid,
get_usesysid(stmt->name));
@@ -599,9 +607,9 @@ ProcessUtility(Node *parsetree,
case 'L': /* CLUSTER ON */
AlterTableClusterOn(relid, stmt->name);
break;
- case 'o': /* ADD OIDS */
+ case 'o': /* ADD OIDS */
AlterTableAlterOids(relid,
- interpretInhOption(stmt->relation->inhOpt),
+ interpretInhOption(stmt->relation->inhOpt),
false);
break;
default: /* oops */
@@ -652,8 +660,8 @@ ProcessUtility(Node *parsetree,
/* check that we are the superuser */
if (!superuser())
ereport(ERROR,
- (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("must be superuser to alter owner")));
+ (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+ errmsg("must be superuser to alter owner")));
/* get_usesysid raises an error if no such user */
AlterTypeOwner(stmt->typename,
get_usesysid(stmt->name));
@@ -828,40 +836,39 @@ ProcessUtility(Node *parsetree,
VariableSetStmt *n = (VariableSetStmt *) parsetree;
/*
- * Special cases for special SQL syntax that
- * effectively sets more than one variable per
- * statement.
+ * Special cases for special SQL syntax that effectively
+ * sets more than one variable per statement.
*/
- if (strcmp(n->name, "TRANSACTION")==0)
+ if (strcmp(n->name, "TRANSACTION") == 0)
{
- List *head;
+ List *head;
foreach(head, n->args)
{
- DefElem *item = (DefElem *) lfirst(head);
+ DefElem *item = (DefElem *) lfirst(head);
- if (strcmp(item->defname, "transaction_isolation")==0)
+ if (strcmp(item->defname, "transaction_isolation") == 0)
SetPGVariable("transaction_isolation",
- makeList1(item->arg), n->is_local);
- else if (strcmp(item->defname, "transaction_read_only")==0)
+ makeList1(item->arg), n->is_local);
+ else if (strcmp(item->defname, "transaction_read_only") == 0)
SetPGVariable("transaction_read_only",
- makeList1(item->arg), n->is_local);
+ makeList1(item->arg), n->is_local);
}
}
- else if (strcmp(n->name, "SESSION CHARACTERISTICS")==0)
+ else if (strcmp(n->name, "SESSION CHARACTERISTICS") == 0)
{
- List *head;
+ List *head;
foreach(head, n->args)
{
- DefElem *item = (DefElem *) lfirst(head);
+ DefElem *item = (DefElem *) lfirst(head);
- if (strcmp(item->defname, "transaction_isolation")==0)
+ if (strcmp(item->defname, "transaction_isolation") == 0)
SetPGVariable("default_transaction_isolation",
- makeList1(item->arg), n->is_local);
- else if (strcmp(item->defname, "transaction_read_only")==0)
+ makeList1(item->arg), n->is_local);
+ else if (strcmp(item->defname, "transaction_read_only") == 0)
SetPGVariable("default_transaction_read_only",
- makeList1(item->arg), n->is_local);
+ makeList1(item->arg), n->is_local);
}
}
else
@@ -1046,14 +1053,14 @@ UtilityReturnsTuples(Node *parsetree)
{
case T_FetchStmt:
{
- FetchStmt *stmt = (FetchStmt *) parsetree;
- Portal portal;
+ FetchStmt *stmt = (FetchStmt *) parsetree;
+ Portal portal;
if (stmt->ismove)
return false;
portal = GetPortalByName(stmt->portalname);
if (!PortalIsValid(portal))
- return false; /* not our business to raise error */
+ return false; /* not our business to raise error */
return portal->tupDesc ? true : false;
}
@@ -1066,7 +1073,7 @@ UtilityReturnsTuples(Node *parsetree)
return false;
entry = FetchPreparedStatement(stmt->name, false);
if (!entry)
- return false; /* not our business to raise error */
+ return false; /* not our business to raise error */
switch (ChoosePortalStrategy(entry->query_list))
{
case PORTAL_ONE_SELECT:
@@ -1106,14 +1113,14 @@ UtilityTupleDescriptor(Node *parsetree)
{
case T_FetchStmt:
{
- FetchStmt *stmt = (FetchStmt *) parsetree;
- Portal portal;
+ FetchStmt *stmt = (FetchStmt *) parsetree;
+ Portal portal;
if (stmt->ismove)
return NULL;
portal = GetPortalByName(stmt->portalname);
if (!PortalIsValid(portal))
- return NULL; /* not our business to raise error */
+ return NULL; /* not our business to raise error */
return CreateTupleDescCopy(portal->tupDesc);
}
@@ -1126,7 +1133,7 @@ UtilityTupleDescriptor(Node *parsetree)
return NULL;
entry = FetchPreparedStatement(stmt->name, false);
if (!entry)
- return NULL; /* not our business to raise error */
+ return NULL; /* not our business to raise error */
return FetchPreparedStatementResultDesc(entry);
}