mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 13:52:28 +00:00
Revert whitespace fixes to third_party (#501)
This commit is contained in:
parent
d4000bb8f7
commit
9de3d8f1e6
365 changed files with 39190 additions and 39211 deletions
96
third_party/sqlite3/trigger.c
vendored
96
third_party/sqlite3/trigger.c
vendored
|
@ -35,7 +35,7 @@ void sqlite3DeleteTriggerStep(sqlite3 *db, TriggerStep *pTriggerStep){
|
|||
}
|
||||
|
||||
/*
|
||||
** Given table pTab, return a list of all the triggers attached to
|
||||
** Given table pTab, return a list of all the triggers attached to
|
||||
** the table. The list is connected by Trigger.pNext pointers.
|
||||
**
|
||||
** All of the triggers on pTab that are in the same database as pTab
|
||||
|
@ -77,11 +77,11 @@ Trigger *sqlite3TriggerList(Parse *pParse, Table *pTab){
|
|||
pTrig->pTabSchema = pTab->pSchema;
|
||||
pTrig->pNext = pList;
|
||||
pList = pTrig;
|
||||
}
|
||||
p = sqliteHashNext(p);
|
||||
}
|
||||
p = sqliteHashNext(p);
|
||||
}
|
||||
}
|
||||
return pList;
|
||||
return pList;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -209,7 +209,7 @@ void sqlite3BeginTrigger(
|
|||
** of triggers.
|
||||
*/
|
||||
if( pTab->pSelect && tr_tm!=TK_INSTEAD ){
|
||||
sqlite3ErrorMsg(pParse, "cannot create %s trigger on view: %S",
|
||||
sqlite3ErrorMsg(pParse, "cannot create %s trigger on view: %S",
|
||||
(tr_tm == TK_BEFORE)?"BEFORE":"AFTER", pTableName, 0);
|
||||
goto trigger_orphan_error;
|
||||
}
|
||||
|
@ -322,8 +322,8 @@ void sqlite3FinishTrigger(
|
|||
}
|
||||
sqlite3TokenInit(&nameToken, pTrig->zName);
|
||||
sqlite3FixInit(&sFix, pParse, iDb, "trigger", &nameToken);
|
||||
if( sqlite3FixTriggerStep(&sFix, pTrig->step_list)
|
||||
|| sqlite3FixExpr(&sFix, pTrig->pWhen)
|
||||
if( sqlite3FixTriggerStep(&sFix, pTrig->step_list)
|
||||
|| sqlite3FixExpr(&sFix, pTrig->pWhen)
|
||||
){
|
||||
goto triggerfinish_cleanup;
|
||||
}
|
||||
|
@ -392,14 +392,14 @@ static char *triggerSpanDup(sqlite3 *db, const char *zStart, const char *zEnd){
|
|||
int i;
|
||||
if( z ) for(i=0; z[i]; i++) if( sqlite3Isspace(z[i]) ) z[i] = ' ';
|
||||
return z;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Turn a SELECT statement (that the pSelect parameter points to) into
|
||||
** a trigger step. Return a pointer to a TriggerStep structure.
|
||||
**
|
||||
** The parser calls this routine when it finds a SELECT statement in
|
||||
** body of a TRIGGER.
|
||||
** body of a TRIGGER.
|
||||
*/
|
||||
TriggerStep *sqlite3TriggerSelectStep(
|
||||
sqlite3 *db, /* Database connection */
|
||||
|
@ -566,7 +566,7 @@ TriggerStep *sqlite3TriggerDeleteStep(
|
|||
return pTriggerStep;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** Recursively delete a Trigger structure
|
||||
*/
|
||||
void sqlite3DeleteTrigger(sqlite3 *db, Trigger *pTrigger){
|
||||
|
@ -580,7 +580,7 @@ void sqlite3DeleteTrigger(sqlite3 *db, Trigger *pTrigger){
|
|||
}
|
||||
|
||||
/*
|
||||
** This function is called to drop a trigger from the database schema.
|
||||
** This function is called to drop a trigger from the database schema.
|
||||
**
|
||||
** This may be called directly from the parser and therefore identifies
|
||||
** the trigger by name. The sqlite3DropTriggerPtr() routine does the
|
||||
|
@ -635,7 +635,7 @@ static Table *tableOfTrigger(Trigger *pTrigger){
|
|||
|
||||
|
||||
/*
|
||||
** Drop a trigger given a pointer to that trigger.
|
||||
** Drop a trigger given a pointer to that trigger.
|
||||
*/
|
||||
void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger){
|
||||
Table *pTable;
|
||||
|
@ -715,12 +715,12 @@ static int checkColumnOverlap(IdList *pIdList, ExprList *pEList){
|
|||
for(e=0; e<pEList->nExpr; e++){
|
||||
if( sqlite3IdListIndex(pIdList, pEList->a[e].zEName)>=0 ) return 1;
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return a list of all triggers on table pTab if there exists at least
|
||||
** one trigger that must be fired when an operation of type 'op' is
|
||||
** one trigger that must be fired when an operation of type 'op' is
|
||||
** performed on the table, and, if that operation is an UPDATE, if at
|
||||
** least one of the columns in pChanges is being modified.
|
||||
*/
|
||||
|
@ -736,7 +736,7 @@ Trigger *sqlite3TriggersExist(
|
|||
Trigger *p;
|
||||
|
||||
pList = sqlite3TriggerList(pParse, pTab);
|
||||
assert( pList==0 || IsVirtual(pTab)==0
|
||||
assert( pList==0 || IsVirtual(pTab)==0
|
||||
|| (pList->bReturning && pList->pNext==0) );
|
||||
if( pList!=0 ){
|
||||
p = pList;
|
||||
|
@ -950,13 +950,13 @@ static void codeReturningTrigger(
|
|||
|
||||
|
||||
/*
|
||||
** Generate VDBE code for the statements inside the body of a single
|
||||
** Generate VDBE code for the statements inside the body of a single
|
||||
** trigger.
|
||||
*/
|
||||
static int codeTriggerProgram(
|
||||
Parse *pParse, /* The parser context */
|
||||
TriggerStep *pStepList, /* List of statements inside the trigger body */
|
||||
int orconf /* Conflict algorithm. (OE_Abort, etc) */
|
||||
int orconf /* Conflict algorithm. (OE_Abort, etc) */
|
||||
){
|
||||
TriggerStep *pStep;
|
||||
Vdbe *v = pParse->pVdbe;
|
||||
|
@ -992,20 +992,20 @@ static int codeTriggerProgram(
|
|||
|
||||
switch( pStep->op ){
|
||||
case TK_UPDATE: {
|
||||
sqlite3Update(pParse,
|
||||
sqlite3Update(pParse,
|
||||
sqlite3TriggerStepSrc(pParse, pStep),
|
||||
sqlite3ExprListDup(db, pStep->pExprList, 0),
|
||||
sqlite3ExprDup(db, pStep->pWhere, 0),
|
||||
sqlite3ExprListDup(db, pStep->pExprList, 0),
|
||||
sqlite3ExprDup(db, pStep->pWhere, 0),
|
||||
pParse->eOrconf, 0, 0, 0
|
||||
);
|
||||
sqlite3VdbeAddOp0(v, OP_ResetCount);
|
||||
break;
|
||||
}
|
||||
case TK_INSERT: {
|
||||
sqlite3Insert(pParse,
|
||||
sqlite3Insert(pParse,
|
||||
sqlite3TriggerStepSrc(pParse, pStep),
|
||||
sqlite3SelectDup(db, pStep->pSelect, 0),
|
||||
sqlite3IdListDup(db, pStep->pIdList),
|
||||
sqlite3SelectDup(db, pStep->pSelect, 0),
|
||||
sqlite3IdListDup(db, pStep->pIdList),
|
||||
pParse->eOrconf,
|
||||
sqlite3UpsertDup(db, pStep->pUpsert)
|
||||
);
|
||||
|
@ -1013,7 +1013,7 @@ static int codeTriggerProgram(
|
|||
break;
|
||||
}
|
||||
case TK_DELETE: {
|
||||
sqlite3DeleteFrom(pParse,
|
||||
sqlite3DeleteFrom(pParse,
|
||||
sqlite3TriggerStepSrc(pParse, pStep),
|
||||
sqlite3ExprDup(db, pStep->pWhere, 0), 0, 0
|
||||
);
|
||||
|
@ -1028,7 +1028,7 @@ static int codeTriggerProgram(
|
|||
sqlite3SelectDelete(db, pSelect);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1070,7 +1070,7 @@ static void transferParseError(Parse *pTo, Parse *pFrom){
|
|||
}
|
||||
|
||||
/*
|
||||
** Create and populate a new TriggerPrg object with a sub-program
|
||||
** Create and populate a new TriggerPrg object with a sub-program
|
||||
** implementing trigger pTrigger with ON CONFLICT policy orconf.
|
||||
*/
|
||||
static TriggerPrg *codeRowTrigger(
|
||||
|
@ -1093,7 +1093,7 @@ static TriggerPrg *codeRowTrigger(
|
|||
assert( pTop->pVdbe );
|
||||
|
||||
/* Allocate the TriggerPrg and SubProgram objects. To ensure that they
|
||||
** are freed if an error occurs, link them into the Parse.pTriggerPrg
|
||||
** are freed if an error occurs, link them into the Parse.pTriggerPrg
|
||||
** list of the top-level Parse object sooner rather than later. */
|
||||
pPrg = sqlite3DbMallocZero(db, sizeof(TriggerPrg));
|
||||
if( !pPrg ) return 0;
|
||||
|
@ -1107,7 +1107,7 @@ static TriggerPrg *codeRowTrigger(
|
|||
pPrg->aColmask[0] = 0xffffffff;
|
||||
pPrg->aColmask[1] = 0xffffffff;
|
||||
|
||||
/* Allocate and populate a new Parse context to use for coding the
|
||||
/* Allocate and populate a new Parse context to use for coding the
|
||||
** trigger sub-program. */
|
||||
pSubParse = sqlite3StackAllocZero(db, sizeof(Parse));
|
||||
if( !pSubParse ) return 0;
|
||||
|
@ -1123,7 +1123,7 @@ static TriggerPrg *codeRowTrigger(
|
|||
|
||||
v = sqlite3GetVdbe(pSubParse);
|
||||
if( v ){
|
||||
VdbeComment((v, "Start: %s.%s (%s %s%s%s ON %s)",
|
||||
VdbeComment((v, "Start: %s.%s (%s %s%s%s ON %s)",
|
||||
pTrigger->zName, onErrorText(orconf),
|
||||
(pTrigger->tr_tm==TRIGGER_BEFORE ? "BEFORE" : "AFTER"),
|
||||
(pTrigger->op==TK_UPDATE ? "UPDATE" : ""),
|
||||
|
@ -1133,19 +1133,19 @@ static TriggerPrg *codeRowTrigger(
|
|||
));
|
||||
#ifndef SQLITE_OMIT_TRACE
|
||||
if( pTrigger->zName ){
|
||||
sqlite3VdbeChangeP4(v, -1,
|
||||
sqlite3VdbeChangeP4(v, -1,
|
||||
sqlite3MPrintf(db, "-- TRIGGER %s", pTrigger->zName), P4_DYNAMIC
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If one was specified, code the WHEN clause. If it evaluates to false
|
||||
** (or NULL) the sub-vdbe is immediately halted by jumping to the
|
||||
** (or NULL) the sub-vdbe is immediately halted by jumping to the
|
||||
** OP_Halt inserted at the end of the program. */
|
||||
if( pTrigger->pWhen ){
|
||||
pWhen = sqlite3ExprDup(db, pTrigger->pWhen, 0);
|
||||
if( SQLITE_OK==sqlite3ResolveExprNames(&sNC, pWhen)
|
||||
&& db->mallocFailed==0
|
||||
if( SQLITE_OK==sqlite3ResolveExprNames(&sNC, pWhen)
|
||||
&& db->mallocFailed==0
|
||||
){
|
||||
iEndTrigger = sqlite3VdbeMakeLabel(pSubParse);
|
||||
sqlite3ExprIfFalse(pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL);
|
||||
|
@ -1181,7 +1181,7 @@ static TriggerPrg *codeRowTrigger(
|
|||
|
||||
return pPrg;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Return a pointer to a TriggerPrg object containing the sub-program for
|
||||
** trigger pTrigger with default ON CONFLICT algorithm orconf. If no such
|
||||
|
@ -1203,8 +1203,8 @@ static TriggerPrg *getRowTrigger(
|
|||
** process of being coded). If this is the case, then an entry with
|
||||
** a matching TriggerPrg.pTrigger field will be present somewhere
|
||||
** in the Parse.pTriggerPrg list. Search for such an entry. */
|
||||
for(pPrg=pRoot->pTriggerPrg;
|
||||
pPrg && (pPrg->pTrigger!=pTrigger || pPrg->orconf!=orconf);
|
||||
for(pPrg=pRoot->pTriggerPrg;
|
||||
pPrg && (pPrg->pTrigger!=pTrigger || pPrg->orconf!=orconf);
|
||||
pPrg=pPrg->pNext
|
||||
);
|
||||
|
||||
|
@ -1217,7 +1217,7 @@ static TriggerPrg *getRowTrigger(
|
|||
}
|
||||
|
||||
/*
|
||||
** Generate code for the trigger program associated with trigger p on
|
||||
** Generate code for the trigger program associated with trigger p on
|
||||
** table pTab. The reg, orconf and ignoreJump parameters passed to this
|
||||
** function are the same as those described in the header function for
|
||||
** sqlite3CodeRowTrigger()
|
||||
|
@ -1235,7 +1235,7 @@ void sqlite3CodeRowTriggerDirect(
|
|||
pPrg = getRowTrigger(pParse, p, pTab, orconf);
|
||||
assert( pPrg || pParse->nErr || pParse->db->mallocFailed );
|
||||
|
||||
/* Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program
|
||||
/* Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program
|
||||
** is a pointer to the sub-vdbe containing the trigger program. */
|
||||
if( pPrg ){
|
||||
int bRecursive = (p->zName && 0==(pParse->db->flags&SQLITE_RecTriggers));
|
||||
|
@ -1264,7 +1264,7 @@ void sqlite3CodeRowTriggerDirect(
|
|||
** If there are no triggers that fire at the specified time for the specified
|
||||
** operation on pTab, this function is a no-op.
|
||||
**
|
||||
** The reg argument is the address of the first in an array of registers
|
||||
** The reg argument is the address of the first in an array of registers
|
||||
** that contain the values substituted for the new.* and old.* references
|
||||
** in the trigger program. If N is the number of columns in table pTab
|
||||
** (a copy of pTab->nCol), then registers are populated as follows:
|
||||
|
@ -1281,12 +1281,12 @@ void sqlite3CodeRowTriggerDirect(
|
|||
** reg+N+N+1 NEW.* value of right-most column of pTab
|
||||
**
|
||||
** For ON DELETE triggers, the registers containing the NEW.* values will
|
||||
** never be accessed by the trigger program, so they are not allocated or
|
||||
** populated by the caller (there is no data to populate them with anyway).
|
||||
** never be accessed by the trigger program, so they are not allocated or
|
||||
** populated by the caller (there is no data to populate them with anyway).
|
||||
** Similarly, for ON INSERT triggers the values stored in the OLD.* registers
|
||||
** are never accessed, and so are not allocated by the caller. So, for an
|
||||
** ON INSERT trigger, the value passed to this function as parameter reg
|
||||
** is not a readable register, although registers (reg+N) through
|
||||
** is not a readable register, although registers (reg+N) through
|
||||
** (reg+N+N+1) are.
|
||||
**
|
||||
** Parameter orconf is the default conflict resolution algorithm for the
|
||||
|
@ -1318,7 +1318,7 @@ void sqlite3CodeRowTrigger(
|
|||
** or else it must be a TEMP trigger. */
|
||||
assert( p->pSchema!=0 );
|
||||
assert( p->pTabSchema!=0 );
|
||||
assert( p->pSchema==p->pTabSchema
|
||||
assert( p->pSchema==p->pTabSchema
|
||||
|| p->pSchema==pParse->db->aDb[1].pSchema );
|
||||
|
||||
/* Determine whether we should code this trigger. One of two choices:
|
||||
|
@ -1327,7 +1327,7 @@ void sqlite3CodeRowTrigger(
|
|||
** doing the UPDATE part of an UPSERT.
|
||||
*/
|
||||
if( (p->op==op || (p->bReturning && p->op==TK_INSERT && op==TK_UPDATE))
|
||||
&& p->tr_tm==tr_tm
|
||||
&& p->tr_tm==tr_tm
|
||||
&& checkColumnOverlap(p->pColumns, pChanges)
|
||||
){
|
||||
if( !p->bReturning ){
|
||||
|
@ -1340,9 +1340,9 @@ void sqlite3CodeRowTrigger(
|
|||
}
|
||||
|
||||
/*
|
||||
** Triggers may access values stored in the old.* or new.* pseudo-table.
|
||||
** This function returns a 32-bit bitmask indicating which columns of the
|
||||
** old.* or new.* tables actually are used by triggers. This information
|
||||
** Triggers may access values stored in the old.* or new.* pseudo-table.
|
||||
** This function returns a 32-bit bitmask indicating which columns of the
|
||||
** old.* or new.* tables actually are used by triggers. This information
|
||||
** may be used by the caller, for example, to avoid having to load the entire
|
||||
** old.* record into memory when executing an UPDATE or DELETE command.
|
||||
**
|
||||
|
@ -1352,7 +1352,7 @@ void sqlite3CodeRowTrigger(
|
|||
** are more than 32 columns in the table, and at least one of the columns
|
||||
** with an index greater than 32 may be accessed, 0xffffffff is returned.
|
||||
**
|
||||
** It is not possible to determine if the old.rowid or new.rowid column is
|
||||
** It is not possible to determine if the old.rowid or new.rowid column is
|
||||
** accessed by triggers. The caller must always assume that it is.
|
||||
**
|
||||
** Parameter isNew must be either 1 or 0. If it is 0, then the mask returned
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue