summaryrefslogtreecommitdiff
path: root/src/backend/commands/trigger.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands/trigger.c')
-rw-r--r--src/backend/commands/trigger.c58
1 files changed, 30 insertions, 28 deletions
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index ce276e5fe5..08d9593de9 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.246 2009/01/22 20:16:02 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.247 2009/06/11 14:48:56 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -274,8 +274,8 @@ CreateTrigger(CreateTrigStmt *stmt, Oid constraintOid, bool checkPermissions)
}
/*
- * Scan pg_trigger for existing triggers on relation. We do this only
- * to give a nice error message if there's already a trigger of the same
+ * Scan pg_trigger for existing triggers on relation. We do this only to
+ * give a nice error message if there's already a trigger of the same
* name. (The unique index on tgrelid/tgname would complain anyway.)
*
* NOTE that this is cool only because we have AccessExclusiveLock on the
@@ -857,12 +857,12 @@ RemoveTriggerById(Oid trigOid)
/*
* We do not bother to try to determine whether any other triggers remain,
- * which would be needed in order to decide whether it's safe to clear
- * the relation's relhastriggers. (In any case, there might be a
- * concurrent process adding new triggers.) Instead, just force a
- * relcache inval to make other backends (and this one too!) rebuild
- * their relcache entries. There's no great harm in leaving relhastriggers
- * true even if there are no triggers left.
+ * which would be needed in order to decide whether it's safe to clear the
+ * relation's relhastriggers. (In any case, there might be a concurrent
+ * process adding new triggers.) Instead, just force a relcache inval to
+ * make other backends (and this one too!) rebuild their relcache entries.
+ * There's no great harm in leaving relhastriggers true even if there are
+ * no triggers left.
*/
CacheInvalidateRelcache(rel);
@@ -1118,8 +1118,8 @@ RelationBuildTriggers(Relation relation)
int i;
/*
- * Allocate a working array to hold the triggers (the array is extended
- * if necessary)
+ * Allocate a working array to hold the triggers (the array is extended if
+ * necessary)
*/
maxtrigs = 16;
triggers = (Trigger *) palloc(maxtrigs * sizeof(Trigger));
@@ -2095,8 +2095,8 @@ ExecBSTruncateTriggers(EState *estate, ResultRelInfo *relinfo)
if (newtuple)
ereport(ERROR,
- (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
- errmsg("BEFORE STATEMENT trigger cannot return a value")));
+ (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
+ errmsg("BEFORE STATEMENT trigger cannot return a value")));
}
}
@@ -2264,7 +2264,7 @@ typedef SetConstraintStateData *SetConstraintState;
* Per-trigger-event data
*
* The actual per-event data, AfterTriggerEventData, includes DONE/IN_PROGRESS
- * status bits and one or two tuple CTIDs. Each event record also has an
+ * status bits and one or two tuple CTIDs. Each event record also has an
* associated AfterTriggerSharedData that is shared across all instances
* of similar events within a "chunk".
*
@@ -2278,12 +2278,13 @@ typedef SetConstraintStateData *SetConstraintState;
* Although this is mutable state, we can keep it in AfterTriggerSharedData
* because all instances of the same type of event in a given event list will
* be fired at the same time, if they were queued between the same firing
- * cycles. So we need only ensure that ats_firing_id is zero when attaching
+ * cycles. So we need only ensure that ats_firing_id is zero when attaching
* a new event to an existing AfterTriggerSharedData record.
*/
typedef uint32 TriggerFlags;
-#define AFTER_TRIGGER_OFFSET 0x0FFFFFFF /* must be low-order bits */
+#define AFTER_TRIGGER_OFFSET 0x0FFFFFFF /* must be low-order
+ * bits */
#define AFTER_TRIGGER_2CTIDS 0x10000000
#define AFTER_TRIGGER_DONE 0x20000000
#define AFTER_TRIGGER_IN_PROGRESS 0x40000000
@@ -2324,13 +2325,13 @@ typedef struct AfterTriggerEventDataOneCtid
/*
* To avoid palloc overhead, we keep trigger events in arrays in successively-
* larger chunks (a slightly more sophisticated version of an expansible
- * array). The space between CHUNK_DATA_START and freeptr is occupied by
+ * array). The space between CHUNK_DATA_START and freeptr is occupied by
* AfterTriggerEventData records; the space between endfree and endptr is
* occupied by AfterTriggerSharedData records.
*/
typedef struct AfterTriggerEventChunk
{
- struct AfterTriggerEventChunk *next; /* list link */
+ struct AfterTriggerEventChunk *next; /* list link */
char *freeptr; /* start of free space in chunk */
char *endfree; /* end of free space in chunk */
char *endptr; /* end of chunk */
@@ -2555,9 +2556,9 @@ afterTriggerAddEvent(AfterTriggerEventList *events,
/* check number of shared records in preceding chunk */
if ((chunk->endptr - chunk->endfree) <=
(100 * sizeof(AfterTriggerSharedData)))
- chunksize *= 2; /* okay, double it */
+ chunksize *= 2; /* okay, double it */
else
- chunksize /= 2; /* too many shared records */
+ chunksize /= 2; /* too many shared records */
chunksize = Min(chunksize, MAX_CHUNK_SIZE);
}
chunk = MemoryContextAlloc(afterTriggers->event_cxt, chunksize);
@@ -2574,8 +2575,8 @@ afterTriggerAddEvent(AfterTriggerEventList *events,
}
/*
- * Try to locate a matching shared-data record already in the chunk.
- * If none, make a new one.
+ * Try to locate a matching shared-data record already in the chunk. If
+ * none, make a new one.
*/
for (newshared = ((AfterTriggerShared) chunk->endptr) - 1;
(char *) newshared >= chunk->endfree;
@@ -2590,7 +2591,7 @@ afterTriggerAddEvent(AfterTriggerEventList *events,
if ((char *) newshared < chunk->endfree)
{
*newshared = *evtshared;
- newshared->ats_firing_id = 0; /* just to be sure */
+ newshared->ats_firing_id = 0; /* just to be sure */
chunk->endfree = (char *) newshared;
}
@@ -2658,6 +2659,7 @@ afterTriggerRestoreEventList(AfterTriggerEventList *events,
/* and clean up the tail chunk to be the right length */
events->tail->next = NULL;
events->tail->freeptr = events->tailfree;
+
/*
* We don't make any effort to remove now-unused shared data records.
* They might still be useful, anyway.
@@ -2940,7 +2942,7 @@ afterTriggerInvokeEvents(AfterTriggerEventList *events,
trigdesc = rInfo->ri_TrigDesc;
finfo = rInfo->ri_TrigFunctions;
instr = rInfo->ri_TrigInstrument;
- if (trigdesc == NULL) /* should not happen */
+ if (trigdesc == NULL) /* should not happen */
elog(ERROR, "relation %u has no triggers",
evtshared->ats_relid);
}
@@ -3015,7 +3017,7 @@ AfterTriggerBeginXact(void)
MemoryContextAlloc(TopTransactionContext,
sizeof(AfterTriggersData));
- afterTriggers->firing_counter = (CommandId) 1; /* mustn't be 0 */
+ afterTriggers->firing_counter = (CommandId) 1; /* mustn't be 0 */
afterTriggers->state = SetConstraintStateCreate(8);
afterTriggers->events.head = NULL;
afterTriggers->events.tail = NULL;
@@ -3348,8 +3350,8 @@ AfterTriggerEndSubXact(bool isCommit)
else
{
/*
- * Aborting. Release any event lists from queries being aborted,
- * and restore query_depth to its pre-subxact value.
+ * Aborting. Release any event lists from queries being aborted, and
+ * restore query_depth to its pre-subxact value.
*/
while (afterTriggers->query_depth > afterTriggers->depth_stack[my_level])
{
@@ -3721,7 +3723,7 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt)
/*
* Make sure a snapshot has been established in case trigger
- * functions need one. Note that we avoid setting a snapshot if
+ * functions need one. Note that we avoid setting a snapshot if
* we don't find at least one trigger that has to be fired now.
* This is so that BEGIN; SET CONSTRAINTS ...; SET TRANSACTION
* ISOLATION LEVEL SERIALIZABLE; ... works properly. (If we are