hi attached is patch which will make temporary disable of triggers possible. i tried it in my application with current data (many inserts in to various table with many triggers on them, which are not meant to be run while importing data). it works and it changed running time from 62 seconds to 4, so i guess its worth it
i added new pragma DISABLE_TRIGGERS which can be set to 0 (default, everything works) or 1 (function which returns triggers always returns empty list so none will be called) honestly, i didn't spent too much time with learning sqlite sources, i just made quick hack which works for me, i hope i diidn't break anything. so i decided to share it. maybe one day this feature can get to official version too
diff -r -u sqlite-3.6.16.orig/src/pragma.c sqlite-3.6.16/src/pragma.c --- sqlite-3.6.16.orig/src/pragma.c 2009-06-25 13:45:58.000000000 +0200 +++ sqlite-3.6.16/src/pragma.c 2009-07-09 12:16:06.312500000 +0200 @@ -1388,6 +1388,10 @@ }else #endif + if( sqlite3StrICmp(zLeft, "DISABLE_TRIGGERS")==0 ){ + db->isDisabledTriggers=(u8)atoi(zRight); + } + else {/* Empty ELSE clause */} diff -r -u sqlite-3.6.16.orig/src/sqliteInt.h sqlite-3.6.16/src/sqliteInt.h --- sqlite-3.6.16.orig/src/sqliteInt.h 2009-06-26 17:14:56.000000000 +0200 +++ sqlite-3.6.16/src/sqliteInt.h 2009-07-09 12:16:10.468750000 +0200 @@ -869,6 +869,7 @@ void (*xUnlockNotify)(void **, int); /* Unlock notify callback */ sqlite3 *pNextBlocked; /* Next in list of all blocked connections */ #endif + u8 isDisabledTriggers; /* True if triggers should be disabled */ }; /* diff -r -u sqlite-3.6.16.orig/src/trigger.c sqlite-3.6.16/src/trigger.c --- sqlite-3.6.16.orig/src/trigger.c 2009-06-25 13:35:52.000000000 +0200 +++ sqlite-3.6.16/src/trigger.c 2009-07-09 12:17:11.156250000 +0200 @@ -50,6 +50,9 @@ Schema * const pTmpSchema = pParse->db->aDb[1].pSchema; Trigger *pList = 0; /* List of triggers to return */ + if(pParse->db->isDisabledTriggers) + return (Trigger *)0; + if( pTmpSchema!=pTab->pSchema ){ HashElem *p; for(p=sqliteHashFirst(&pTmpSchema->trigHash); p; p=sqliteHashNext(p)){
_______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users