mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Standard pgindent run for 8.1.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/dest.c,v 1.65 2005/03/16 21:38:08 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/dest.c,v 1.66 2005/10/15 02:49:26 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -173,9 +173,8 @@ 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');
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/fastpath.c,v 1.82 2005/09/24 17:53:15 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/fastpath.c,v 1.83 2005/10/15 02:49:26 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* This cruft is the server side of PQfn.
|
||||
@@ -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)
|
||||
@@ -204,11 +204,10 @@ fetch_fp_info(Oid func_id, struct fp_info * fip)
|
||||
/*
|
||||
* Since the validity of this structure is determined by whether the
|
||||
* funcid is OK, we clear the funcid here. It must not be set to the
|
||||
* correct value until we are about to return with a good struct
|
||||
* fp_info, since we can be interrupted (i.e., with an ereport(ERROR,
|
||||
* ...)) at any time. [No longer really an issue since we don't save
|
||||
* the struct fp_info across transactions anymore, but keep it
|
||||
* anyway.]
|
||||
* correct value until we are about to return with a good struct fp_info,
|
||||
* since we can be interrupted (i.e., with an ereport(ERROR, ...)) at any
|
||||
* time. [No longer really an issue since we don't save the struct
|
||||
* fp_info across transactions anymore, but keep it anyway.]
|
||||
*/
|
||||
MemSet(fip, 0, sizeof(struct fp_info));
|
||||
fip->funcid = InvalidOid;
|
||||
@@ -294,14 +293,14 @@ HandleFunctionRequest(StringInfo msgBuf)
|
||||
|
||||
/*
|
||||
* Now that we've eaten the input message, check to see if we actually
|
||||
* want to do the function call or not. It's now safe to ereport();
|
||||
* we won't lose sync with the frontend.
|
||||
* want to do the function call or not. It's now safe to ereport(); we
|
||||
* won't lose sync with the frontend.
|
||||
*/
|
||||
if (IsAbortedTransactionBlockState())
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
|
||||
errmsg("current transaction is aborted, "
|
||||
"commands ignored until end of transaction block")));
|
||||
"commands ignored until end of transaction block")));
|
||||
|
||||
/*
|
||||
* Begin parsing the buffer contents.
|
||||
@@ -440,8 +439,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;
|
||||
@@ -500,8 +499,8 @@ parse_fcall_arguments(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)));
|
||||
}
|
||||
else
|
||||
ereport(ERROR,
|
||||
@@ -543,9 +542,9 @@ parse_fcall_arguments_20(StringInfo msgBuf, struct fp_info * fip,
|
||||
* Copy supplied arguments into arg vector. In protocol 2.0 these are
|
||||
* always assumed to be supplied in binary format.
|
||||
*
|
||||
* Note: although the original protocol 2.0 code did not have any way for
|
||||
* the frontend to specify a NULL argument, we now choose to interpret
|
||||
* length == -1 as meaning a NULL.
|
||||
* Note: although the original protocol 2.0 code did not have any way for the
|
||||
* frontend to specify a NULL argument, we now choose to interpret length
|
||||
* == -1 as meaning a NULL.
|
||||
*/
|
||||
for (i = 0; i < nargs; ++i)
|
||||
{
|
||||
@@ -563,8 +562,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;
|
||||
@@ -587,8 +586,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 */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/pquery.c,v 1.94 2005/06/22 17:45:46 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/pquery.c,v 1.95 2005/10/15 02:49:27 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -72,7 +72,7 @@ CreateQueryDesc(Query *parsetree,
|
||||
qd->parsetree = parsetree; /* parse tree */
|
||||
qd->plantree = plantree; /* plan */
|
||||
qd->snapshot = snapshot; /* snapshot */
|
||||
qd->crosscheck_snapshot = crosscheck_snapshot; /* RI check snapshot */
|
||||
qd->crosscheck_snapshot = crosscheck_snapshot; /* RI check snapshot */
|
||||
qd->dest = dest; /* output dest */
|
||||
qd->params = params; /* parameter values passed into query */
|
||||
qd->doInstrument = doInstrument; /* instrumentation wanted? */
|
||||
@@ -138,16 +138,16 @@ ProcessQuery(Query *parsetree,
|
||||
* SELECT INTO table (a/k/a CREATE AS ... SELECT).
|
||||
*
|
||||
* Override the normal communication destination; execMain.c
|
||||
* special-cases this case. (Perhaps would be cleaner to have
|
||||
* an additional destination type?)
|
||||
* special-cases this case. (Perhaps would be cleaner to have an
|
||||
* additional destination type?)
|
||||
*/
|
||||
dest = None_Receiver;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Must always set snapshot for plannable queries. Note we assume
|
||||
* that caller will take care of restoring ActiveSnapshot on exit/error.
|
||||
* Must always set snapshot for plannable queries. Note we assume that
|
||||
* caller will take care of restoring ActiveSnapshot on exit/error.
|
||||
*/
|
||||
ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
|
||||
|
||||
@@ -191,7 +191,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,
|
||||
@@ -270,31 +270,31 @@ FetchPortalTargetList(Portal portal)
|
||||
return ((Query *) linitial(portal->parseTrees))->targetList;
|
||||
if (portal->strategy == PORTAL_UTIL_SELECT)
|
||||
{
|
||||
Node *utilityStmt;
|
||||
Node *utilityStmt;
|
||||
|
||||
utilityStmt = ((Query *) linitial(portal->parseTrees))->utilityStmt;
|
||||
switch (nodeTag(utilityStmt))
|
||||
{
|
||||
case T_FetchStmt:
|
||||
{
|
||||
FetchStmt *substmt = (FetchStmt *) utilityStmt;
|
||||
Portal subportal;
|
||||
{
|
||||
FetchStmt *substmt = (FetchStmt *) utilityStmt;
|
||||
Portal subportal;
|
||||
|
||||
Assert(!substmt->ismove);
|
||||
subportal = GetPortalByName(substmt->portalname);
|
||||
Assert(PortalIsValid(subportal));
|
||||
return FetchPortalTargetList(subportal);
|
||||
}
|
||||
Assert(!substmt->ismove);
|
||||
subportal = GetPortalByName(substmt->portalname);
|
||||
Assert(PortalIsValid(subportal));
|
||||
return FetchPortalTargetList(subportal);
|
||||
}
|
||||
|
||||
case T_ExecuteStmt:
|
||||
{
|
||||
ExecuteStmt *substmt = (ExecuteStmt *) utilityStmt;
|
||||
PreparedStatement *entry;
|
||||
{
|
||||
ExecuteStmt *substmt = (ExecuteStmt *) utilityStmt;
|
||||
PreparedStatement *entry;
|
||||
|
||||
Assert(!substmt->into);
|
||||
entry = FetchPreparedStatement(substmt->name, true);
|
||||
return FetchPreparedStatementTargetList(entry);
|
||||
}
|
||||
Assert(!substmt->into);
|
||||
entry = FetchPreparedStatement(substmt->name, true);
|
||||
return FetchPreparedStatementTargetList(entry);
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
@@ -335,8 +335,7 @@ PortalStart(Portal portal, ParamListInfo params, Snapshot snapshot)
|
||||
AssertState(portal->status == PORTAL_NEW); /* else extra PortalStart */
|
||||
|
||||
/*
|
||||
* Set up global portal context pointers. (Should we set
|
||||
* QueryContext?)
|
||||
* Set up global portal context pointers. (Should we set QueryContext?)
|
||||
*/
|
||||
saveActivePortal = ActivePortal;
|
||||
saveActiveSnapshot = ActiveSnapshot;
|
||||
@@ -345,7 +344,7 @@ PortalStart(Portal portal, ParamListInfo params, Snapshot snapshot)
|
||||
PG_TRY();
|
||||
{
|
||||
ActivePortal = portal;
|
||||
ActiveSnapshot = NULL; /* will be set later */
|
||||
ActiveSnapshot = NULL; /* will be set later */
|
||||
CurrentResourceOwner = portal->resowner;
|
||||
PortalContext = PortalGetHeapMemory(portal);
|
||||
|
||||
@@ -367,7 +366,7 @@ PortalStart(Portal portal, ParamListInfo params, Snapshot snapshot)
|
||||
case PORTAL_ONE_SELECT:
|
||||
|
||||
/*
|
||||
* Must set snapshot before starting executor. Be sure to
|
||||
* Must set snapshot before starting executor. Be sure to
|
||||
* copy it into the portal's context.
|
||||
*/
|
||||
if (snapshot)
|
||||
@@ -376,11 +375,11 @@ PortalStart(Portal portal, ParamListInfo params, Snapshot snapshot)
|
||||
ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
|
||||
|
||||
/*
|
||||
* Create QueryDesc in portal's context; for the moment,
|
||||
* set the destination to None.
|
||||
* Create QueryDesc in portal's context; for the moment, set
|
||||
* the destination to None.
|
||||
*/
|
||||
queryDesc = CreateQueryDesc((Query *) linitial(portal->parseTrees),
|
||||
(Plan *) linitial(portal->planTrees),
|
||||
(Plan *) linitial(portal->planTrees),
|
||||
ActiveSnapshot,
|
||||
InvalidSnapshot,
|
||||
None_Receiver,
|
||||
@@ -388,10 +387,10 @@ PortalStart(Portal portal, ParamListInfo params, Snapshot snapshot)
|
||||
false);
|
||||
|
||||
/*
|
||||
* We do *not* call AfterTriggerBeginQuery() here. We
|
||||
* assume that a SELECT cannot queue any triggers. It
|
||||
* would be messy to support triggers since the execution
|
||||
* of the portal may be interleaved with other queries.
|
||||
* We do *not* call AfterTriggerBeginQuery() here. We assume
|
||||
* that a SELECT cannot queue any triggers. It would be messy
|
||||
* to support triggers since the execution of the portal may
|
||||
* be interleaved with other queries.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -421,8 +420,8 @@ PortalStart(Portal portal, ParamListInfo params, Snapshot snapshot)
|
||||
case PORTAL_UTIL_SELECT:
|
||||
|
||||
/*
|
||||
* We don't set snapshot here, because
|
||||
* PortalRunUtility will take care of it if needed.
|
||||
* We don't set snapshot here, because PortalRunUtility will
|
||||
* take care of it if needed.
|
||||
*/
|
||||
portal->tupDesc =
|
||||
UtilityTupleDescriptor(((Query *) linitial(portal->parseTrees))->utilityStmt);
|
||||
@@ -579,14 +578,14 @@ PortalRun(Portal portal, long count,
|
||||
*
|
||||
* We have to play a special game here to support utility commands like
|
||||
* VACUUM and CLUSTER, which internally start and commit transactions.
|
||||
* When we are called to execute such a command, CurrentResourceOwner
|
||||
* will be pointing to the TopTransactionResourceOwner --- which will
|
||||
* be destroyed and replaced in the course of the internal commit and
|
||||
* restart. So we need to be prepared to restore it as pointing to
|
||||
* the exit-time TopTransactionResourceOwner. (Ain't that ugly? This
|
||||
* idea of internally starting whole new transactions is not good.)
|
||||
* CurrentMemoryContext has a similar problem, but the other pointers
|
||||
* we save here will be NULL or pointing to longer-lived objects.
|
||||
* When we are called to execute such a command, CurrentResourceOwner will
|
||||
* be pointing to the TopTransactionResourceOwner --- which will be
|
||||
* destroyed and replaced in the course of the internal commit and
|
||||
* restart. So we need to be prepared to restore it as pointing to the
|
||||
* exit-time TopTransactionResourceOwner. (Ain't that ugly? This idea of
|
||||
* internally starting whole new transactions is not good.)
|
||||
* CurrentMemoryContext has a similar problem, but the other pointers we
|
||||
* save here will be NULL or pointing to longer-lived objects.
|
||||
*/
|
||||
saveTopTransactionResourceOwner = TopTransactionResourceOwner;
|
||||
saveTopTransactionContext = TopTransactionContext;
|
||||
@@ -599,7 +598,7 @@ PortalRun(Portal portal, long count,
|
||||
PG_TRY();
|
||||
{
|
||||
ActivePortal = portal;
|
||||
ActiveSnapshot = NULL; /* will be set later */
|
||||
ActiveSnapshot = NULL; /* will be set later */
|
||||
CurrentResourceOwner = portal->resowner;
|
||||
PortalContext = PortalGetHeapMemory(portal);
|
||||
QueryContext = portal->queryContext;
|
||||
@@ -618,8 +617,7 @@ PortalRun(Portal portal, long count,
|
||||
portal->status = PORTAL_READY;
|
||||
|
||||
/*
|
||||
* Since it's a forward fetch, say DONE iff atEnd is now
|
||||
* true.
|
||||
* Since it's a forward fetch, say DONE iff atEnd is now true.
|
||||
*/
|
||||
result = portal->atEnd;
|
||||
break;
|
||||
@@ -658,8 +656,7 @@ PortalRun(Portal portal, long count,
|
||||
portal->status = PORTAL_READY;
|
||||
|
||||
/*
|
||||
* Since it's a forward fetch, say DONE iff atEnd is now
|
||||
* true.
|
||||
* Since it's a forward fetch, say DONE iff atEnd is now true.
|
||||
*/
|
||||
result = portal->atEnd;
|
||||
break;
|
||||
@@ -750,8 +747,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);
|
||||
|
||||
@@ -768,15 +765,15 @@ PortalRunSelect(Portal portal,
|
||||
queryDesc->dest = dest;
|
||||
|
||||
/*
|
||||
* Determine which direction to go in, and check to see if we're
|
||||
* already at the end of the available tuples in that direction. If
|
||||
* so, set the direction to NoMovement to avoid trying to fetch any
|
||||
* tuples. (This check exists because not all plan node types are
|
||||
* robust about being called again if they've already returned NULL
|
||||
* once.) Then call the executor (we must not skip this, because the
|
||||
* destination needs to see a setup and shutdown even if no tuples are
|
||||
* available). Finally, update the portal position state depending on
|
||||
* the number of tuples that were retrieved.
|
||||
* Determine which direction to go in, and check to see if we're already
|
||||
* at the end of the available tuples in that direction. If so, set the
|
||||
* direction to NoMovement to avoid trying to fetch any tuples. (This
|
||||
* check exists because not all plan node types are robust about being
|
||||
* called again if they've already returned NULL once.) Then call the
|
||||
* executor (we must not skip this, because the destination needs to see a
|
||||
* setup and shutdown even if no tuples are available). Finally, update
|
||||
* the portal position state depending on the number of tuples that were
|
||||
* retrieved.
|
||||
*/
|
||||
if (forward)
|
||||
{
|
||||
@@ -924,9 +921,9 @@ RunFromStore(Portal portal, ScanDirection direction, long count,
|
||||
ExecClearTuple(slot);
|
||||
|
||||
/*
|
||||
* 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)
|
||||
@@ -955,19 +952,18 @@ PortalRunUtility(Portal portal, Query *query,
|
||||
(errmsg_internal("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.
|
||||
*
|
||||
* Note we assume that caller will take care of restoring ActiveSnapshot
|
||||
* on exit/error.
|
||||
* Note we assume that caller will take care of restoring ActiveSnapshot on
|
||||
* exit/error.
|
||||
*/
|
||||
if (!(IsA(utilityStmt, TransactionStmt) ||
|
||||
IsA(utilityStmt, LockStmt) ||
|
||||
@@ -1020,13 +1016,13 @@ PortalRunMulti(Portal portal,
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
if (dest->mydest == RemoteExecute)
|
||||
dest = None_Receiver;
|
||||
@@ -1034,8 +1030,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.
|
||||
*/
|
||||
forboth(querylist_item, portal->parseTrees,
|
||||
planlist_item, portal->planTrees)
|
||||
@@ -1087,8 +1083,8 @@ PortalRunMulti(Portal portal,
|
||||
}
|
||||
|
||||
/*
|
||||
* Increment command counter between queries, but not after the
|
||||
* last one.
|
||||
* Increment command counter between queries, but not after the last
|
||||
* one.
|
||||
*/
|
||||
if (lnext(planlist_item) != NULL)
|
||||
CommandCounterIncrement();
|
||||
@@ -1102,12 +1098,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')
|
||||
{
|
||||
@@ -1164,7 +1160,7 @@ PortalRunFetch(Portal portal,
|
||||
PG_TRY();
|
||||
{
|
||||
ActivePortal = portal;
|
||||
ActiveSnapshot = NULL; /* will be set later */
|
||||
ActiveSnapshot = NULL; /* will be set later */
|
||||
CurrentResourceOwner = portal->resowner;
|
||||
PortalContext = PortalGetHeapMemory(portal);
|
||||
QueryContext = portal->queryContext;
|
||||
@@ -1276,11 +1272,11 @@ 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)
|
||||
@@ -1309,11 +1305,10 @@ 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)
|
||||
@@ -1332,8 +1327,7 @@ 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);
|
||||
@@ -1342,8 +1336,8 @@ DoPortalRunFetch(Portal portal,
|
||||
else if (count < 0)
|
||||
{
|
||||
/*
|
||||
* Definition: back up abs(count)-1 rows, return prior row
|
||||
* (if any).
|
||||
* Definition: back up abs(count)-1 rows, return prior row (if
|
||||
* any).
|
||||
*/
|
||||
if (count < -1)
|
||||
PortalRunSelect(portal, false, -count - 1, None_Receiver);
|
||||
@@ -1362,8 +1356,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);
|
||||
|
||||
@@ -1385,11 +1379,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)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.244 2005/10/06 21:30:36 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.245 2005/10/15 02:49:27 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -214,8 +214,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);
|
||||
@@ -236,9 +236,9 @@ QueryIsReadOnly(Query *parsetree)
|
||||
{
|
||||
case CMD_SELECT:
|
||||
if (parsetree->into != NULL)
|
||||
return false; /* SELECT INTO */
|
||||
return false; /* SELECT INTO */
|
||||
else if (parsetree->rowMarks != NIL)
|
||||
return false; /* SELECT FOR UPDATE/SHARE */
|
||||
return false; /* SELECT FOR UPDATE/SHARE */
|
||||
else
|
||||
return true;
|
||||
case CMD_UPDATE:
|
||||
@@ -269,8 +269,8 @@ check_xact_readonly(Node *parsetree)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Note: Commands that need to do more complicated checking are
|
||||
* handled elsewhere.
|
||||
* Note: Commands that need to do more complicated checking are handled
|
||||
* elsewhere.
|
||||
*/
|
||||
|
||||
switch (nodeTag(parsetree))
|
||||
@@ -367,8 +367,8 @@ ProcessUtility(Node *parsetree,
|
||||
switch (stmt->kind)
|
||||
{
|
||||
/*
|
||||
* START TRANSACTION, as defined by SQL99:
|
||||
* Identical to BEGIN. Same code for both.
|
||||
* START TRANSACTION, as defined by SQL99: Identical
|
||||
* to BEGIN. Same code for both.
|
||||
*/
|
||||
case TRANS_STMT_BEGIN:
|
||||
case TRANS_STMT_START:
|
||||
@@ -498,8 +498,8 @@ ProcessUtility(Node *parsetree,
|
||||
RELKIND_RELATION);
|
||||
|
||||
/*
|
||||
* Let AlterTableCreateToastTable decide if this one needs
|
||||
* a secondary relation too.
|
||||
* Let AlterTableCreateToastTable decide if this one needs a
|
||||
* secondary relation too.
|
||||
*/
|
||||
CommandCounterIncrement();
|
||||
AlterTableCreateToastTable(relOid, true);
|
||||
@@ -558,8 +558,7 @@ ProcessUtility(Node *parsetree,
|
||||
case OBJECT_DOMAIN:
|
||||
|
||||
/*
|
||||
* RemoveDomain does its own permissions
|
||||
* checks
|
||||
* RemoveDomain does its own permissions checks
|
||||
*/
|
||||
RemoveDomain(names, stmt->behavior);
|
||||
break;
|
||||
@@ -571,8 +570,7 @@ ProcessUtility(Node *parsetree,
|
||||
case OBJECT_SCHEMA:
|
||||
|
||||
/*
|
||||
* RemoveSchema does its own permissions
|
||||
* checks
|
||||
* RemoveSchema does its own permissions checks
|
||||
*/
|
||||
RemoveSchema(names, stmt->behavior);
|
||||
break;
|
||||
@@ -584,8 +582,8 @@ ProcessUtility(Node *parsetree,
|
||||
}
|
||||
|
||||
/*
|
||||
* We used to need to do CommandCounterIncrement()
|
||||
* here, but now it's done inside performDeletion().
|
||||
* We used to need to do CommandCounterIncrement() here,
|
||||
* but now it's done inside performDeletion().
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -651,8 +649,8 @@ ProcessUtility(Node *parsetree,
|
||||
case 'T': /* ALTER DOMAIN DEFAULT */
|
||||
|
||||
/*
|
||||
* Recursively alter column default for table and,
|
||||
* if requested, for descendants
|
||||
* Recursively alter column default for table and, if
|
||||
* requested, for descendants
|
||||
*/
|
||||
AlterDomainDefault(stmt->typename,
|
||||
stmt->def);
|
||||
@@ -691,8 +689,7 @@ ProcessUtility(Node *parsetree,
|
||||
break;
|
||||
|
||||
/*
|
||||
* ******************************** object creation /
|
||||
* destruction ********************************
|
||||
* ******************************** object creation / destruction ********************************
|
||||
*
|
||||
*/
|
||||
case T_DefineStmt:
|
||||
@@ -738,7 +735,7 @@ ProcessUtility(Node *parsetree,
|
||||
CreateFunction((CreateFunctionStmt *) parsetree);
|
||||
break;
|
||||
|
||||
case T_AlterFunctionStmt: /* ALTER FUNCTION */
|
||||
case T_AlterFunctionStmt: /* ALTER FUNCTION */
|
||||
AlterFunction((AlterFunctionStmt *) parsetree);
|
||||
break;
|
||||
|
||||
@@ -750,7 +747,7 @@ ProcessUtility(Node *parsetree,
|
||||
|
||||
DefineIndex(stmt->relation, /* relation */
|
||||
stmt->idxname, /* index name */
|
||||
InvalidOid, /* no predefined OID */
|
||||
InvalidOid, /* no predefined OID */
|
||||
stmt->accessMethod, /* am name */
|
||||
stmt->tableSpace,
|
||||
stmt->indexParams, /* parameters */
|
||||
@@ -865,8 +862,8 @@ 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)
|
||||
{
|
||||
@@ -878,10 +875,10 @@ ProcessUtility(Node *parsetree,
|
||||
|
||||
if (strcmp(item->defname, "transaction_isolation") == 0)
|
||||
SetPGVariable("transaction_isolation",
|
||||
list_make1(item->arg), n->is_local);
|
||||
list_make1(item->arg), n->is_local);
|
||||
else if (strcmp(item->defname, "transaction_read_only") == 0)
|
||||
SetPGVariable("transaction_read_only",
|
||||
list_make1(item->arg), n->is_local);
|
||||
list_make1(item->arg), n->is_local);
|
||||
}
|
||||
}
|
||||
else if (strcmp(n->name, "SESSION CHARACTERISTICS") == 0)
|
||||
@@ -894,10 +891,10 @@ ProcessUtility(Node *parsetree,
|
||||
|
||||
if (strcmp(item->defname, "transaction_isolation") == 0)
|
||||
SetPGVariable("default_transaction_isolation",
|
||||
list_make1(item->arg), n->is_local);
|
||||
list_make1(item->arg), n->is_local);
|
||||
else if (strcmp(item->defname, "transaction_read_only") == 0)
|
||||
SetPGVariable("default_transaction_read_only",
|
||||
list_make1(item->arg), n->is_local);
|
||||
list_make1(item->arg), n->is_local);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1380,30 +1377,30 @@ CreateCommandTag(Node *parsetree)
|
||||
break;
|
||||
|
||||
case T_AlterObjectSchemaStmt:
|
||||
switch (((AlterObjectSchemaStmt *) parsetree)->objectType)
|
||||
{
|
||||
switch (((AlterObjectSchemaStmt *) parsetree)->objectType)
|
||||
{
|
||||
case OBJECT_AGGREGATE:
|
||||
tag = "ALTER AGGREGATE";
|
||||
break;
|
||||
tag = "ALTER AGGREGATE";
|
||||
break;
|
||||
case OBJECT_DOMAIN:
|
||||
tag = "ALTER DOMAIN";
|
||||
break;
|
||||
tag = "ALTER DOMAIN";
|
||||
break;
|
||||
case OBJECT_FUNCTION:
|
||||
tag = "ALTER FUNCTION";
|
||||
break;
|
||||
tag = "ALTER FUNCTION";
|
||||
break;
|
||||
case OBJECT_SEQUENCE:
|
||||
tag = "ALTER SEQUENCE";
|
||||
break;
|
||||
tag = "ALTER SEQUENCE";
|
||||
break;
|
||||
case OBJECT_TABLE:
|
||||
tag = "ALTER TABLE";
|
||||
break;
|
||||
tag = "ALTER TABLE";
|
||||
break;
|
||||
case OBJECT_TYPE:
|
||||
tag = "ALTER TYPE";
|
||||
break;
|
||||
tag = "ALTER TYPE";
|
||||
break;
|
||||
default:
|
||||
tag = "???";
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case T_AlterOwnerStmt:
|
||||
@@ -1480,7 +1477,7 @@ CreateCommandTag(Node *parsetree)
|
||||
|
||||
case T_GrantRoleStmt:
|
||||
{
|
||||
GrantRoleStmt *stmt = (GrantRoleStmt *) parsetree;
|
||||
GrantRoleStmt *stmt = (GrantRoleStmt *) parsetree;
|
||||
|
||||
tag = (stmt->is_grant) ? "GRANT ROLE" : "REVOKE ROLE";
|
||||
}
|
||||
@@ -1717,9 +1714,10 @@ CreateQueryTag(Query *parsetree)
|
||||
switch (parsetree->commandType)
|
||||
{
|
||||
case CMD_SELECT:
|
||||
|
||||
/*
|
||||
* We take a little extra care here so that the result will
|
||||
* be useful for complaints about read-only statements
|
||||
* We take a little extra care here so that the result will be
|
||||
* useful for complaints about read-only statements
|
||||
*/
|
||||
if (parsetree->into != NULL)
|
||||
tag = "SELECT INTO";
|
||||
|
||||
Reference in New Issue
Block a user