Index: src/pragma.c ================================================================== --- src/pragma.c +++ src/pragma.c @@ -292,10 +292,18 @@ lwr = mid + 1; } } return lwr>upr ? 0 : &aPragmaName[mid]; } + +/* +** A progress handler callback that interrupts. +*/ +static int interruptProgressHandler(void *pDb){ + sqlite3_interrupt((sqlite3*)pDb); + return 1; +} /* ** Process a pragma statement. ** ** Pragmas are of this form: @@ -733,10 +741,27 @@ sqlite3VdbeAddOp2(v, OP_IfPos, 1, addr); VdbeCoverage(v); sqlite3VdbeJumpHere(v, addr); break; } #endif + + /* + ** PRAGMA vdbe_cycle_limit=N + ** + ** Arrange to interrupt any SQL statement that runs for more than N + ** virtual machine instructions. If N is zero, allow virtual machines + ** to run indefinitely. + */ + case PragTyp_VDBE_CYCLE_LIMIT: { + assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); + if( zRight ){ + int N = sqlite3Atoi(zRight); + sqlite3_progress_handler(db, N, N>0 ? interruptProgressHandler : 0, db); + } + break; + } + #ifndef SQLITE_OMIT_PAGER_PRAGMAS /* ** PRAGMA [schema.]cache_size ** PRAGMA [schema.]cache_size=N Index: src/pragma.h ================================================================== --- src/pragma.h +++ src/pragma.h @@ -38,18 +38,19 @@ #define PragTyp_SYNCHRONOUS 30 #define PragTyp_TABLE_INFO 31 #define PragTyp_TEMP_STORE 32 #define PragTyp_TEMP_STORE_DIRECTORY 33 #define PragTyp_THREADS 34 -#define PragTyp_WAL_AUTOCHECKPOINT 35 -#define PragTyp_WAL_CHECKPOINT 36 -#define PragTyp_ACTIVATE_EXTENSIONS 37 -#define PragTyp_HEXKEY 38 -#define PragTyp_KEY 39 -#define PragTyp_REKEY 40 -#define PragTyp_LOCK_STATUS 41 -#define PragTyp_PARSER_TRACE 42 +#define PragTyp_VDBE_CYCLE_LIMIT 35 +#define PragTyp_WAL_AUTOCHECKPOINT 36 +#define PragTyp_WAL_CHECKPOINT 37 +#define PragTyp_ACTIVATE_EXTENSIONS 38 +#define PragTyp_HEXKEY 39 +#define PragTyp_KEY 40 +#define PragTyp_REKEY 41 +#define PragTyp_LOCK_STATUS 42 +#define PragTyp_PARSER_TRACE 43 /* Property flags associated with various pragma. */ #define PragFlg_NeedSchema 0x01 /* Force schema load before running */ #define PragFlg_NoColumns 0x02 /* OP_ResultRow called with zero columns */ #define PragFlg_NoColumns1 0x04 /* zero columns if RHS argument is present */ @@ -560,10 +561,19 @@ {/* zName: */ "vdbe_addoptrace", /* ePragTyp: */ PragTyp_FLAG, /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1, /* ColNames: */ 0, 0, /* iArg: */ SQLITE_VdbeAddopTrace }, +#endif +#endif + {/* zName: */ "vdbe_cycle_limit", + /* ePragTyp: */ PragTyp_VDBE_CYCLE_LIMIT, + /* ePragFlg: */ PragFlg_NoColumns, + /* ColNames: */ 0, 0, + /* iArg: */ 0 }, +#if !defined(SQLITE_OMIT_FLAG_PRAGMAS) +#if defined(SQLITE_DEBUG) {/* zName: */ "vdbe_debug", /* ePragTyp: */ PragTyp_FLAG, /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1, /* ColNames: */ 0, 0, /* iArg: */ SQLITE_SqlTrace|SQLITE_VdbeListing|SQLITE_VdbeTrace }, @@ -602,6 +612,6 @@ /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1, /* ColNames: */ 0, 0, /* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode }, #endif }; -/* Number of pragmas: 60 on by default, 73 total. */ +/* Number of pragmas: 61 on by default, 74 total. */ Index: tool/mkpragmatab.tcl ================================================================== --- tool/mkpragmatab.tcl +++ tool/mkpragmatab.tcl @@ -328,10 +328,13 @@ NAME: wal_autocheckpoint IF: !defined(SQLITE_OMIT_WAL) NAME: shrink_memory FLAG: NoColumns + + NAME: vdbe_cycle_limit + FLAG: NoColumns NAME: busy_timeout FLAG: Result0 COLS: timeout