Rework the PRAGMA implementation to only call sqlite3ReadSchema() from a single

place, based on a flag in the pragma table, rather than separately from each
case which needs the schema.

FossilOrigin-Name: 8338232a111be16d6c2ab57176d0a23a001f02ad
This commit is contained in:
drh 2013-10-03 14:08:07 +00:00
parent 46539d7cfa
commit f63936e805
4 changed files with 351 additions and 166 deletions

View File

@ -1,5 +1,5 @@
C Return\san\serror\sif\san\sattempt\sis\smade\sto\screate\sa\strigger\swith\san\sSQL\svariable\sembedded\swithin\sit.\sIf\ssuch\sa\svariable\sreference\sis\sfound\swithin\sa\strigger\sdefinition\sloaded\sfrom\sthe\ssqlite_master\stable,\ssilently\sreplace\sit\swith\sa\sNULL.
D 2013-10-03T12:29:38.279
C Rework\sthe\sPRAGMA\simplementation\sto\sonly\scall\ssqlite3ReadSchema()\sfrom\sa\ssingle\nplace,\sbased\son\sa\sflag\sin\sthe\spragma\stable,\srather\sthan\sseparately\sfrom\seach\ncase\swhich\sneeds\sthe\sschema.
D 2013-10-03T14:08:07.579
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -210,7 +210,7 @@ F src/parse.y a97566d6da75075589a7c716d1bda14b586cf8da
F src/pcache.c f8043b433a57aba85384a531e3937a804432a346
F src/pcache.h a5e4f5d9f5d592051d91212c5949517971ae6222
F src/pcache1.c a467393909a4ed7ca9de066d85ba5c5b04a5be63
F src/pragma.c 0c7a67a75cb4f9849190f33f62534d37f38ff8ed
F src/pragma.c 5a4d8d9c3c7d22ef920487a260ea3d4b59d3b3a6
F src/prepare.c fa6988589f39af8504a61731614cd4f6ae71554f
F src/printf.c da9119eb31a187a4b99f60aa4a225141c0ebb74b
F src/random.c 0b2dbc37fdfbfa6bd455b091dfcef5bdb32dba68
@ -1086,7 +1086,7 @@ F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc
F tool/mkautoconfamal.sh f8d8dbf7d62f409ebed5134998bf5b51d7266383
F tool/mkkeywordhash.c bb52064aa614e1426445e4b2b9b00eeecd23cc79
F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e
F tool/mkpragmatab.tcl e24da1496b4af6de448e9673cf6adbef53e6e830
F tool/mkpragmatab.tcl 33fa7a6e824b14f7b04109ed75b19f3e9e228412
F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
F tool/mksqlite3c-noext.tcl 8bce31074e4cbe631bb7676526a048335f4c9f02
F tool/mksqlite3c.tcl d344cc3144a0271cd853c5e3df36e9f31d78d619
@ -1119,7 +1119,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
P eec3187bc68ddebdbc2113f77c7f5cd32e9be61f
R bcf82dacad10da610aa03ba9f5dccbf3
U dan
Z 81b7035f34aeb81458a978a9137553b8
P f35f6ae3da77dbdf5f7a4a9927475659fc6e0ca6
R 7c202bdb865ce04d0b0e729a78eddfa4
U drh
Z ea56288271c03042a253b9d48679c21a

View File

@ -1 +1 @@
f35f6ae3da77dbdf5f7a4a9927475659fc6e0ca6
8338232a111be16d6c2ab57176d0a23a001f02ad

View File

@ -68,175 +68,353 @@
#define PragTyp_REKEY 37
#define PragTyp_LOCK_STATUS 38
#define PragTyp_PARSER_TRACE 39
#define PragFlag_NeedSchema 0x01
static const struct sPragmaNames {
const char *const zName; /* Name of pragma */
u8 ePragTyp; /* PragTyp_XXX value */
u8 mPragFlag; /* Zero or more PragFlag_XXX values */
u32 iArg; /* Extra argument */
} aPragmaNames[] = {
#if defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)
{ "activate_extensions", PragTyp_ACTIVATE_EXTENSIONS, 0 },
{ /* zName: */ "activate_extensions",
/* ePragTyp: */ PragTyp_ACTIVATE_EXTENSIONS,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
{ "application_id", PragTyp_HEADER_VALUE, 0 },
{ /* zName: */ "application_id",
/* ePragTyp: */ PragTyp_HEADER_VALUE,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_AUTOVACUUM)
{ "auto_vacuum", PragTyp_AUTO_VACUUM, 0 },
{ /* zName: */ "auto_vacuum",
/* ePragTyp: */ PragTyp_AUTO_VACUUM,
/* ePragFlag: */ PragFlag_NeedSchema,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_AUTOMATIC_INDEX)
{ "automatic_index", PragTyp_FLAG,
SQLITE_AutoIndex },
{ /* zName: */ "automatic_index",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlag: */ 0,
/* iArg: */ SQLITE_AutoIndex },
#endif
{ "busy_timeout", PragTyp_BUSY_TIMEOUT, 0 },
{ /* zName: */ "busy_timeout",
/* ePragTyp: */ PragTyp_BUSY_TIMEOUT,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
{ "cache_size", PragTyp_CACHE_SIZE, 0 },
{ /* zName: */ "cache_size",
/* ePragTyp: */ PragTyp_CACHE_SIZE,
/* ePragFlag: */ PragFlag_NeedSchema,
/* iArg: */ 0 },
#endif
{ "cache_spill", PragTyp_FLAG,
SQLITE_CacheSpill },
{ "case_sensitive_like", PragTyp_CASE_SENSITIVE_LIKE, 0 },
{ "checkpoint_fullfsync", PragTyp_FLAG,
SQLITE_CkptFullFSync },
{ /* zName: */ "cache_spill",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlag: */ 0,
/* iArg: */ SQLITE_CacheSpill },
{ /* zName: */ "case_sensitive_like",
/* ePragTyp: */ PragTyp_CASE_SENSITIVE_LIKE,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
{ /* zName: */ "checkpoint_fullfsync",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlag: */ 0,
/* iArg: */ SQLITE_CkptFullFSync },
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
{ "collation_list", PragTyp_COLLATION_LIST, 0 },
{ /* zName: */ "collation_list",
/* ePragTyp: */ PragTyp_COLLATION_LIST,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
{ "compile_options", PragTyp_COMPILE_OPTIONS, 0 },
{ /* zName: */ "compile_options",
/* ePragTyp: */ PragTyp_COMPILE_OPTIONS,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
#endif
{ "count_changes", PragTyp_FLAG,
SQLITE_CountRows },
{ /* zName: */ "count_changes",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlag: */ 0,
/* iArg: */ SQLITE_CountRows },
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_OS_WIN
{ "data_store_directory", PragTyp_DATA_STORE_DIRECTORY, 0 },
{ /* zName: */ "data_store_directory",
/* ePragTyp: */ PragTyp_DATA_STORE_DIRECTORY,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
{ "database_list", PragTyp_DATABASE_LIST, 0 },
{ /* zName: */ "database_list",
/* ePragTyp: */ PragTyp_DATABASE_LIST,
/* ePragFlag: */ PragFlag_NeedSchema,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
{ "default_cache_size", PragTyp_DEFAULT_CACHE_SIZE, 0 },
{ /* zName: */ "default_cache_size",
/* ePragTyp: */ PragTyp_DEFAULT_CACHE_SIZE,
/* ePragFlag: */ PragFlag_NeedSchema,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
{ "defer_foreign_keys", PragTyp_FLAG,
SQLITE_DeferFKs },
{ /* zName: */ "defer_foreign_keys",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlag: */ 0,
/* iArg: */ SQLITE_DeferFKs },
#endif
{ "empty_result_callbacks", PragTyp_FLAG,
SQLITE_NullCallback },
{ /* zName: */ "empty_result_callbacks",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlag: */ 0,
/* iArg: */ SQLITE_NullCallback },
#if !defined(SQLITE_OMIT_UTF16)
{ "encoding", PragTyp_ENCODING, 0 },
{ /* zName: */ "encoding",
/* ePragTyp: */ PragTyp_ENCODING,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
{ "foreign_key_check", PragTyp_FOREIGN_KEY_CHECK, 0 },
{ /* zName: */ "foreign_key_check",
/* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK,
/* ePragFlag: */ PragFlag_NeedSchema,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_FOREIGN_KEY)
{ "foreign_key_list", PragTyp_FOREIGN_KEY_LIST, 0 },
{ /* zName: */ "foreign_key_list",
/* ePragTyp: */ PragTyp_FOREIGN_KEY_LIST,
/* ePragFlag: */ PragFlag_NeedSchema,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
{ "foreign_keys", PragTyp_FLAG,
SQLITE_ForeignKeys },
{ /* zName: */ "foreign_keys",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlag: */ 0,
/* iArg: */ SQLITE_ForeignKeys },
#endif
#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
{ "freelist_count", PragTyp_HEADER_VALUE, 0 },
{ /* zName: */ "freelist_count",
/* ePragTyp: */ PragTyp_HEADER_VALUE,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
#endif
{ "full_column_names", PragTyp_FLAG,
SQLITE_FullColNames },
{ "fullfsync", PragTyp_FLAG,
SQLITE_FullFSync },
{ /* zName: */ "full_column_names",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlag: */ 0,
/* iArg: */ SQLITE_FullColNames },
{ /* zName: */ "fullfsync",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlag: */ 0,
/* iArg: */ SQLITE_FullFSync },
#if defined(SQLITE_HAS_CODEC)
{ "hexkey", PragTyp_HEXKEY, 0 },
{ /* zName: */ "hexkey",
/* ePragTyp: */ PragTyp_HEXKEY,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_CHECK)
{ "ignore_check_constraints", PragTyp_FLAG,
SQLITE_IgnoreChecks },
{ /* zName: */ "ignore_check_constraints",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlag: */ 0,
/* iArg: */ SQLITE_IgnoreChecks },
#endif
#if !defined(SQLITE_OMIT_AUTOVACUUM)
{ "incremental_vacuum", PragTyp_INCREMENTAL_VACUUM, 0 },
{ /* zName: */ "incremental_vacuum",
/* ePragTyp: */ PragTyp_INCREMENTAL_VACUUM,
/* ePragFlag: */ PragFlag_NeedSchema,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
{ "index_info", PragTyp_INDEX_INFO, 0 },
{ "index_list", PragTyp_INDEX_LIST, 0 },
{ /* zName: */ "index_info",
/* ePragTyp: */ PragTyp_INDEX_INFO,
/* ePragFlag: */ PragFlag_NeedSchema,
/* iArg: */ 0 },
{ /* zName: */ "index_list",
/* ePragTyp: */ PragTyp_INDEX_LIST,
/* ePragFlag: */ PragFlag_NeedSchema,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
{ "integrity_check", PragTyp_INTEGRITY_CHECK, 0 },
{ /* zName: */ "integrity_check",
/* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
/* ePragFlag: */ PragFlag_NeedSchema,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
{ "journal_mode", PragTyp_JOURNAL_MODE, 0 },
{ "journal_size_limit", PragTyp_JOURNAL_SIZE_LIMIT, 0 },
{ /* zName: */ "journal_mode",
/* ePragTyp: */ PragTyp_JOURNAL_MODE,
/* ePragFlag: */ PragFlag_NeedSchema,
/* iArg: */ 0 },
{ /* zName: */ "journal_size_limit",
/* ePragTyp: */ PragTyp_JOURNAL_SIZE_LIMIT,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
#endif
#if defined(SQLITE_HAS_CODEC)
{ "key", PragTyp_KEY, 0 },
{ /* zName: */ "key",
/* ePragTyp: */ PragTyp_KEY,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
#endif
{ "legacy_file_format", PragTyp_FLAG,
SQLITE_LegacyFileFmt },
{ /* zName: */ "legacy_file_format",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlag: */ 0,
/* iArg: */ SQLITE_LegacyFileFmt },
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_ENABLE_LOCKING_STYLE
{ "lock_proxy_file", PragTyp_LOCK_PROXY_FILE, 0 },
{ /* zName: */ "lock_proxy_file",
/* ePragTyp: */ PragTyp_LOCK_PROXY_FILE,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
#endif
#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
{ "lock_status", PragTyp_LOCK_STATUS, 0 },
{ /* zName: */ "lock_status",
/* ePragTyp: */ PragTyp_LOCK_STATUS,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
{ "locking_mode", PragTyp_LOCKING_MODE, 0 },
{ "max_page_count", PragTyp_PAGE_COUNT, 0 },
{ "mmap_size", PragTyp_MMAP_SIZE, 0 },
{ "page_count", PragTyp_PAGE_COUNT, 0 },
{ "page_size", PragTyp_PAGE_SIZE, 0 },
{ /* zName: */ "locking_mode",
/* ePragTyp: */ PragTyp_LOCKING_MODE,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
{ /* zName: */ "max_page_count",
/* ePragTyp: */ PragTyp_PAGE_COUNT,
/* ePragFlag: */ PragFlag_NeedSchema,
/* iArg: */ 0 },
{ /* zName: */ "mmap_size",
/* ePragTyp: */ PragTyp_MMAP_SIZE,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
{ /* zName: */ "page_count",
/* ePragTyp: */ PragTyp_PAGE_COUNT,
/* ePragFlag: */ PragFlag_NeedSchema,
/* iArg: */ 0 },
{ /* zName: */ "page_size",
/* ePragTyp: */ PragTyp_PAGE_SIZE,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
#endif
#if defined(SQLITE_DEBUG)
{ "parser_trace", PragTyp_PARSER_TRACE, 0 },
{ /* zName: */ "parser_trace",
/* ePragTyp: */ PragTyp_PARSER_TRACE,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
#endif
{ "query_only", PragTyp_FLAG,
SQLITE_QueryOnly },
{ /* zName: */ "query_only",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlag: */ 0,
/* iArg: */ SQLITE_QueryOnly },
#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
{ "quick_check", PragTyp_INTEGRITY_CHECK, 0 },
{ /* zName: */ "quick_check",
/* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
/* ePragFlag: */ PragFlag_NeedSchema,
/* iArg: */ 0 },
#endif
{ "read_uncommitted", PragTyp_FLAG,
SQLITE_ReadUncommitted },
{ "recursive_triggers", PragTyp_FLAG,
SQLITE_RecTriggers },
{ /* zName: */ "read_uncommitted",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlag: */ 0,
/* iArg: */ SQLITE_ReadUncommitted },
{ /* zName: */ "recursive_triggers",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlag: */ 0,
/* iArg: */ SQLITE_RecTriggers },
#if defined(SQLITE_HAS_CODEC)
{ "rekey", PragTyp_REKEY, 0 },
{ /* zName: */ "rekey",
/* ePragTyp: */ PragTyp_REKEY,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
#endif
{ "reverse_unordered_selects", PragTyp_FLAG,
SQLITE_ReverseOrder },
{ /* zName: */ "reverse_unordered_selects",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlag: */ 0,
/* iArg: */ SQLITE_ReverseOrder },
#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
{ "schema_version", PragTyp_HEADER_VALUE, 0 },
{ /* zName: */ "schema_version",
/* ePragTyp: */ PragTyp_HEADER_VALUE,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
{ "secure_delete", PragTyp_SECURE_DELETE, 0 },
{ /* zName: */ "secure_delete",
/* ePragTyp: */ PragTyp_SECURE_DELETE,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
#endif
{ "short_column_names", PragTyp_FLAG,
SQLITE_ShortColNames },
{ "shrink_memory", PragTyp_SHRINK_MEMORY, 0 },
{ "soft_heap_limit", PragTyp_SOFT_HEAP_LIMIT, 0 },
{ /* zName: */ "short_column_names",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlag: */ 0,
/* iArg: */ SQLITE_ShortColNames },
{ /* zName: */ "shrink_memory",
/* ePragTyp: */ PragTyp_SHRINK_MEMORY,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
{ /* zName: */ "soft_heap_limit",
/* ePragTyp: */ PragTyp_SOFT_HEAP_LIMIT,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
#if defined(SQLITE_DEBUG)
{ "sql_trace", PragTyp_FLAG,
SQLITE_SqlTrace },
{ /* zName: */ "sql_trace",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlag: */ 0,
/* iArg: */ SQLITE_SqlTrace },
#endif
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
{ "synchronous", PragTyp_SYNCHRONOUS, 0 },
{ /* zName: */ "synchronous",
/* ePragTyp: */ PragTyp_SYNCHRONOUS,
/* ePragFlag: */ PragFlag_NeedSchema,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
{ "table_info", PragTyp_TABLE_INFO, 0 },
{ /* zName: */ "table_info",
/* ePragTyp: */ PragTyp_TABLE_INFO,
/* ePragFlag: */ PragFlag_NeedSchema,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
{ "temp_store", PragTyp_TEMP_STORE, 0 },
{ "temp_store_directory", PragTyp_TEMP_STORE_DIRECTORY, 0 },
{ /* zName: */ "temp_store",
/* ePragTyp: */ PragTyp_TEMP_STORE,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
{ /* zName: */ "temp_store_directory",
/* ePragTyp: */ PragTyp_TEMP_STORE_DIRECTORY,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
{ "user_version", PragTyp_HEADER_VALUE, 0 },
{ /* zName: */ "user_version",
/* ePragTyp: */ PragTyp_HEADER_VALUE,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
#endif
#if defined(SQLITE_DEBUG)
{ "vdbe_addoptrace", PragTyp_FLAG,
SQLITE_VdbeAddopTrace },
{ "vdbe_debug", PragTyp_FLAG,
SQLITE_SqlTrace|SQLITE_VdbeListing|SQLITE_VdbeTrace },
{ "vdbe_listing", PragTyp_FLAG,
SQLITE_VdbeListing },
{ "vdbe_trace", PragTyp_FLAG,
SQLITE_VdbeTrace },
{ /* zName: */ "vdbe_addoptrace",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlag: */ 0,
/* iArg: */ SQLITE_VdbeAddopTrace },
{ /* zName: */ "vdbe_debug",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlag: */ 0,
/* iArg: */ SQLITE_SqlTrace|SQLITE_VdbeListing|SQLITE_VdbeTrace },
{ /* zName: */ "vdbe_listing",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlag: */ 0,
/* iArg: */ SQLITE_VdbeListing },
{ /* zName: */ "vdbe_trace",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlag: */ 0,
/* iArg: */ SQLITE_VdbeTrace },
#endif
#if !defined(SQLITE_OMIT_WAL)
{ "wal_autocheckpoint", PragTyp_WAL_AUTOCHECKPOINT, 0 },
{ "wal_checkpoint", PragTyp_WAL_CHECKPOINT, 0 },
{ /* zName: */ "wal_autocheckpoint",
/* ePragTyp: */ PragTyp_WAL_AUTOCHECKPOINT,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
{ /* zName: */ "wal_checkpoint",
/* ePragTyp: */ PragTyp_WAL_CHECKPOINT,
/* ePragFlag: */ PragFlag_NeedSchema,
/* iArg: */ 0 },
#endif
{ "writable_schema", PragTyp_FLAG,
SQLITE_WriteSchema|SQLITE_RecoveryMode },
{ /* zName: */ "writable_schema",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlag: */ 0,
/* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
};
/* Number of pragmas: 55 on by default, 66 total. */
/* End of the automatically generated pragma table.
@ -571,6 +749,11 @@ void sqlite3Pragma(
}
if( lwr>upr ) goto pragma_out;
/* Make sure the database schema is loaded if the pragma requires that */
if( (aPragmaNames[mid].mPragFlag & PragFlag_NeedSchema)!=0 ){
if( sqlite3ReadSchema(pParse) ) goto pragma_out;
}
/* Jump to the appropriate pragma handler */
switch( aPragmaNames[mid].ePragTyp ){
@ -604,7 +787,6 @@ void sqlite3Pragma(
{ OP_ResultRow, 1, 1, 0},
};
int addr;
if( sqlite3ReadSchema(pParse) ) goto pragma_out;
sqlite3VdbeUsesBtree(v, iDb);
if( !zRight ){
sqlite3VdbeSetNumCols(v, 1);
@ -700,7 +882,6 @@ void sqlite3Pragma(
*/
case PragTyp_PAGE_COUNT: {
int iReg;
if( sqlite3ReadSchema(pParse) ) goto pragma_out;
sqlite3CodeVerifySchema(pParse, iDb);
iReg = ++pParse->nMem;
if( sqlite3Tolower(zLeft[0])=='p' ){
@ -773,14 +954,6 @@ void sqlite3Pragma(
int eMode; /* One of the PAGER_JOURNALMODE_XXX symbols */
int ii; /* Loop counter */
/* Force the schema to be loaded on all databases. This causes all
** database files to be opened and the journal_modes set. This is
** necessary because subsequent processing must know if the databases
** are in WAL mode. */
if( sqlite3ReadSchema(pParse) ){
goto pragma_out;
}
sqlite3VdbeSetNumCols(v, 1);
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "journal_mode", SQLITE_STATIC);
@ -846,51 +1019,40 @@ void sqlite3Pragma(
case PragTyp_AUTO_VACUUM: {
Btree *pBt = pDb->pBt;
assert( pBt!=0 );
if( sqlite3ReadSchema(pParse) ){
goto pragma_out;
}
if( !zRight ){
int auto_vacuum;
if( ALWAYS(pBt) ){
auto_vacuum = sqlite3BtreeGetAutoVacuum(pBt);
}else{
auto_vacuum = SQLITE_DEFAULT_AUTOVACUUM;
}
returnSingleInt(pParse, "auto_vacuum", auto_vacuum);
returnSingleInt(pParse, "auto_vacuum", sqlite3BtreeGetAutoVacuum(pBt));
}else{
int eAuto = getAutoVacuum(zRight);
assert( eAuto>=0 && eAuto<=2 );
db->nextAutovac = (u8)eAuto;
if( ALWAYS(eAuto>=0) ){
/* Call SetAutoVacuum() to set initialize the internal auto and
** incr-vacuum flags. This is required in case this connection
** creates the database file. It is important that it is created
** as an auto-vacuum capable db.
/* Call SetAutoVacuum() to set initialize the internal auto and
** incr-vacuum flags. This is required in case this connection
** creates the database file. It is important that it is created
** as an auto-vacuum capable db.
*/
rc = sqlite3BtreeSetAutoVacuum(pBt, eAuto);
if( rc==SQLITE_OK && (eAuto==1 || eAuto==2) ){
/* When setting the auto_vacuum mode to either "full" or
** "incremental", write the value of meta[6] in the database
** file. Before writing to meta[6], check that meta[3] indicates
** that this really is an auto-vacuum capable database.
*/
rc = sqlite3BtreeSetAutoVacuum(pBt, eAuto);
if( rc==SQLITE_OK && (eAuto==1 || eAuto==2) ){
/* When setting the auto_vacuum mode to either "full" or
** "incremental", write the value of meta[6] in the database
** file. Before writing to meta[6], check that meta[3] indicates
** that this really is an auto-vacuum capable database.
*/
static const VdbeOpList setMeta6[] = {
{ OP_Transaction, 0, 1, 0}, /* 0 */
{ OP_ReadCookie, 0, 1, BTREE_LARGEST_ROOT_PAGE},
{ OP_If, 1, 0, 0}, /* 2 */
{ OP_Halt, SQLITE_OK, OE_Abort, 0}, /* 3 */
{ OP_Integer, 0, 1, 0}, /* 4 */
{ OP_SetCookie, 0, BTREE_INCR_VACUUM, 1}, /* 5 */
};
int iAddr;
iAddr = sqlite3VdbeAddOpList(v, ArraySize(setMeta6), setMeta6);
sqlite3VdbeChangeP1(v, iAddr, iDb);
sqlite3VdbeChangeP1(v, iAddr+1, iDb);
sqlite3VdbeChangeP2(v, iAddr+2, iAddr+4);
sqlite3VdbeChangeP1(v, iAddr+4, eAuto-1);
sqlite3VdbeChangeP1(v, iAddr+5, iDb);
sqlite3VdbeUsesBtree(v, iDb);
}
static const VdbeOpList setMeta6[] = {
{ OP_Transaction, 0, 1, 0}, /* 0 */
{ OP_ReadCookie, 0, 1, BTREE_LARGEST_ROOT_PAGE},
{ OP_If, 1, 0, 0}, /* 2 */
{ OP_Halt, SQLITE_OK, OE_Abort, 0}, /* 3 */
{ OP_Integer, 0, 1, 0}, /* 4 */
{ OP_SetCookie, 0, BTREE_INCR_VACUUM, 1}, /* 5 */
};
int iAddr;
iAddr = sqlite3VdbeAddOpList(v, ArraySize(setMeta6), setMeta6);
sqlite3VdbeChangeP1(v, iAddr, iDb);
sqlite3VdbeChangeP1(v, iAddr+1, iDb);
sqlite3VdbeChangeP2(v, iAddr+2, iAddr+4);
sqlite3VdbeChangeP1(v, iAddr+4, eAuto-1);
sqlite3VdbeChangeP1(v, iAddr+5, iDb);
sqlite3VdbeUsesBtree(v, iDb);
}
}
break;
@ -905,9 +1067,6 @@ void sqlite3Pragma(
#ifndef SQLITE_OMIT_AUTOVACUUM
case PragTyp_INCREMENTAL_VACUUM: {
int iLimit, addr;
if( sqlite3ReadSchema(pParse) ){
goto pragma_out;
}
if( zRight==0 || !sqlite3GetInt32(zRight, &iLimit) || iLimit<=0 ){
iLimit = 0x7fffffff;
}
@ -935,7 +1094,6 @@ void sqlite3Pragma(
** of memory.
*/
case PragTyp_CACHE_SIZE: {
if( sqlite3ReadSchema(pParse) ) goto pragma_out;
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
if( !zRight ){
returnSingleInt(pParse, "cache_size", pDb->pSchema->cache_size);
@ -1156,7 +1314,6 @@ void sqlite3Pragma(
** opened.
*/
case PragTyp_SYNCHRONOUS: {
if( sqlite3ReadSchema(pParse) ) goto pragma_out;
if( !zRight ){
returnSingleInt(pParse, "synchronous", pDb->safety_level-1);
}else{
@ -1218,7 +1375,6 @@ void sqlite3Pragma(
*/
case PragTyp_TABLE_INFO: if( zRight ){
Table *pTab;
if( sqlite3ReadSchema(pParse) ) goto pragma_out;
pTab = sqlite3FindTable(db, zRight, zDb);
if( pTab ){
int i, k;
@ -1268,7 +1424,6 @@ void sqlite3Pragma(
case PragTyp_INDEX_INFO: if( zRight ){
Index *pIdx;
Table *pTab;
if( sqlite3ReadSchema(pParse) ) goto pragma_out;
pIdx = sqlite3FindIndex(db, zRight, zDb);
if( pIdx ){
int i;
@ -1294,7 +1449,6 @@ void sqlite3Pragma(
case PragTyp_INDEX_LIST: if( zRight ){
Index *pIdx;
Table *pTab;
if( sqlite3ReadSchema(pParse) ) goto pragma_out;
pTab = sqlite3FindTable(db, zRight, zDb);
if( pTab ){
v = sqlite3GetVdbe(pParse);
@ -1322,7 +1476,6 @@ void sqlite3Pragma(
case PragTyp_DATABASE_LIST: {
int i;
if( sqlite3ReadSchema(pParse) ) goto pragma_out;
sqlite3VdbeSetNumCols(v, 3);
pParse->nMem = 3;
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seq", SQLITE_STATIC);
@ -1361,7 +1514,6 @@ void sqlite3Pragma(
case PragTyp_FOREIGN_KEY_LIST: if( zRight ){
FKey *pFK;
Table *pTab;
if( sqlite3ReadSchema(pParse) ) goto pragma_out;
pTab = sqlite3FindTable(db, zRight, zDb);
if( pTab ){
v = sqlite3GetVdbe(pParse);
@ -1423,7 +1575,6 @@ void sqlite3Pragma(
int addrOk; /* Jump here if the key is OK */
int *aiCols; /* child to parent column mapping */
if( sqlite3ReadSchema(pParse) ) goto pragma_out;
regResult = pParse->nMem+1;
pParse->nMem += 4;
regKey = ++pParse->nMem;
@ -1584,7 +1735,6 @@ void sqlite3Pragma(
if( pId2->z==0 ) iDb = -1;
/* Initialize the VDBE program */
if( sqlite3ReadSchema(pParse) ) goto pragma_out;
pParse->nMem = 6;
sqlite3VdbeSetNumCols(v, 1);
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "integrity_check", SQLITE_STATIC);
@ -1908,7 +2058,6 @@ void sqlite3Pragma(
eMode = SQLITE_CHECKPOINT_RESTART;
}
}
if( sqlite3ReadSchema(pParse) ) goto pragma_out;
sqlite3VdbeSetNumCols(v, 3);
pParse->nMem = 3;
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "busy", SQLITE_STATIC);

View File

@ -109,6 +109,7 @@ set pragma_def {
IF: !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
NAME: default_cache_size
FLAG: NeedSchema
IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
NAME: page_size
@ -118,31 +119,37 @@ set pragma_def {
IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS)
NAME: page_count
FLAG: NeedSchema
IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS)
NAME: max_page_count
TYPE: PAGE_COUNT
FLAG: NeedSchema
IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS)
NAME: locking_mode
IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS)
NAME: journal_mode
FLAG: NeedSchema
IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS)
NAME: journal_size_limit
IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS)
NAME: cache_size
FLAG: NeedSchema
IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS)
NAME: mmap_size
IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS)
NAME: auto_vacuum
FLAG: NeedSchema
IF: !defined(SQLITE_OMIT_AUTOVACUUM)
NAME: incremental_vacuum
FLAG: NeedSchema
IF: !defined(SQLITE_OMIT_AUTOVACUUM)
NAME: temp_store
@ -158,27 +165,34 @@ set pragma_def {
IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_ENABLE_LOCKING_STYLE
NAME: synchronous
FLAG: NeedSchema
IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS)
NAME: table_info
FLAG: NeedSchema
IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
NAME: index_info
FLAG: NeedSchema
IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
NAME: index_list
FLAG: NeedSchema
IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
NAME: database_list
FLAG: NeedSchema
IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
NAME: collation_list
IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
NAME: foreign_key_list
FLAG: NeedSchema
IF: !defined(SQLITE_OMIT_FOREIGN_KEY)
NAME: foreign_key_check
FLAG: NeedSchema
IF: !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
NAME: parser_trace
@ -187,10 +201,12 @@ set pragma_def {
NAME: case_sensitive_like
NAME: integrity_check
FLAG: NeedSchema
IF: !defined(SQLITE_OMIT_INTEGRITY_CHECK)
NAME: quick_check
TYPE: INTEGRITY_CHECK
FLAG: NeedSchema
IF: !defined(SQLITE_OMIT_INTEGRITY_CHECK)
NAME: encoding
@ -216,6 +232,7 @@ set pragma_def {
IF: !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
NAME: wal_checkpoint
FLAG: NeedSchema
IF: !defined(SQLITE_OMIT_WAL)
NAME: wal_autocheckpoint
@ -245,14 +262,16 @@ set pragma_def {
set name {}
set type {}
set if {}
set flags {}
set arg 0
proc record_one {} {
global name type if arg allbyname typebyif
global name type if arg allbyname typebyif flags
if {$name==""} return
set allbyname($name) [list $type $arg $if]
set allbyname($name) [list $type $arg $if $flags]
set name {}
set type {}
set if {}
set flags {}
set arg 0
}
foreach line [split $pragma_def \n] {
@ -270,6 +289,11 @@ foreach line [split $pragma_def \n] {
set arg $val
} elseif {$id=="IF"} {
set if $val
} elseif {$id=="FLAG"} {
foreach term [split $val] {
lappend flags $term
set allflags($term) 1
}
} else {
error "bad pragma_def line: $line"
}
@ -308,30 +332,42 @@ foreach name $allnames {
incr pnum
}
# Generate #defines for flags
#
set fv 1
foreach f [lsort [array names allflags]] {
puts [format {#define PragFlag_%-20s 0x%02x} $f $fv]
set fv [expr {$fv*2}]
}
# Generate the lookup table
#
puts "static const struct sPragmaNames \173"
puts " const char *const zName; /* Name of pragma */"
puts " u8 ePragTyp; /* PragTyp_XXX value */"
puts " u8 mPragFlag; /* Zero or more PragFlag_XXX values */"
puts " u32 iArg; /* Extra argument */"
puts "\175 aPragmaNames\[\] = \173"
set current_if {}
set spacer [format { %26s } {}]
foreach name $allnames {
foreach {type arg if} $allbyname($name) break
foreach {type arg if flag} $allbyname($name) break
if {$if!=$current_if} {
if {$current_if!=""} {puts "#endif"}
set current_if $if
if {$current_if!=""} {puts "#if $current_if"}
}
set namex [format %-26s \"$name\",]
set typex [format PragTyp_%-23s $type,]
if {[string length $arg]>10} {
puts " \173 $namex $typex\n$spacer$arg \175,"
if {$flag==""} {
set flagx "0"
} else {
puts " \173 $namex $typex $arg \175,"
set flagx PragFlag_[join $flag {|PragFlag_}]
}
puts " \173 /* zName: */ \"$name\","
puts " /* ePragTyp: */ PragTyp_$type,"
puts " /* ePragFlag: */ $flagx,"
puts " /* iArg: */ $arg \175,"
}
if {$current_if!=""} {puts "#endif"}
puts "\175;"