If the SQLITE_FCNTL_PRAGMA file-control returns anything other than

SQLTIE_NOTFOUND and SQLITE_OK, then treat the result as an error.

FossilOrigin-Name: 5643618108a8aafba67ed4004039b862bb5e5da8
This commit is contained in:
drh 2012-02-22 19:56:17 +00:00
parent eb9a9696f6
commit 92c700dbb7
5 changed files with 53 additions and 12 deletions

View File

@ -1,5 +1,5 @@
C Disable\sthe\s"filename"\spragma\simplemented\sby\sos_unix.c\sexcept\swhen\scompiled\nwith\sSQLITE_TEST. C If\sthe\sSQLITE_FCNTL_PRAGMA\sfile-control\sreturns\sanything\sother\sthan\nSQLTIE_NOTFOUND\sand\sSQLITE_OK,\sthen\streat\sthe\sresult\sas\san\serror.
D 2012-02-22T19:03:19.757 D 2012-02-22T19:56:17.256
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34 F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -174,7 +174,7 @@ F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e
F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 F src/pcache.c f8043b433a57aba85384a531e3937a804432a346
F src/pcache.h 1b5dcc3dc8103d03e625b177023ee67764fa6b7c F src/pcache.h 1b5dcc3dc8103d03e625b177023ee67764fa6b7c
F src/pcache1.c b30b1c35908346ecc43d8d9d17f2ddf6817f8f60 F src/pcache1.c b30b1c35908346ecc43d8d9d17f2ddf6817f8f60
F src/pragma.c c452bbbd2afc48e80a42adaba559bd63e998ea17 F src/pragma.c a6b1b209a143fd235fe61cad4bf4e0d1f765f5ce
F src/prepare.c ec4989f7f480544bdc4192fe663470d2a2d7d61e F src/prepare.c ec4989f7f480544bdc4192fe663470d2a2d7d61e
F src/printf.c 7ffb4ebb8b341f67e049695ba031da717b3d2699 F src/printf.c 7ffb4ebb8b341f67e049695ba031da717b3d2699
F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
@ -230,7 +230,7 @@ F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd
F src/test_syscall.c a992d8c80ea91fbf21fb2dd570db40e77dd7e6ae F src/test_syscall.c a992d8c80ea91fbf21fb2dd570db40e77dd7e6ae
F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa
F src/test_thread.c e286f2173563f2a1747c24bcda6b9d030bf4f4e4 F src/test_thread.c e286f2173563f2a1747c24bcda6b9d030bf4f4e4
F src/test_vfs.c 07157a0bbfe161cb5e32cad2079abd26cd611c4b F src/test_vfs.c 37d523ce239e853a302933327ccbc8c73c4572c1
F src/test_vfstrace.c f20a32a5fd46feb59a93d2cf650f1ff92da3872b F src/test_vfstrace.c f20a32a5fd46feb59a93d2cf650f1ff92da3872b
F src/test_wholenumber.c 6129adfbe7c7444f2e60cc785927f3aa74e12290 F src/test_wholenumber.c 6129adfbe7c7444f2e60cc785927f3aa74e12290
F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
@ -635,7 +635,7 @@ F test/pagesize.test 1dd51367e752e742f58e861e65ed7390603827a0
F test/pcache.test 065aa286e722ab24f2e51792c1f093bf60656b16 F test/pcache.test 065aa286e722ab24f2e51792c1f093bf60656b16
F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025 F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025
F test/permutations.test fa6f0e5f13fe0b1d3f7a7613179b7f7b20028184 F test/permutations.test fa6f0e5f13fe0b1d3f7a7613179b7f7b20028184
F test/pragma.test 7fa35e53085812dac94c2bfcbb02c2a4ad35df5e F test/pragma.test 01abcc2e43d080db8df0f9517233937c20892bd1
F test/pragma2.test 3a55f82b954242c642f8342b17dffc8b47472947 F test/pragma2.test 3a55f82b954242c642f8342b17dffc8b47472947
F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552 F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552
F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301
@ -990,7 +990,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
P a1f29fa653b788f563967f55c3d20e64cbe3f549 P 9a1da91850b6074e5f9d18382f517eb868cad63c
R 69256c5b535e2ca4839b991d3bdc0dd8 R 38bcf4842421c21898ae536d39030b7a
U drh U drh
Z 24345afb75f6875260101e2916714082 Z 347350cb546f31164cbf5b1b4da5c224

View File

@ -1 +1 @@
9a1da91850b6074e5f9d18382f517eb868cad63c 5643618108a8aafba67ed4004039b862bb5e5da8

View File

@ -357,9 +357,7 @@ void sqlite3Pragma(
aFcntl[1] = zLeft; aFcntl[1] = zLeft;
aFcntl[2] = zRight; aFcntl[2] = zRight;
aFcntl[3] = 0; aFcntl[3] = 0;
sqlite3BeginBenignMalloc();
rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_PRAGMA, (void*)aFcntl); rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_PRAGMA, (void*)aFcntl);
sqlite3EndBenignMalloc();
if( rc==SQLITE_OK ){ if( rc==SQLITE_OK ){
if( aFcntl[0] ){ if( aFcntl[0] ){
int mem = ++pParse->nMem; int mem = ++pParse->nMem;
@ -369,7 +367,14 @@ void sqlite3Pragma(
sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1); sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1);
sqlite3_free(aFcntl[0]); sqlite3_free(aFcntl[0]);
} }
}else }else if( rc!=SQLITE_NOTFOUND ){
if( aFcntl[0] ){
sqlite3ErrorMsg(pParse, "%s", aFcntl[0]);
sqlite3_free(aFcntl[0]);
}
pParse->nErr++;
pParse->rc = rc;
}
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED) #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)

View File

@ -480,6 +480,23 @@ static int tvfsCheckReservedLock(sqlite3_file *pFile, int *pResOut){
*/ */
static int tvfsFileControl(sqlite3_file *pFile, int op, void *pArg){ static int tvfsFileControl(sqlite3_file *pFile, int op, void *pArg){
TestvfsFd *p = tvfsGetFd(pFile); TestvfsFd *p = tvfsGetFd(pFile);
if( op==SQLITE_FCNTL_PRAGMA ){
char **argv = (char**)pArg;
if( sqlite3_stricmp(argv[1],"error")==0 ){
int rc = SQLITE_ERROR;
if( argv[2] ){
const char *z = argv[2];
int x = atoi(z);
if( x ){
rc = x;
while( sqlite3Isdigit(z[0]) ){ z++; }
while( sqlite3Isspace(z[0]) ){ z++; }
}
if( z[0] ) argv[0] = sqlite3_mprintf("%s", z);
}
return rc;
}
}
return sqlite3OsFileControl(p->pReal, op, pArg); return sqlite3OsFileControl(p->pReal, op, pArg);
} }

View File

@ -1489,4 +1489,23 @@ foreach {temp_setting val} {
} $val } $val
} }
# The SQLITE_FCNTL_PRAGMA logic, with error handling.
#
db close
testvfs tvfs
sqlite3 db test.db -vfs tvfs
do_test pragma-19.1 {
catchsql {PRAGMA error}
} {1 {SQL logic error or missing database}}
do_test pragma-19.2 {
catchsql {PRAGMA error='This is the error message'}
} {1 {This is the error message}}
do_test pragma-19.3 {
catchsql {PRAGMA error='7 This is the error message'}
} {1 {This is the error message}}
do_test pragma-19.4 {
catchsql {PRAGMA error=7}
} {1 {out of memory}}
finish_test finish_test