1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-06-26 20:21:09 +03:00

Coverage improvements in pragma.c. Change the __DARWIN__ macro to __APPLE__,

which is available by default on Leopard. (CVS 6153)

FossilOrigin-Name: 64c56226b91e57883c8059f65330318e53376b8a
This commit is contained in:
drh
2009-01-09 21:41:17 +00:00
parent 0371f1b243
commit d2cb50b74c
9 changed files with 247 additions and 97 deletions

View File

@ -1,5 +1,5 @@
C Increase\spager.c\scoverage\sa\sbit.\sFix\san\sassert\sfailure\sthat\scan\soccur\sfollowing\sa\s"PRAGMA\somit_readlock"\scommand\son\sa\sread-only\sdatabase.\s(CVS\s6152) C Coverage\simprovements\sin\spragma.c.\s\sChange\sthe\s__DARWIN__\smacro\sto\s__APPLE__,\nwhich\sis\savailable\sby\sdefault\son\sLeopard.\s(CVS\s6153)
D 2009-01-09T17:11:05 D 2009-01-09T21:41:17
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 05461a9b5803d5ad10c79f989801e9fd2cc3e592 F Makefile.in 05461a9b5803d5ad10c79f989801e9fd2cc3e592
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -140,7 +140,7 @@ F src/os.c ed93a6b46132a602c4fd7a58142e2981c829c79d
F src/os.h 4ee25a35c00e75a569cecb5080be299b0c3e208e F src/os.h 4ee25a35c00e75a569cecb5080be299b0c3e208e
F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60 F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60
F src/os_os2.c bed77dc26e3a95ce4a204936b9a1ca6fe612fcc5 F src/os_os2.c bed77dc26e3a95ce4a204936b9a1ca6fe612fcc5
F src/os_unix.c a1f05f59c24e61186c981f2a7fea13986db620f1 F src/os_unix.c 7825c6178597713382d74adbf8c8c00ffcdc42d4
F src/os_win.c 496e3ceb499aedc63622a89ef76f7af2dd902709 F src/os_win.c 496e3ceb499aedc63622a89ef76f7af2dd902709
F src/pager.c 97bfbacae6131b8d228628803606e98dd763b474 F src/pager.c 97bfbacae6131b8d228628803606e98dd763b474
F src/pager.h 9870acb2d653848d90d765d7cbf163496d6c8111 F src/pager.h 9870acb2d653848d90d765d7cbf163496d6c8111
@ -148,7 +148,7 @@ F src/parse.y 4d0e33a702dc3ea7b69d8ae1914b3fbd32e46057
F src/pcache.c 16dc8da6e6ba6250f8dfd9ee46036db1cbceedc6 F src/pcache.c 16dc8da6e6ba6250f8dfd9ee46036db1cbceedc6
F src/pcache.h f20c3e82dd6da622c3fe296170cb1801f9a2d75a F src/pcache.h f20c3e82dd6da622c3fe296170cb1801f9a2d75a
F src/pcache1.c c0aa84ff69ea759fa944dbee9167a2463ab7c322 F src/pcache1.c c0aa84ff69ea759fa944dbee9167a2463ab7c322
F src/pragma.c d6dfc47979623cf593d0db926daff49d214a8eb3 F src/pragma.c ec9470bc3ee91dd8933adad209a24311401ca78c
F src/prepare.c 2a11736383d0af2ea80aa62270f15ad80dd8b5cd F src/prepare.c 2a11736383d0af2ea80aa62270f15ad80dd8b5cd
F src/printf.c 9866a9a9c4a90f6d4147407f373df3fd5d5f9b6f F src/printf.c 9866a9a9c4a90f6d4147407f373df3fd5d5f9b6f
F src/random.c 676b9d7ac820fe81e6fb2394ac8c10cff7f38628 F src/random.c 676b9d7ac820fe81e6fb2394ac8c10cff7f38628
@ -163,7 +163,7 @@ F src/sqliteLimit.h 651a2757ba55aeba1da167786b6a8c3404433940
F src/status.c 237b193efae0cf6ac3f0817a208de6c6c6ef6d76 F src/status.c 237b193efae0cf6ac3f0817a208de6c6c6ef6d76
F src/table.c 23db1e5f27c03160987c122a078b4bb51ef0b2f8 F src/table.c 23db1e5f27c03160987c122a078b4bb51ef0b2f8
F src/tclsqlite.c 4415e1033bd3e92b05a6a9cde911ee4de3b82df9 F src/tclsqlite.c 4415e1033bd3e92b05a6a9cde911ee4de3b82df9
F src/test1.c 473a6a230988f50129abe7614c95a9512f6efa78 F src/test1.c 243bbbdb91618ecce2a51e0ee1c7d8f3f8740193
F src/test2.c 724095fc69cb54b018aaa4463a56836c0b53a17a F src/test2.c 724095fc69cb54b018aaa4463a56836c0b53a17a
F src/test3.c 88a246b56b824275300e6c899634fbac1dc94b14 F src/test3.c 88a246b56b824275300e6c899634fbac1dc94b14
F src/test4.c f79ab52d27ff49b784b631a42e2ccd52cfd5c84c F src/test4.c f79ab52d27ff49b784b631a42e2ccd52cfd5c84c
@ -175,7 +175,7 @@ F src/test9.c 904ebe0ed1472d6bad17a81e2ecbfc20017dc237
F src/test_async.c 45024094ed7cf780c5d5dccda645145f95cf78ef F src/test_async.c 45024094ed7cf780c5d5dccda645145f95cf78ef
F src/test_autoext.c f53b0cdf7bf5f08100009572a5d65cdb540bd0ad F src/test_autoext.c f53b0cdf7bf5f08100009572a5d65cdb540bd0ad
F src/test_btree.c d7b8716544611c323860370ee364e897c861f1b0 F src/test_btree.c d7b8716544611c323860370ee364e897c861f1b0
F src/test_config.c 4f85387a52f3c7966c3ffab913e988a3830fe1af F src/test_config.c e568dc1062a79710e05e5ae79b168b7c64bf7e5d
F src/test_devsym.c 9f4bc2551e267ce7aeda195f3897d0f30c5228f4 F src/test_devsym.c 9f4bc2551e267ce7aeda195f3897d0f30c5228f4
F src/test_func.c a55c4d5479ff2eb5c0a22d4d88e9528ab59c953b F src/test_func.c a55c4d5479ff2eb5c0a22d4d88e9528ab59c953b
F src/test_hexio.c 2f1122aa3f012fa0142ee3c36ce5c902a70cd12f F src/test_hexio.c 2f1122aa3f012fa0142ee3c36ce5c902a70cd12f
@ -312,7 +312,7 @@ F test/exec.test e949714dc127eaa5ecc7d723efec1ec27118fdd7
F test/expr.test bc1e6997c27238f6de539f1079ff93e5078ea7c3 F test/expr.test bc1e6997c27238f6de539f1079ff93e5078ea7c3
F test/filectrl.test 8923a6dc7630f31c8a9dd3d3d740aa0922df7bf8 F test/filectrl.test 8923a6dc7630f31c8a9dd3d3d740aa0922df7bf8
F test/filefmt.test 053b622009fbbb74dd37921ffad374d852c13cd8 F test/filefmt.test 053b622009fbbb74dd37921ffad374d852c13cd8
F test/fkey1.test c373e4f1ec43416957e0591c4a5cebb63b8a12e7 F test/fkey1.test 78506fa55800d553d8fe1f3e7f73ce996fd2cef9
F test/format4.test 1f0cac8ff3895e9359ed87e41aaabee982a812eb F test/format4.test 1f0cac8ff3895e9359ed87e41aaabee982a812eb
F test/fts1a.test 46090311f85da51bb33bd5ce84f7948359c6d8d7 F test/fts1a.test 46090311f85da51bb33bd5ce84f7948359c6d8d7
F test/fts1b.test 5d8a01aefbecc8b7442b36c94c05eb7a845462d5 F test/fts1b.test 5d8a01aefbecc8b7442b36c94c05eb7a845462d5
@ -416,7 +416,7 @@ F test/journal1.test 36f2d1bb9bf03f790f43fbdb439e44c0657fab19
F test/jrnlmode.test e004a5ed138e06464d74dbd6bead01908f264c52 F test/jrnlmode.test e004a5ed138e06464d74dbd6bead01908f264c52
F test/lastinsert.test 474d519c68cb79d07ecae56a763aa7f322c72f51 F test/lastinsert.test 474d519c68cb79d07ecae56a763aa7f322c72f51
F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200 F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200
F test/like.test e55cbbc21729f577b74ec333c753a2d6eda03f9f F test/like.test 22f7857f9d7da7ff5061ded8806c43a6271109fc
F test/like2.test 3b2ee13149ba4a8a60b59756f4e5d345573852da F test/like2.test 3b2ee13149ba4a8a60b59756f4e5d345573852da
F test/limit.test 2db7b3b34fb925b8e847d583d2eb67531d0ce67e F test/limit.test 2db7b3b34fb925b8e847d583d2eb67531d0ce67e
F test/loadext.test 18db29c081380fdedcfbd8c633847712059ae104 F test/loadext.test 18db29c081380fdedcfbd8c633847712059ae104
@ -481,7 +481,7 @@ F test/pagesize.test 0d9ff3fedfce6e5ffe8fa7aca9b6d3433a2e843b
F test/pcache.test ccd18b4d2b432f44319a82b0367ed843ee18cebd F test/pcache.test ccd18b4d2b432f44319a82b0367ed843ee18cebd
F test/pcache2.test 46efd980a89f737847b99327bda19e08fe11e402 F test/pcache2.test 46efd980a89f737847b99327bda19e08fe11e402
F test/permutations.test af0962c17a32631de8b301c301c497adea9739f4 F test/permutations.test af0962c17a32631de8b301c301c497adea9739f4
F test/pragma.test 325aa0833d483b8e0c98e8196f1cc49fa5d8c336 F test/pragma.test 3fd4d3cc9f48aa5f2fb050d17234222ddac68ec6
F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47 F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47
F test/printf.test 262a5acd3158f788e9bdf7f18d718f3af32ff6ef F test/printf.test 262a5acd3158f788e9bdf7f18d718f3af32ff6ef
F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x
@ -696,7 +696,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P c917961743e9ab60a096801c8910c6cd8367ee2f P 0f3f9011fa143f7b63c9bf79d3e411327d5c6f9d
R 84887d8478ad2a6db00d201594f1baf7 R e1e4036b9a98af33862eb0ed9594debc
U danielk1977 U drh
Z 53b1598924155611310d0a2e9e4862da Z a59dff8080441c305d285f6286bef741

