Index: mkopcodeh.awk ================================================================== --- mkopcodeh.awk +++ mkopcodeh.awk @@ -1,6 +1,8 @@ #!/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. # @@ -9,10 +11,19 @@ # 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 Index: src/pragma.c ================================================================== --- src/pragma.c +++ src/pragma.c @@ -9,36 +9,20 @@ ** 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.71 2004/10/22 20:29:22 drh Exp $ +** $Id: pragma.c,v 1.72 2004/10/25 20:33:44 drh Exp $ */ #include "sqliteInt.h" #include #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) # include "pager.h" # include "btree.h" #endif -/* -** Interpret the given string as a boolean value. -*/ -static int getBoolean(const u8 *z){ - static const u8 *azTrue[] = { "yes", "on", "true" }; - int i; - if( z[0]==0 ) return 0; - if( sqlite3IsNumber(z, 0, SQLITE_UTF8) ){ - return atoi(z); - } - for(i=0; iflags. 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 { + 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 }, @@ -139,28 +125,28 @@ { "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 */ + /* The following is VERY experimental */ { "writable_schema", SQLITE_WriteSchema }, }; int i; - for(i=0; izName)==0 ){ sqlite3 *db = pParse->db; Vdbe *v; if( zRight==0 ){ v = sqlite3GetVdbe(pParse); if( v ){ - returnSingleInt(pParse, - aPragma[i].zName, (db->flags&aPragma[i].mask)!=0); + returnSingleInt(pParse, p->zName, (db->flags & p->mask)!=0 ); } }else if( getBoolean(zRight) ){ - db->flags |= aPragma[i].mask; + db->flags |= p->mask; }else{ - db->flags &= ~aPragma[i].mask; + db->flags &= ~p->mask; } return 1; } } return 0;