Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(73)

Delta Between Two Patch Sets: third_party/sqlite_google/src/pragma.c

Issue 924: sqlite3 pragma get/set user_version implemented (Closed) SVN Base: http://google-gears.googlecode.com/svn/contrib/dimitri.glazkov/database2/gears/
Left Patch Set: Removed starting a transaction, just report SQLITE_MISUSE now. Created 2 months, 3 weeks ago
Right Patch Set: moved code to btree.c, restructured Created 3 months, 1 week ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
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 ** 13 **
14 ** $Id: pragma.c,v 1.139 2007/05/23 13:50:24 danielk1977 Exp $ 14 ** $Id: pragma.c,v 1.139 2007/05/23 13:50:24 danielk1977 Exp $
15 */ 15 */
16 #include "sqliteInt.h" 16 #include "sqliteInt.h"
17 #include "os.h" 17 #include "os.h"
18 #include <ctype.h> 18 #include <ctype.h>
19 19
20 /* Ignore this whole file if pragmas are disabled 20 /* Ignore this whole file if pragmas are disabled
21 */ 21 */
22 #if !defined(SQLITE_OMIT_PRAGMA) && !defined(SQLITE_OMIT_PARSER) 22 #if !defined(SQLITE_OMIT_PRAGMA) && !defined(SQLITE_OMIT_PARSER)
23 23
24 #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) 24 #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
25 # include "pager.h" 25 # include "pager.h"
26 # include "btree.h" 26 # include "btree.h"
27 #endif 27 #endif
28 28
29 /* 29 /*
30 ** Interpret the given string as a safety level. Return 0 for OFF, 30 ** Interpret the given string as a safety level. Return 0 for OFF,
31 ** 1 for ON or NORMAL and 2 for FULL. Return 1 for an empty or 31 ** 1 for ON or NORMAL and 2 for FULL. Return 1 for an empty or
32 ** unrecognized string argument. 32 ** unrecognized string argument.
33 ** 33 **
34 ** Note that the values returned are one less that the values that 34 ** Note that the values returned are one less that the values that
35 ** should be passed into sqlite3BtreeSetSafetyLevel(). The is done 35 ** should be passed into sqlite3BtreeSetSafetyLevel(). The is done
36 ** to support legacy SQL code. The safety level used to be boolean 36 ** to support legacy SQL code. The safety level used to be boolean
37 ** and older scripts may have used numbers 0 for OFF and 1 for ON. 37 ** and older scripts may have used numbers 0 for OFF and 1 for ON.
38 */ 38 */
39 static int getSafetyLevel(const char *z){ 39 static int getSafetyLevel(const char *z){
40 /* 123456789 123456789 */ 40 /* 123456789 123456789 */
41 static const char zText[] = "onoffalseyestruefull"; 41 static const char zText[] = "onoffalseyestruefull";
42 static const u8 iOffset[] = {0, 1, 2, 4, 9, 12, 16}; 42 static const u8 iOffset[] = {0, 1, 2, 4, 9, 12, 16};
43 static const u8 iLength[] = {2, 2, 3, 5, 3, 4, 4}; 43 static const u8 iLength[] = {2, 2, 3, 5, 3, 4, 4};
44 static const u8 iValue[] = {1, 0, 0, 0, 1, 1, 2}; 44 static const u8 iValue[] = {1, 0, 0, 0, 1, 1, 2};
45 int i, n; 45 int i, n;
46 if( isdigit(*z) ){ 46 if( isdigit(*z) ){
47 return atoi(z); 47 return atoi(z);
48 } 48 }
49 n = strlen(z); 49 n = strlen(z);
50 for(i=0; i<sizeof(iLength); i++){ 50 for(i=0; i<sizeof(iLength); i++){
(...skipping 1035 matching lines...) Show 10 above Show 10 below
1086 #endif 1086 #endif
1087 1087
1088 #if SQLITE_HAS_CODEC 1088 #if SQLITE_HAS_CODEC
1089 if( sqlite3StrICmp(zLeft, "key")==0 ){ 1089 if( sqlite3StrICmp(zLeft, "key")==0 ){
1090 sqlite3_key(db, zRight, strlen(zRight)); 1090 sqlite3_key(db, zRight, strlen(zRight));
1091 }else 1091 }else
1092 #endif 1092 #endif
1093 #if SQLITE_HAS_CODEC || defined(SQLITE_ENABLE_CEROD) 1093 #if SQLITE_HAS_CODEC || defined(SQLITE_ENABLE_CEROD)
1094 if( sqlite3StrICmp(zLeft, "activate_extensions")==0 ){ 1094 if( sqlite3StrICmp(zLeft, "activate_extensions")==0 ){
1095 #if SQLITE_HAS_CODEC 1095 #if SQLITE_HAS_CODEC
1096 if( sqlite3StrNICmp(zRight, "see-", 4)==0 ){ 1096 if( sqlite3StrNICmp(zRight, "see-", 4)==0 ){
1097 extern void sqlite3_activate_see(const char*); 1097 extern void sqlite3_activate_see(const char*);
1098 sqlite3_activate_see(&zRight[4]); 1098 sqlite3_activate_see(&zRight[4]);
1099 } 1099 }
1100 #endif 1100 #endif
1101 #ifdef SQLITE_ENABLE_CEROD 1101 #ifdef SQLITE_ENABLE_CEROD
1102 if( sqlite3StrNICmp(zRight, "cerod-", 6)==0 ){ 1102 if( sqlite3StrNICmp(zRight, "cerod-", 6)==0 ){
1103 extern void sqlite3_activate_cerod(const char*); 1103 extern void sqlite3_activate_cerod(const char*);
1104 sqlite3_activate_cerod(&zRight[6]); 1104 sqlite3_activate_cerod(&zRight[6]);
1105 } 1105 }
1106 #endif 1106 #endif
1107 } 1107 }
1108 #endif 1108 #endif
1109 1109
1110 {} 1110 {}
1111 1111
1112 if( v ){ 1112 if( v ){
1113 /* Code an OP_Expire at the end of each PRAGMA program to cause 1113 /* Code an OP_Expire at the end of each PRAGMA program to cause
1114 ** the VDBE implementing the pragma to expire. Most (all?) pragmas 1114 ** the VDBE implementing the pragma to expire. Most (all?) pragmas
1115 ** are only valid for a single execution. 1115 ** are only valid for a single execution.
1116 */ 1116 */
1117 sqlite3VdbeAddOp(v, OP_Expire, 1, 0); 1117 sqlite3VdbeAddOp(v, OP_Expire, 1, 0);
1118 1118
1119 /* 1119 /*
1120 ** Reset the safety level, in case the fullfsync flag or synchronous 1120 ** Reset the safety level, in case the fullfsync flag or synchronous
1121 ** setting changed. 1121 ** setting changed.
1122 */ 1122 */
1123 #ifndef SQLITE_OMIT_PAGER_PRAGMAS 1123 #ifndef SQLITE_OMIT_PAGER_PRAGMAS
1124 if( db->autoCommit ){ 1124 if( db->autoCommit ){
1125 sqlite3BtreeSetSafetyLevel(pDb->pBt, pDb->safety_level, 1125 sqlite3BtreeSetSafetyLevel(pDb->pBt, pDb->safety_level,
1126 (db->flags&SQLITE_FullFSync)!=0); 1126 (db->flags&SQLITE_FullFSync)!=0);
1127 } 1127 }
1128 #endif 1128 #endif
1129 } 1129 }
1130 pragma_out: 1130 pragma_out:
1131 sqliteFree(zLeft); 1131 sqliteFree(zLeft);
1132 sqliteFree(zRight); 1132 sqliteFree(zRight);
1133 } 1133 }
1134 1134
1135 #endif /* SQLITE_OMIT_PRAGMA || SQLITE_OMIT_PARSER */ 1135 #endif /* SQLITE_OMIT_PRAGMA || SQLITE_OMIT_PARSER */
LEFTRIGHT

Powered by Google App Engine
This is Rietveld r292