View File

@ -1 +1 @@
0f3f9011fa143f7b63c9bf79d3e411327d5c6f9d 64c56226b91e57883c8059f65330318e53376b8a

View File

@ -43,7 +43,7 @@
** * Definitions of sqlite3_vfs objects for all locking methods ** * Definitions of sqlite3_vfs objects for all locking methods
** plus implementations of sqlite3_os_init() and sqlite3_os_end(). ** plus implementations of sqlite3_os_init() and sqlite3_os_end().
** **
** $Id: os_unix.c,v 1.234 2009/01/08 14:36:20 drh Exp $ ** $Id: os_unix.c,v 1.235 2009/01/09 21:41:17 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#if SQLITE_OS_UNIX /* This file is used on unix only */ #if SQLITE_OS_UNIX /* This file is used on unix only */
@ -66,7 +66,7 @@
** where the database is located. ** where the database is located.
*/ */
#if !defined(SQLITE_ENABLE_LOCKING_STYLE) #if !defined(SQLITE_ENABLE_LOCKING_STYLE)
# if defined(__DARWIN__) # if defined(__APPLE__)
# define SQLITE_ENABLE_LOCKING_STYLE 1 # define SQLITE_ENABLE_LOCKING_STYLE 1
# else # else
# define SQLITE_ENABLE_LOCKING_STYLE 0 # define SQLITE_ENABLE_LOCKING_STYLE 0
@ -2174,7 +2174,7 @@ static int semClose(sqlite3_file *id) {
** only works on OSX. ** only works on OSX.
*/ */
#if defined(__DARWIN__) && SQLITE_ENABLE_LOCKING_STYLE #if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE
/* /*
** The afpLockingContext structure contains all afp lock specific state ** The afpLockingContext structure contains all afp lock specific state
*/ */
@ -2557,7 +2557,7 @@ static int afpClose(sqlite3_file *id) {
return SQLITE_OK; return SQLITE_OK;
} }
#endif /* defined(__DARWIN__) && SQLITE_ENABLE_LOCKING_STYLE */ #endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */
/* /*
** The code above is the AFP lock implementation. The code is specific ** The code above is the AFP lock implementation. The code is specific
** to MacOSX and does not work on other unix platforms. No alternative ** to MacOSX and does not work on other unix platforms. No alternative
@ -2936,7 +2936,7 @@ static int unixFileSize(sqlite3_file *id, i64 *pSize){
return SQLITE_OK; return SQLITE_OK;
} }
#if SQLITE_ENABLE_LOCKING_STYLE && defined(__DARWIN__) #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
/* /*
** Handler for proxy-locking file-control verbs. Defined below in the ** Handler for proxy-locking file-control verbs. Defined below in the
** proxying locking division. ** proxying locking division.
@ -2958,12 +2958,12 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){
*(int*)pArg = ((unixFile*)id)->lastErrno; *(int*)pArg = ((unixFile*)id)->lastErrno;
return SQLITE_OK; return SQLITE_OK;
} }
#if SQLITE_ENABLE_LOCKING_STYLE && defined(__DARWIN__) #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
case SQLITE_SET_LOCKPROXYFILE: case SQLITE_SET_LOCKPROXYFILE:
case SQLITE_GET_LOCKPROXYFILE: { case SQLITE_GET_LOCKPROXYFILE: {
return proxyFileControl(id,op,pArg); return proxyFileControl(id,op,pArg);
} }
#endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__DARWIN__) */ #endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) */
} }
return SQLITE_ERROR; return SQLITE_ERROR;
} }
@ -3106,7 +3106,7 @@ IOMETHODS(
) )
#endif #endif
#if defined(__DARWIN__) && SQLITE_ENABLE_LOCKING_STYLE #if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE
IOMETHODS( IOMETHODS(
afpIoFinder, /* Finder function name */ afpIoFinder, /* Finder function name */
afpIoMethods, /* sqlite3_io_methods object name */ afpIoMethods, /* sqlite3_io_methods object name */
@ -3126,7 +3126,7 @@ IOMETHODS(
** to go ahead and define the sqlite3_io_methods and finder function ** to go ahead and define the sqlite3_io_methods and finder function
** for proxy locking here. So we forward declare the I/O methods. ** for proxy locking here. So we forward declare the I/O methods.
*/ */
#if defined(__DARWIN__) && SQLITE_ENABLE_LOCKING_STYLE #if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE
static int proxyClose(sqlite3_file*); static int proxyClose(sqlite3_file*);
static int proxyLock(sqlite3_file*, int); static int proxyLock(sqlite3_file*, int);
static int proxyUnlock(sqlite3_file*, int); static int proxyUnlock(sqlite3_file*, int);
@ -3142,7 +3142,7 @@ IOMETHODS(
#endif #endif
#if defined(__DARWIN__) && SQLITE_ENABLE_LOCKING_STYLE #if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE
/* /*
** This "finder" function attempts to determine the best locking strategy ** This "finder" function attempts to determine the best locking strategy
** for the database file "filePath". It then returns the sqlite3_io_methods ** for the database file "filePath". It then returns the sqlite3_io_methods
@ -3206,7 +3206,7 @@ static const sqlite3_io_methods *autolockIoFinderImpl(
static const sqlite3_io_methods *(*const autolockIoFinder)(const char*,int) static const sqlite3_io_methods *(*const autolockIoFinder)(const char*,int)
= autolockIoFinderImpl; = autolockIoFinderImpl;
#endif /* defined(__DARWIN__) && SQLITE_ENABLE_LOCKING_STYLE */ #endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */
/* /*
** An abstract type for a pointer to a IO method finder function: ** An abstract type for a pointer to a IO method finder function:
@ -3279,7 +3279,7 @@ static int fillInUnixFile(
unixLeaveMutex(); unixLeaveMutex();
} }
#if SQLITE_ENABLE_LOCKING_STYLE && defined(__DARWIN__) #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
else if( pLockingStyle == &afpIoMethods ){ else if( pLockingStyle == &afpIoMethods ){
/* AFP locking uses the file path so it needs to be included in /* AFP locking uses the file path so it needs to be included in
** the afpLockingContext. ** the afpLockingContext.
@ -3451,7 +3451,7 @@ static int getTempname(int nBuf, char *zBuf){
return SQLITE_OK; return SQLITE_OK;
} }
#if SQLITE_ENABLE_LOCKING_STYLE && defined(__DARWIN__) #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
/* /*
** Routine to transform a unixFile into a proxy-locking unixFile. ** Routine to transform a unixFile into a proxy-locking unixFile.
** Implementation in the proxy-lock division, but used by unixOpen() ** Implementation in the proxy-lock division, but used by unixOpen()
@ -4098,7 +4098,7 @@ static int unixGetLastError(sqlite3_vfs *NotUsed, int NotUsed2, char *NotUsed3){
/* /*
** Proxy locking is only available on MacOSX ** Proxy locking is only available on MacOSX
*/ */
#if defined(__DARWIN__) && SQLITE_ENABLE_LOCKING_STYLE #if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE
#ifdef SQLITE_TEST #ifdef SQLITE_TEST
/* simulate multiple hosts by creating unique hostid file paths */ /* simulate multiple hosts by creating unique hostid file paths */
@ -4588,7 +4588,7 @@ static int switchLockProxyPath(unixFile *pFile, const char *path) {
** int dbPath. ** int dbPath.
*/ */
static int proxyGetDbPathForUnixFile(unixFile *pFile, char *dbPath){ static int proxyGetDbPathForUnixFile(unixFile *pFile, char *dbPath){
#if defined(__DARWIN__) #if defined(__APPLE__)
if( pFile->pMethod == &afpIoMethods ){ if( pFile->pMethod == &afpIoMethods ){
/* afp style keeps a reference to the db path in the filePath field /* afp style keeps a reference to the db path in the filePath field
** of the struct */ ** of the struct */
@ -4857,7 +4857,7 @@ static int proxyClose(sqlite3_file *id) {
#endif /* defined(__DARWIN__) && SQLITE_ENABLE_LOCKING_STYLE */ #endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */
/* /*
** The proxy locking style is intended for use with AFP filesystems. ** The proxy locking style is intended for use with AFP filesystems.
** And since AFP is only supported on MacOSX, the proxy locking is also ** And since AFP is only supported on MacOSX, the proxy locking is also
@ -4930,7 +4930,7 @@ int sqlite3_os_init(void){
** array cannot be const. ** array cannot be const.
*/ */
static sqlite3_vfs aVfs[] = { static sqlite3_vfs aVfs[] = {
#if SQLITE_ENABLE_LOCKING_STYLE && defined(__DARWIN__) #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
UNIXVFS("unix", autolockIoFinder ), UNIXVFS("unix", autolockIoFinder ),
#else #else
UNIXVFS("unix", posixIoFinder ), UNIXVFS("unix", posixIoFinder ),
@ -4944,7 +4944,7 @@ int sqlite3_os_init(void){
UNIXVFS("unix-posix", posixIoFinder ), UNIXVFS("unix-posix", posixIoFinder ),
UNIXVFS("unix-flock", flockIoFinder ), UNIXVFS("unix-flock", flockIoFinder ),
#endif #endif
#if SQLITE_ENABLE_LOCKING_STYLE && defined(__DARWIN__) #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
UNIXVFS("unix-afp", afpIoFinder ), UNIXVFS("unix-afp", afpIoFinder ),
UNIXVFS("unix-proxy", proxyIoFinder ), UNIXVFS("unix-proxy", proxyIoFinder ),
#endif #endif

View File

@ -11,7 +11,7 @@
************************************************************************* *************************************************************************
** This file contains code used to implement the PRAGMA command. ** This file contains code used to implement the PRAGMA command.
** **
** $Id: pragma.c,v 1.199 2008/12/10 23:04:13 drh Exp $ ** $Id: pragma.c,v 1.200 2009/01/09 21:41:17 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@ -196,7 +196,8 @@ static int flagPragma(Parse *pParse, const char *zLeft, const char *zRight){
sqlite3 *db = pParse->db; sqlite3 *db = pParse->db;
Vdbe *v; Vdbe *v;
v = sqlite3GetVdbe(pParse); v = sqlite3GetVdbe(pParse);
if( v ){ assert( v!=0 ); /* Already allocated by sqlite3Pragma() */
if( ALWAYS(v) ){
if( zRight==0 ){ if( zRight==0 ){
returnSingleInt(pParse, p->zName, (db->flags & p->mask)!=0 ); returnSingleInt(pParse, p->zName, (db->flags & p->mask)!=0 );
}else{ }else{
@ -221,14 +222,19 @@ static int flagPragma(Parse *pParse, const char *zLeft, const char *zRight){
} }
#endif /* SQLITE_OMIT_FLAG_PRAGMAS */ #endif /* SQLITE_OMIT_FLAG_PRAGMAS */
/*
** Return a human-readable name for a constraint resolution action.
*/
static const char *actionName(u8 action){ static const char *actionName(u8 action){
const char *zName;
switch( action ){ switch( action ){
case OE_SetNull: return "SET NULL"; case OE_SetNull: zName = "SET NULL"; break;
case OE_SetDflt: return "SET DEFAULT"; case OE_SetDflt: zName = "SET DEFAULT"; break;
case OE_Restrict: return "RESTRICT"; case OE_Cascade: zName = "CASCADE"; break;
case OE_Cascade: return "CASCADE"; default: zName = "RESTRICT";
assert( action==OE_Restrict ); break;
} }
return ""; return zName;
} }
/* /*
@ -285,7 +291,8 @@ void sqlite3Pragma(
zRight = sqlite3NameFromToken(db, pValue); zRight = sqlite3NameFromToken(db, pValue);
} }
zDb = ((pId2 && pId2->n>0)?pDb->zName:0); assert( pId2 );
zDb = pId2->n>0 ? pDb->zName : 0;
if( sqlite3AuthCheck(pParse, SQLITE_PRAGMA, zLeft, zRight, zDb) ){ if( sqlite3AuthCheck(pParse, SQLITE_PRAGMA, zLeft, zRight, zDb) ){
goto pragma_out; goto pragma_out;
} }
@ -353,8 +360,9 @@ void sqlite3Pragma(
*/ */
if( sqlite3StrICmp(zLeft,"page_size")==0 ){ if( sqlite3StrICmp(zLeft,"page_size")==0 ){
Btree *pBt = pDb->pBt; Btree *pBt = pDb->pBt;
assert( pBt!=0 );
if( !zRight ){ if( !zRight ){
int size = pBt ? sqlite3BtreeGetPageSize(pBt) : 0; int size = ALWAYS(pBt) ? sqlite3BtreeGetPageSize(pBt) : 0;
returnSingleInt(pParse, "page_size", size); returnSingleInt(pParse, "page_size", size);
}else{ }else{
/* Malloc may fail when setting the page-size, as there is an internal /* Malloc may fail when setting the page-size, as there is an internal
@ -379,10 +387,11 @@ void sqlite3Pragma(
if( sqlite3StrICmp(zLeft,"max_page_count")==0 ){ if( sqlite3StrICmp(zLeft,"max_page_count")==0 ){
Btree *pBt = pDb->pBt; Btree *pBt = pDb->pBt;
int newMax = 0; int newMax = 0;
assert( pBt!=0 );
if( zRight ){ if( zRight ){
newMax = atoi(zRight); newMax = atoi(zRight);
} }
if( pBt ){ if( ALWAYS(pBt) ){
newMax = sqlite3BtreeMaxPageCount(pBt, newMax); newMax = sqlite3BtreeMaxPageCount(pBt, newMax);
} }
returnSingleInt(pParse, "max_page_count", newMax); returnSingleInt(pParse, "max_page_count", newMax);
@ -395,7 +404,7 @@ void sqlite3Pragma(
*/ */
if( sqlite3StrICmp(zLeft,"page_count")==0 ){ if( sqlite3StrICmp(zLeft,"page_count")==0 ){
int iReg; int iReg;
if( !v || sqlite3ReadSchema(pParse) ) goto pragma_out; if( sqlite3ReadSchema(pParse) ) goto pragma_out;
sqlite3CodeVerifySchema(pParse, iDb); sqlite3CodeVerifySchema(pParse, iDb);
iReg = ++pParse->nMem; iReg = ++pParse->nMem;
sqlite3VdbeAddOp2(v, OP_Pagecount, iDb, iReg); sqlite3VdbeAddOp2(v, OP_Pagecount, iDb, iReg);
@ -543,17 +552,23 @@ void sqlite3Pragma(
#ifndef SQLITE_OMIT_AUTOVACUUM #ifndef SQLITE_OMIT_AUTOVACUUM
if( sqlite3StrICmp(zLeft,"auto_vacuum")==0 ){ if( sqlite3StrICmp(zLeft,"auto_vacuum")==0 ){
Btree *pBt = pDb->pBt; Btree *pBt = pDb->pBt;
assert( pBt!=0 );
if( sqlite3ReadSchema(pParse) ){ if( sqlite3ReadSchema(pParse) ){
goto pragma_out; goto pragma_out;
} }
if( !zRight ){ if( !zRight ){
int auto_vacuum = int auto_vacuum;
pBt ? sqlite3BtreeGetAutoVacuum(pBt) : SQLITE_DEFAULT_AUTOVACUUM; if( ALWAYS(pBt) ){
auto_vacuum = sqlite3BtreeGetAutoVacuum(pBt);
}else{
auto_vacuum = SQLITE_DEFAULT_AUTOVACUUM;
}
returnSingleInt(pParse, "auto_vacuum", auto_vacuum); returnSingleInt(pParse, "auto_vacuum", auto_vacuum);
}else{ }else{
int eAuto = getAutoVacuum(zRight); int eAuto = getAutoVacuum(zRight);
assert( eAuto>=0 && eAuto<=2 );
db->nextAutovac = (u8)eAuto; db->nextAutovac = (u8)eAuto;
if( eAuto>=0 ){ if( ALWAYS(eAuto>=0) ){
/* Call SetAutoVacuum() to set initialize the internal auto and /* Call SetAutoVacuum() to set initialize the internal auto and
** incr-vacuum flags. This is required in case this connection ** incr-vacuum flags. This is required in case this connection
** creates the database file. It is important that it is created ** creates the database file. It is important that it is created
@ -704,6 +719,14 @@ void sqlite3Pragma(
} }
}else }else
#if !defined(SQLITE_ENABLE_LOCKING_STYLE)
# if defined(__APPLE__)
# define SQLITE_ENABLE_LOCKING_STYLE 1
# else
# define SQLITE_ENABLE_LOCKING_STYLE 0
# endif
#endif
#if SQLITE_ENABLE_LOCKING_STYLE
/* /*
** PRAGMA [database.]lock_proxy_file ** PRAGMA [database.]lock_proxy_file
** PRAGMA [database.]lock_proxy_file = ":auto:"|"lock_file_path" ** PRAGMA [database.]lock_proxy_file = ":auto:"|"lock_file_path"
@ -744,7 +767,7 @@ void sqlite3Pragma(
} }
} }
}else }else
#endif /* SQLITE_ENABLE_LOCKING_STYLE */
/* /*
** PRAGMA [database.]synchronous ** PRAGMA [database.]synchronous
@ -818,7 +841,9 @@ void sqlite3Pragma(
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,
pCol->zType ? pCol->zType : "", 0); pCol->zType ? pCol->zType : "", 0);
sqlite3VdbeAddOp2(v, OP_Integer, (pCol->notNull ? 1 : 0), 4); sqlite3VdbeAddOp2(v, OP_Integer, (pCol->notNull ? 1 : 0), 4);
if( pCol->pDflt && (pDflt = &pCol->pDflt->span)->z ){ if( pCol->pDflt ){
pDflt = &pCol->pDflt->span;
assert( pDflt->z );
sqlite3VdbeAddOp4(v, OP_String8, 0, 5, 0, (char*)pDflt->z, pDflt->n); sqlite3VdbeAddOp4(v, OP_String8, 0, 5, 0, (char*)pDflt->z, pDflt->n);
}else{ }else{
sqlite3VdbeAddOp2(v, OP_Null, 0, 5); sqlite3VdbeAddOp2(v, OP_Null, 0, 5);
@ -1178,11 +1203,11 @@ void sqlite3Pragma(
char *zName; char *zName;
u8 enc; u8 enc;
} encnames[] = { } encnames[] = {
{ "UTF-8", SQLITE_UTF8 },
{ "UTF8", SQLITE_UTF8 }, { "UTF8", SQLITE_UTF8 },
{ "UTF-16le", SQLITE_UTF16LE }, { "UTF-8", SQLITE_UTF8 }, /* Must be element [1] */
{ "UTF-16le", SQLITE_UTF16LE }, /* Must be element [2] */
{ "UTF-16be", SQLITE_UTF16BE }, /* Must be element [3] */
{ "UTF16le", SQLITE_UTF16LE }, { "UTF16le", SQLITE_UTF16LE },
{ "UTF-16be", SQLITE_UTF16BE },
{ "UTF16be", SQLITE_UTF16BE }, { "UTF16be", SQLITE_UTF16BE },
{ "UTF-16", 0 }, /* SQLITE_UTF16NATIVE */ { "UTF-16", 0 }, /* SQLITE_UTF16NATIVE */
{ "UTF16", 0 }, /* SQLITE_UTF16NATIVE */ { "UTF16", 0 }, /* SQLITE_UTF16NATIVE */
@ -1194,12 +1219,10 @@ void sqlite3Pragma(
sqlite3VdbeSetNumCols(v, 1); sqlite3VdbeSetNumCols(v, 1);
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "encoding", SQLITE_STATIC); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "encoding", SQLITE_STATIC);
sqlite3VdbeAddOp2(v, OP_String8, 0, 1); sqlite3VdbeAddOp2(v, OP_String8, 0, 1);
for(pEnc=&encnames[0]; pEnc->zName; pEnc++){ assert( encnames[SQLITE_UTF8].enc==SQLITE_UTF8 );
if( pEnc->enc==ENC(pParse->db) ){ assert( encnames[SQLITE_UTF16LE].enc==SQLITE_UTF16LE );
sqlite3VdbeChangeP4(v, -1, pEnc->zName, P4_STATIC); assert( encnames[SQLITE_UTF16BE].enc==SQLITE_UTF16BE );
break; sqlite3VdbeChangeP4(v, -1, encnames[ENC(pParse->db)].zName, P4_STATIC);
}
}
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
}else{ /* "PRAGMA encoding = XXX" */ }else{ /* "PRAGMA encoding = XXX" */
/* Only change the value of sqlite.enc if the database handle is not /* Only change the value of sqlite.enc if the database handle is not
@ -1344,9 +1367,27 @@ void sqlite3Pragma(
#endif #endif
#if SQLITE_HAS_CODEC #if SQLITE_HAS_CODEC
if( sqlite3StrICmp(zLeft, "key")==0 ){ if( sqlite3StrICmp(zLeft, "key")==0 && zRight ){
sqlite3_key(db, zRight, sqlite3Strlen30(zRight)); sqlite3_key(db, zRight, sqlite3Strlen30(zRight));
}else }else
if( sqlite3StrICmp(zLeft, "rekey")==0 && zRight ){
sqlite3_rekey(db, zRight, sqlite3Strlen30(zRight));
}else
if( zRight && (sqlite3StrICmp(zLeft, "hexkey")==0 ||
sqlite3StrICmp(zLeft, "hexrekey")==0) ){
int i, h1, h2;
char zKey[40];
for(i=0; (h1 = zRight[i])!=0 && (h2 = zRight[i+1])!=0; i+=2){
h1 += 9*(1&(h1>>6));
h2 += 9*(1&(h2>>6));
zKey[i/2] = (h2 & 0x0f) | ((h1 & 0xf)<<4);
}
if( (zLeft[3] & 0xf)==0xb ){
sqlite3_key(db, zKey, i/2);
}else{
sqlite3_rekey(db, zKey, i/2);
}
}else
#endif #endif
#if SQLITE_HAS_CODEC || defined(SQLITE_ENABLE_CEROD) #if SQLITE_HAS_CODEC || defined(SQLITE_ENABLE_CEROD)
if( sqlite3StrICmp(zLeft, "activate_extensions")==0 ){ if( sqlite3StrICmp(zLeft, "activate_extensions")==0 ){
@ -1362,29 +1403,28 @@ void sqlite3Pragma(
sqlite3_activate_cerod(&zRight[6]); sqlite3_activate_cerod(&zRight[6]);
} }
#endif #endif
} }else
#endif #endif
{}
if( v ){ {/* Empty ELSE clause */}
/* Code an OP_Expire at the end of each PRAGMA program to cause
** the VDBE implementing the pragma to expire. Most (all?) pragmas
** are only valid for a single execution.
*/
sqlite3VdbeAddOp2(v, OP_Expire, 1, 0);
/* /* Code an OP_Expire at the end of each PRAGMA program to cause
** Reset the safety level, in case the fullfsync flag or synchronous ** the VDBE implementing the pragma to expire. Most (all?) pragmas
** setting changed. ** are only valid for a single execution.
*/ */
sqlite3VdbeAddOp2(v, OP_Expire, 1, 0);
/*
** Reset the safety level, in case the fullfsync flag or synchronous
** setting changed.
*/
#ifndef SQLITE_OMIT_PAGER_PRAGMAS #ifndef SQLITE_OMIT_PAGER_PRAGMAS
if( db->autoCommit ){ if( db->autoCommit ){
sqlite3BtreeSetSafetyLevel(pDb->pBt, pDb->safety_level, sqlite3BtreeSetSafetyLevel(pDb->pBt, pDb->safety_level,
(db->flags&SQLITE_FullFSync)!=0); (db->flags&SQLITE_FullFSync)!=0);
}
#endif
} }
#endif
pragma_out: pragma_out:
sqlite3DbFree(db, zLeft); sqlite3DbFree(db, zLeft);
sqlite3DbFree(db, zRight); sqlite3DbFree(db, zRight);

View File

@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated ** is not included in the SQLite library. It is used for automated
** testing of the SQLite library. ** testing of the SQLite library.
** **
** $Id: test1.c,v 1.340 2009/01/09 02:49:32 drh Exp $ ** $Id: test1.c,v 1.341 2009/01/09 21:41:17 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include "tcl.h" #include "tcl.h"
@ -4577,13 +4577,13 @@ static int file_control_lockproxy_test(
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
#if !defined(SQLITE_ENABLE_LOCKING_STYLE) #if !defined(SQLITE_ENABLE_LOCKING_STYLE)
# if defined(__DARWIN__) # if defined(__APPLE__)
# define SQLITE_ENABLE_LOCKING_STYLE 1 # define SQLITE_ENABLE_LOCKING_STYLE 1
# else # else
# define SQLITE_ENABLE_LOCKING_STYLE 0 # define SQLITE_ENABLE_LOCKING_STYLE 0
# endif # endif
#endif #endif
#if SQLITE_ENABLE_LOCKING_STYLE && defined(__DARWIN__) #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
{ {
char *proxyPath = "test.proxy"; char *proxyPath = "test.proxy";
char *testPath; char *testPath;
@ -4784,7 +4784,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
extern int sqlite3_open_file_count; extern int sqlite3_open_file_count;
extern int sqlite3_sort_count; extern int sqlite3_sort_count;
extern int sqlite3_current_time; extern int sqlite3_current_time;
#if SQLITE_OS_UNIX && defined(__DARWIN__) #if SQLITE_OS_UNIX && defined(__APPLE__)
extern int sqlite3_hostid_num; extern int sqlite3_hostid_num;
#endif #endif
extern int sqlite3_max_blobsize; extern int sqlite3_max_blobsize;
@ -5008,7 +5008,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
(char*)&sqlite3_open_file_count, TCL_LINK_INT); (char*)&sqlite3_open_file_count, TCL_LINK_INT);
Tcl_LinkVar(interp, "sqlite_current_time", Tcl_LinkVar(interp, "sqlite_current_time",
(char*)&sqlite3_current_time, TCL_LINK_INT); (char*)&sqlite3_current_time, TCL_LINK_INT);
#if SQLITE_OS_UNIX && defined(__DARWIN__) #if SQLITE_OS_UNIX && defined(__APPLE__)
Tcl_LinkVar(interp, "sqlite_hostid_num", Tcl_LinkVar(interp, "sqlite_hostid_num",
(char*)&sqlite3_hostid_num, TCL_LINK_INT); (char*)&sqlite3_hostid_num, TCL_LINK_INT);
#endif #endif

View File

@ -16,7 +16,7 @@
** The focus of this file is providing the TCL testing layer ** The focus of this file is providing the TCL testing layer
** access to compile-time constants. ** access to compile-time constants.
** **
** $Id: test_config.c,v 1.45 2008/11/29 02:20:27 drh Exp $ ** $Id: test_config.c,v 1.46 2009/01/09 21:41:17 drh Exp $
*/ */
#include "sqliteLimit.h" #include "sqliteLimit.h"
@ -393,13 +393,13 @@ Tcl_SetVar2(interp, "sqlite_options", "long_double",
#endif #endif
#if !defined(SQLITE_ENABLE_LOCKING_STYLE) #if !defined(SQLITE_ENABLE_LOCKING_STYLE)
# if defined(__DARWIN__) # if defined(__APPLE__)
# define SQLITE_ENABLE_LOCKING_STYLE 1 # define SQLITE_ENABLE_LOCKING_STYLE 1
# else # else
# define SQLITE_ENABLE_LOCKING_STYLE 0 # define SQLITE_ENABLE_LOCKING_STYLE 0
# endif # endif
#endif #endif
#if SQLITE_ENABLE_LOCKING_STYLE && defined(__DARWIN__) #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
Tcl_SetVar2(interp,"sqlite_options","lock_proxy_pragmas","1",TCL_GLOBAL_ONLY); Tcl_SetVar2(interp,"sqlite_options","lock_proxy_pragmas","1",TCL_GLOBAL_ONLY);
#else #else
Tcl_SetVar2(interp,"sqlite_options","lock_proxy_pragmas","0",TCL_GLOBAL_ONLY); Tcl_SetVar2(interp,"sqlite_options","lock_proxy_pragmas","0",TCL_GLOBAL_ONLY);

View File

@ -106,5 +106,16 @@ do_test fkey1-3.3 {
{0 0 t5 d {} {SET NULL} CASCADE NONE} \ {0 0 t5 d {} {SET NULL} CASCADE NONE} \
{0 1 t5 e {} {SET NULL} CASCADE NONE} \ {0 1 t5 e {} {SET NULL} CASCADE NONE} \
] ]
do_test fkey1-3.4 {
execsql {
CREATE TABLE t9(d, e, f,
FOREIGN KEY (d, e) REFERENCES t5 ON DELETE CASCADE ON UPDATE SET DEFAULT
);
PRAGMA foreign_key_list(t9);
}
} [concat \
{0 0 t5 d {} {SET DEFAULT} CASCADE NONE} \
{0 1 t5 e {} {SET DEFAULT} CASCADE NONE} \
]
finish_test finish_test

View File

@ -13,7 +13,7 @@
# in particular the optimizations that occur to help those operators # in particular the optimizations that occur to help those operators
# run faster. # run faster.
# #
# $Id: like.test,v 1.11 2009/01/07 18:24:03 drh Exp $ # $Id: like.test,v 1.12 2009/01/09 21:41:17 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@ -69,12 +69,18 @@ do_test like-1.4 {
SELECT x FROM t1 WHERE x LIKE 'aBc' ORDER BY 1; SELECT x FROM t1 WHERE x LIKE 'aBc' ORDER BY 1;
} }
} {ABC abc} } {ABC abc}
do_test like-1.5 { do_test like-1.5.1 {
execsql { execsql {
PRAGMA case_sensitive_like=on; PRAGMA case_sensitive_like=on;
SELECT x FROM t1 WHERE x LIKE 'abc' ORDER BY 1; SELECT x FROM t1 WHERE x LIKE 'abc' ORDER BY 1;
} }
} {abc} } {abc}
do_test like-1.5.2 {
execsql {
PRAGMA case_sensitive_like; -- no argument; does not change setting
SELECT x FROM t1 WHERE x LIKE 'abc' ORDER BY 1;
}
} {abc}
do_test like-1.6 { do_test like-1.6 {
execsql { execsql {
SELECT x FROM t1 WHERE x GLOB 'abc' ORDER BY 1; SELECT x FROM t1 WHERE x GLOB 'abc' ORDER BY 1;
@ -96,6 +102,12 @@ do_test like-1.9 {
SELECT x FROM t1 WHERE x LIKE 'abc' ORDER BY 1; SELECT x FROM t1 WHERE x LIKE 'abc' ORDER BY 1;
} }
} {ABC abc} } {ABC abc}
do_test like-1.10 {
execsql {
PRAGMA case_sensitive_like; -- No argument, does not change setting.
SELECT x FROM t1 WHERE x LIKE 'abc' ORDER BY 1;
}
} {ABC abc}
# Tests of the REGEXP operator # Tests of the REGEXP operator
# #

View File

@ -12,7 +12,7 @@
# #
# This file implements tests for the PRAGMA command. # This file implements tests for the PRAGMA command.
# #
# $Id: pragma.test,v 1.71 2008/12/30 17:55:00 drh Exp $ # $Id: pragma.test,v 1.72 2009/01/09 21:41:17 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@ -89,7 +89,7 @@ do_test pragma-1.4 {
} [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ 0] } [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ 0]
do_test pragma-1.5 { do_test pragma-1.5 {
execsql { execsql {
PRAGMA cache_size=4321; PRAGMA cache_size=-4321;
PRAGMA cache_size; PRAGMA cache_size;
PRAGMA default_cache_size; PRAGMA default_cache_size;
PRAGMA synchronous; PRAGMA synchronous;
@ -114,7 +114,7 @@ do_test pragma-1.7 {
} [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ 2] } [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ 2]
do_test pragma-1.8 { do_test pragma-1.8 {
execsql { execsql {
PRAGMA default_cache_size=123; PRAGMA default_cache_size=-123;
PRAGMA cache_size; PRAGMA cache_size;
PRAGMA default_cache_size; PRAGMA default_cache_size;
PRAGMA synchronous; PRAGMA synchronous;
@ -411,13 +411,14 @@ Page 4 is never used
Page 5 is never used Page 5 is never used
Page 6 is never used} {rowid 1 missing from index i2}} Page 6 is never used} {rowid 1 missing from index i2}}
} }
do_test pragma-3.99 { do_test pragma-3.19 {
catchsql {DETACH t3} catch {db close}
catchsql {DETACH t2} file delete -force test.db test.db-journal
file delete -force testerr.db testerr.db-journal sqlite3 db test.db
catchsql {DROP INDEX i2} db eval {PRAGMA integrity_check}
} {0 {}} } {ok}
} }
#exit
# Test modifying the cache_size of an attached database. # Test modifying the cache_size of an attached database.
ifcapable pager_pragmas&&attach { ifcapable pager_pragmas&&attach {
@ -503,9 +504,15 @@ ifcapable tempdb&&attach {
} }
do_test pragma-6.2 { do_test pragma-6.2 {
execsql { execsql {
CREATE TABLE t2(a,b,c);
pragma table_info(t2) pragma table_info(t2)
} }
} {0 a {} 0 {} 0 1 b {} 0 {} 0 2 c {} 0 {} 0} } {0 a {} 0 {} 0 1 b {} 0 {} 0 2 c {} 0 {} 0}
do_test pragma-6.2.1 {
execsql {
pragma table_info;
}
} {}
db nullvalue <<NULL>> db nullvalue <<NULL>>
do_test pragma-6.2.2 { do_test pragma-6.2.2 {
execsql { execsql {
@ -521,12 +528,27 @@ do_test pragma-6.2.2 {
} {0 a TEXT 0 CURRENT_TIMESTAMP 0 1 b {} 0 5+3 0 2 c TEXT 0 <<NULL>> 0 3 d INTEGER 0 NULL 0 4 e TEXT 0 '' 0} } {0 a TEXT 0 CURRENT_TIMESTAMP 0 1 b {} 0 5+3 0 2 c TEXT 0 <<NULL>> 0 3 d INTEGER 0 NULL 0 4 e TEXT 0 '' 0}
db nullvalue {} db nullvalue {}
ifcapable {foreignkey} { ifcapable {foreignkey} {
do_test pragma-6.3 { do_test pragma-6.3.1 {
execsql { execsql {
CREATE TABLE t3(a int references t2(b), b UNIQUE); CREATE TABLE t3(a int references t2(b), b UNIQUE);
pragma foreign_key_list(t3); pragma foreign_key_list(t3);
} }
} {0 0 t2 a b RESTRICT RESTRICT NONE} } {0 0 t2 a b RESTRICT RESTRICT NONE}
do_test pragma-6.3.2 {
execsql {
pragma foreign_key_list;
}
} {}
do_test pragma-6.3.3 {
execsql {
pragma foreign_key_list(t3_bogus);
}
} {}
do_test pragma-6.3.4 {
execsql {
pragma foreign_key_list(t5);
}
} {}
do_test pragma-6.4 { do_test pragma-6.4 {
execsql { execsql {
pragma index_list(t3); pragma index_list(t3);
@ -536,12 +558,17 @@ ifcapable {foreignkey} {
ifcapable {!foreignkey} { ifcapable {!foreignkey} {
execsql {CREATE TABLE t3(a,b UNIQUE)} execsql {CREATE TABLE t3(a,b UNIQUE)}
} }
do_test pragma-6.5 { do_test pragma-6.5.1 {
execsql { execsql {
CREATE INDEX t3i1 ON t3(a,b); CREATE INDEX t3i1 ON t3(a,b);
pragma index_info(t3i1); pragma index_info(t3i1);
} }
} {0 0 a 1 1 b} } {0 0 a 1 1 b}
do_test pragma-6.5.2 {
execsql {
pragma index_info(t3i1_bogus);
}
} {}
ifcapable tempdb { ifcapable tempdb {
# Test for ticket #3320. When a temp table of the same name exists, make # Test for ticket #3320. When a temp table of the same name exists, make
@ -592,7 +619,7 @@ do_test pragma-6.7 {
# Miscellaneous tests # Miscellaneous tests
# #
ifcapable schema_pragmas { ifcapable schema_pragmas {
do_test pragma-7.1 { do_test pragma-7.1.1 {
# Make sure a pragma knows to read the schema if it needs to # Make sure a pragma knows to read the schema if it needs to
db close db close
sqlite3 db test.db sqlite3 db test.db
@ -600,6 +627,11 @@ do_test pragma-7.1 {
pragma index_list(t3); pragma index_list(t3);
} }
} {0 t3i1 0 1 sqlite_autoindex_t3_1 1} } {0 t3i1 0 1 sqlite_autoindex_t3_1 1}
do_test pragma-7.1.2 {
execsql {
pragma index_list(t3_bogus);
}
} {}
} ;# ifcapable schema_pragmas } ;# ifcapable schema_pragmas
ifcapable {utf16} { ifcapable {utf16} {
do_test pragma-7.2 { do_test pragma-7.2 {
@ -1382,4 +1414,59 @@ ifcapable lock_proxy_pragmas {
set env(SQLITE_FORCE_PROXY_LOCKING) $using_proxy set env(SQLITE_FORCE_PROXY_LOCKING) $using_proxy
set sqlite_hostid_num 0 set sqlite_hostid_num 0
} }
# Parsing of auto_vacuum settings.
#
foreach {autovac_setting val} {
0 0
1 1
2 2
3 0
-1 0
none 0
NONE 0
NoNe 0
full 1
FULL 1
incremental 2
INCREMENTAL 2
-1234 0
1234 0
} {
do_test pragma-17.1.$autovac_setting {
catch {db close}
sqlite3 db :memory:
execsql "
PRAGMA auto_vacuum=$::autovac_setting;
PRAGMA auto_vacuum;
"
} $val
}
# Parsing of temp_store settings.
#
foreach {temp_setting val} {
0 0
1 1
2 2
3 0
-1 0
file 1
FILE 1
fIlE 1
memory 2
MEMORY 2
MeMoRy 2
} {
do_test pragma-18.1.$temp_setting {
catch {db close}
sqlite3 db :memory:
execsql "
PRAGMA temp_store=$::temp_setting;
PRAGMA temp_store=$::temp_setting;
PRAGMA temp_store;
"
} $val
}
finish_test finish_test