From: drh Date: Fri, 15 Aug 2003 13:24:51 +0000 (+0000) Subject: Fix a segfault that occurs in the VACUUM command if run on an empty database X-Git-Tag: version-3.6.10~4995 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8e18bac7937eb448fa4169ee08f6989500ae3b88;p=thirdparty%2Fsqlite.git Fix a segfault that occurs in the VACUUM command if run on an empty database with the EMPTY_RESULT_CALLBACKS pragma enabled. Ticket #427. (CVS 1073) FossilOrigin-Name: 3563e9cf9d6b20f09e92deb21fdda93bcd8fb583 --- diff --git a/manifest b/manifest index 6cd51e8ddd..24e9d4b146 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\sNULL-handling\schart\swith\snew\sinformation\sabout\sFirebird.\s(CVS\s1072) -D 2003-08-13T11:29:24 +C Fix\sa\ssegfault\sthat\soccurs\sin\sthe\sVACUUM\scommand\sif\srun\son\san\sempty\sdatabase\nwith\sthe\sEMPTY_RESULT_CALLBACKS\spragma\senabled.\s\sTicket\s#427.\s(CVS\s1073) +D 2003-08-15T13:24:52 F Makefile.in 9ad23ed4ca97f9670c4496432e3fbd4b3760ebde F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -58,7 +58,7 @@ F src/tokenize.c 2ba93fe10d5f57f0cc20b07417c3244a30c324b3 F src/trigger.c 6ff205aaac4869e402d9902e528e1d22a85de14c F src/update.c 24260b4fda00c9726d27699a0561d53c0dccc397 F src/util.c 9ab0f573d31ad8c3cf1fcb6bef7a6299e09463fa -F src/vacuum.c 0820984615786c9ccdaad8032a792309b354a8eb +F src/vacuum.c e4724eade07e4cf8897060a8cf632dbd92408eeb F src/vdbe.c 779fa3b15148161282a71241ff9733a54a8b0648 F src/vdbe.h d853ed6cc4727fa9e8ace6187c55afcf817041dd F src/where.c 83b2a2d26d5c3bea33457a83e541bb1dcf7b1248 @@ -127,7 +127,7 @@ F test/trigger3.test a95ccace88291449f5eae7139ec438a42f90654d F test/trigger4.test 542afce45774e8f8e1130b96b8675f414d6e4bd8 F test/unique.test 0e38d4cc7affeef2527720d1dafd1f6870f02f2b F test/update.test 2ef5a6655f2966f0aef733a9f4495b3fe8e16809 -F test/vacuum.test 4d8c8af30338577af03e563bc815d7898ae65258 +F test/vacuum.test 9a5a519b088287f6e20a4e936a59519b4df6a5de F test/version.test 605fd0d7e7d571370c32b12dbf395b58953de246 F test/view.test 1ee12c6f8f4791a2c0655120d5562a49400cfe53 F test/where.test cb3a2ed062ce4b5f08aff2d08027c6a46d68c47b @@ -168,7 +168,7 @@ F www/speed.tcl 2f6b1155b99d39adb185f900456d1d592c4832b3 F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331 F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1 -P 02fac304c9ec9012f3cc4f04d2c4cac5e37b0024 -R c5c60d7816b69e7ad636fa582dc70cef +P 17bdfeb284880d82cd546e6c191c3a37121ec861 +R 99126044d381fca63089f0ab608b861d U drh -Z 5cc44053e6e9f069f799212980612ed0 +Z ffa6c41bb25f99b70e59810bf367fde2 diff --git a/manifest.uuid b/manifest.uuid index 1f397b7b48..cf5cbdc27c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -17bdfeb284880d82cd546e6c191c3a37121ec861 \ No newline at end of file +3563e9cf9d6b20f09e92deb21fdda93bcd8fb583 \ No newline at end of file diff --git a/src/vacuum.c b/src/vacuum.c index afa1e263b3..76863b5f49 100644 --- a/src/vacuum.c +++ b/src/vacuum.c @@ -14,7 +14,7 @@ ** Most of the code in this file may be omitted by defining the ** SQLITE_OMIT_VACUUM macro. ** -** $Id: vacuum.c,v 1.7 2003/05/13 00:21:59 drh Exp $ +** $Id: vacuum.c,v 1.8 2003/08/15 13:24:52 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -111,6 +111,7 @@ static int vacuumCallback2(void *pArg, int argc, char **argv, char **NotUsed){ const char *zSep = "("; int i; + if( argv==0 ) return 0; p->s2.nUsed = 0; appendText(&p->s2, "INSERT INTO ", -1); appendQuoted(&p->s2, p->zTable); @@ -141,6 +142,7 @@ static int vacuumCallback1(void *pArg, int argc, char **argv, char **NotUsed){ vacuumStruct *p = (vacuumStruct*)pArg; int rc = 0; assert( argc==3 ); + if( argv==0 ) return 0; assert( argv[0]!=0 ); assert( argv[1]!=0 ); assert( argv[2]!=0 ); @@ -169,6 +171,7 @@ static int vacuumCallback3(void *pArg, int argc, char **argv, char **NotUsed){ int rc = 0; char zBuf[200]; assert( argc==1 ); + if( argv==0 ) return 0; assert( argv[0]!=0 ); assert( strlen(p->zPragma)<100 ); assert( strlen(argv[0])<30 ); diff --git a/test/vacuum.test b/test/vacuum.test index 235c860609..8a650552ef 100644 --- a/test/vacuum.test +++ b/test/vacuum.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing the VACUUM statement. # -# $Id: vacuum.test,v 1.10 2003/04/25 13:28:03 drh Exp $ +# $Id: vacuum.test,v 1.11 2003/08/15 13:24:53 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -120,6 +120,18 @@ do_test vacuum-2.4 { cksum db2 } $cksum +# Ticket #427. Make sure VACUUM works when the EMPTY_RESULT_CALLBACKS +# pragma is turned on. +# +do_test vacuum-3.1 { + db close + file delete test.db + sqlite db test.db + execsql { + PRAGMA empty_result_callbacks=on; + VACUUM; + } +} {} catch {db2 close}