Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Minor optimizations in the pragma module. (CVS 2029) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
63efd50a1608eb4ccac44a233c0f77c3 |
User & Date: | drh 2004-10-25 20:33:44.000 |
Context
2004-10-26
| ||
00:08 | Fix a bug in the ".databases" command of the command-line shell. Ticket #973 (CVS 2030) (check-in: 507d8e6f5c user: drh tags: trunk) | |
2004-10-25
| ||
20:33 | Minor optimizations in the pragma module. (CVS 2029) (check-in: 63efd50a16 user: drh tags: trunk) | |
2004-10-23
| ||
05:10 | Tighter encoding of the keyword hash table in the tokenizer. (CVS 2028) (check-in: 7b9886f8d4 user: drh tags: trunk) | |
Changes
Changes to mkopcodeh.awk.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #!/usr/bin/awk -f # # This AWK script scans a concatenation of the parse.h output file from the # parser and the vdbe.c source file in order to generate the opcodes numbers # for all opcodes. # # The lines of the vdbe.c that we are interested in are of the form: # # case OP_aaaa: /* same as TK_bbbbb */ # # The TK_ comment is optional. If it is present, then the value assigned to # the OP_ is the same as the TK_ value. If missing, the OP_ value is assigned # a small integer that is different from every other OP_ value. # # Remember the TK_ values from the parse.h file /^#define TK_/ { tk[$2] = $3 } | > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #!/usr/bin/awk -f # # Generate the file opcodes.h. # # This AWK script scans a concatenation of the parse.h output file from the # parser and the vdbe.c source file in order to generate the opcodes numbers # for all opcodes. # # The lines of the vdbe.c that we are interested in are of the form: # # case OP_aaaa: /* same as TK_bbbbb */ # # The TK_ comment is optional. If it is present, then the value assigned to # the OP_ is the same as the TK_ value. If missing, the OP_ value is assigned # a small integer that is different from every other OP_ value. # # We go to the trouble of making some OP_ value the same as TK_ values # as an optimization. During parsing, things like expression operators # are coded with TK_ values such as TK_ADD, TK_DIVIDE, and so forth. Later # during code generation, we need to generate corresponding opcodes like # OP_Add and OP_Divide. By making TK_ADD==OP_Add and TK_DIVIDE==OP_Divide, # code to translation from one to the other is avoided. This makes the # code generator run (infinitesimally) faster and more importantly it makes # the total library smaller. # # Remember the TK_ values from the parse.h file /^#define TK_/ { tk[$2] = $3 } |
︙ | ︙ |
Changes to src/pragma.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* ** 2003 April 6 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains code used to implement the PRAGMA command. ** | | < < < < < < < < < < < < < < < < | > | | < | | < < < < < < < | | < > | > | > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | /* ** 2003 April 6 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains code used to implement the PRAGMA command. ** ** $Id: pragma.c,v 1.72 2004/10/25 20:33:44 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) # include "pager.h" # include "btree.h" #endif /* ** Interpret the given string as a safety level. Return 0 for OFF, ** 1 for ON or NORMAL and 2 for FULL. Return 1 for an empty or ** unrecognized string argument. ** ** Note that the values returned are one less that the values that ** should be passed into sqlite3BtreeSetSafetyLevel(). The is done ** to support legacy SQL code. The safety level used to be boolean ** and older scripts may have used numbers 0 for OFF and 1 for ON. */ static int getSafetyLevel(const u8 *z){ /* 123456789 123456789 */ static const char zText[] = "onoffalseyestruefull"; static const u8 iOffset[] = {0, 1, 2, 4, 9, 12, 16}; static const u8 iLength[] = {2, 2, 3, 5, 3, 4, 4}; static const u8 iValue[] = {1, 0, 0, 0, 1, 1, 2}; int i, n; if( isdigit(*z) ){ return atoi(z); } n = strlen(z); for(i=0; i<sizeof(iLength); i++){ if( iLength[i]==n && sqlite3StrNICmp(&zText[iOffset[i]],z,n)==0 ){ return iValue[i]; } } return 1; } /* ** Interpret the given string as a boolean value. */ static int getBoolean(const u8 *z){ return getSafetyLevel(z)&1; } /* ** Interpret the given string as a temp db location. Return 1 for file ** backed temporary databases, 2 for the Red-Black tree in memory database ** and 0 to use the compile-time default. */ static int getTempStore(const char *z){ |
︙ | ︙ | |||
126 127 128 129 130 131 132 | /* ** Check to see if zRight and zLeft refer to a pragma that queries ** or changes one of the flags in db->flags. Return 1 if so and 0 if not. ** Also, implement the pragma. */ static int flagPragma(Parse *pParse, const char *zLeft, const char *zRight){ | | | > | | | < | | | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | /* ** Check to see if zRight and zLeft refer to a pragma that queries ** or changes one of the flags in db->flags. Return 1 if so and 0 if not. ** Also, implement the pragma. */ static int flagPragma(Parse *pParse, const char *zLeft, const char *zRight){ static const struct sPragmaType { const char *zName; /* Name of the pragma */ int mask; /* Mask for the db->flags value */ } aPragma[] = { { "vdbe_trace", SQLITE_VdbeTrace }, { "sql_trace", SQLITE_SqlTrace }, { "vdbe_listing", SQLITE_VdbeListing }, { "full_column_names", SQLITE_FullColNames }, { "short_column_names", SQLITE_ShortColNames }, { "count_changes", SQLITE_CountRows }, { "empty_result_callbacks", SQLITE_NullCallback }, /* The following is VERY experimental */ { "writable_schema", SQLITE_WriteSchema }, }; int i; const struct sPragmaType *p; for(i=0, p=aPragma; i<sizeof(aPragma)/sizeof(aPragma[0]); i++, p++){ if( sqlite3StrICmp(zLeft, p->zName)==0 ){ sqlite3 *db = pParse->db; Vdbe *v; if( zRight==0 ){ v = sqlite3GetVdbe(pParse); if( v ){ returnSingleInt(pParse, p->zName, (db->flags & p->mask)!=0 ); } }else if( getBoolean(zRight) ){ db->flags |= p->mask; }else{ db->flags &= ~p->mask; } return 1; } } return 0; } |
︙ | ︙ |