-C Tighter\sencoding\sof\sthe\skeyword\shash\stable\sin\sthe\stokenizer.\s(CVS\s2028)
-D 2004-10-23T05:10:18
+C Minor\soptimizations\sin\sthe\spragma\smodule.\s(CVS\s2029)
+D 2004-10-25T20:33:44
F Makefile.in 52c1cc106cad9148d4b7cb387b458e82dc86b339
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1
F main.mk bf65bb9f839aa8777796c9846816be590a7cd4b0
F mkdll.sh 468d4f41d3ea98221371df4825cfbffbaac4d7e4
F mkopcodec.awk 80311cdeb16d78017cc62e4ad6c6d008e5fe0e17
-F mkopcodeh.awk 877459a51b4c75a99d7336159790aca51e4c2cad
+F mkopcodeh.awk 4090944e4de0a2ccb99aa0083290f73bce4db406
F mkso.sh 7b67da1d63070875ba948e749aee9ef50ce36e3d
F publish.sh 72bde067dda3fc2d33e92f20253b924e3b97da30
F spec.template b2f6c4e488cbc3b993a57deba22cbc36203c4da3
F src/pager.c cc2e7fb3d7913862d7b1170f923d2dcfdbac3bed
F src/pager.h 774d1973acbda341827d21b0da0150575d69f7d9
F src/parse.y 8d97a91cba7e35b5eaac064c9f6e597dc6442b29
-F src/pragma.c 2b65e0150ca1af8041c3db95e7b1c41dc51a3e95
+F src/pragma.c 263e20f7640df1e7937f1c71372fa286356aaf09
F src/printf.c 7a92adc00b758cd5ce087dae80181a8bbdb70ed2
F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
F src/select.c de51ec24aef0d5370819dac6c2613460effac42c
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
F www/whentouse.tcl fdacb0ba2d39831e8a6240d05a490026ad4c4e4c
-P 39f7870a54d90d5163fcad3f08cd63699c4bb567
-R f3fcd5be76f79a1c63d8d5fffbad49dd
+P 7b9886f8d4db366bc7dbf25495f0d3b907d25689
+R e866ede2f03d84f2dce38e1442866c10
U drh
-Z 91960f90f1e7a02a6b795447e3b7377d
+Z 5a8b8e324cda1249d7cb76835accaa40
#!/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 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_/ {
*************************************************************************
** 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 <ctype.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; i<sizeof(azTrue)/sizeof(azTrue[0]); i++){
- if( sqlite3StrICmp(z,azTrue[i])==0 ) return 1;
- }
- return 0;
-}
-
/*
** 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
** 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(u8 *z){
- static const struct {
- const u8 *zWord;
- int val;
- } aKey[] = {
- { "no", 0 },
- { "off", 0 },
- { "false", 0 },
- { "yes", 1 },
- { "on", 1 },
- { "true", 1 },
- { "full", 2 },
- };
- int i;
- if( z[0]==0 ) return 1;
- if( sqlite3IsNumber(z, 0, SQLITE_UTF8) ){
+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);
}
- for(i=0; i<sizeof(aKey)/sizeof(aKey[0]); i++){
- if( sqlite3StrICmp(z,aKey[i].zWord)==0 ) return aKey[i].val;
+ 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
** 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[] = {
{ "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; i<sizeof(aPragma)/sizeof(aPragma[0]); i++){
- if( sqlite3StrICmp(zLeft, aPragma[i].zName)==0 ){
+ 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,
- 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;
}