Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: third_party/sqlite/src/src/pragma.c

Issue 6990047: Import SQLite 3.7.6.3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/sqlite/src/src/pcache1.c ('k') | third_party/sqlite/src/src/prepare.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ** 2003 April 6 2 ** 2003 April 6
3 ** 3 **
4 ** The author disclaims copyright to this source code. In place of 4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing: 5 ** a legal notice, here is a blessing:
6 ** 6 **
7 ** May you do good and not evil. 7 ** May you do good and not evil.
8 ** May you find forgiveness for yourself and forgive others. 8 ** May you find forgiveness for yourself and forgive others.
9 ** May you share freely, never taking more than you give. 9 ** May you share freely, never taking more than you give.
10 ** 10 **
11 ************************************************************************* 11 *************************************************************************
12 ** This file contains code used to implement the PRAGMA command. 12 ** This file contains code used to implement the PRAGMA command.
13 **
14 ** $Id: pragma.c,v 1.214 2009/07/02 07:47:33 danielk1977 Exp $
15 */ 13 */
16 #include "sqliteInt.h" 14 #include "sqliteInt.h"
17 15
18 /* Ignore this whole file if pragmas are disabled 16 /* Ignore this whole file if pragmas are disabled
19 */ 17 */
20 #if !defined(SQLITE_OMIT_PRAGMA) 18 #if !defined(SQLITE_OMIT_PRAGMA)
21 19
22 /* 20 /*
23 ** Interpret the given string as a safety level. Return 0 for OFF, 21 ** Interpret the given string as a safety level. Return 0 for OFF,
24 ** 1 for ON or NORMAL and 2 for FULL. Return 1 for an empty or 22 ** 1 for ON or NORMAL and 2 for FULL. Return 1 for an empty or
25 ** unrecognized string argument. 23 ** unrecognized string argument.
26 ** 24 **
27 ** Note that the values returned are one less that the values that 25 ** Note that the values returned are one less that the values that
28 ** should be passed into sqlite3BtreeSetSafetyLevel(). The is done 26 ** should be passed into sqlite3BtreeSetSafetyLevel(). The is done
29 ** to support legacy SQL code. The safety level used to be boolean 27 ** to support legacy SQL code. The safety level used to be boolean
30 ** and older scripts may have used numbers 0 for OFF and 1 for ON. 28 ** and older scripts may have used numbers 0 for OFF and 1 for ON.
31 */ 29 */
32 static u8 getSafetyLevel(const char *z){ 30 static u8 getSafetyLevel(const char *z){
33 /* 123456789 123456789 */ 31 /* 123456789 123456789 */
34 static const char zText[] = "onoffalseyestruefull"; 32 static const char zText[] = "onoffalseyestruefull";
35 static const u8 iOffset[] = {0, 1, 2, 4, 9, 12, 16}; 33 static const u8 iOffset[] = {0, 1, 2, 4, 9, 12, 16};
36 static const u8 iLength[] = {2, 2, 3, 5, 3, 4, 4}; 34 static const u8 iLength[] = {2, 2, 3, 5, 3, 4, 4};
37 static const u8 iValue[] = {1, 0, 0, 0, 1, 1, 2}; 35 static const u8 iValue[] = {1, 0, 0, 0, 1, 1, 2};
38 int i, n; 36 int i, n;
39 if( sqlite3Isdigit(*z) ){ 37 if( sqlite3Isdigit(*z) ){
40 return (u8)atoi(z); 38 return (u8)sqlite3Atoi(z);
41 } 39 }
42 n = sqlite3Strlen30(z); 40 n = sqlite3Strlen30(z);
43 for(i=0; i<ArraySize(iLength); i++){ 41 for(i=0; i<ArraySize(iLength); i++){
44 if( iLength[i]==n && sqlite3StrNICmp(&zText[iOffset[i]],z,n)==0 ){ 42 if( iLength[i]==n && sqlite3StrNICmp(&zText[iOffset[i]],z,n)==0 ){
45 return iValue[i]; 43 return iValue[i];
46 } 44 }
47 } 45 }
48 return 1; 46 return 1;
49 } 47 }
50 48
(...skipping 20 matching lines...) Expand all
71 ** Interpret the given string as an auto-vacuum mode value. 69 ** Interpret the given string as an auto-vacuum mode value.
72 ** 70 **
73 ** The following strings, "none", "full" and "incremental" are 71 ** The following strings, "none", "full" and "incremental" are
74 ** acceptable, as are their numeric equivalents: 0, 1 and 2 respectively. 72 ** acceptable, as are their numeric equivalents: 0, 1 and 2 respectively.
75 */ 73 */
76 static int getAutoVacuum(const char *z){ 74 static int getAutoVacuum(const char *z){
77 int i; 75 int i;
78 if( 0==sqlite3StrICmp(z, "none") ) return BTREE_AUTOVACUUM_NONE; 76 if( 0==sqlite3StrICmp(z, "none") ) return BTREE_AUTOVACUUM_NONE;
79 if( 0==sqlite3StrICmp(z, "full") ) return BTREE_AUTOVACUUM_FULL; 77 if( 0==sqlite3StrICmp(z, "full") ) return BTREE_AUTOVACUUM_FULL;
80 if( 0==sqlite3StrICmp(z, "incremental") ) return BTREE_AUTOVACUUM_INCR; 78 if( 0==sqlite3StrICmp(z, "incremental") ) return BTREE_AUTOVACUUM_INCR;
81 i = atoi(z); 79 i = sqlite3Atoi(z);
82 return (u8)((i>=0&&i<=2)?i:0); 80 return (u8)((i>=0&&i<=2)?i:0);
83 } 81 }
84 #endif /* ifndef SQLITE_OMIT_AUTOVACUUM */ 82 #endif /* ifndef SQLITE_OMIT_AUTOVACUUM */
85 83
86 #ifndef SQLITE_OMIT_PAGER_PRAGMAS 84 #ifndef SQLITE_OMIT_PAGER_PRAGMAS
87 /* 85 /*
88 ** Interpret the given string as a temp db location. Return 1 for file 86 ** Interpret the given string as a temp db location. Return 1 for file
89 ** backed temporary databases, 2 for the Red-Black tree in memory database 87 ** backed temporary databases, 2 for the Red-Black tree in memory database
90 ** and 0 to use the compile-time default. 88 ** and 0 to use the compile-time default.
91 */ 89 */
(...skipping 18 matching lines...) Expand all
110 static int invalidateTempStorage(Parse *pParse){ 108 static int invalidateTempStorage(Parse *pParse){
111 sqlite3 *db = pParse->db; 109 sqlite3 *db = pParse->db;
112 if( db->aDb[1].pBt!=0 ){ 110 if( db->aDb[1].pBt!=0 ){
113 if( !db->autoCommit || sqlite3BtreeIsInReadTrans(db->aDb[1].pBt) ){ 111 if( !db->autoCommit || sqlite3BtreeIsInReadTrans(db->aDb[1].pBt) ){
114 sqlite3ErrorMsg(pParse, "temporary storage cannot be changed " 112 sqlite3ErrorMsg(pParse, "temporary storage cannot be changed "
115 "from within a transaction"); 113 "from within a transaction");
116 return SQLITE_ERROR; 114 return SQLITE_ERROR;
117 } 115 }
118 sqlite3BtreeClose(db->aDb[1].pBt); 116 sqlite3BtreeClose(db->aDb[1].pBt);
119 db->aDb[1].pBt = 0; 117 db->aDb[1].pBt = 0;
120 sqlite3ResetInternalSchema(db, 0); 118 sqlite3ResetInternalSchema(db, -1);
121 } 119 }
122 return SQLITE_OK; 120 return SQLITE_OK;
123 } 121 }
124 #endif /* SQLITE_PAGER_PRAGMAS */ 122 #endif /* SQLITE_PAGER_PRAGMAS */
125 123
126 #ifndef SQLITE_OMIT_PAGER_PRAGMAS 124 #ifndef SQLITE_OMIT_PAGER_PRAGMAS
127 /* 125 /*
128 ** If the TEMP database is open, close it and mark the database schema 126 ** If the TEMP database is open, close it and mark the database schema
129 ** as needing reloading. This must be done when using the SQLITE_TEMP_STORE 127 ** as needing reloading. This must be done when using the SQLITE_TEMP_STORE
130 ** or DEFAULT_TEMP_STORE pragmas. 128 ** or DEFAULT_TEMP_STORE pragmas.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 static const struct sPragmaType { 165 static const struct sPragmaType {
168 const char *zName; /* Name of the pragma */ 166 const char *zName; /* Name of the pragma */
169 int mask; /* Mask for the db->flags value */ 167 int mask; /* Mask for the db->flags value */
170 } aPragma[] = { 168 } aPragma[] = {
171 { "full_column_names", SQLITE_FullColNames }, 169 { "full_column_names", SQLITE_FullColNames },
172 { "short_column_names", SQLITE_ShortColNames }, 170 { "short_column_names", SQLITE_ShortColNames },
173 { "count_changes", SQLITE_CountRows }, 171 { "count_changes", SQLITE_CountRows },
174 { "empty_result_callbacks", SQLITE_NullCallback }, 172 { "empty_result_callbacks", SQLITE_NullCallback },
175 { "legacy_file_format", SQLITE_LegacyFileFmt }, 173 { "legacy_file_format", SQLITE_LegacyFileFmt },
176 { "fullfsync", SQLITE_FullFSync }, 174 { "fullfsync", SQLITE_FullFSync },
175 { "checkpoint_fullfsync", SQLITE_CkptFullFSync },
177 { "reverse_unordered_selects", SQLITE_ReverseOrder }, 176 { "reverse_unordered_selects", SQLITE_ReverseOrder },
177 #ifndef SQLITE_OMIT_AUTOMATIC_INDEX
178 { "automatic_index", SQLITE_AutoIndex },
179 #endif
178 #ifdef SQLITE_DEBUG 180 #ifdef SQLITE_DEBUG
179 { "sql_trace", SQLITE_SqlTrace }, 181 { "sql_trace", SQLITE_SqlTrace },
180 { "vdbe_listing", SQLITE_VdbeListing }, 182 { "vdbe_listing", SQLITE_VdbeListing },
181 { "vdbe_trace", SQLITE_VdbeTrace }, 183 { "vdbe_trace", SQLITE_VdbeTrace },
182 #endif 184 #endif
183 #ifndef SQLITE_OMIT_CHECK 185 #ifndef SQLITE_OMIT_CHECK
184 { "ignore_check_constraints", SQLITE_IgnoreChecks }, 186 { "ignore_check_constraints", SQLITE_IgnoreChecks },
185 #endif 187 #endif
186 /* The following is VERY experimental */ 188 /* The following is VERY experimental */
187 { "writable_schema", SQLITE_WriteSchema|SQLITE_RecoveryMode }, 189 { "writable_schema", SQLITE_WriteSchema|SQLITE_RecoveryMode },
188 { "omit_readlock", SQLITE_NoReadlock }, 190 { "omit_readlock", SQLITE_NoReadlock },
189 191
190 /* TODO: Maybe it shouldn't be possible to change the ReadUncommitted 192 /* TODO: Maybe it shouldn't be possible to change the ReadUncommitted
191 ** flag if there are any active statements. */ 193 ** flag if there are any active statements. */
192 { "read_uncommitted", SQLITE_ReadUncommitted }, 194 { "read_uncommitted", SQLITE_ReadUncommitted },
193 { "recursive_triggers", SQLITE_RecTriggers }, 195 { "recursive_triggers", SQLITE_RecTriggers },
196
197 /* This flag may only be set if both foreign-key and trigger support
198 ** are present in the build. */
199 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
200 { "foreign_keys", SQLITE_ForeignKeys },
201 #endif
194 }; 202 };
195 int i; 203 int i;
196 const struct sPragmaType *p; 204 const struct sPragmaType *p;
197 for(i=0, p=aPragma; i<ArraySize(aPragma); i++, p++){ 205 for(i=0, p=aPragma; i<ArraySize(aPragma); i++, p++){
198 if( sqlite3StrICmp(zLeft, p->zName)==0 ){ 206 if( sqlite3StrICmp(zLeft, p->zName)==0 ){
199 sqlite3 *db = pParse->db; 207 sqlite3 *db = pParse->db;
200 Vdbe *v; 208 Vdbe *v;
201 v = sqlite3GetVdbe(pParse); 209 v = sqlite3GetVdbe(pParse);
202 assert( v!=0 ); /* Already allocated by sqlite3Pragma() */ 210 assert( v!=0 ); /* Already allocated by sqlite3Pragma() */
203 if( ALWAYS(v) ){ 211 if( ALWAYS(v) ){
204 if( zRight==0 ){ 212 if( zRight==0 ){
205 returnSingleInt(pParse, p->zName, (db->flags & p->mask)!=0 ); 213 returnSingleInt(pParse, p->zName, (db->flags & p->mask)!=0 );
206 }else{ 214 }else{
215 int mask = p->mask; /* Mask of bits to set or clear. */
216 if( db->autoCommit==0 ){
217 /* Foreign key support may not be enabled or disabled while not
218 ** in auto-commit mode. */
219 mask &= ~(SQLITE_ForeignKeys);
220 }
221
207 if( getBoolean(zRight) ){ 222 if( getBoolean(zRight) ){
208 db->flags |= p->mask; 223 db->flags |= mask;
209 }else{ 224 }else{
210 db->flags &= ~p->mask; 225 db->flags &= ~mask;
211 } 226 }
212 227
213 /* Many of the flag-pragmas modify the code generated by the SQL 228 /* Many of the flag-pragmas modify the code generated by the SQL
214 ** compiler (eg. count_changes). So add an opcode to expire all 229 ** compiler (eg. count_changes). So add an opcode to expire all
215 ** compiled SQL statements after modifying a pragma value. 230 ** compiled SQL statements after modifying a pragma value.
216 */ 231 */
217 sqlite3VdbeAddOp2(v, OP_Expire, 0, 0); 232 sqlite3VdbeAddOp2(v, OP_Expire, 0, 0);
218 } 233 }
219 } 234 }
220 235
221 return 1; 236 return 1;
222 } 237 }
223 } 238 }
224 return 0; 239 return 0;
225 } 240 }
226 #endif /* SQLITE_OMIT_FLAG_PRAGMAS */ 241 #endif /* SQLITE_OMIT_FLAG_PRAGMAS */
227 242
228 /* 243 /*
229 ** Return a human-readable name for a constraint resolution action. 244 ** Return a human-readable name for a constraint resolution action.
230 */ 245 */
246 #ifndef SQLITE_OMIT_FOREIGN_KEY
231 static const char *actionName(u8 action){ 247 static const char *actionName(u8 action){
232 const char *zName; 248 const char *zName;
233 switch( action ){ 249 switch( action ){
234 case OE_SetNull: zName = "SET NULL"; break; 250 case OE_SetNull: zName = "SET NULL"; break;
235 case OE_SetDflt: zName = "SET DEFAULT"; break; 251 case OE_SetDflt: zName = "SET DEFAULT"; break;
236 case OE_Cascade: zName = "CASCADE"; break; 252 case OE_Cascade: zName = "CASCADE"; break;
237 default: zName = "RESTRICT"; 253 case OE_Restrict: zName = "RESTRICT"; break;
238 assert( action==OE_Restrict ); break; 254 default: zName = "NO ACTION";
255 assert( action==OE_None ); break;
239 } 256 }
240 return zName; 257 return zName;
241 } 258 }
259 #endif
260
261
262 /*
263 ** Parameter eMode must be one of the PAGER_JOURNALMODE_XXX constants
264 ** defined in pager.h. This function returns the associated lowercase
265 ** journal-mode name.
266 */
267 const char *sqlite3JournalModename(int eMode){
268 static char * const azModeName[] = {
269 "delete", "persist", "off", "truncate", "memory"
270 #ifndef SQLITE_OMIT_WAL
271 , "wal"
272 #endif
273 };
274 assert( PAGER_JOURNALMODE_DELETE==0 );
275 assert( PAGER_JOURNALMODE_PERSIST==1 );
276 assert( PAGER_JOURNALMODE_OFF==2 );
277 assert( PAGER_JOURNALMODE_TRUNCATE==3 );
278 assert( PAGER_JOURNALMODE_MEMORY==4 );
279 assert( PAGER_JOURNALMODE_WAL==5 );
280 assert( eMode>=0 && eMode<=ArraySize(azModeName) );
281
282 if( eMode==ArraySize(azModeName) ) return 0;
283 return azModeName[eMode];
284 }
242 285
243 /* 286 /*
244 ** Process a pragma statement. 287 ** Process a pragma statement.
245 ** 288 **
246 ** Pragmas are of this form: 289 ** Pragmas are of this form:
247 ** 290 **
248 ** PRAGMA [database.]id [= value] 291 ** PRAGMA [database.]id [= value]
249 ** 292 **
250 ** The identifier might also be a string. The value is a string, and 293 ** The identifier might also be a string. The value is a string, and
251 ** identifier, or a number. If minusFlag is true, then the value is 294 ** identifier, or a number. If minusFlag is true, then the value is
(...skipping 12 matching lines...) Expand all
264 ){ 307 ){
265 char *zLeft = 0; /* Nul-terminated UTF-8 string <id> */ 308 char *zLeft = 0; /* Nul-terminated UTF-8 string <id> */
266 char *zRight = 0; /* Nul-terminated UTF-8 string <value>, or NULL */ 309 char *zRight = 0; /* Nul-terminated UTF-8 string <value>, or NULL */
267 const char *zDb = 0; /* The database name */ 310 const char *zDb = 0; /* The database name */
268 Token *pId; /* Pointer to <id> token */ 311 Token *pId; /* Pointer to <id> token */
269 int iDb; /* Database index for <database> */ 312 int iDb; /* Database index for <database> */
270 sqlite3 *db = pParse->db; 313 sqlite3 *db = pParse->db;
271 Db *pDb; 314 Db *pDb;
272 Vdbe *v = pParse->pVdbe = sqlite3VdbeCreate(db); 315 Vdbe *v = pParse->pVdbe = sqlite3VdbeCreate(db);
273 if( v==0 ) return; 316 if( v==0 ) return;
317 sqlite3VdbeRunOnlyOnce(v);
274 pParse->nMem = 2; 318 pParse->nMem = 2;
275 319
276 /* Interpret the [database.] part of the pragma statement. iDb is the 320 /* Interpret the [database.] part of the pragma statement. iDb is the
277 ** index of the database this pragma is being applied to in db.aDb[]. */ 321 ** index of the database this pragma is being applied to in db.aDb[]. */
278 iDb = sqlite3TwoPartName(pParse, pId1, pId2, &pId); 322 iDb = sqlite3TwoPartName(pParse, pId1, pId2, &pId);
279 if( iDb<0 ) return; 323 if( iDb<0 ) return;
280 pDb = &db->aDb[iDb]; 324 pDb = &db->aDb[iDb];
281 325
282 /* If the temp database has been explicitly named as part of the 326 /* If the temp database has been explicitly named as part of the
283 ** pragma, make sure it is open. 327 ** pragma, make sure it is open.
(...skipping 20 matching lines...) Expand all
304 /* 348 /*
305 ** PRAGMA [database.]default_cache_size 349 ** PRAGMA [database.]default_cache_size
306 ** PRAGMA [database.]default_cache_size=N 350 ** PRAGMA [database.]default_cache_size=N
307 ** 351 **
308 ** The first form reports the current persistent setting for the 352 ** The first form reports the current persistent setting for the
309 ** page cache size. The value returned is the maximum number of 353 ** page cache size. The value returned is the maximum number of
310 ** pages in the page cache. The second form sets both the current 354 ** pages in the page cache. The second form sets both the current
311 ** page cache size value and the persistent page cache size value 355 ** page cache size value and the persistent page cache size value
312 ** stored in the database file. 356 ** stored in the database file.
313 ** 357 **
314 ** The default cache size is stored in meta-value 2 of page 1 of the 358 ** Older versions of SQLite would set the default cache size to a
315 ** database file. The cache size is actually the absolute value of 359 ** negative number to indicate synchronous=OFF. These days, synchronous
316 ** this memory location. The sign of meta-value 2 determines the 360 ** is always on by default regardless of the sign of the default cache
317 ** synchronous setting. A negative value means synchronous is off 361 ** size. But continue to take the absolute value of the default cache
318 ** and a positive value means synchronous is on. 362 ** size of historical compatibility.
319 */ 363 */
320 if( sqlite3StrICmp(zLeft,"default_cache_size")==0 ){ 364 if( sqlite3StrICmp(zLeft,"default_cache_size")==0 ){
321 static const VdbeOpList getCacheSize[] = { 365 static const VdbeOpList getCacheSize[] = {
322 { OP_Transaction, 0, 0, 0}, /* 0 */ 366 { OP_Transaction, 0, 0, 0}, /* 0 */
323 { OP_ReadCookie, 0, 1, BTREE_DEFAULT_CACHE_SIZE}, /* 1 */ 367 { OP_ReadCookie, 0, 1, BTREE_DEFAULT_CACHE_SIZE}, /* 1 */
324 { OP_IfPos, 1, 7, 0}, 368 { OP_IfPos, 1, 7, 0},
325 { OP_Integer, 0, 2, 0}, 369 { OP_Integer, 0, 2, 0},
326 { OP_Subtract, 1, 2, 1}, 370 { OP_Subtract, 1, 2, 1},
327 { OP_IfPos, 1, 7, 0}, 371 { OP_IfPos, 1, 7, 0},
328 { OP_Integer, 0, 1, 0}, /* 6 */ 372 { OP_Integer, 0, 1, 0}, /* 6 */
329 { OP_ResultRow, 1, 1, 0}, 373 { OP_ResultRow, 1, 1, 0},
330 }; 374 };
331 int addr; 375 int addr;
332 if( sqlite3ReadSchema(pParse) ) goto pragma_out; 376 if( sqlite3ReadSchema(pParse) ) goto pragma_out;
333 sqlite3VdbeUsesBtree(v, iDb); 377 sqlite3VdbeUsesBtree(v, iDb);
334 if( !zRight ){ 378 if( !zRight ){
335 sqlite3VdbeSetNumCols(v, 1); 379 sqlite3VdbeSetNumCols(v, 1);
336 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "cache_size", SQLITE_STATIC); 380 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "cache_size", SQLITE_STATIC);
337 pParse->nMem += 2; 381 pParse->nMem += 2;
338 addr = sqlite3VdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize); 382 addr = sqlite3VdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize);
339 sqlite3VdbeChangeP1(v, addr, iDb); 383 sqlite3VdbeChangeP1(v, addr, iDb);
340 sqlite3VdbeChangeP1(v, addr+1, iDb); 384 sqlite3VdbeChangeP1(v, addr+1, iDb);
341 sqlite3VdbeChangeP1(v, addr+6, SQLITE_DEFAULT_CACHE_SIZE); 385 sqlite3VdbeChangeP1(v, addr+6, SQLITE_DEFAULT_CACHE_SIZE);
342 }else{ 386 }else{
343 int size = atoi(zRight); 387 int size = sqlite3AbsInt32(sqlite3Atoi(zRight));
344 if( size<0 ) size = -size;
345 sqlite3BeginWriteOperation(pParse, 0, iDb); 388 sqlite3BeginWriteOperation(pParse, 0, iDb);
346 sqlite3VdbeAddOp2(v, OP_Integer, size, 1); 389 sqlite3VdbeAddOp2(v, OP_Integer, size, 1);
347 sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, 2, BTREE_DEFAULT_CACHE_SIZE);
348 addr = sqlite3VdbeAddOp2(v, OP_IfPos, 2, 0);
349 sqlite3VdbeAddOp2(v, OP_Integer, -size, 1);
350 sqlite3VdbeJumpHere(v, addr);
351 sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_DEFAULT_CACHE_SIZE, 1); 390 sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_DEFAULT_CACHE_SIZE, 1);
391 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
352 pDb->pSchema->cache_size = size; 392 pDb->pSchema->cache_size = size;
353 sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size); 393 sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);
354 } 394 }
355 }else 395 }else
356 396
357 /* 397 /*
358 ** PRAGMA [database.]page_size 398 ** PRAGMA [database.]page_size
359 ** PRAGMA [database.]page_size=N 399 ** PRAGMA [database.]page_size=N
360 ** 400 **
361 ** The first form reports the current setting for the 401 ** The first form reports the current setting for the
362 ** database page size in bytes. The second form sets the 402 ** database page size in bytes. The second form sets the
363 ** database page size value. The value can only be set if 403 ** database page size value. The value can only be set if
364 ** the database has not yet been created. 404 ** the database has not yet been created.
365 */ 405 */
366 if( sqlite3StrICmp(zLeft,"page_size")==0 ){ 406 if( sqlite3StrICmp(zLeft,"page_size")==0 ){
367 Btree *pBt = pDb->pBt; 407 Btree *pBt = pDb->pBt;
368 assert( pBt!=0 ); 408 assert( pBt!=0 );
369 if( !zRight ){ 409 if( !zRight ){
370 int size = ALWAYS(pBt) ? sqlite3BtreeGetPageSize(pBt) : 0; 410 int size = ALWAYS(pBt) ? sqlite3BtreeGetPageSize(pBt) : 0;
371 returnSingleInt(pParse, "page_size", size); 411 returnSingleInt(pParse, "page_size", size);
372 }else{ 412 }else{
373 /* Malloc may fail when setting the page-size, as there is an internal 413 /* Malloc may fail when setting the page-size, as there is an internal
374 ** buffer that the pager module resizes using sqlite3_realloc(). 414 ** buffer that the pager module resizes using sqlite3_realloc().
375 */ 415 */
376 db->nextPagesize = atoi(zRight); 416 db->nextPagesize = sqlite3Atoi(zRight);
377 if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize, -1, 0) ){ 417 if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize, -1, 0) ){
378 db->mallocFailed = 1; 418 db->mallocFailed = 1;
379 } 419 }
380 } 420 }
381 }else 421 }else
382 422
383 /* 423 /*
424 ** PRAGMA [database.]secure_delete
425 ** PRAGMA [database.]secure_delete=ON/OFF
426 **
427 ** The first form reports the current setting for the
428 ** secure_delete flag. The second form changes the secure_delete
429 ** flag setting and reports thenew value.
430 */
431 if( sqlite3StrICmp(zLeft,"secure_delete")==0 ){
432 Btree *pBt = pDb->pBt;
433 int b = -1;
434 assert( pBt!=0 );
435 if( zRight ){
436 b = getBoolean(zRight);
437 }
438 if( pId2->n==0 && b>=0 ){
439 int ii;
440 for(ii=0; ii<db->nDb; ii++){
441 sqlite3BtreeSecureDelete(db->aDb[ii].pBt, b);
442 }
443 }
444 b = sqlite3BtreeSecureDelete(pBt, b);
445 returnSingleInt(pParse, "secure_delete", b);
446 }else
447
448 /*
384 ** PRAGMA [database.]max_page_count 449 ** PRAGMA [database.]max_page_count
385 ** PRAGMA [database.]max_page_count=N 450 ** PRAGMA [database.]max_page_count=N
386 ** 451 **
387 ** The first form reports the current setting for the 452 ** The first form reports the current setting for the
388 ** maximum number of pages in the database file. The 453 ** maximum number of pages in the database file. The
389 ** second form attempts to change this setting. Both 454 ** second form attempts to change this setting. Both
390 ** forms return the current setting. 455 ** forms return the current setting.
391 */ 456 **
392 if( sqlite3StrICmp(zLeft,"max_page_count")==0 ){
393 Btree *pBt = pDb->pBt;
394 int newMax = 0;
395 assert( pBt!=0 );
396 if( zRight ){
397 newMax = atoi(zRight);
398 }
399 if( ALWAYS(pBt) ){
400 newMax = sqlite3BtreeMaxPageCount(pBt, newMax);
401 }
402 returnSingleInt(pParse, "max_page_count", newMax);
403 }else
404
405 /*
406 ** PRAGMA [database.]page_count 457 ** PRAGMA [database.]page_count
407 ** 458 **
408 ** Return the number of pages in the specified database. 459 ** Return the number of pages in the specified database.
409 */ 460 */
410 if( sqlite3StrICmp(zLeft,"page_count")==0 ){ 461 if( sqlite3StrICmp(zLeft,"page_count")==0
462 || sqlite3StrICmp(zLeft,"max_page_count")==0
463 ){
411 int iReg; 464 int iReg;
412 if( sqlite3ReadSchema(pParse) ) goto pragma_out; 465 if( sqlite3ReadSchema(pParse) ) goto pragma_out;
413 sqlite3CodeVerifySchema(pParse, iDb); 466 sqlite3CodeVerifySchema(pParse, iDb);
414 iReg = ++pParse->nMem; 467 iReg = ++pParse->nMem;
415 sqlite3VdbeAddOp2(v, OP_Pagecount, iDb, iReg); 468 if( zLeft[0]=='p' ){
469 sqlite3VdbeAddOp2(v, OP_Pagecount, iDb, iReg);
470 }else{
471 sqlite3VdbeAddOp3(v, OP_MaxPgcnt, iDb, iReg, sqlite3Atoi(zRight));
472 }
416 sqlite3VdbeAddOp2(v, OP_ResultRow, iReg, 1); 473 sqlite3VdbeAddOp2(v, OP_ResultRow, iReg, 1);
417 sqlite3VdbeSetNumCols(v, 1); 474 sqlite3VdbeSetNumCols(v, 1);
418 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "page_count", SQLITE_STATIC); 475 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLeft, SQLITE_TRANSIENT);
419 }else 476 }else
420 477
421 /* 478 /*
422 ** PRAGMA [database.]locking_mode 479 ** PRAGMA [database.]locking_mode
423 ** PRAGMA [database.]locking_mode = (normal|exclusive) 480 ** PRAGMA [database.]locking_mode = (normal|exclusive)
424 */ 481 */
425 if( sqlite3StrICmp(zLeft,"locking_mode")==0 ){ 482 if( sqlite3StrICmp(zLeft,"locking_mode")==0 ){
426 const char *zRet = "normal"; 483 const char *zRet = "normal";
427 int eMode = getLockingMode(zRight); 484 int eMode = getLockingMode(zRight);
428 485
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 zRet = "exclusive"; 517 zRet = "exclusive";
461 } 518 }
462 sqlite3VdbeSetNumCols(v, 1); 519 sqlite3VdbeSetNumCols(v, 1);
463 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "locking_mode", SQLITE_STATIC); 520 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "locking_mode", SQLITE_STATIC);
464 sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, zRet, 0); 521 sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, zRet, 0);
465 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); 522 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
466 }else 523 }else
467 524
468 /* 525 /*
469 ** PRAGMA [database.]journal_mode 526 ** PRAGMA [database.]journal_mode
470 ** PRAGMA [database.]journal_mode = (delete|persist|off|truncate|memory) 527 ** PRAGMA [database.]journal_mode =
528 ** (delete|persist|off|truncate|memory|wal|off)
471 */ 529 */
472 if( sqlite3StrICmp(zLeft,"journal_mode")==0 ){ 530 if( sqlite3StrICmp(zLeft,"journal_mode")==0 ){
473 int eMode; 531 int eMode; /* One of the PAGER_JOURNALMODE_XXX symbols */
474 static char * const azModeName[] = { 532 int ii; /* Loop counter */
475 "delete", "persist", "off", "truncate", "memory" 533
476 }; 534 /* Force the schema to be loaded on all databases. This cases all
535 ** database files to be opened and the journal_modes set. */
536 if( sqlite3ReadSchema(pParse) ){
537 goto pragma_out;
538 }
539
540 sqlite3VdbeSetNumCols(v, 1);
541 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "journal_mode", SQLITE_STATIC);
477 542
478 if( zRight==0 ){ 543 if( zRight==0 ){
544 /* If there is no "=MODE" part of the pragma, do a query for the
545 ** current mode */
479 eMode = PAGER_JOURNALMODE_QUERY; 546 eMode = PAGER_JOURNALMODE_QUERY;
480 }else{ 547 }else{
548 const char *zMode;
481 int n = sqlite3Strlen30(zRight); 549 int n = sqlite3Strlen30(zRight);
482 eMode = sizeof(azModeName)/sizeof(azModeName[0]) - 1; 550 for(eMode=0; (zMode = sqlite3JournalModename(eMode))!=0; eMode++){
483 while( eMode>=0 && sqlite3StrNICmp(zRight, azModeName[eMode], n)!=0 ){ 551 if( sqlite3StrNICmp(zRight, zMode, n)==0 ) break;
484 eMode--; 552 }
553 if( !zMode ){
554 /* If the "=MODE" part does not match any known journal mode,
555 ** then do a query */
556 eMode = PAGER_JOURNALMODE_QUERY;
485 } 557 }
486 } 558 }
487 if( pId2->n==0 && eMode==PAGER_JOURNALMODE_QUERY ){ 559 if( eMode==PAGER_JOURNALMODE_QUERY && pId2->n==0 ){
488 /* Simple "PRAGMA journal_mode;" statement. This is a query for 560 /* Convert "PRAGMA journal_mode" into "PRAGMA main.journal_mode" */
489 ** the current default journal mode (which may be different to 561 iDb = 0;
490 ** the journal-mode of the main database). 562 pId2->n = 1;
491 */ 563 }
492 eMode = db->dfltJournalMode; 564 for(ii=db->nDb-1; ii>=0; ii--){
493 }else{ 565 if( db->aDb[ii].pBt && (ii==iDb || pId2->n==0) ){
494 Pager *pPager; 566 sqlite3VdbeUsesBtree(v, ii);
495 if( pId2->n==0 ){ 567 sqlite3VdbeAddOp3(v, OP_JournalMode, ii, 1, eMode);
496 /* This indicates that no database name was specified as part
497 ** of the PRAGMA command. In this case the journal-mode must be
498 ** set on all attached databases, as well as the main db file.
499 **
500 ** Also, the sqlite3.dfltJournalMode variable is set so that
501 ** any subsequently attached databases also use the specified
502 ** journal mode.
503 */
504 int ii;
505 assert(pDb==&db->aDb[0]);
506 for(ii=1; ii<db->nDb; ii++){
507 if( db->aDb[ii].pBt ){
508 pPager = sqlite3BtreePager(db->aDb[ii].pBt);
509 sqlite3PagerJournalMode(pPager, eMode);
510 }
511 }
512 db->dfltJournalMode = (u8)eMode;
513 } 568 }
514 pPager = sqlite3BtreePager(pDb->pBt);
515 eMode = sqlite3PagerJournalMode(pPager, eMode);
516 } 569 }
517 assert( eMode==PAGER_JOURNALMODE_DELETE
518 || eMode==PAGER_JOURNALMODE_TRUNCATE
519 || eMode==PAGER_JOURNALMODE_PERSIST
520 || eMode==PAGER_JOURNALMODE_OFF
521 || eMode==PAGER_JOURNALMODE_MEMORY );
522 sqlite3VdbeSetNumCols(v, 1);
523 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "journal_mode", SQLITE_STATIC);
524 sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0,
525 azModeName[eMode], P4_STATIC);
526 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); 570 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
527 }else 571 }else
528 572
529 /* 573 /*
530 ** PRAGMA [database.]journal_size_limit 574 ** PRAGMA [database.]journal_size_limit
531 ** PRAGMA [database.]journal_size_limit=N 575 ** PRAGMA [database.]journal_size_limit=N
532 ** 576 **
533 ** Get or set the size limit on rollback journal files. 577 ** Get or set the size limit on rollback journal files.
534 */ 578 */
535 if( sqlite3StrICmp(zLeft,"journal_size_limit")==0 ){ 579 if( sqlite3StrICmp(zLeft,"journal_size_limit")==0 ){
536 Pager *pPager = sqlite3BtreePager(pDb->pBt); 580 Pager *pPager = sqlite3BtreePager(pDb->pBt);
537 i64 iLimit = -2; 581 i64 iLimit = -2;
538 if( zRight ){ 582 if( zRight ){
539 sqlite3Atoi64(zRight, &iLimit); 583 sqlite3Atoi64(zRight, &iLimit, 1000000, SQLITE_UTF8);
540 if( iLimit<-1 ) iLimit = -1; 584 if( iLimit<-1 ) iLimit = -1;
541 } 585 }
542 iLimit = sqlite3PagerJournalSizeLimit(pPager, iLimit); 586 iLimit = sqlite3PagerJournalSizeLimit(pPager, iLimit);
543 returnSingleInt(pParse, "journal_size_limit", iLimit); 587 returnSingleInt(pParse, "journal_size_limit", iLimit);
544 }else 588 }else
545 589
546 #endif /* SQLITE_OMIT_PAGER_PRAGMAS */ 590 #endif /* SQLITE_OMIT_PAGER_PRAGMAS */
547 591
548 /* 592 /*
549 ** PRAGMA [database.]auto_vacuum 593 ** PRAGMA [database.]auto_vacuum
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 ** the persistent cache size value that is stored in the database 684 ** the persistent cache size value that is stored in the database
641 ** file itself. The value returned is the maximum number of 685 ** file itself. The value returned is the maximum number of
642 ** pages in the page cache. The second form sets the local 686 ** pages in the page cache. The second form sets the local
643 ** page cache size value. It does not change the persistent 687 ** page cache size value. It does not change the persistent
644 ** cache size stored on the disk so the cache size will revert 688 ** cache size stored on the disk so the cache size will revert
645 ** to its default value when the database is closed and reopened. 689 ** to its default value when the database is closed and reopened.
646 ** N should be a positive integer. 690 ** N should be a positive integer.
647 */ 691 */
648 if( sqlite3StrICmp(zLeft,"cache_size")==0 ){ 692 if( sqlite3StrICmp(zLeft,"cache_size")==0 ){
649 if( sqlite3ReadSchema(pParse) ) goto pragma_out; 693 if( sqlite3ReadSchema(pParse) ) goto pragma_out;
694 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
650 if( !zRight ){ 695 if( !zRight ){
651 returnSingleInt(pParse, "cache_size", pDb->pSchema->cache_size); 696 returnSingleInt(pParse, "cache_size", pDb->pSchema->cache_size);
652 }else{ 697 }else{
653 int size = atoi(zRight); 698 int size = sqlite3AbsInt32(sqlite3Atoi(zRight));
654 if( size<0 ) size = -size;
655 pDb->pSchema->cache_size = size; 699 pDb->pSchema->cache_size = size;
656 sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size); 700 sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);
657 } 701 }
658 }else 702 }else
659 703
660 /* 704 /*
661 ** PRAGMA temp_store 705 ** PRAGMA temp_store
662 ** PRAGMA temp_store = "default"|"memory"|"file" 706 ** PRAGMA temp_store = "default"|"memory"|"file"
663 ** 707 **
664 ** Return or set the local value of the temp_store flag. Changing 708 ** Return or set the local value of the temp_store flag. Changing
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 } 751 }
708 } 752 }
709 if( SQLITE_TEMP_STORE==0 753 if( SQLITE_TEMP_STORE==0
710 || (SQLITE_TEMP_STORE==1 && db->temp_store<=1) 754 || (SQLITE_TEMP_STORE==1 && db->temp_store<=1)
711 || (SQLITE_TEMP_STORE==2 && db->temp_store==1) 755 || (SQLITE_TEMP_STORE==2 && db->temp_store==1)
712 ){ 756 ){
713 invalidateTempStorage(pParse); 757 invalidateTempStorage(pParse);
714 } 758 }
715 sqlite3_free(sqlite3_temp_directory); 759 sqlite3_free(sqlite3_temp_directory);
716 if( zRight[0] ){ 760 if( zRight[0] ){
717 sqlite3_temp_directory = sqlite3DbStrDup(0, zRight); 761 sqlite3_temp_directory = sqlite3_mprintf("%s", zRight);
718 }else{ 762 }else{
719 sqlite3_temp_directory = 0; 763 sqlite3_temp_directory = 0;
720 } 764 }
721 #endif /* SQLITE_OMIT_WSD */ 765 #endif /* SQLITE_OMIT_WSD */
722 } 766 }
723 }else 767 }else
724 768
725 #if !defined(SQLITE_ENABLE_LOCKING_STYLE) 769 #if !defined(SQLITE_ENABLE_LOCKING_STYLE)
726 # if defined(__APPLE__) 770 # if defined(__APPLE__)
727 # define SQLITE_ENABLE_LOCKING_STYLE 1 771 # define SQLITE_ENABLE_LOCKING_STYLE 1
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "table", SQLITE_STATIC); 1002 sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "table", SQLITE_STATIC);
959 sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "from", SQLITE_STATIC); 1003 sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "from", SQLITE_STATIC);
960 sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "to", SQLITE_STATIC); 1004 sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "to", SQLITE_STATIC);
961 sqlite3VdbeSetColName(v, 5, COLNAME_NAME, "on_update", SQLITE_STATIC); 1005 sqlite3VdbeSetColName(v, 5, COLNAME_NAME, "on_update", SQLITE_STATIC);
962 sqlite3VdbeSetColName(v, 6, COLNAME_NAME, "on_delete", SQLITE_STATIC); 1006 sqlite3VdbeSetColName(v, 6, COLNAME_NAME, "on_delete", SQLITE_STATIC);
963 sqlite3VdbeSetColName(v, 7, COLNAME_NAME, "match", SQLITE_STATIC); 1007 sqlite3VdbeSetColName(v, 7, COLNAME_NAME, "match", SQLITE_STATIC);
964 while(pFK){ 1008 while(pFK){
965 int j; 1009 int j;
966 for(j=0; j<pFK->nCol; j++){ 1010 for(j=0; j<pFK->nCol; j++){
967 char *zCol = pFK->aCol[j].zCol; 1011 char *zCol = pFK->aCol[j].zCol;
968 char *zOnUpdate = (char *)actionName(pFK->updateConf); 1012 char *zOnDelete = (char *)actionName(pFK->aAction[0]);
969 char *zOnDelete = (char *)actionName(pFK->deleteConf); 1013 char *zOnUpdate = (char *)actionName(pFK->aAction[1]);
970 sqlite3VdbeAddOp2(v, OP_Integer, i, 1); 1014 sqlite3VdbeAddOp2(v, OP_Integer, i, 1);
971 sqlite3VdbeAddOp2(v, OP_Integer, j, 2); 1015 sqlite3VdbeAddOp2(v, OP_Integer, j, 2);
972 sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pFK->zTo, 0); 1016 sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pFK->zTo, 0);
973 sqlite3VdbeAddOp4(v, OP_String8, 0, 4, 0, 1017 sqlite3VdbeAddOp4(v, OP_String8, 0, 4, 0,
974 pTab->aCol[pFK->aCol[j].iFrom].zName, 0); 1018 pTab->aCol[pFK->aCol[j].iFrom].zName, 0);
975 sqlite3VdbeAddOp4(v, zCol ? OP_String8 : OP_Null, 0, 5, 0, zCol, 0); 1019 sqlite3VdbeAddOp4(v, zCol ? OP_String8 : OP_Null, 0, 5, 0, zCol, 0);
976 sqlite3VdbeAddOp4(v, OP_String8, 0, 6, 0, zOnUpdate, 0); 1020 sqlite3VdbeAddOp4(v, OP_String8, 0, 6, 0, zOnUpdate, 0);
977 sqlite3VdbeAddOp4(v, OP_String8, 0, 7, 0, zOnDelete, 0); 1021 sqlite3VdbeAddOp4(v, OP_String8, 0, 7, 0, zOnDelete, 0);
978 sqlite3VdbeAddOp4(v, OP_String8, 0, 8, 0, "NONE", 0); 1022 sqlite3VdbeAddOp4(v, OP_String8, 0, 8, 0, "NONE", 0);
979 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 8); 1023 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 8);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 1080
1037 /* Initialize the VDBE program */ 1081 /* Initialize the VDBE program */
1038 if( sqlite3ReadSchema(pParse) ) goto pragma_out; 1082 if( sqlite3ReadSchema(pParse) ) goto pragma_out;
1039 pParse->nMem = 6; 1083 pParse->nMem = 6;
1040 sqlite3VdbeSetNumCols(v, 1); 1084 sqlite3VdbeSetNumCols(v, 1);
1041 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "integrity_check", SQLITE_STATIC); 1085 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "integrity_check", SQLITE_STATIC);
1042 1086
1043 /* Set the maximum error count */ 1087 /* Set the maximum error count */
1044 mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX; 1088 mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;
1045 if( zRight ){ 1089 if( zRight ){
1046 mxErr = atoi(zRight); 1090 sqlite3GetInt32(zRight, &mxErr);
1047 if( mxErr<=0 ){ 1091 if( mxErr<=0 ){
1048 mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX; 1092 mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;
1049 } 1093 }
1050 } 1094 }
1051 sqlite3VdbeAddOp2(v, OP_Integer, mxErr, 1); /* reg[1] holds errors left */ 1095 sqlite3VdbeAddOp2(v, OP_Integer, mxErr, 1); /* reg[1] holds errors left */
1052 1096
1053 /* Do an integrity check on each database file */ 1097 /* Do an integrity check on each database file */
1054 for(i=0; i<db->nDb; i++){ 1098 for(i=0; i<db->nDb; i++){
1055 HashElem *x; 1099 HashElem *x;
1056 Hash *pTbls; 1100 Hash *pTbls;
1057 int cnt = 0; 1101 int cnt = 0;
1058 1102
1059 if( OMIT_TEMPDB && i==1 ) continue; 1103 if( OMIT_TEMPDB && i==1 ) continue;
1060 1104
1061 sqlite3CodeVerifySchema(pParse, i); 1105 sqlite3CodeVerifySchema(pParse, i);
1062 addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Halt if out of errors */ 1106 addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Halt if out of errors */
1063 sqlite3VdbeAddOp2(v, OP_Halt, 0, 0); 1107 sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
1064 sqlite3VdbeJumpHere(v, addr); 1108 sqlite3VdbeJumpHere(v, addr);
1065 1109
1066 /* Do an integrity check of the B-Tree 1110 /* Do an integrity check of the B-Tree
1067 ** 1111 **
1068 ** Begin by filling registers 2, 3, ... with the root pages numbers 1112 ** Begin by filling registers 2, 3, ... with the root pages numbers
1069 ** for all tables and indices in the database. 1113 ** for all tables and indices in the database.
1070 */ 1114 */
1115 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
1071 pTbls = &db->aDb[i].pSchema->tblHash; 1116 pTbls = &db->aDb[i].pSchema->tblHash;
1072 for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){ 1117 for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){
1073 Table *pTab = sqliteHashData(x); 1118 Table *pTab = sqliteHashData(x);
1074 Index *pIdx; 1119 Index *pIdx;
1075 sqlite3VdbeAddOp2(v, OP_Integer, pTab->tnum, 2+cnt); 1120 sqlite3VdbeAddOp2(v, OP_Integer, pTab->tnum, 2+cnt);
1076 cnt++; 1121 cnt++;
1077 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ 1122 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
1078 sqlite3VdbeAddOp2(v, OP_Integer, pIdx->tnum, 2+cnt); 1123 sqlite3VdbeAddOp2(v, OP_Integer, pIdx->tnum, 2+cnt);
1079 cnt++; 1124 cnt++;
1080 } 1125 }
(...skipping 26 matching lines...) Expand all
1107 if( pTab->pIndex==0 ) continue; 1152 if( pTab->pIndex==0 ) continue;
1108 addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Stop if out of errors */ 1153 addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Stop if out of errors */
1109 sqlite3VdbeAddOp2(v, OP_Halt, 0, 0); 1154 sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
1110 sqlite3VdbeJumpHere(v, addr); 1155 sqlite3VdbeJumpHere(v, addr);
1111 sqlite3OpenTableAndIndices(pParse, pTab, 1, OP_OpenRead); 1156 sqlite3OpenTableAndIndices(pParse, pTab, 1, OP_OpenRead);
1112 sqlite3VdbeAddOp2(v, OP_Integer, 0, 2); /* reg(2) will count entries */ 1157 sqlite3VdbeAddOp2(v, OP_Integer, 0, 2); /* reg(2) will count entries */
1113 loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0); 1158 loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0);
1114 sqlite3VdbeAddOp2(v, OP_AddImm, 2, 1); /* increment entry count */ 1159 sqlite3VdbeAddOp2(v, OP_AddImm, 2, 1); /* increment entry count */
1115 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ 1160 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
1116 int jmp2; 1161 int jmp2;
1162 int r1;
1117 static const VdbeOpList idxErr[] = { 1163 static const VdbeOpList idxErr[] = {
1118 { OP_AddImm, 1, -1, 0}, 1164 { OP_AddImm, 1, -1, 0},
1119 { OP_String8, 0, 3, 0}, /* 1 */ 1165 { OP_String8, 0, 3, 0}, /* 1 */
1120 { OP_Rowid, 1, 4, 0}, 1166 { OP_Rowid, 1, 4, 0},
1121 { OP_String8, 0, 5, 0}, /* 3 */ 1167 { OP_String8, 0, 5, 0}, /* 3 */
1122 { OP_String8, 0, 6, 0}, /* 4 */ 1168 { OP_String8, 0, 6, 0}, /* 4 */
1123 { OP_Concat, 4, 3, 3}, 1169 { OP_Concat, 4, 3, 3},
1124 { OP_Concat, 5, 3, 3}, 1170 { OP_Concat, 5, 3, 3},
1125 { OP_Concat, 6, 3, 3}, 1171 { OP_Concat, 6, 3, 3},
1126 { OP_ResultRow, 3, 1, 0}, 1172 { OP_ResultRow, 3, 1, 0},
1127 { OP_IfPos, 1, 0, 0}, /* 9 */ 1173 { OP_IfPos, 1, 0, 0}, /* 9 */
1128 { OP_Halt, 0, 0, 0}, 1174 { OP_Halt, 0, 0, 0},
1129 }; 1175 };
1130 sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 1); 1176 r1 = sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 0);
1131 jmp2 = sqlite3VdbeAddOp3(v, OP_Found, j+2, 0, 3); 1177 jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, j+2, 0, r1, pIdx->nColumn+1);
1132 addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr); 1178 addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr);
1133 sqlite3VdbeChangeP4(v, addr+1, "rowid ", P4_STATIC); 1179 sqlite3VdbeChangeP4(v, addr+1, "rowid ", P4_STATIC);
1134 sqlite3VdbeChangeP4(v, addr+3, " missing from index ", P4_STATIC); 1180 sqlite3VdbeChangeP4(v, addr+3, " missing from index ", P4_STATIC);
1135 sqlite3VdbeChangeP4(v, addr+4, pIdx->zName, P4_STATIC); 1181 sqlite3VdbeChangeP4(v, addr+4, pIdx->zName, P4_TRANSIENT);
1136 sqlite3VdbeJumpHere(v, addr+9); 1182 sqlite3VdbeJumpHere(v, addr+9);
1137 sqlite3VdbeJumpHere(v, jmp2); 1183 sqlite3VdbeJumpHere(v, jmp2);
1138 } 1184 }
1139 sqlite3VdbeAddOp2(v, OP_Next, 1, loopTop+1); 1185 sqlite3VdbeAddOp2(v, OP_Next, 1, loopTop+1);
1140 sqlite3VdbeJumpHere(v, loopTop); 1186 sqlite3VdbeJumpHere(v, loopTop);
1141 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ 1187 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
1142 static const VdbeOpList cntIdx[] = { 1188 static const VdbeOpList cntIdx[] = {
1143 { OP_Integer, 0, 3, 0}, 1189 { OP_Integer, 0, 3, 0},
1144 { OP_Rewind, 0, 0, 0}, /* 1 */ 1190 { OP_Rewind, 0, 0, 0}, /* 1 */
1145 { OP_AddImm, 3, 1, 0}, 1191 { OP_AddImm, 3, 1, 0},
1146 { OP_Next, 0, 0, 0}, /* 3 */ 1192 { OP_Next, 0, 0, 0}, /* 3 */
1147 { OP_Eq, 2, 0, 3}, /* 4 */ 1193 { OP_Eq, 2, 0, 3}, /* 4 */
1148 { OP_AddImm, 1, -1, 0}, 1194 { OP_AddImm, 1, -1, 0},
1149 { OP_String8, 0, 2, 0}, /* 6 */ 1195 { OP_String8, 0, 2, 0}, /* 6 */
1150 { OP_String8, 0, 3, 0}, /* 7 */ 1196 { OP_String8, 0, 3, 0}, /* 7 */
1151 { OP_Concat, 3, 2, 2}, 1197 { OP_Concat, 3, 2, 2},
1152 { OP_ResultRow, 2, 1, 0}, 1198 { OP_ResultRow, 2, 1, 0},
1153 }; 1199 };
1154 addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); 1200 addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1);
1155 sqlite3VdbeAddOp2(v, OP_Halt, 0, 0); 1201 sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
1156 sqlite3VdbeJumpHere(v, addr); 1202 sqlite3VdbeJumpHere(v, addr);
1157 addr = sqlite3VdbeAddOpList(v, ArraySize(cntIdx), cntIdx); 1203 addr = sqlite3VdbeAddOpList(v, ArraySize(cntIdx), cntIdx);
1158 sqlite3VdbeChangeP1(v, addr+1, j+2); 1204 sqlite3VdbeChangeP1(v, addr+1, j+2);
1159 sqlite3VdbeChangeP2(v, addr+1, addr+4); 1205 sqlite3VdbeChangeP2(v, addr+1, addr+4);
1160 sqlite3VdbeChangeP1(v, addr+3, j+2); 1206 sqlite3VdbeChangeP1(v, addr+3, j+2);
1161 sqlite3VdbeChangeP2(v, addr+3, addr+2); 1207 sqlite3VdbeChangeP2(v, addr+3, addr+2);
1162 sqlite3VdbeJumpHere(v, addr+4); 1208 sqlite3VdbeJumpHere(v, addr+4);
1163 sqlite3VdbeChangeP4(v, addr+6, 1209 sqlite3VdbeChangeP4(v, addr+6,
1164 "wrong # of entries in index ", P4_STATIC); 1210 "wrong # of entries in index ", P4_STATIC);
1165 sqlite3VdbeChangeP4(v, addr+7, pIdx->zName, P4_STATIC); 1211 sqlite3VdbeChangeP4(v, addr+7, pIdx->zName, P4_TRANSIENT);
1166 } 1212 }
1167 } 1213 }
1168 } 1214 }
1169 addr = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode); 1215 addr = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode);
1170 sqlite3VdbeChangeP2(v, addr, -mxErr); 1216 sqlite3VdbeChangeP2(v, addr, -mxErr);
1171 sqlite3VdbeJumpHere(v, addr+1); 1217 sqlite3VdbeJumpHere(v, addr+1);
1172 sqlite3VdbeChangeP4(v, addr+2, "ok", P4_STATIC); 1218 sqlite3VdbeChangeP4(v, addr+2, "ok", P4_STATIC);
1173 }else 1219 }else
1174 #endif /* SQLITE_OMIT_INTEGRITY_CHECK */ 1220 #endif /* SQLITE_OMIT_INTEGRITY_CHECK */
1175 1221
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 1338
1293 if( zRight && iCookie!=BTREE_FREE_PAGE_COUNT ){ 1339 if( zRight && iCookie!=BTREE_FREE_PAGE_COUNT ){
1294 /* Write the specified cookie value */ 1340 /* Write the specified cookie value */
1295 static const VdbeOpList setCookie[] = { 1341 static const VdbeOpList setCookie[] = {
1296 { OP_Transaction, 0, 1, 0}, /* 0 */ 1342 { OP_Transaction, 0, 1, 0}, /* 0 */
1297 { OP_Integer, 0, 1, 0}, /* 1 */ 1343 { OP_Integer, 0, 1, 0}, /* 1 */
1298 { OP_SetCookie, 0, 0, 1}, /* 2 */ 1344 { OP_SetCookie, 0, 0, 1}, /* 2 */
1299 }; 1345 };
1300 int addr = sqlite3VdbeAddOpList(v, ArraySize(setCookie), setCookie); 1346 int addr = sqlite3VdbeAddOpList(v, ArraySize(setCookie), setCookie);
1301 sqlite3VdbeChangeP1(v, addr, iDb); 1347 sqlite3VdbeChangeP1(v, addr, iDb);
1302 sqlite3VdbeChangeP1(v, addr+1, atoi(zRight)); 1348 sqlite3VdbeChangeP1(v, addr+1, sqlite3Atoi(zRight));
1303 sqlite3VdbeChangeP1(v, addr+2, iDb); 1349 sqlite3VdbeChangeP1(v, addr+2, iDb);
1304 sqlite3VdbeChangeP2(v, addr+2, iCookie); 1350 sqlite3VdbeChangeP2(v, addr+2, iCookie);
1305 }else{ 1351 }else{
1306 /* Read the specified cookie value */ 1352 /* Read the specified cookie value */
1307 static const VdbeOpList readCookie[] = { 1353 static const VdbeOpList readCookie[] = {
1308 { OP_Transaction, 0, 0, 0}, /* 0 */ 1354 { OP_Transaction, 0, 0, 0}, /* 0 */
1309 { OP_ReadCookie, 0, 1, 0}, /* 1 */ 1355 { OP_ReadCookie, 0, 1, 0}, /* 1 */
1310 { OP_ResultRow, 1, 1, 0} 1356 { OP_ResultRow, 1, 1, 0}
1311 }; 1357 };
1312 int addr = sqlite3VdbeAddOpList(v, ArraySize(readCookie), readCookie); 1358 int addr = sqlite3VdbeAddOpList(v, ArraySize(readCookie), readCookie);
1313 sqlite3VdbeChangeP1(v, addr, iDb); 1359 sqlite3VdbeChangeP1(v, addr, iDb);
1314 sqlite3VdbeChangeP1(v, addr+1, iDb); 1360 sqlite3VdbeChangeP1(v, addr+1, iDb);
1315 sqlite3VdbeChangeP3(v, addr+1, iCookie); 1361 sqlite3VdbeChangeP3(v, addr+1, iCookie);
1316 sqlite3VdbeSetNumCols(v, 1); 1362 sqlite3VdbeSetNumCols(v, 1);
1317 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLeft, SQLITE_TRANSIENT); 1363 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLeft, SQLITE_TRANSIENT);
1318 } 1364 }
1319 }else 1365 }else
1320 #endif /* SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS */ 1366 #endif /* SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS */
1321 1367
1368 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
1369 /*
1370 ** PRAGMA compile_options
1371 **
1372 ** Return the names of all compile-time options used in this build,
1373 ** one option per row.
1374 */
1375 if( sqlite3StrICmp(zLeft, "compile_options")==0 ){
1376 int i = 0;
1377 const char *zOpt;
1378 sqlite3VdbeSetNumCols(v, 1);
1379 pParse->nMem = 1;
1380 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "compile_option", SQLITE_STATIC);
1381 while( (zOpt = sqlite3_compileoption_get(i++))!=0 ){
1382 sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, zOpt, 0);
1383 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
1384 }
1385 }else
1386 #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
1387
1388 #ifndef SQLITE_OMIT_WAL
1389 /*
1390 ** PRAGMA [database.]wal_checkpoint = passive|full|restart
1391 **
1392 ** Checkpoint the database.
1393 */
1394 if( sqlite3StrICmp(zLeft, "wal_checkpoint")==0 ){
1395 int iBt = (pId2->z?iDb:SQLITE_MAX_ATTACHED);
1396 int eMode = SQLITE_CHECKPOINT_PASSIVE;
1397 if( zRight ){
1398 if( sqlite3StrICmp(zRight, "full")==0 ){
1399 eMode = SQLITE_CHECKPOINT_FULL;
1400 }else if( sqlite3StrICmp(zRight, "restart")==0 ){
1401 eMode = SQLITE_CHECKPOINT_RESTART;
1402 }
1403 }
1404 if( sqlite3ReadSchema(pParse) ) goto pragma_out;
1405 sqlite3VdbeSetNumCols(v, 3);
1406 pParse->nMem = 3;
1407 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "busy", SQLITE_STATIC);
1408 sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "log", SQLITE_STATIC);
1409 sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "checkpointed", SQLITE_STATIC);
1410
1411 sqlite3VdbeAddOp3(v, OP_Checkpoint, iBt, eMode, 1);
1412 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);
1413 }else
1414
1415 /*
1416 ** PRAGMA wal_autocheckpoint
1417 ** PRAGMA wal_autocheckpoint = N
1418 **
1419 ** Configure a database connection to automatically checkpoint a database
1420 ** after accumulating N frames in the log. Or query for the current value
1421 ** of N.
1422 */
1423 if( sqlite3StrICmp(zLeft, "wal_autocheckpoint")==0 ){
1424 if( zRight ){
1425 sqlite3_wal_autocheckpoint(db, sqlite3Atoi(zRight));
1426 }
1427 returnSingleInt(pParse, "wal_autocheckpoint",
1428 db->xWalCallback==sqlite3WalDefaultHook ?
1429 SQLITE_PTR_TO_INT(db->pWalArg) : 0);
1430 }else
1431 #endif
1432
1322 #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) 1433 #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
1323 /* 1434 /*
1324 ** Report the current state of file logs for all databases 1435 ** Report the current state of file logs for all databases
1325 */ 1436 */
1326 if( sqlite3StrICmp(zLeft, "lock_status")==0 ){ 1437 if( sqlite3StrICmp(zLeft, "lock_status")==0 ){
1327 static const char *const azLockName[] = { 1438 static const char *const azLockName[] = {
1328 "unlocked", "shared", "reserved", "pending", "exclusive" 1439 "unlocked", "shared", "reserved", "pending", "exclusive"
1329 }; 1440 };
1330 int i; 1441 int i;
1331 sqlite3VdbeSetNumCols(v, 2); 1442 sqlite3VdbeSetNumCols(v, 2);
(...skipping 14 matching lines...) Expand all
1346 SQLITE_FCNTL_LOCKSTATE, &j)==SQLITE_OK ){ 1457 SQLITE_FCNTL_LOCKSTATE, &j)==SQLITE_OK ){
1347 zState = azLockName[j]; 1458 zState = azLockName[j];
1348 } 1459 }
1349 sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, zState, P4_STATIC); 1460 sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, zState, P4_STATIC);
1350 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2); 1461 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2);
1351 } 1462 }
1352 1463
1353 }else 1464 }else
1354 #endif 1465 #endif
1355 1466
1356 #if SQLITE_HAS_CODEC 1467 #ifdef SQLITE_HAS_CODEC
1357 if( sqlite3StrICmp(zLeft, "key")==0 && zRight ){ 1468 if( sqlite3StrICmp(zLeft, "key")==0 && zRight ){
1358 sqlite3_key(db, zRight, sqlite3Strlen30(zRight)); 1469 sqlite3_key(db, zRight, sqlite3Strlen30(zRight));
1359 }else 1470 }else
1360 if( sqlite3StrICmp(zLeft, "rekey")==0 && zRight ){ 1471 if( sqlite3StrICmp(zLeft, "rekey")==0 && zRight ){
1361 sqlite3_rekey(db, zRight, sqlite3Strlen30(zRight)); 1472 sqlite3_rekey(db, zRight, sqlite3Strlen30(zRight));
1362 }else 1473 }else
1363 if( zRight && (sqlite3StrICmp(zLeft, "hexkey")==0 || 1474 if( zRight && (sqlite3StrICmp(zLeft, "hexkey")==0 ||
1364 sqlite3StrICmp(zLeft, "hexrekey")==0) ){ 1475 sqlite3StrICmp(zLeft, "hexrekey")==0) ){
1365 int i, h1, h2; 1476 int i, h1, h2;
1366 char zKey[40]; 1477 char zKey[40];
1367 for(i=0; (h1 = zRight[i])!=0 && (h2 = zRight[i+1])!=0; i+=2){ 1478 for(i=0; (h1 = zRight[i])!=0 && (h2 = zRight[i+1])!=0; i+=2){
1368 h1 += 9*(1&(h1>>6)); 1479 h1 += 9*(1&(h1>>6));
1369 h2 += 9*(1&(h2>>6)); 1480 h2 += 9*(1&(h2>>6));
1370 zKey[i/2] = (h2 & 0x0f) | ((h1 & 0xf)<<4); 1481 zKey[i/2] = (h2 & 0x0f) | ((h1 & 0xf)<<4);
1371 } 1482 }
1372 if( (zLeft[3] & 0xf)==0xb ){ 1483 if( (zLeft[3] & 0xf)==0xb ){
1373 sqlite3_key(db, zKey, i/2); 1484 sqlite3_key(db, zKey, i/2);
1374 }else{ 1485 }else{
1375 sqlite3_rekey(db, zKey, i/2); 1486 sqlite3_rekey(db, zKey, i/2);
1376 } 1487 }
1377 }else 1488 }else
1378 #endif 1489 #endif
1379 #if SQLITE_HAS_CODEC || defined(SQLITE_ENABLE_CEROD) 1490 #if defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)
1380 if( sqlite3StrICmp(zLeft, "activate_extensions")==0 ){ 1491 if( sqlite3StrICmp(zLeft, "activate_extensions")==0 ){
1381 #if SQLITE_HAS_CODEC 1492 #ifdef SQLITE_HAS_CODEC
1382 if( sqlite3StrNICmp(zRight, "see-", 4)==0 ){ 1493 if( sqlite3StrNICmp(zRight, "see-", 4)==0 ){
1383 extern void sqlite3_activate_see(const char*);
1384 sqlite3_activate_see(&zRight[4]); 1494 sqlite3_activate_see(&zRight[4]);
1385 } 1495 }
1386 #endif 1496 #endif
1387 #ifdef SQLITE_ENABLE_CEROD 1497 #ifdef SQLITE_ENABLE_CEROD
1388 if( sqlite3StrNICmp(zRight, "cerod-", 6)==0 ){ 1498 if( sqlite3StrNICmp(zRight, "cerod-", 6)==0 ){
1389 extern void sqlite3_activate_cerod(const char*);
1390 sqlite3_activate_cerod(&zRight[6]); 1499 sqlite3_activate_cerod(&zRight[6]);
1391 } 1500 }
1392 #endif 1501 #endif
1393 }else 1502 }else
1394 #endif 1503 #endif
1395 1504
1396 1505
1397 {/* Empty ELSE clause */} 1506 {/* Empty ELSE clause */}
1398 1507
1399 /* Code an OP_Expire at the end of each PRAGMA program to cause
1400 ** the VDBE implementing the pragma to expire. Most (all?) pragmas
1401 ** are only valid for a single execution.
1402 */
1403 sqlite3VdbeAddOp2(v, OP_Expire, 1, 0);
1404
1405 /* 1508 /*
1406 ** Reset the safety level, in case the fullfsync flag or synchronous 1509 ** Reset the safety level, in case the fullfsync flag or synchronous
1407 ** setting changed. 1510 ** setting changed.
1408 */ 1511 */
1409 #ifndef SQLITE_OMIT_PAGER_PRAGMAS 1512 #ifndef SQLITE_OMIT_PAGER_PRAGMAS
1410 if( db->autoCommit ){ 1513 if( db->autoCommit ){
1411 sqlite3BtreeSetSafetyLevel(pDb->pBt, pDb->safety_level, 1514 sqlite3BtreeSetSafetyLevel(pDb->pBt, pDb->safety_level,
1412 (db->flags&SQLITE_FullFSync)!=0); 1515 (db->flags&SQLITE_FullFSync)!=0,
1516 (db->flags&SQLITE_CkptFullFSync)!=0);
1413 } 1517 }
1414 #endif 1518 #endif
1415 pragma_out: 1519 pragma_out:
1416 sqlite3DbFree(db, zLeft); 1520 sqlite3DbFree(db, zLeft);
1417 sqlite3DbFree(db, zRight); 1521 sqlite3DbFree(db, zRight);
1418 } 1522 }
1419 1523
1420 #endif /* SQLITE_OMIT_PRAGMA */ 1524 #endif /* SQLITE_OMIT_PRAGMA */
OLDNEW
« no previous file with comments | « third_party/sqlite/src/src/pcache1.c ('k') | third_party/sqlite/src/src/prepare.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698