-C More\scode\scleanup\sand\ssize\sreduction.\s(CVS\s1256)
-D 2004-02-21T13:31:10
+C Flag\spragmas\slike\svdbe_trace\snow\sreturn\stheir\scurrent\ssetting\sif\sthey\nare\scalled\swith\sno\sarguments.\s(CVS\s1257)
+D 2004-02-21T14:00:29
F Makefile.in cfd75c46b335881999333a9e4b982fa8491f200b
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
F src/pager.c 29ddad4dd454f0aaa98e2bcd327710ab9f02f833
F src/pager.h 82332878799280145639a48d88cdb4058925e3f6
F src/parse.y 226bbdba2dee362d4b1cacc424bd82f7740071ee
-F src/pragma.c dab17a6093fc249c0faf93c7b65dccc056fec7fb
+F src/pragma.c a8d43661193ba3114da787f43969d0a34f0ed07c
F src/printf.c ef1838bd06246d5d323600dc592d337b1c0762b0
F src/random.c 775913e0b7fbd6295d21f12a7bd35b46387c44b2
F src/select.c 9a41dace754f0dab5e991e402c05fa3c24d04f19
F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P ffa971934867b6bbe943c004154d5f161e0ea697
-R 3a6c0549c38d90190c4b2bf7000765c4
+P 8e3eda2a909bd80b2b14ace36ab44303750a4409
+R a43c4de14dbe7097b5ca3dff718096d1
U drh
-Z dede23b0f1723cf1feddae3af208c31d
+Z 74241342cf04355015de5f00644a1b7e
*************************************************************************
** This file contains code used to implement the PRAGMA command.
**
-** $Id: pragma.c,v 1.16 2004/02/21 13:31:10 drh Exp $
+** $Id: pragma.c,v 1.17 2004/02/21 14:00:29 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
/*
** Interpret the given string as a boolean value.
*/
-static int getBoolean(char *z){
+static int getBoolean(const char *z){
static char *azTrue[] = { "yes", "on", "true" };
int i;
if( z[0]==0 ) return 0;
}
}
+/*
+** 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 {
+ const char *zName; /* Name of the pragma */
+ int mask; /* Mask for the db->flags value */
+ } aPragma[] = {
+ { "vdbe_trace", SQLITE_VdbeTrace },
+ { "full_column_names", SQLITE_FullColNames },
+ { "short_column_names", SQLITE_ShortColNames },
+ { "show_datatypes", SQLITE_ReportTypes },
+ { "count_changes", SQLITE_CountRows },
+ { "empty_result_callbacks", SQLITE_NullCallback },
+ };
+ int i;
+ for(i=0; i<sizeof(aPragma)/sizeof(aPragma[0]); i++){
+ if( sqliteStrICmp(zLeft, aPragma[i].zName)==0 ){
+ sqlite *db = pParse->db;
+ Vdbe *v;
+ if( strcmp(zLeft,zRight)==0 && (v = sqliteGetVdbe(pParse))!=0 ){
+ sqliteVdbeAddOp(v, OP_ColumnName, 0, 1);
+ sqliteVdbeChangeP3(v, -1, aPragma[i].zName, P3_STATIC);
+ sqliteVdbeAddOp(v, OP_ColumnName, 1, 0);
+ sqliteVdbeChangeP3(v, -1, "boolean", P3_STATIC);
+ sqliteVdbeAddOp(v, OP_Integer, (db->flags & aPragma[i].mask)!=0, 0);
+ sqliteVdbeAddOp(v, OP_Callback, 1, 0);
+ }else if( getBoolean(zRight) ){
+ db->flags |= aPragma[i].mask;
+ }else{
+ db->flags &= ~aPragma[i].mask;
+ }
+ return 1;
+ }
+ }
+ return 0;
+}
+
/*
** Process a pragma statement.
**
}
}else
+#ifndef NDEBUG
if( sqliteStrICmp(zLeft, "trigger_overhead_test")==0 ){
if( getBoolean(zRight) ){
always_code_trigger_setup = 1;
always_code_trigger_setup = 0;
}
}else
+#endif
- if( sqliteStrICmp(zLeft, "vdbe_trace")==0 ){
- if( getBoolean(zRight) ){
- db->flags |= SQLITE_VdbeTrace;
- }else{
- db->flags &= ~SQLITE_VdbeTrace;
- }
- }else
-
- if( sqliteStrICmp(zLeft, "full_column_names")==0 ){
- if( getBoolean(zRight) ){
- db->flags |= SQLITE_FullColNames;
- }else{
- db->flags &= ~SQLITE_FullColNames;
- }
- }else
-
- if( sqliteStrICmp(zLeft, "short_column_names")==0 ){
- if( getBoolean(zRight) ){
- db->flags |= SQLITE_ShortColNames;
- }else{
- db->flags &= ~SQLITE_ShortColNames;
- }
- }else
-
- if( sqliteStrICmp(zLeft, "show_datatypes")==0 ){
- if( getBoolean(zRight) ){
- db->flags |= SQLITE_ReportTypes;
- }else{
- db->flags &= ~SQLITE_ReportTypes;
- }
- }else
-
- if( sqliteStrICmp(zLeft, "count_changes")==0 ){
- if( getBoolean(zRight) ){
- db->flags |= SQLITE_CountRows;
- }else{
- db->flags &= ~SQLITE_CountRows;
- }
- }else
-
- if( sqliteStrICmp(zLeft, "empty_result_callbacks")==0 ){
- if( getBoolean(zRight) ){
- db->flags |= SQLITE_NullCallback;
- }else{
- db->flags &= ~SQLITE_NullCallback;
- }
+ if( flagPragma(pParse, zLeft, zRight) ){
+ /* The flagPragma() call also generates any necessary code */
}else
if( sqliteStrICmp(zLeft, "table_info")==0 ){