mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Optimization to sqlite3TriggersExist() saves over 700K CPU cycles.
FossilOrigin-Name: 5043a3507e0781878e0e1bea5095a33273958820baead4af8fc2929e9d7c07ee
This commit is contained in:
@@ -729,13 +729,22 @@ static int checkColumnOverlap(IdList *pIdList, ExprList *pEList){
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return true if any TEMP triggers exist
|
||||
*/
|
||||
static int tempTriggersExist(sqlite3 *db){
|
||||
if( db->aDb[1].pSchema==0 ) return 0;
|
||||
if( sqliteHashFirst(&db->aDb[1].pSchema->trigHash)==0 ) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
** 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
|
||||
** performed on the table, and, if that operation is an UPDATE, if at
|
||||
** least one of the columns in pChanges is being modified.
|
||||
*/
|
||||
Trigger *sqlite3TriggersExist(
|
||||
static SQLITE_NOINLINE Trigger *triggersReallyExist(
|
||||
Parse *pParse, /* Parse context */
|
||||
Table *pTab, /* The table the contains the triggers */
|
||||
int op, /* one of TK_DELETE, TK_INSERT, TK_UPDATE */
|
||||
@@ -798,6 +807,22 @@ exit_triggers_exist:
|
||||
}
|
||||
return (mask ? pList : 0);
|
||||
}
|
||||
Trigger *sqlite3TriggersExist(
|
||||
Parse *pParse, /* Parse context */
|
||||
Table *pTab, /* The table the contains the triggers */
|
||||
int op, /* one of TK_DELETE, TK_INSERT, TK_UPDATE */
|
||||
ExprList *pChanges, /* Columns that change in an UPDATE statement */
|
||||
int *pMask /* OUT: Mask of TRIGGER_BEFORE|TRIGGER_AFTER */
|
||||
){
|
||||
assert( pTab!=0 );
|
||||
if( (pTab->pTrigger==0 && !tempTriggersExist(pParse->db))
|
||||
|| pParse->disableTriggers
|
||||
){
|
||||
if( pMask ) *pMask = 0;
|
||||
return 0;
|
||||
}
|
||||
return triggersReallyExist(pParse,pTab,op,pChanges,pMask);
|
||||
}
|
||||
|
||||
/*
|
||||
** Convert the pStep->zTarget string into a SrcList and return a pointer
|
||||
|
Reference in New Issue
Block a user