diff --git a/manifest b/manifest index 2643604ef6..a89c80d025 100644 --- a/manifest +++ b/manifest @@ -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) -D 2009-01-09T17:11:05 +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-09T21:41:17 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 05461a9b5803d5ad10c79f989801e9fd2cc3e592 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -140,7 +140,7 @@ F src/os.c ed93a6b46132a602c4fd7a58142e2981c829c79d F src/os.h 4ee25a35c00e75a569cecb5080be299b0c3e208e F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60 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/pager.c 97bfbacae6131b8d228628803606e98dd763b474 F src/pager.h 9870acb2d653848d90d765d7cbf163496d6c8111 @@ -148,7 +148,7 @@ F src/parse.y 4d0e33a702dc3ea7b69d8ae1914b3fbd32e46057 F src/pcache.c 16dc8da6e6ba6250f8dfd9ee46036db1cbceedc6 F src/pcache.h f20c3e82dd6da622c3fe296170cb1801f9a2d75a F src/pcache1.c c0aa84ff69ea759fa944dbee9167a2463ab7c322 -F src/pragma.c d6dfc47979623cf593d0db926daff49d214a8eb3 +F src/pragma.c ec9470bc3ee91dd8933adad209a24311401ca78c F src/prepare.c 2a11736383d0af2ea80aa62270f15ad80dd8b5cd F src/printf.c 9866a9a9c4a90f6d4147407f373df3fd5d5f9b6f F src/random.c 676b9d7ac820fe81e6fb2394ac8c10cff7f38628 @@ -163,7 +163,7 @@ F src/sqliteLimit.h 651a2757ba55aeba1da167786b6a8c3404433940 F src/status.c 237b193efae0cf6ac3f0817a208de6c6c6ef6d76 F src/table.c 23db1e5f27c03160987c122a078b4bb51ef0b2f8 F src/tclsqlite.c 4415e1033bd3e92b05a6a9cde911ee4de3b82df9 -F src/test1.c 473a6a230988f50129abe7614c95a9512f6efa78 +F src/test1.c 243bbbdb91618ecce2a51e0ee1c7d8f3f8740193 F src/test2.c 724095fc69cb54b018aaa4463a56836c0b53a17a F src/test3.c 88a246b56b824275300e6c899634fbac1dc94b14 F src/test4.c f79ab52d27ff49b784b631a42e2ccd52cfd5c84c @@ -175,7 +175,7 @@ F src/test9.c 904ebe0ed1472d6bad17a81e2ecbfc20017dc237 F src/test_async.c 45024094ed7cf780c5d5dccda645145f95cf78ef F src/test_autoext.c f53b0cdf7bf5f08100009572a5d65cdb540bd0ad 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_func.c a55c4d5479ff2eb5c0a22d4d88e9528ab59c953b F src/test_hexio.c 2f1122aa3f012fa0142ee3c36ce5c902a70cd12f @@ -312,7 +312,7 @@ F test/exec.test e949714dc127eaa5ecc7d723efec1ec27118fdd7 F test/expr.test bc1e6997c27238f6de539f1079ff93e5078ea7c3 F test/filectrl.test 8923a6dc7630f31c8a9dd3d3d740aa0922df7bf8 F test/filefmt.test 053b622009fbbb74dd37921ffad374d852c13cd8 -F test/fkey1.test c373e4f1ec43416957e0591c4a5cebb63b8a12e7 +F test/fkey1.test 78506fa55800d553d8fe1f3e7f73ce996fd2cef9 F test/format4.test 1f0cac8ff3895e9359ed87e41aaabee982a812eb F test/fts1a.test 46090311f85da51bb33bd5ce84f7948359c6d8d7 F test/fts1b.test 5d8a01aefbecc8b7442b36c94c05eb7a845462d5 @@ -416,7 +416,7 @@ F test/journal1.test 36f2d1bb9bf03f790f43fbdb439e44c0657fab19 F test/jrnlmode.test e004a5ed138e06464d74dbd6bead01908f264c52 F test/lastinsert.test 474d519c68cb79d07ecae56a763aa7f322c72f51 F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200 -F test/like.test e55cbbc21729f577b74ec333c753a2d6eda03f9f +F test/like.test 22f7857f9d7da7ff5061ded8806c43a6271109fc F test/like2.test 3b2ee13149ba4a8a60b59756f4e5d345573852da F test/limit.test 2db7b3b34fb925b8e847d583d2eb67531d0ce67e F test/loadext.test 18db29c081380fdedcfbd8c633847712059ae104 @@ -481,7 +481,7 @@ F test/pagesize.test 0d9ff3fedfce6e5ffe8fa7aca9b6d3433a2e843b F test/pcache.test ccd18b4d2b432f44319a82b0367ed843ee18cebd F test/pcache2.test 46efd980a89f737847b99327bda19e08fe11e402 F test/permutations.test af0962c17a32631de8b301c301c497adea9739f4 -F test/pragma.test 325aa0833d483b8e0c98e8196f1cc49fa5d8c336 +F test/pragma.test 3fd4d3cc9f48aa5f2fb050d17234222ddac68ec6 F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47 F test/printf.test 262a5acd3158f788e9bdf7f18d718f3af32ff6ef F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x @@ -696,7 +696,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P c917961743e9ab60a096801c8910c6cd8367ee2f -R 84887d8478ad2a6db00d201594f1baf7 -U danielk1977 -Z 53b1598924155611310d0a2e9e4862da +P 0f3f9011fa143f7b63c9bf79d3e411327d5c6f9d +R e1e4036b9a98af33862eb0ed9594debc +U drh +Z a59dff8080441c305d285f6286bef741 diff --git a/manifest.uuid b/manifest.uuid index 097accf838..3b3e35b29e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0f3f9011fa143f7b63c9bf79d3e411327d5c6f9d \ No newline at end of file +64c56226b91e57883c8059f65330318e53376b8a \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 014c7216e4..5c7a8a5292 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -43,7 +43,7 @@ ** * Definitions of sqlite3_vfs objects for all locking methods ** 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" #if SQLITE_OS_UNIX /* This file is used on unix only */ @@ -66,7 +66,7 @@ ** where the database is located. */ #if !defined(SQLITE_ENABLE_LOCKING_STYLE) -# if defined(__DARWIN__) +# if defined(__APPLE__) # define SQLITE_ENABLE_LOCKING_STYLE 1 # else # define SQLITE_ENABLE_LOCKING_STYLE 0 @@ -2174,7 +2174,7 @@ static int semClose(sqlite3_file *id) { ** 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 */ @@ -2557,7 +2557,7 @@ static int afpClose(sqlite3_file *id) { 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 ** 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; } -#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 ** proxying locking division. @@ -2958,12 +2958,12 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){ *(int*)pArg = ((unixFile*)id)->lastErrno; return SQLITE_OK; } -#if SQLITE_ENABLE_LOCKING_STYLE && defined(__DARWIN__) +#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) case SQLITE_SET_LOCKPROXYFILE: case SQLITE_GET_LOCKPROXYFILE: { return proxyFileControl(id,op,pArg); } -#endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__DARWIN__) */ +#endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) */ } return SQLITE_ERROR; } @@ -3106,7 +3106,7 @@ IOMETHODS( ) #endif -#if defined(__DARWIN__) && SQLITE_ENABLE_LOCKING_STYLE +#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE IOMETHODS( afpIoFinder, /* Finder function name */ afpIoMethods, /* sqlite3_io_methods object name */ @@ -3126,7 +3126,7 @@ IOMETHODS( ** to go ahead and define the sqlite3_io_methods and finder function ** 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 proxyLock(sqlite3_file*, int); static int proxyUnlock(sqlite3_file*, int); @@ -3142,7 +3142,7 @@ IOMETHODS( #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 ** 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) = 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: @@ -3279,7 +3279,7 @@ static int fillInUnixFile( unixLeaveMutex(); } -#if SQLITE_ENABLE_LOCKING_STYLE && defined(__DARWIN__) +#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) else if( pLockingStyle == &afpIoMethods ){ /* AFP locking uses the file path so it needs to be included in ** the afpLockingContext. @@ -3451,7 +3451,7 @@ static int getTempname(int nBuf, char *zBuf){ 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. ** 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 */ -#if defined(__DARWIN__) && SQLITE_ENABLE_LOCKING_STYLE +#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE #ifdef SQLITE_TEST /* simulate multiple hosts by creating unique hostid file paths */ @@ -4588,7 +4588,7 @@ static int switchLockProxyPath(unixFile *pFile, const char *path) { ** int dbPath. */ static int proxyGetDbPathForUnixFile(unixFile *pFile, char *dbPath){ -#if defined(__DARWIN__) +#if defined(__APPLE__) if( pFile->pMethod == &afpIoMethods ){ /* afp style keeps a reference to the db path in the filePath field ** 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. ** 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. */ static sqlite3_vfs aVfs[] = { -#if SQLITE_ENABLE_LOCKING_STYLE && defined(__DARWIN__) +#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) UNIXVFS("unix", autolockIoFinder ), #else UNIXVFS("unix", posixIoFinder ), @@ -4944,7 +4944,7 @@ int sqlite3_os_init(void){ UNIXVFS("unix-posix", posixIoFinder ), UNIXVFS("unix-flock", flockIoFinder ), #endif -#if SQLITE_ENABLE_LOCKING_STYLE && defined(__DARWIN__) +#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) UNIXVFS("unix-afp", afpIoFinder ), UNIXVFS("unix-proxy", proxyIoFinder ), #endif diff --git a/src/pragma.c b/src/pragma.c index 5f301b13a5..7890208f34 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -11,7 +11,7 @@ ************************************************************************* ** 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 @@ -196,7 +196,8 @@ static int flagPragma(Parse *pParse, const char *zLeft, const char *zRight){ sqlite3 *db = pParse->db; Vdbe *v; v = sqlite3GetVdbe(pParse); - if( v ){ + assert( v!=0 ); /* Already allocated by sqlite3Pragma() */ + if( ALWAYS(v) ){ if( zRight==0 ){ returnSingleInt(pParse, p->zName, (db->flags & p->mask)!=0 ); }else{ @@ -221,14 +222,19 @@ static int flagPragma(Parse *pParse, const char *zLeft, const char *zRight){ } #endif /* SQLITE_OMIT_FLAG_PRAGMAS */ +/* +** Return a human-readable name for a constraint resolution action. +*/ static const char *actionName(u8 action){ + const char *zName; switch( action ){ - case OE_SetNull: return "SET NULL"; - case OE_SetDflt: return "SET DEFAULT"; - case OE_Restrict: return "RESTRICT"; - case OE_Cascade: return "CASCADE"; + case OE_SetNull: zName = "SET NULL"; break; + case OE_SetDflt: zName = "SET DEFAULT"; break; + case OE_Cascade: zName = "CASCADE"; break; + default: zName = "RESTRICT"; + assert( action==OE_Restrict ); break; } - return ""; + return zName; } /* @@ -285,7 +291,8 @@ void sqlite3Pragma( 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) ){ goto pragma_out; } @@ -353,8 +360,9 @@ void sqlite3Pragma( */ if( sqlite3StrICmp(zLeft,"page_size")==0 ){ Btree *pBt = pDb->pBt; + assert( pBt!=0 ); if( !zRight ){ - int size = pBt ? sqlite3BtreeGetPageSize(pBt) : 0; + int size = ALWAYS(pBt) ? sqlite3BtreeGetPageSize(pBt) : 0; returnSingleInt(pParse, "page_size", size); }else{ /* 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 ){ Btree *pBt = pDb->pBt; int newMax = 0; + assert( pBt!=0 ); if( zRight ){ newMax = atoi(zRight); } - if( pBt ){ + if( ALWAYS(pBt) ){ newMax = sqlite3BtreeMaxPageCount(pBt, newMax); } returnSingleInt(pParse, "max_page_count", newMax); @@ -395,7 +404,7 @@ void sqlite3Pragma( */ if( sqlite3StrICmp(zLeft,"page_count")==0 ){ int iReg; - if( !v || sqlite3ReadSchema(pParse) ) goto pragma_out; + if( sqlite3ReadSchema(pParse) ) goto pragma_out; sqlite3CodeVerifySchema(pParse, iDb); iReg = ++pParse->nMem; sqlite3VdbeAddOp2(v, OP_Pagecount, iDb, iReg); @@ -543,17 +552,23 @@ void sqlite3Pragma( #ifndef SQLITE_OMIT_AUTOVACUUM if( sqlite3StrICmp(zLeft,"auto_vacuum")==0 ){ Btree *pBt = pDb->pBt; + assert( pBt!=0 ); if( sqlite3ReadSchema(pParse) ){ goto pragma_out; } if( !zRight ){ - int auto_vacuum = - pBt ? sqlite3BtreeGetAutoVacuum(pBt) : SQLITE_DEFAULT_AUTOVACUUM; + int auto_vacuum; + if( ALWAYS(pBt) ){ + auto_vacuum = sqlite3BtreeGetAutoVacuum(pBt); + }else{ + auto_vacuum = SQLITE_DEFAULT_AUTOVACUUM; + } returnSingleInt(pParse, "auto_vacuum", auto_vacuum); }else{ int eAuto = getAutoVacuum(zRight); + assert( eAuto>=0 && eAuto<=2 ); db->nextAutovac = (u8)eAuto; - if( eAuto>=0 ){ + 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 @@ -704,6 +719,14 @@ void sqlite3Pragma( } }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 = ":auto:"|"lock_file_path" @@ -744,7 +767,7 @@ void sqlite3Pragma( } } }else - +#endif /* SQLITE_ENABLE_LOCKING_STYLE */ /* ** PRAGMA [database.]synchronous @@ -818,7 +841,9 @@ void sqlite3Pragma( sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pCol->zType ? pCol->zType : "", 0); 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); }else{ sqlite3VdbeAddOp2(v, OP_Null, 0, 5); @@ -1178,11 +1203,11 @@ void sqlite3Pragma( char *zName; u8 enc; } encnames[] = { - { "UTF-8", 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 }, - { "UTF-16be", SQLITE_UTF16BE }, { "UTF16be", SQLITE_UTF16BE }, { "UTF-16", 0 }, /* SQLITE_UTF16NATIVE */ { "UTF16", 0 }, /* SQLITE_UTF16NATIVE */ @@ -1194,12 +1219,10 @@ void sqlite3Pragma( sqlite3VdbeSetNumCols(v, 1); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "encoding", SQLITE_STATIC); sqlite3VdbeAddOp2(v, OP_String8, 0, 1); - for(pEnc=&encnames[0]; pEnc->zName; pEnc++){ - if( pEnc->enc==ENC(pParse->db) ){ - sqlite3VdbeChangeP4(v, -1, pEnc->zName, P4_STATIC); - break; - } - } + assert( encnames[SQLITE_UTF8].enc==SQLITE_UTF8 ); + assert( encnames[SQLITE_UTF16LE].enc==SQLITE_UTF16LE ); + assert( encnames[SQLITE_UTF16BE].enc==SQLITE_UTF16BE ); + sqlite3VdbeChangeP4(v, -1, encnames[ENC(pParse->db)].zName, P4_STATIC); sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); }else{ /* "PRAGMA encoding = XXX" */ /* Only change the value of sqlite.enc if the database handle is not @@ -1344,9 +1367,27 @@ void sqlite3Pragma( #endif #if SQLITE_HAS_CODEC - if( sqlite3StrICmp(zLeft, "key")==0 ){ + if( sqlite3StrICmp(zLeft, "key")==0 && zRight ){ sqlite3_key(db, zRight, sqlite3Strlen30(zRight)); }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 #if SQLITE_HAS_CODEC || defined(SQLITE_ENABLE_CEROD) if( sqlite3StrICmp(zLeft, "activate_extensions")==0 ){ @@ -1362,29 +1403,28 @@ void sqlite3Pragma( sqlite3_activate_cerod(&zRight[6]); } #endif - } + }else #endif - {} + + {/* Empty ELSE clause */} - if( v ){ - /* 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 + ** the VDBE implementing the pragma to expire. Most (all?) pragmas + ** 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. - */ + /* + ** Reset the safety level, in case the fullfsync flag or synchronous + ** setting changed. + */ #ifndef SQLITE_OMIT_PAGER_PRAGMAS - if( db->autoCommit ){ - sqlite3BtreeSetSafetyLevel(pDb->pBt, pDb->safety_level, - (db->flags&SQLITE_FullFSync)!=0); - } -#endif + if( db->autoCommit ){ + sqlite3BtreeSetSafetyLevel(pDb->pBt, pDb->safety_level, + (db->flags&SQLITE_FullFSync)!=0); } +#endif pragma_out: sqlite3DbFree(db, zLeft); sqlite3DbFree(db, zRight); diff --git a/src/test1.c b/src/test1.c index f5ba0cb0ce..7ce482a758 100644 --- a/src/test1.c +++ b/src/test1.c @@ -13,7 +13,7 @@ ** is not included in the SQLite library. It is used for automated ** 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 "tcl.h" @@ -4577,13 +4577,13 @@ static int file_control_lockproxy_test( if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; #if !defined(SQLITE_ENABLE_LOCKING_STYLE) -# if defined(__DARWIN__) +# if defined(__APPLE__) # define SQLITE_ENABLE_LOCKING_STYLE 1 # else # define SQLITE_ENABLE_LOCKING_STYLE 0 # endif #endif -#if SQLITE_ENABLE_LOCKING_STYLE && defined(__DARWIN__) +#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) { char *proxyPath = "test.proxy"; char *testPath; @@ -4784,7 +4784,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ extern int sqlite3_open_file_count; extern int sqlite3_sort_count; extern int sqlite3_current_time; -#if SQLITE_OS_UNIX && defined(__DARWIN__) +#if SQLITE_OS_UNIX && defined(__APPLE__) extern int sqlite3_hostid_num; #endif extern int sqlite3_max_blobsize; @@ -5008,7 +5008,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ (char*)&sqlite3_open_file_count, TCL_LINK_INT); Tcl_LinkVar(interp, "sqlite_current_time", (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", (char*)&sqlite3_hostid_num, TCL_LINK_INT); #endif diff --git a/src/test_config.c b/src/test_config.c index d6662f671e..5658138567 100644 --- a/src/test_config.c +++ b/src/test_config.c @@ -16,7 +16,7 @@ ** The focus of this file is providing the TCL testing layer ** 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" @@ -393,13 +393,13 @@ Tcl_SetVar2(interp, "sqlite_options", "long_double", #endif #if !defined(SQLITE_ENABLE_LOCKING_STYLE) -# if defined(__DARWIN__) +# if defined(__APPLE__) # define SQLITE_ENABLE_LOCKING_STYLE 1 # else # define SQLITE_ENABLE_LOCKING_STYLE 0 # 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); #else Tcl_SetVar2(interp,"sqlite_options","lock_proxy_pragmas","0",TCL_GLOBAL_ONLY); diff --git a/test/fkey1.test b/test/fkey1.test index a4f363bb61..8a4fb70d3b 100644 --- a/test/fkey1.test +++ b/test/fkey1.test @@ -106,5 +106,16 @@ do_test fkey1-3.3 { {0 0 t5 d {} {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 diff --git a/test/like.test b/test/like.test index 15d3c66aaf..cd766079ff 100644 --- a/test/like.test +++ b/test/like.test @@ -13,7 +13,7 @@ # in particular the optimizations that occur to help those operators # 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] source $testdir/tester.tcl @@ -69,12 +69,18 @@ do_test like-1.4 { SELECT x FROM t1 WHERE x LIKE 'aBc' ORDER BY 1; } } {ABC abc} -do_test like-1.5 { +do_test like-1.5.1 { execsql { PRAGMA case_sensitive_like=on; SELECT x FROM t1 WHERE x LIKE 'abc' ORDER BY 1; } } {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 { execsql { 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; } } {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 # diff --git a/test/pragma.test b/test/pragma.test index ce0fd23f67..aea0027ac3 100644 --- a/test/pragma.test +++ b/test/pragma.test @@ -12,7 +12,7 @@ # # 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] source $testdir/tester.tcl @@ -89,7 +89,7 @@ do_test pragma-1.4 { } [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ 0] do_test pragma-1.5 { execsql { - PRAGMA cache_size=4321; + PRAGMA cache_size=-4321; PRAGMA cache_size; PRAGMA default_cache_size; PRAGMA synchronous; @@ -114,7 +114,7 @@ do_test pragma-1.7 { } [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ 2] do_test pragma-1.8 { execsql { - PRAGMA default_cache_size=123; + PRAGMA default_cache_size=-123; PRAGMA cache_size; PRAGMA default_cache_size; PRAGMA synchronous; @@ -411,13 +411,14 @@ Page 4 is never used Page 5 is never used Page 6 is never used} {rowid 1 missing from index i2}} } - do_test pragma-3.99 { - catchsql {DETACH t3} - catchsql {DETACH t2} - file delete -force testerr.db testerr.db-journal - catchsql {DROP INDEX i2} - } {0 {}} + do_test pragma-3.19 { + catch {db close} + file delete -force test.db test.db-journal + sqlite3 db test.db + db eval {PRAGMA integrity_check} + } {ok} } +#exit # Test modifying the cache_size of an attached database. ifcapable pager_pragmas&&attach { @@ -503,9 +504,15 @@ ifcapable tempdb&&attach { } do_test pragma-6.2 { execsql { + CREATE TABLE t2(a,b,c); pragma table_info(t2) } } {0 a {} 0 {} 0 1 b {} 0 {} 0 2 c {} 0 {} 0} +do_test pragma-6.2.1 { + execsql { + pragma table_info; + } +} {} db nullvalue <> do_test pragma-6.2.2 { 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 <> 0 3 d INTEGER 0 NULL 0 4 e TEXT 0 '' 0} db nullvalue {} ifcapable {foreignkey} { - do_test pragma-6.3 { + do_test pragma-6.3.1 { execsql { CREATE TABLE t3(a int references t2(b), b UNIQUE); pragma foreign_key_list(t3); } } {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 { execsql { pragma index_list(t3); @@ -536,12 +558,17 @@ ifcapable {foreignkey} { ifcapable {!foreignkey} { execsql {CREATE TABLE t3(a,b UNIQUE)} } -do_test pragma-6.5 { +do_test pragma-6.5.1 { execsql { CREATE INDEX t3i1 ON t3(a,b); pragma index_info(t3i1); } } {0 0 a 1 1 b} +do_test pragma-6.5.2 { + execsql { + pragma index_info(t3i1_bogus); + } +} {} ifcapable tempdb { # 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 # 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 db close sqlite3 db test.db @@ -600,6 +627,11 @@ do_test pragma-7.1 { pragma index_list(t3); } } {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 {utf16} { do_test pragma-7.2 { @@ -1382,4 +1414,59 @@ ifcapable lock_proxy_pragmas { set env(SQLITE_FORCE_PROXY_LOCKING) $using_proxy 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