mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Fix for ticket #104: Make triggers on views work properly even after closing
and reopening the database. Also fixed an unrelated bug in the version 2.6.0 database format upgrade logic. The upgrade logic bug was found while testing the trigger fixes. (CVS 697) FossilOrigin-Name: 04973fc2a6a0c93877de7e564618e0e9fcffc06c
This commit is contained in:
16
src/main.c
16
src/main.c
@@ -14,7 +14,7 @@
|
||||
** other files are for internal use by SQLite and should not be
|
||||
** accessed by users of the library.
|
||||
**
|
||||
** $Id: main.c,v 1.93 2002/07/30 18:43:41 drh Exp $
|
||||
** $Id: main.c,v 1.94 2002/07/31 00:32:50 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "os.h"
|
||||
@@ -118,6 +118,8 @@ int upgrade_3_callback(void *pInit, int argc, char **argv, char **NotUsed){
|
||||
char *zErr = 0;
|
||||
|
||||
pTab = sqliteFindTable(pData->db, argv[0]);
|
||||
assert( pTab!=0 );
|
||||
assert( sqliteStrICmp(pTab->zName, argv[0])==0 );
|
||||
if( pTab ){
|
||||
pTrig = pTab->pTrigger;
|
||||
pTab->pTrigger = 0; /* Disable all triggers before rebuilding the table */
|
||||
@@ -132,7 +134,17 @@ int upgrade_3_callback(void *pInit, int argc, char **argv, char **NotUsed){
|
||||
sqliteSetString(pData->pzErrMsg, zErr, 0);
|
||||
sqlite_freemem(zErr);
|
||||
}
|
||||
if( pTab ) pTab->pTrigger = pTrig; /* Re-enable triggers */
|
||||
|
||||
/* If an error occurred in the SQL above, then the transaction will
|
||||
** rollback which will delete the internal symbol tables. This will
|
||||
** cause the structure that pTab points to be deleted. In case that
|
||||
** happened, we need to refetch pTab.
|
||||
*/
|
||||
pTab = sqliteFindTable(pData->db, argv[0]);
|
||||
if( pTab ){
|
||||
assert( sqliteStrICmp(pTab->zName, argv[0])==0 );
|
||||
pTab->pTrigger = pTrig; /* Re-enable triggers */
|
||||
}
|
||||
return rc!=SQLITE_OK;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user