1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-07 19:06:32 +03:00

Remove dashes in comments that don't need them, rewrap with pgindent.

This commit is contained in:
Bruce Momjian
2001-03-22 06:16:21 +00:00
parent 9e1552607a
commit 0686d49da0
100 changed files with 4522 additions and 6023 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/recipe.c,v 1.12 2001/01/24 19:42:53 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/recipe.c,v 1.13 2001/03/22 06:16:12 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -203,10 +203,10 @@ beginRecipe(RecipeStmt *stmt)
* skip the rule rewrite and time qual stuff
*/
/* ----------------------------------------------------------
* 1) plan the main query, everything from an eye node back to
a Tee
* ---------------------------------------------------------- */
/*
* 1) plan the main query, everything from an eye node back to a
* Tee
*/
parsetree = qList->qtrees[0];
/*
@@ -218,11 +218,11 @@ beginRecipe(RecipeStmt *stmt)
plan = planner(parsetree);
/* ----------------------------------------------------------
* 2) plan the tee queries, (subgraphs rooted from a Tee)
by the time the eye is processed, all tees that contribute
to that eye will have been included in the teeInfo list
* ---------------------------------------------------------- */
/*
* 2) plan the tee queries, (subgraphs rooted from a Tee) by the
* time the eye is processed, all tees that contribute to that eye
* will have been included in the teeInfo list
*/
if (teeInfo)
{
int t;
@@ -258,10 +258,10 @@ beginRecipe(RecipeStmt *stmt)
}
}
/* ----------------------------------------------------------
* 3) replace the tee table scans in the main plan with
actual tee plannodes
* ---------------------------------------------------------- */
/*
* 3) replace the tee table scans in the main plan with actual
* tee plannodes
*/
plan = replaceTeeScans(plan, parsetree, teeInfo);
@@ -274,9 +274,9 @@ beginRecipe(RecipeStmt *stmt)
queryDesc = CreateQueryDesc(parsetree,
plan,
whereToSendOutput);
/* ----------------
* call ExecStart to prepare the plan for execution
* ----------------
/*
* call ExecStart to prepare the plan for execution
*/
attinfo = ExecutorStart(queryDesc, NULL);
@@ -323,16 +323,15 @@ tg_rewriteQuery(TgRecipe * r,
orig = q->qtrees[0];
/*-------------------------------------------------------------------
step 1:
form a combined range table from all the range tables in the original
query as well as the input nodes
form a combined qualification from the qual in the original plus
the quals of the input nodes
-------------------------------------------------------------------
*/
/*
* step 1:
*
* form a combined range table from all the range tables in the original
* query as well as the input nodes
*
* form a combined qualification from the qual in the original plus the
* quals of the input nodes
*/
/* start with the original range table */
rtable = orig->rtable;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.15 2001/03/22 03:59:20 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.16 2001/03/22 06:16:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -582,9 +582,8 @@ update_attstats(Oid relid, int natts, VacAttrStats *vacattrstats)
for (i = 0; i < Natts_pg_statistic; ++i)
nulls[i] = ' ';
/* ----------------
* initialize values[]
* ----------------
/*
* initialize values[]
*/
i = 0;
values[i++] = ObjectIdGetDatum(relid); /* starelid */

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.123 2001/03/22 03:59:21 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.124 2001/03/22 06:16:11 momjian Exp $
*
* NOTES
* The PerformAddAttribute() code, like most of the relation
@@ -69,28 +69,24 @@ PortalCleanup(Portal portal)
{
MemoryContext oldcontext;
/* ----------------
* sanity checks
* ----------------
/*
* sanity checks
*/
AssertArg(PortalIsValid(portal));
AssertArg(portal->cleanup == PortalCleanup);
/* ----------------
* set proper portal-executor context before calling ExecMain.
* ----------------
/*
* set proper portal-executor context before calling ExecMain.
*/
oldcontext = MemoryContextSwitchTo(PortalGetHeapMemory(portal));
/* ----------------
* tell the executor to shutdown the query
* ----------------
/*
* tell the executor to shutdown the query
*/
ExecutorEnd(PortalGetQueryDesc(portal), PortalGetState(portal));
/* ----------------
* switch back to previous context
* ----------------
/*
* switch back to previous context
*/
MemoryContextSwitchTo(oldcontext);
}
@@ -111,9 +107,8 @@ PerformPortalFetch(char *name,
EState *estate;
MemoryContext oldcontext;
/* ----------------
* sanity checks
* ----------------
/*
* sanity checks
*/
if (name == NULL)
{
@@ -121,9 +116,8 @@ PerformPortalFetch(char *name,
return;
}
/* ----------------
* get the portal from the portal name
* ----------------
/*
* get the portal from the portal name
*/
portal = GetPortalByName(name);
if (!PortalIsValid(portal))
@@ -133,18 +127,16 @@ PerformPortalFetch(char *name,
return;
}
/* ----------------
* switch into the portal context
* ----------------
/*
* switch into the portal context
*/
oldcontext = MemoryContextSwitchTo(PortalGetHeapMemory(portal));
/* ----------------
* tell the destination to prepare to receive some tuples.
/*
* tell the destination to prepare to receive some tuples.
*
* If we've been asked for a MOVE, make a temporary QueryDesc
* with the appropriate dummy destination.
* ----------------
* If we've been asked for a MOVE, make a temporary QueryDesc with the
* appropriate dummy destination.
*/
queryDesc = PortalGetQueryDesc(portal);
estate = PortalGetState(portal);
@@ -168,15 +160,14 @@ PerformPortalFetch(char *name,
tag,
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, do
* nothing. (This check exists because not all plan node types are
* robust about being called again if they've already returned NULL
* once.) If it's OK to do the fetch, call the executor. Then,
* update the atStart/atEnd 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, do nothing. (This check exists because not all plan node types
* are robust about being called again if they've already returned
* NULL once.) If it's OK to do the fetch, call the executor. Then,
* update the atStart/atEnd state depending on the number of tuples
* that were retrieved.
*/
if (forward)
{
@@ -201,19 +192,17 @@ PerformPortalFetch(char *name,
}
}
/* ----------------
* Clean up and switch back to old context.
* ----------------
/*
* Clean up and switch back to old context.
*/
if (dest == None) /* MOVE */
pfree(queryDesc);
MemoryContextSwitchTo(oldcontext);
/* ----------------
* Note: the "end-of-command" tag is returned by higher-level
* utility code
* ----------------
/*
* Note: the "end-of-command" tag is returned by higher-level utility
* code
*/
}
@@ -226,9 +215,8 @@ PerformPortalClose(char *name, CommandDest dest)
{
Portal portal;
/* ----------------
* sanity checks
* ----------------
/*
* sanity checks
*/
if (name == NULL)
{
@@ -236,9 +224,8 @@ PerformPortalClose(char *name, CommandDest dest)
return;
}
/* ----------------
* get the portal from the portal name
* ----------------
/*
* get the portal from the portal name
*/
portal = GetPortalByName(name);
if (!PortalIsValid(portal))
@@ -248,9 +235,8 @@ PerformPortalClose(char *name, CommandDest dest)
return;
}
/* ----------------
* Note: PortalCleanup is called as a side-effect
* ----------------
/*
* Note: PortalCleanup is called as a side-effect
*/
PortalDrop(&portal);
}

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.135 2001/03/22 03:59:21 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.136 2001/03/22 06:16:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -888,16 +888,14 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp,
{
ExecStoreTuple(tuple, slot, InvalidBuffer, false);
/* ----------------
/*
* Check the constraints of the tuple
* ----------------
*/
if (rel->rd_att->constr)
ExecConstraints("CopyFrom", resultRelInfo, slot, estate);
/* ----------------
/*
* OK, store the tuple and create index entries for it
* ----------------
*/
heap_insert(rel, tuple);

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.73 2001/03/22 03:59:22 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.74 2001/03/22 06:16:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -68,10 +68,9 @@ DefineRelation(CreateStmt *stmt, char relkind)
stmt->relname, NAMEDATALEN);
StrNCpy(relname, stmt->relname, NAMEDATALEN);
/* ----------------
* Look up inheritance ancestors and generate relation schema,
* including inherited attributes.
* ----------------
/*
* Look up inheritance ancestors and generate relation schema,
* including inherited attributes.
*/
schema = MergeAttributes(schema, stmt->inhRelnames, stmt->istemp,
&inheritOids, &old_constraints);
@@ -80,14 +79,12 @@ DefineRelation(CreateStmt *stmt, char relkind)
if (numberOfAttributes <= 0)
elog(ERROR, "DefineRelation: please inherit from a relation or define an attribute");
/* ----------------
* create a relation descriptor from the relation schema
* and create the relation. Note that in this stage only
* inherited (pre-cooked) defaults and constraints will be
* included into the new relation. (BuildDescForRelation
* takes care of the inherited defaults, but we have to copy
* inherited constraints here.)
* ----------------
/*
* create a relation descriptor from the relation schema and create
* the relation. Note that in this stage only inherited (pre-cooked)
* defaults and constraints will be included into the new relation.
* (BuildDescForRelation takes care of the inherited defaults, but we
* have to copy inherited constraints here.)
*/
descriptor = BuildDescForRelation(schema, relname);
@@ -559,18 +556,16 @@ StoreCatalogInheritance(Oid relationId, List *supers)
List *entry;
HeapTuple tuple;
/* ----------------
* sanity checks
* ----------------
/*
* sanity checks
*/
AssertArg(OidIsValid(relationId));
if (supers == NIL)
return;
/* ----------------
/*
* Catalog INHERITS information using direct ancestors only.
* ----------------
*/
relation = heap_openr(InheritsRelationName, RowExclusiveLock);
desc = RelationGetDescr(relation);
@@ -620,9 +615,8 @@ StoreCatalogInheritance(Oid relationId, List *supers)
* ----------------
*/
/* ----------------
* 1. append after each relationId, its superclasses, recursively.
* ----------------
/*
* 1. append after each relationId, its superclasses, recursively.
*/
foreach(entry, supers)
{
@@ -656,9 +650,8 @@ StoreCatalogInheritance(Oid relationId, List *supers)
lnext(current) = next;
}
/* ----------------
* 2. remove all but last of duplicates.
* ----------------
/*
* 2. remove all but last of duplicates.
*/
foreach(entry, supers)
{
@@ -690,9 +683,8 @@ again:
}
}
/* ----------------
/*
* Catalog IPL information using expanded list.
* ----------------
*/
relation = heap_openr(InheritancePrecidenceListRelationName, RowExclusiveLock);
desc = RelationGetDescr(relation);

View File

@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.53 2001/03/22 03:59:22 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.54 2001/03/22 06:16:11 momjian Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
@@ -442,9 +442,8 @@ DefineOperator(char *oprName,
if (functionName == NULL)
elog(ERROR, "Define: \"procedure\" unspecified");
/* ----------------
* now have OperatorCreate do all the work..
* ----------------
/*
* now have OperatorCreate do all the work..
*/
OperatorCreate(oprName, /* operator name */
typeName1, /* first type name */
@@ -640,9 +639,8 @@ DefineType(char *typeName, List *parameters)
if (internalLength != -1 && storage != 'p')
elog(ERROR, "Define: fixed size types must have storage PLAIN");
/* ----------------
* now have TypeCreate do all the real work.
* ----------------
/*
* now have TypeCreate do all the real work.
*/
TypeCreate(typeName, /* type name */
InvalidOid, /* preassigned type oid (not done here) */
@@ -661,10 +659,9 @@ DefineType(char *typeName, List *parameters)
alignment, /* required alignment */
storage); /* TOAST strategy */
/* ----------------
* When we create a base type (as opposed to a complex type)
* we need to have an array entry for it in pg_type as well.
* ----------------
/*
* When we create a base type (as opposed to a complex type) we need
* to have an array entry for it in pg_type as well.
*/
shadow_type = makeArrayTypeName(typeName);

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.46 2001/03/22 03:59:23 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.47 2001/03/22 06:16:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -405,16 +405,15 @@ FuncIndexArgs(IndexInfo *indexInfo,
nargs++;
}
/* ----------------
/*
* Lookup the function procedure to get its OID and result type.
*
* We rely on parse_func.c to find the correct function in the
* possible presence of binary-compatible types. However, parse_func
* may do too much: it will accept a function that requires run-time
* coercion of input types, and the executor is not currently set up
* to support that. So, check to make sure that the selected function
* has exact-match or binary-compatible input types.
* ----------------
* We rely on parse_func.c to find the correct function in the possible
* presence of binary-compatible types. However, parse_func may do
* too much: it will accept a function that requires run-time coercion
* of input types, and the executor is not currently set up to support
* that. So, check to make sure that the selected function has
* exact-match or binary-compatible input types.
*/
if (!func_get_detail(funcIndex->name, nargs, argTypes,
&funcid, &rettype, &retset, &true_typeids))
@@ -637,11 +636,10 @@ ReindexIndex(const char *name, bool force /* currently unused */ )
HeapTuple tuple;
bool overwrite = false;
/* ----------------
* REINDEX within a transaction block is dangerous, because
* if the transaction is later rolled back we have no way to
* undo truncation of the index's physical file. Disallow it.
* ----------------
/*
* REINDEX within a transaction block is dangerous, because if the
* transaction is later rolled back we have no way to undo truncation
* of the index's physical file. Disallow it.
*/
if (IsTransactionBlock())
elog(ERROR, "REINDEX cannot run inside a BEGIN/END block");
@@ -681,11 +679,10 @@ ReindexTable(const char *name, bool force)
{
HeapTuple tuple;
/* ----------------
* REINDEX within a transaction block is dangerous, because
* if the transaction is later rolled back we have no way to
* undo truncation of the index's physical file. Disallow it.
* ----------------
/*
* REINDEX within a transaction block is dangerous, because if the
* transaction is later rolled back we have no way to undo truncation
* of the index's physical file. Disallow it.
*/
if (IsTransactionBlock())
elog(ERROR, "REINDEX cannot run inside a BEGIN/END block");

View File

@@ -59,9 +59,8 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
int i;
/* ----------------
/*
* Check permission
* ----------------
*/
if (!superuser())
{
@@ -69,10 +68,9 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
"permitted to create procedural languages");
}
/* ----------------
* Translate the language name and check that
* this language doesn't already exist
* ----------------
/*
* Translate the language name and check that this language doesn't
* already exist
*/
case_translate_language_name(stmt->plname, languageName);
@@ -81,10 +79,9 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
0, 0, 0))
elog(ERROR, "Language %s already exists", languageName);
/* ----------------
* Lookup the PL handler function and check that it is
* of return type Opaque
* ----------------
/*
* Lookup the PL handler function and check that it is of return type
* Opaque
*/
memset(typev, 0, sizeof(typev));
procTup = SearchSysCache(PROCNAME,
@@ -99,9 +96,8 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
elog(ERROR, "PL handler function %s() isn't of return type Opaque",
stmt->plhandler);
/* ----------------
/*
* Insert the new language into pg_language
* ----------------
*/
for (i = 0; i < Natts_pg_language; i++)
{
@@ -150,9 +146,8 @@ DropProceduralLanguage(DropPLangStmt *stmt)
HeapTuple langTup;
Relation rel;
/* ----------------
/*
* Check permission
* ----------------
*/
if (!superuser())
{
@@ -160,10 +155,9 @@ DropProceduralLanguage(DropPLangStmt *stmt)
"permitted to drop procedural languages");
}
/* ----------------
* Translate the language name, check that
* this language exist and is a PL
* ----------------
/*
* Translate the language name, check that this language exist and is
* a PL
*/
case_translate_language_name(stmt->plname, languageName);

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.89 2001/03/22 03:59:23 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.90 2001/03/22 06:16:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -72,10 +72,9 @@ CreateTrigger(CreateTrigStmt *stmt)
if (!pg_ownercheck(GetUserId(), stmt->relname, RELNAME))
elog(ERROR, "%s: %s", stmt->relname, aclcheck_error_strings[ACLCHECK_NOT_OWNER]);
/* ----------
* If trigger is a constraint, user trigger name as constraint
* name and build a unique trigger name instead.
* ----------
/*
* If trigger is a constraint, user trigger name as constraint name
* and build a unique trigger name instead.
*/
if (stmt->isconstraint)
{
@@ -413,15 +412,14 @@ RelationRemoveTriggers(Relation rel)
heap_endscan(tgscan);
/* ----------
* If we deleted any triggers, must update pg_class entry and
* advance command counter to make the updated entry visible.
* This is fairly annoying, since we'e just going to drop the
* durn thing later, but it's necessary to have a consistent
* state in case we do CommandCounterIncrement() below ---
* if RelationBuildTriggers() runs, it will complain otherwise.
* Perhaps RelationBuildTriggers() shouldn't be so picky...
* ----------
/*
* If we deleted any triggers, must update pg_class entry and advance
* command counter to make the updated entry visible. This is fairly
* annoying, since we'e just going to drop the durn thing later, but
* it's necessary to have a consistent state in case we do
* CommandCounterIncrement() below --- if RelationBuildTriggers()
* runs, it will complain otherwise. Perhaps RelationBuildTriggers()
* shouldn't be so picky...
*/
if (found)
{
@@ -446,9 +444,8 @@ RelationRemoveTriggers(Relation rel)
CommandCounterIncrement();
}
/* ----------
/*
* Also drop all constraint triggers referencing this relation
* ----------
*/
ScanKeyEntryInitialize(&key, 0, Anum_pg_trigger_tgconstrrelid,
F_OIDEQ, RelationGetRelid(rel));
@@ -473,12 +470,11 @@ RelationRemoveTriggers(Relation rel)
DropTrigger(&stmt);
/* ----------
* Need to do a command counter increment here to show up
* new pg_class.reltriggers in the next loop iteration
* (in case there are multiple referential integrity action
* triggers for the same FK table defined on the PK table).
* ----------
/*
* Need to do a command counter increment here to show up new
* pg_class.reltriggers in the next loop iteration (in case there
* are multiple referential integrity action triggers for the same
* FK table defined on the PK table).
*/
CommandCounterIncrement();
@@ -1182,18 +1178,15 @@ deferredTriggerCheckState(Oid tgoid, int32 itemstate)
List *sl;
DeferredTriggerStatus trigstate;
/* ----------
* Not deferrable triggers (i.e. normal AFTER ROW triggers
* and constraints declared NOT DEFERRABLE, the state is
* allways false.
* ----------
/*
* Not deferrable triggers (i.e. normal AFTER ROW triggers and
* constraints declared NOT DEFERRABLE, the state is allways false.
*/
if ((itemstate & TRIGGER_DEFERRED_DEFERRABLE) == 0)
return false;
/* ----------
/*
* Lookup if we know an individual state for this trigger
* ----------
*/
foreach(sl, deftrig_trigstates)
{
@@ -1202,19 +1195,16 @@ deferredTriggerCheckState(Oid tgoid, int32 itemstate)
return trigstate->dts_tgisdeferred;
}
/* ----------
* No individual state known - so if the user issued a
* SET CONSTRAINT ALL ..., we return that instead of the
* triggers default state.
* ----------
/*
* No individual state known - so if the user issued a SET CONSTRAINT
* ALL ..., we return that instead of the triggers default state.
*/
if (deftrig_all_isset)
return deftrig_all_isdeferred;
/* ----------
* No ALL state known either, remember the default state
* as the current and return that.
* ----------
/*
* No ALL state known either, remember the default state as the
* current and return that.
*/
oldcxt = MemoryContextSwitchTo(deftrig_cxt);
@@ -1319,9 +1309,8 @@ deferredTriggerExecute(DeferredTriggerEvent event, int itemno,
Buffer oldbuffer;
Buffer newbuffer;
/* ----------
/*
* Open the heap and fetch the required OLD and NEW tuples.
* ----------
*/
rel = heap_open(event->dte_relid, NoLock);
@@ -1341,9 +1330,8 @@ deferredTriggerExecute(DeferredTriggerEvent event, int itemno,
elog(ERROR, "deferredTriggerExecute: failed to fetch new tuple");
}
/* ----------
/*
* Setup the trigger information
* ----------
*/
LocTriggerData.type = T_TriggerData;
LocTriggerData.tg_event = (event->dte_event & TRIGGER_EVENT_OPMASK) |
@@ -1374,10 +1362,9 @@ deferredTriggerExecute(DeferredTriggerEvent event, int itemno,
break;
}
/* ----------
* Call the trigger and throw away an eventually returned
* updated tuple.
* ----------
/*
* Call the trigger and throw away an eventually returned updated
* tuple.
*/
rettuple = ExecCallTriggerFunc(LocTriggerData.tg_trigger,
&LocTriggerData,
@@ -1385,16 +1372,14 @@ deferredTriggerExecute(DeferredTriggerEvent event, int itemno,
if (rettuple != NULL && rettuple != &oldtuple && rettuple != &newtuple)
heap_freetuple(rettuple);
/* ----------
* Might have been a referential integrity constraint trigger.
* Reset the snapshot overriding flag.
* ----------
/*
* Might have been a referential integrity constraint trigger. Reset
* the snapshot overriding flag.
*/
ReferentialIntegritySnapshotOverride = false;
/* ----------
/*
* Release buffers and close the relation
* ----------
*/
if (ItemPointerIsValid(&(event->dte_oldctid)))
ReleaseBuffer(oldbuffer);
@@ -1420,14 +1405,13 @@ deferredTriggerInvokeEvents(bool immediate_only)
int i;
MemoryContext per_tuple_context;
/* ----------
* For now we process all events - to speedup transaction blocks
* we need to remember the actual end of the queue at EndQuery
* and process only events that are newer. On state changes we
* simply reset the position to the beginning of the queue and
* process all events once with the new states when the
* SET CONSTRAINTS ... command finishes and calls EndQuery.
* ----------
/*
* For now we process all events - to speedup transaction blocks we
* need to remember the actual end of the queue at EndQuery and
* process only events that are newer. On state changes we simply
* reset the position to the beginning of the queue and process all
* events once with the new states when the SET CONSTRAINTS ...
* command finishes and calls EndQuery.
*/
/* Make a per-tuple memory context for trigger function calls */
@@ -1440,9 +1424,9 @@ deferredTriggerInvokeEvents(bool immediate_only)
for (event = deftrig_events; event != NULL; event = event->dte_next)
{
/* ----------
/*
* Check if event is completely done.
* ----------
*/
if (event->dte_event & (TRIGGER_DEFERRED_DONE |
TRIGGER_DEFERRED_CANCELED))
@@ -1450,9 +1434,8 @@ deferredTriggerInvokeEvents(bool immediate_only)
MemoryContextReset(per_tuple_context);
/* ----------
/*
* Check each trigger item in the event.
* ----------
*/
still_deferred_ones = false;
for (i = 0; i < event->dte_n_items; i++)
@@ -1460,10 +1443,9 @@ deferredTriggerInvokeEvents(bool immediate_only)
if (event->dte_item[i].dti_state & TRIGGER_DEFERRED_DONE)
continue;
/* ----------
* This trigger item hasn't been called yet. Check if
* we should call it now.
* ----------
/*
* This trigger item hasn't been called yet. Check if we
* should call it now.
*/
if (immediate_only && deferredTriggerCheckState(
event->dte_item[i].dti_tgoid,
@@ -1473,18 +1455,15 @@ deferredTriggerInvokeEvents(bool immediate_only)
continue;
}
/* ----------
/*
* So let's fire it...
* ----------
*/
deferredTriggerExecute(event, i, per_tuple_context);
event->dte_item[i].dti_state |= TRIGGER_DEFERRED_DONE;
}
/* ----------
* Remember in the event itself if all trigger items are
* done.
* ----------
/*
* Remember in the event itself if all trigger items are done.
*/
if (!still_deferred_ones)
event->dte_event |= TRIGGER_DEFERRED_DONE;
@@ -1532,10 +1511,9 @@ DeferredTriggerBeginXact(void)
elog(ERROR,
"DeferredTriggerBeginXact() called while inside transaction");
/* ----------
* Create the per transaction memory context and copy all states
* from the per session context to here.
* ----------
/*
* Create the per transaction memory context and copy all states from
* the per session context to here.
*/
deftrig_cxt = AllocSetContextCreate(TopTransactionContext,
"DeferredTriggerXact",
@@ -1578,9 +1556,9 @@ DeferredTriggerBeginXact(void)
void
DeferredTriggerEndQuery(void)
{
/* ----------
/*
* Ignore call if we aren't in a transaction.
* ----------
*/
if (deftrig_cxt == NULL)
return;
@@ -1599,9 +1577,9 @@ DeferredTriggerEndQuery(void)
void
DeferredTriggerEndXact(void)
{
/* ----------
/*
* Ignore call if we aren't in a transaction.
* ----------
*/
if (deftrig_cxt == NULL)
return;
@@ -1624,9 +1602,9 @@ DeferredTriggerEndXact(void)
void
DeferredTriggerAbortXact(void)
{
/* ----------
/*
* Ignore call if we aren't in a transaction.
* ----------
*/
if (deftrig_cxt == NULL)
return;
@@ -1655,20 +1633,19 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
DeferredTriggerStatus state;
bool hasindex;
/* ----------
/*
* Handle SET CONSTRAINTS ALL ...
* ----------
*/
if (stmt->constraints == NIL)
{
if (!IsTransactionBlock())
{
/* ----------
/*
* ... outside of a transaction block
*
* Drop all information about individual trigger states per
* session.
* ----------
*/
l = deftrig_dfl_trigstates;
while (l != NIL)
@@ -1681,9 +1658,8 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
}
deftrig_dfl_trigstates = NIL;
/* ----------
/*
* Set the session ALL state to known.
* ----------
*/
deftrig_dfl_all_isset = true;
deftrig_dfl_all_isdeferred = stmt->deferred;
@@ -1692,12 +1668,12 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
}
else
{
/* ----------
/*
* ... inside of a transaction block
*
* Drop all information about individual trigger states per
* transaction.
* ----------
*/
l = deftrig_trigstates;
while (l != NIL)
@@ -1710,9 +1686,8 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
}
deftrig_trigstates = NIL;
/* ----------
/*
* Set the per transaction ALL state to known.
* ----------
*/
deftrig_all_isset = true;
deftrig_all_isdeferred = stmt->deferred;
@@ -1743,16 +1718,14 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
Form_pg_trigger pg_trigger;
Oid constr_oid;
/* ----------
/*
* Check that only named constraints are set explicitly
* ----------
*/
if (strcmp((char *) lfirst(l), "") == 0)
elog(ERROR, "unnamed constraints cannot be set explicitly");
/* ----------
/*
* Setup to scan pg_trigger by tgconstrname ...
* ----------
*/
ScanKeyEntryInitialize(&skey,
(bits16) 0x0,
@@ -1765,9 +1738,8 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
else
tgscan = heap_beginscan(tgrel, 0, SnapshotNow, 1, &skey);
/* ----------
/*
* ... and search for the constraint trigger row
* ----------
*/
found = false;
for (;;)
@@ -1792,11 +1764,10 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
break;
}
/* ----------
* If we found some, check that they fit the deferrability
* but skip ON <event> RESTRICT ones, since they are silently
/*
* If we found some, check that they fit the deferrability but
* skip ON <event> RESTRICT ones, since they are silently
* never deferrable.
* ----------
*/
pg_trigger = (Form_pg_trigger) GETSTRUCT(htup);
if (stmt->deferred && !pg_trigger->tgdeferrable &&
@@ -1813,9 +1784,8 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
ReleaseBuffer(buffer);
}
/* ----------
/*
* Not found ?
* ----------
*/
if (!found)
elog(ERROR, "Constraint '%s' does not exist", (char *) lfirst(l));
@@ -1831,10 +1801,10 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
if (!IsTransactionBlock())
{
/* ----------
* Outside of a transaction block set the trigger
* states of individual triggers on session level.
* ----------
/*
* Outside of a transaction block set the trigger states of
* individual triggers on session level.
*/
oldcxt = MemoryContextSwitchTo(deftrig_gcxt);
@@ -1869,10 +1839,10 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
}
else
{
/* ----------
* Inside of a transaction block set the trigger
* states of individual triggers on transaction level.
* ----------
/*
* Inside of a transaction block set the trigger states of
* individual triggers on transaction level.
*/
oldcxt = MemoryContextSwitchTo(deftrig_cxt);
@@ -1938,9 +1908,8 @@ DeferredTriggerSaveEvent(Relation rel, int event,
elog(ERROR,
"DeferredTriggerSaveEvent() called outside of transaction");
/* ----------
/*
* Get the CTID's of OLD and NEW
* ----------
*/
if (oldtup != NULL)
ItemPointerCopy(&(oldtup->t_self), &(oldctid));
@@ -1951,9 +1920,8 @@ DeferredTriggerSaveEvent(Relation rel, int event,
else
ItemPointerSetInvalid(&(newctid));
/* ----------
/*
* Create a new event
* ----------
*/
oldcxt = MemoryContextSwitchTo(deftrig_cxt);
@@ -1991,11 +1959,11 @@ DeferredTriggerSaveEvent(Relation rel, int event,
break;
case TRIGGER_EVENT_UPDATE:
/* ----------
* On UPDATE check if the tuple updated has been inserted
* or a foreign referenced key value that's changing now
* has been updated once before in this transaction.
* ----------
/*
* On UPDATE check if the tuple updated has been inserted or a
* foreign referenced key value that's changing now has been
* updated once before in this transaction.
*/
if (oldtup->t_data->t_xmin != GetCurrentTransactionId())
prev_event = NULL;
@@ -2003,18 +1971,16 @@ DeferredTriggerSaveEvent(Relation rel, int event,
prev_event =
deferredTriggerGetPreviousEvent(rel->rd_id, &oldctid);
/* ----------
/*
* Now check if one of the referenced keys is changed.
* ----------
*/
for (i = 0; i < ntriggers; i++)
{
bool is_ri_trigger;
bool key_unchanged;
/* ----------
/*
* We are interested in RI_FKEY triggers only.
* ----------
*/
switch (triggers[i]->tgfoid)
{
@@ -2044,11 +2010,11 @@ DeferredTriggerSaveEvent(Relation rel, int event,
if (key_unchanged)
{
/* ----------
/*
* The key hasn't changed, so no need later to invoke
* the trigger at all. But remember other states from
* the possible earlier event.
* ----------
*/
new_event->dte_item[i].dti_state |= TRIGGER_DEFERRED_DONE;
@@ -2057,10 +2023,11 @@ DeferredTriggerSaveEvent(Relation rel, int event,
if (prev_event->dte_event &
TRIGGER_DEFERRED_ROW_INSERTED)
{
/* ----------
* This is a row inserted during our transaction.
* So any key value is considered changed.
* ----------
/*
* This is a row inserted during our
* transaction. So any key value is considered
* changed.
*/
new_event->dte_event |=
TRIGGER_DEFERRED_ROW_INSERTED;
@@ -2071,11 +2038,11 @@ DeferredTriggerSaveEvent(Relation rel, int event,
}
else
{
/* ----------
* This is a row, previously updated. So
* if this key has been changed before, we
* still remember that it happened.
* ----------
/*
* This is a row, previously updated. So if
* this key has been changed before, we still
* remember that it happened.
*/
if (prev_event->dte_item[i].dti_state &
TRIGGER_DEFERRED_KEY_CHANGED)
@@ -2090,10 +2057,10 @@ DeferredTriggerSaveEvent(Relation rel, int event,
}
else
{
/* ----------
/*
* Bomb out if this key has been changed before.
* Otherwise remember that we do so.
* ----------
*/
if (prev_event)
{
@@ -2112,10 +2079,9 @@ DeferredTriggerSaveEvent(Relation rel, int event,
NameGetDatum(&(rel->rd_rel->relname)))));
}
/* ----------
* This is the first change to this key, so let
* it happen.
* ----------
/*
* This is the first change to this key, so let it
* happen.
*/
new_event->dte_item[i].dti_state |=
TRIGGER_DEFERRED_KEY_CHANGED;
@@ -2126,18 +2092,17 @@ DeferredTriggerSaveEvent(Relation rel, int event,
break;
case TRIGGER_EVENT_DELETE:
/* ----------
* On DELETE check if the tuple deleted has been inserted
* or a possibly referenced key value has changed in this
/*
* On DELETE check if the tuple deleted has been inserted or a
* possibly referenced key value has changed in this
* transaction.
* ----------
*/
if (oldtup->t_data->t_xmin != GetCurrentTransactionId())
break;
/* ----------
/*
* Look at the previous event to the same tuple.
* ----------
*/
prev_event = deferredTriggerGetPreviousEvent(rel->rd_id, &oldctid);
if (prev_event->dte_event & TRIGGER_DEFERRED_KEY_CHANGED)
@@ -2149,9 +2114,8 @@ DeferredTriggerSaveEvent(Relation rel, int event,
break;
}
/* ----------
/*
* Anything's fine up to here. Add the new event to the queue.
* ----------
*/
oldcxt = MemoryContextSwitchTo(deftrig_cxt);
deferredTriggerAddEvent(new_event);

View File

@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.74 2001/03/22 03:59:24 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.75 2001/03/22 06:16:12 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -538,14 +538,14 @@ DropUser(DropUserStmt *stmt)
usesysid = DatumGetInt32(heap_getattr(tuple, Anum_pg_shadow_usesysid, pg_shadow_dsc, &null));
/*-------------------
/*
* Check if user still owns a database. If so, error out.
*
* (It used to be that this function would drop the database automatically.
* This is not only very dangerous for people that don't read the manual,
* it doesn't seem to be the behaviour one would expect either.)
* -- petere 2000/01/14)
*-------------------*/
* (It used to be that this function would drop the database
* automatically. This is not only very dangerous for people that
* don't read the manual, it doesn't seem to be the behaviour one
* would expect either.) -- petere 2000/01/14)
*/
pg_rel = heap_openr(DatabaseRelationName, AccessExclusiveLock);
pg_dsc = RelationGetDescr(pg_rel);