From: drh Date: Sat, 14 Feb 2004 16:31:02 +0000 (+0000) Subject: The sqlite_exec() function is now implemented using sqlite_compile() and X-Git-Tag: version-3.6.10~4828 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a1f9b5ee0becb1e1d9b01dd281719538786de083;p=thirdparty%2Fsqlite.git The sqlite_exec() function is now implemented using sqlite_compile() and sqlite_step(). This opens up lots of opportunity to remove old code. (CVS 1240) FossilOrigin-Name: 9771ad1e811e02e10bb738550fbea447749083c5 --- diff --git a/manifest b/manifest index a49e5787c6..da85d57f91 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disable\sthe\smalloc.test\stests\sif\snot\scompiled\swith\s-DMEMORY_DEBUG\s(CVS\s1239) -D 2004-02-14T01:39:50 +C The\ssqlite_exec()\sfunction\sis\snow\simplemented\susing\ssqlite_compile()\sand\nsqlite_step().\s\sThis\sopens\sup\slots\sof\sopportunity\sto\sremove\sold\scode.\s(CVS\s1240) +D 2004-02-14T16:31:03 F Makefile.in cfd75c46b335881999333a9e4b982fa8491f200b F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -26,7 +26,7 @@ F src/auth.c c59ad0dab501888f8b1fccc25e2f5965d2265116 F src/btree.c 9aefacf529226b5875b487d59e9be0224961ef3d F src/btree.h 41cb3ff6ebc3f6da2d0a074e39ff8c7a2287469f F src/btree_rb.c 32b2cb4285c0fbd53b89de021637b63d52257e54 -F src/build.c f25e98306518b76190c526bf970ebcda60919674 +F src/build.c 94fdf4d8abe56f957a519d139b0e49a92cbfb242 F src/copy.c 9e47975ea96751c658bcf1a0c4f0bb7c6ee61e73 F src/date.c c9d2bfd40b1c95f8f97d53a5eba981d7167c7b61 F src/delete.c 0778fe05df0a1d62ac27fd1a3dba237c186ff4d1 @@ -36,7 +36,7 @@ F src/func.c cbc5edd10c82a5193b9ca0726873328be445e6c1 F src/hash.c 9b56ef3b291e25168f630d5643a4264ec011c70e F src/hash.h 3247573ab95b9dd90bcca0307a75d9a16da1ccc7 F src/insert.c 01f66866f35c986eab4a57373ca689a3255ef2df -F src/main.c cfe8ca913219dbfb45990a5bdac01ad63361a3f3 +F src/main.c e38bf6463dd628d7f9b590b2a81293624f9482e9 F src/md5.c fe4f9c9c6f71dfc26af8da63e4d04489b1430565 F src/os.c f5fc4954725b2fcd852979f2746085fe8ca27710 F src/os.h 250a3789be609adfee5c5aa20137ce8683276f24 @@ -46,8 +46,8 @@ F src/parse.y 1e311dc6aae9261f8641abca9328dd6193083753 F src/pragma.c 89d62c31c6f0a43376fe8d20549b87a6d30c467a F src/printf.c 84e4ea4ba49cbbf930e95e82295127ad5843ae1f F src/random.c 775913e0b7fbd6295d21f12a7bd35b46387c44b2 -F src/select.c da4f383736a5dacf7ff856de091ffd1ca9874623 -F src/shell.c 60b33fe4b3efc0756c94efe842bbfe7459b21410 +F src/select.c 7cbd9cca5294399657da9e2d6c441add4610fb18 +F src/shell.c c3d3404fa82bb0808444fda9884d1bb572fd18b9 F src/sqlite.h.in 64f016cd5ce190643a0f47760188fdf4e0b2227e F src/sqliteInt.h c45fbae6278407111d7a00aa9280ddc0f51344ad F src/table.c d845cb101b5afc1f7fea083c99e3d2fa7998d895 @@ -61,10 +61,10 @@ F src/trigger.c ce83e017b407d046e909d05373d7f8ee70f9f7f9 F src/update.c 24260b4fda00c9726d27699a0561d53c0dccc397 F src/util.c 64995b5949a5d377629ffd2598747bc771cade1e F src/vacuum.c d9e80c2b36ee1f623dbf1bdf3cedad24a23f87ac -F src/vdbe.c 13df29e02f8015505a6ed31cd6b098932f5da07f +F src/vdbe.c a1d90927d1768c94caa972593f0d5e960ae5d848 F src/vdbe.h 3957844e46fea71fd030e78f6a3bd2f7e320fb43 F src/vdbeInt.h 8a3baf749115cba81a810b7a52208aef055eda7b -F src/vdbeaux.c c55d87d6658487e87ef09ca80c1aa2f314024fed +F src/vdbeaux.c e7dabd709bfe356df3257491a52835e80eaaa598 F src/where.c 1302d728bd338c237e6a8282e4e3eadbbdf11e45 F test/all.test 569a92a8ee88f5300c057cc4a8f50fbbc69a3242 F test/attach.test ba8261d38da6b6a7d4f78ec543c548c4418582ef @@ -100,7 +100,7 @@ F test/ioerr.test 5dbaf09f96b56ee01cf3edd762b96eb4ad2c9ca4 F test/join.test 9ef6aabaac9de51d5fc41e68d1f4355da05a84cd F test/join2.test c97e4c5aa65dea462145529e58212a709b4722b8 F test/limit.test fa2a8b3fe377ebe60e0bc9a6a35af9ac4eb3d2b3 -F test/lock.test 3d1855ba930732566f569d680e828656bd5b7f5c +F test/lock.test 226ef831dad60ad4d200dc83e25479ba952aac7e F test/main.test 6a851b5992c4881a725a3d9647e629199df8de9d F test/malloc.test 2cfcffb7c858640e01e6520ee1cd54ca57d98e80 F test/memdb.test 6ece25c7c0e6500199d3662607a3edca081abb2a @@ -130,19 +130,19 @@ F test/subselect.test f0fea8cf9f386d416d64d152e3c65f9116d0f50f F test/table.test 371a1fc1c470982b2f68f9732f903a5d96f949c4 F test/tableapi.test e0c4cce61e58343caa84dab33fa6823cb35fe1e1 F test/tclsqlite.test 602c73172b46c47221d4e699beaf6684eb120d48 -F test/temptable.test c82bd6f800f10e8cf96921af6315e5f1c21e2692 +F test/temptable.test a770ba6308d7f7332fce985086b8e06bed6430c2 F test/tester.tcl 2f1d43df1311c9dc06acaa7a82e87bfea85dea5f F test/thread1.test 53f050d5be6932d9430df7756edd379366508ff6 F test/threadtest1.c f7f896e62ed46feae1dc411114a48c15a0f82ee2 F test/threadtest2.c d94ca4114fd1504f7e0ae724bcd83d4b40931d86 F test/trans.test 75e7a171b5d2d94ee56766459113e2ad0e5f809d -F test/trigger1.test d9f600448b9198e4936a86a186b20435a8faa1f2 +F test/trigger1.test 4538c1c7d6bbca5dfe619ea6e1682b07ece95b21 F test/trigger2.test 0767ab30cb5a2c8402c8524f3d566b410b6f5263 F test/trigger3.test a95ccace88291449f5eae7139ec438a42f90654d F test/trigger4.test 542afce45774e8f8e1130b96b8675f414d6e4bd8 F test/unique.test 0e38d4cc7affeef2527720d1dafd1f6870f02f2b F test/update.test b29bd9061a1150426dab6959806fcc73a41b1217 -F test/vacuum.test 9447f1d7633b083c9b97f807fa05f9b27ada7503 +F test/vacuum.test a2a44544df719666efb51afbfeb6062fd59a672a F test/version.test 92adee5d98cf6e3eb0d1cf5186952e8114931bf6 F test/view.test 1ee12c6f8f4791a2c0655120d5562a49400cfe53 F test/where.test cb3a2ed062ce4b5f08aff2d08027c6a46d68c47b @@ -184,7 +184,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604 F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 -P 5a56090dde10ee29863021356d21c3f8c86e3f46 -R dabcde68c3990f47cc36bbc340949e46 +P 41b6ad78a6097f35bfac6ff40d2e5d6071a1c4cd +R 04c6371ce6d9b1f09f738b1da76bdeed U drh -Z 4b848e641103eb94f052a00ee105ac09 +Z bce0f6e9739dfadbfaaf175be01d71c3 diff --git a/manifest.uuid b/manifest.uuid index 013d220c58..08dc942886 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -41b6ad78a6097f35bfac6ff40d2e5d6071a1c4cd \ No newline at end of file +9771ad1e811e02e10bb738550fbea447749083c5 \ No newline at end of file diff --git a/src/build.c b/src/build.c index a63aa527b6..7d4347e54e 100644 --- a/src/build.c +++ b/src/build.c @@ -23,7 +23,7 @@ ** ROLLBACK ** PRAGMA ** -** $Id: build.c,v 1.167 2004/02/13 16:22:23 drh Exp $ +** $Id: build.c,v 1.168 2004/02/14 16:31:03 drh Exp $ */ #include "sqliteInt.h" #include @@ -112,7 +112,7 @@ void sqliteExec(Parse *pParse){ pParse->rc = pParse->nErr ? SQLITE_ERROR : SQLITE_DONE; } pParse->colNamesSet = 0; - }else if( pParse->useCallback==0 ){ + }else if( pParse->useCallback==0 && pParse->rc==SQLITE_OK ){ pParse->rc = SQLITE_ERROR; } pParse->nTab = 0; diff --git a/src/main.c b/src/main.c index 718b071984..3c665f8b86 100644 --- a/src/main.c +++ b/src/main.c @@ -14,7 +14,7 @@ ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** -** $Id: main.c,v 1.151 2004/02/13 16:30:10 drh Exp $ +** $Id: main.c,v 1.152 2004/02/14 16:31:03 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -153,8 +153,8 @@ int upgrade_3_callback(void *pInit, int argc, char **argv, char **NotUsed){ "DROP TABLE sqlite_x;", 0, 0, &zErr, argv[0], argv[0], argv[0]); if( zErr ){ - sqliteSetString(pData->pzErrMsg, zErr, (char*)0); - sqlite_freemem(zErr); + if( *pData->pzErrMsg ) sqlite_freemem(*pData->pzErrMsg); + *pData->pzErrMsg = zErr; } /* If an error occurred in the SQL above, then the transaction will @@ -588,15 +588,79 @@ void sqliteRollbackAll(sqlite *db){ } /* -** This routine does the work of either sqlite_exec() or sqlite_compile(). -** It works like sqlite_exec() if pVm==NULL and it works like sqlite_compile() -** otherwise. +** Execute SQL code. Return one of the SQLITE_ success/failure +** codes. Also write an error message into memory obtained from +** malloc() and make *pzErrMsg point to that message. +** +** If the SQL is a query, then for each row in the query result +** the xCallback() function is called. pArg becomes the first +** argument to xCallback(). If xCallback=NULL then no callback +** is invoked, even for queries. */ -static int sqliteMain( +int sqlite_exec( sqlite *db, /* The database on which the SQL executes */ const char *zSql, /* The SQL to be executed */ sqlite_callback xCallback, /* Invoke this callback routine */ void *pArg, /* First argument to xCallback() */ + char **pzErrMsg /* Write error messages here */ +){ + int rc = SQLITE_OK; + const char *zLeftover; + sqlite_vm *pVm; + int nRetry = 0; + int nChange = 0; + + if( zSql==0 ) return SQLITE_OK; + while( rc==SQLITE_OK && zSql[0] ){ + pVm = 0; + rc = sqlite_compile(db, zSql, &zLeftover, &pVm, pzErrMsg); + if( rc!=SQLITE_OK ){ + assert( pVm==0 ); + return rc; + } + if( pVm==0 ){ + /* This happens if the zSql input contained only whitespace */ + break; + } + db->nChange += nChange; + while(1){ + int nArg; + char **azArg, **azCol; + rc = sqlite_step(pVm, &nArg, (const char***)&azArg,(const char***)&azCol); + if( rc==SQLITE_ROW ){ + if( xCallback(pArg, nArg, azArg, azCol) ){ + sqlite_finalize(pVm, 0); + return SQLITE_ABORT; + } + }else{ + rc = sqlite_finalize(pVm, pzErrMsg); + if( rc==SQLITE_SCHEMA && nRetry<2 ){ + nRetry++; + rc = SQLITE_OK; + break; + } + if( db->pVdbe==0 ){ + nChange = db->nChange; + } + nRetry = 0; + zSql = zLeftover; + while( isspace(zSql[0]) ) zSql++; + break; + } + } + } + return rc; +} + + +/* +** Compile a single statement of SQL into a virtual machine. Return one +** of the SQLITE_ success/failure codes. Also write an error message into +** memory obtained from malloc() and make *pzErrMsg point to that message. +*/ +int sqlite_compile( + sqlite *db, /* The database on which the SQL executes */ + const char *zSql, /* The SQL to be executed */ const char **pzTail, /* OUT: Next statement after the first */ sqlite_vm **ppVm, /* OUT: The virtual machine */ char **pzErrMsg /* OUT: Write error messages here */ @@ -627,9 +691,7 @@ static int sqliteMain( if( db->pVdbe==0 ){ db->nChange = 0; } memset(&sParse, 0, sizeof(sParse)); sParse.db = db; - sParse.xCallback = xCallback; - sParse.pArg = pArg; - sParse.useCallback = ppVm==0; + sParse.useCallback = 0; if( db->xTrace ) db->xTrace(db->pTraceArg, zSql); sqliteRunParser(&sParse, zSql, pzErrMsg); if( sqlite_malloc_failed ){ @@ -647,11 +709,9 @@ static int sqliteMain( if( sParse.rc==SQLITE_SCHEMA ){ sqliteResetInternalSchema(db, 0); } - if( sParse.useCallback==0 ){ - assert( ppVm ); - *ppVm = (sqlite_vm*)sParse.pVdbe; - if( pzTail ) *pzTail = sParse.zTail; - } + assert( ppVm ); + *ppVm = (sqlite_vm*)sParse.pVdbe; + if( pzTail ) *pzTail = sParse.zTail; if( sqliteSafetyOff(db) ) goto exec_misuse; return sParse.rc; @@ -664,93 +724,6 @@ exec_misuse: return SQLITE_MISUSE; } -/* -** Execute SQL code. Return one of the SQLITE_ success/failure -** codes. Also write an error message into memory obtained from -** malloc() and make *pzErrMsg point to that message. -** -** If the SQL is a query, then for each row in the query result -** the xCallback() function is called. pArg becomes the first -** argument to xCallback(). If xCallback=NULL then no callback -** is invoked, even for queries. -*/ -int sqlite_exec( - sqlite *db, /* The database on which the SQL executes */ - const char *zSql, /* The SQL to be executed */ - sqlite_callback xCallback, /* Invoke this callback routine */ - void *pArg, /* First argument to xCallback() */ - char **pzErrMsg /* Write error messages here */ -){ -#if 1 - return sqliteMain(db, zSql, xCallback, pArg, 0, 0, pzErrMsg); -#else - int rc; - const char *zLeftover; - sqlite_vm *pVm; - - if( zSql==0 ) return SQLITE_OK; - while( zSql[0] ){ - int nBusy = 0; - rc = sqlite_compile(db, zSql, &zLeftover, &pVm, pzErrMsg); - if( rc!=SQLITE_OK ){ - /* sqlite_finalize(pVm, 0); */ - return rc; - } - while(1){ - int nArg; - char **azArg, **azCol; - rc = sqlite_step(pVm, &nArg, &azArg, &azCol); - if( rc==SQLITE_ROW ){ - if( xCallback(pArg, nArg, azArg, azCol) ){ - sqlite_finalize(pVm, 0); - return SQLITE_ABORT; - } -#if 0 - }else if( rc==SQLITE_BUSY ){ - if( db->xBusyCallback==0 - || db->xBusyCallback(db->pBusyArg, "", nBusy++)==0 ){ - sqlite_finalize(pVm, 0); - return SQLITE_BUSY; - } -#endif - }else if( rc==SQLITE_SCHEMA ){ - sqlite_finalize(pVm, 0); - break; - }else{ - rc = sqlite_finalize(pVm, pzErrMsg); - if( rc==SQLITE_SCHEMA ){ - sqliteResetInternalSchema(db, 0); - /* break; */ - } - if( rc!=SQLITE_OK ){ - return rc; - } - zSql = zLeftover; - while( isspace(zSql[0]) ) zSql++; - break; - } - } - } - return SQLITE_OK; -#endif -} - - -/* -** Compile a single statement of SQL into a virtual machine. Return one -** of the SQLITE_ success/failure codes. Also write an error message into -** memory obtained from malloc() and make *pzErrMsg point to that message. -*/ -int sqlite_compile( - sqlite *db, /* The database on which the SQL executes */ - const char *zSql, /* The SQL to be executed */ - const char **pzTail, /* OUT: Next statement after the first */ - sqlite_vm **ppVm, /* OUT: The virtual machine */ - char **pzErrMsg /* OUT: Write error messages here */ -){ - return sqliteMain(db, zSql, 0, 0, pzTail, ppVm, pzErrMsg); -} - /* ** The following routine destroys a virtual machine that is created by diff --git a/src/select.c b/src/select.c index 81b2bfbd1c..e063b78596 100644 --- a/src/select.c +++ b/src/select.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** -** $Id: select.c,v 1.153 2004/02/13 16:22:23 drh Exp $ +** $Id: select.c,v 1.154 2004/02/14 16:31:04 drh Exp $ */ #include "sqliteInt.h" @@ -1502,8 +1502,8 @@ static int multiSelect(Parse *pParse, Select *p, int eDest, int iParm){ /* Issue a null callback if that is what the user wants. */ - if( eDest==SRT_Callback && - (pParse->useCallback==0 || (pParse->db->flags & SQLITE_NullCallback)!=0) + if( eDest==SRT_Callback /* && + (pParse->useCallback==0 || (pParse->db->flags & SQLITE_NullCallback)!=0) */ ){ sqliteVdbeAddOp(v, OP_NullCallback, p->pEList->nExpr, 0); } @@ -2402,8 +2402,8 @@ int sqliteSelect( /* Issue a null callback if that is what the user wants. */ - if( eDest==SRT_Callback && - (pParse->useCallback==0 || (pParse->db->flags & SQLITE_NullCallback)!=0) + if( eDest==SRT_Callback /* && + (pParse->useCallback==0 || (pParse->db->flags & SQLITE_NullCallback)!=0) */ ){ sqliteVdbeAddOp(v, OP_NullCallback, pEList->nExpr, 0); } diff --git a/src/shell.c b/src/shell.c index 498c51b395..e41a3d46fb 100644 --- a/src/shell.c +++ b/src/shell.c @@ -12,7 +12,7 @@ ** This file contains code to implement the "sqlite" command line ** utility for accessing SQLite databases. ** -** $Id: shell.c,v 1.89 2004/02/13 20:09:42 drh Exp $ +** $Id: shell.c,v 1.90 2004/02/14 16:31:04 drh Exp $ */ #include #include @@ -751,7 +751,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ p->out = stdout; strcpy(p->outfile,"stdout"); }else{ - p->out = fopen(azArg[1], "w"); + p->out = fopen(azArg[1], "wb"); if( p->out==0 ){ fprintf(stderr,"can't write to \"%s\"\n", azArg[1]); p->out = stdout; @@ -776,7 +776,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ }else if( c=='r' && strncmp(azArg[0], "read", n)==0 && nArg==2 ){ - FILE *alt = fopen(azArg[1], "r"); + FILE *alt = fopen(azArg[1], "rb"); if( alt==0 ){ fprintf(stderr,"can't open \"%s\"\n", azArg[1]); }else{ @@ -1149,7 +1149,7 @@ static void process_sqliterc( free(home_dir); sqliterc = (const char*)zBuf; } - in = fopen(sqliterc,"r"); + in = fopen(sqliterc,"rb"); if( in ){ if( isatty(fileno(stdout)) ){ printf("Loading resources from %s\n",sqliterc); diff --git a/src/vdbe.c b/src/vdbe.c index ec2172af01..174cfd781a 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -43,7 +43,7 @@ ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** -** $Id: vdbe.c,v 1.261 2004/02/13 14:07:13 drh Exp $ +** $Id: vdbe.c,v 1.262 2004/02/14 16:31:04 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -119,6 +119,7 @@ int sqlite_step( } db = p->db; if( sqliteSafetyOn(db) ){ + p->rc = SQLITE_MISUSE; return SQLITE_MISUSE; } if( p->explain ){ @@ -870,6 +871,7 @@ case OP_Callback: { } } azArgv[i] = 0; + p->nCallback++; if( p->xCallback==0 ){ p->azResColumn = azArgv; p->nResColumn = pOp->p1; @@ -883,7 +885,6 @@ case OP_Callback: { rc = SQLITE_ABORT; } if( sqliteSafetyOn(db) ) goto abort_due_to_misuse; - p->nCallback++; popStack(&pTos, pOp->p1); assert( pTos>=&p->aStack[-1] ); if( sqlite_malloc_failed ) goto no_mem; @@ -907,14 +908,23 @@ case OP_Callback: { ** in cases where the result set is empty. */ case OP_NullCallback: { - if( p->nCallback==0 && p->xCallback!=0 ){ - if( sqliteSafetyOff(db) ) goto abort_due_to_misuse; - if( p->xCallback(p->pCbArg, pOp->p1, 0, p->azColName)!=0 ){ - rc = SQLITE_ABORT; + if( p->nCallback==0 && (db->flags & SQLITE_NullCallback)!=0 ){ + if( p->xCallback!=0 ){ + if( sqliteSafetyOff(db) ) goto abort_due_to_misuse; + if( p->xCallback(p->pCbArg, pOp->p1, 0, p->azColName)!=0 ){ + rc = SQLITE_ABORT; + } + if( sqliteSafetyOn(db) ) goto abort_due_to_misuse; + if( sqlite_malloc_failed ) goto no_mem; + }else{ + p->azResColumn = 0; + p->nResColumn = pOp->p1; + p->popStack = 0; + p->pc = pc + 1; + p->pTos = pTos; + return SQLITE_ROW; } - if( sqliteSafetyOn(db) ) goto abort_due_to_misuse; p->nCallback++; - if( sqlite_malloc_failed ) goto no_mem; } p->nResColumn = pOp->p1; break; @@ -4084,6 +4094,7 @@ case OP_SortNext: { case OP_SortCallback: { assert( pTos>=p->aStack ); assert( pTos->flags & MEM_Str ); + p->nCallback++; if( p->xCallback==0 ){ p->pc = pc+1; p->azResColumn = (char**)pTos->z; @@ -4097,7 +4108,6 @@ case OP_SortCallback: { rc = SQLITE_ABORT; } if( sqliteSafetyOn(db) ) goto abort_due_to_misuse; - p->nCallback++; } Release(pTos); pTos--; diff --git a/src/vdbeaux.c b/src/vdbeaux.c index f3f73cad00..ddfd12efe6 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -826,6 +826,8 @@ int sqliteVdbeReset(Vdbe *p, char **pzErrMsg){ sqliteFree(p->zErrMsg); } p->zErrMsg = 0; + }else if( p->rc ){ + sqliteSetString(pzErrMsg, sqlite_error_string(p->rc), (char*)0); } Cleanup(p); if( p->rc!=SQLITE_OK ){ @@ -909,6 +911,9 @@ int sqliteVdbeFinalize(Vdbe *p, char **pzErrMsg){ if( db->want_to_close && db->pVdbe==0 ){ sqlite_close(db); } + if( rc==SQLITE_SCHEMA ){ + sqliteResetInternalSchema(db, 0); + } return rc; } diff --git a/test/lock.test b/test/lock.test index e7f1eddd05..4b30fd0bf9 100644 --- a/test/lock.test +++ b/test/lock.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this script is database locks. # -# $Id: lock.test,v 1.19 2004/01/15 13:29:40 drh Exp $ +# $Id: lock.test,v 1.20 2004/02/14 16:31:04 drh Exp $ set testdir [file dirname $argv0] @@ -33,11 +33,11 @@ do_test lock-1.3 { execsql {CREATE TABLE t1(a int, b int)} execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name} } {t1} -do_test lock-1.4 { - catchsql { - SELECT name FROM sqlite_master WHERE type='table' ORDER BY name - } db2 -} {1 {database schema has changed}} +#do_test lock-1.4 { +# catchsql { +# SELECT name FROM sqlite_master WHERE type='table' ORDER BY name +# } db2 +#} {1 {database schema has changed}} do_test lock-1.5 { catchsql { SELECT name FROM sqlite_master WHERE type='table' ORDER BY name @@ -75,9 +75,12 @@ do_test lock-1.13 { execsql {INSERT INTO t2 VALUES(8,9)} execsql {SELECT * FROM t2} } {8 9} -do_test lock-1.14 { +do_test lock-1.14.1 { + catchsql {SELECT * FROM t2} db2 +} {1 {no such table: t2}} +do_test lock-1.14.2 { catchsql {SELECT * FROM t1} db2 -} {1 {database schema has changed}} +} {0 {2 1}} do_test lock-1.15 { catchsql {SELECT * FROM t2} db2 } {0 {8 9}} diff --git a/test/temptable.test b/test/temptable.test index 8a1b70a709..644df0d4ec 100644 --- a/test/temptable.test +++ b/test/temptable.test @@ -12,7 +12,7 @@ # # This file implements tests for temporary tables and indices. # -# $Id: temptable.test,v 1.10 2003/05/17 17:35:13 drh Exp $ +# $Id: temptable.test,v 1.11 2004/02/14 16:31:04 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -176,11 +176,11 @@ do_test temptable-4.4.2 { SELECT * FROM main.t2; } db2 } {1 {no such table: main.t2}} -do_test temptable-4.4.3 { - catchsql { - SELECT name FROM main.sqlite_master WHERE type='table'; - } db2 -} {1 {database schema has changed}} +#do_test temptable-4.4.3 { +# catchsql { +# SELECT name FROM main.sqlite_master WHERE type='table'; +# } db2 +#} {1 {database schema has changed}} do_test temptable-4.4.4 { catchsql { SELECT name FROM main.sqlite_master WHERE type='table'; @@ -237,11 +237,11 @@ do_test temptable-4.10.1 { SELECT * FROM t2; } db2 } {0 {1 2}} -do_test temptable-4.10.2 { - catchsql { - SELECT name FROM sqlite_master WHERE type='table' - } db2 -} {1 {database schema has changed}} +#do_test temptable-4.10.2 { +# catchsql { +# SELECT name FROM sqlite_master WHERE type='table' +# } db2 +#} {1 {database schema has changed}} do_test temptable-4.10.3 { catchsql { SELECT name FROM sqlite_master WHERE type='table' @@ -290,11 +290,11 @@ do_test temptable-5.1 { SELECT * FROM t2; } } {3 4} -do_test temptable-5.2 { - catchsql { - SELECT * FROM t2; - } db2 -} {1 {database schema has changed}} +#do_test temptable-5.2 { +# catchsql { +# SELECT * FROM t2; +# } db2 +#} {1 {database schema has changed}} do_test temptable-5.3 { catchsql { SELECT * FROM t2; diff --git a/test/trigger1.test b/test/trigger1.test index afdfeda1b1..b55ca12378 100644 --- a/test/trigger1.test +++ b/test/trigger1.test @@ -179,7 +179,7 @@ do_test trigger1-1.13 { # Ensure that we cannot create AFTER triggers on views do_test trigger1-1.14 { catchsql { - create table t1(a,b); + drop view v1; create view v1 as select * from t1; create trigger v1t AFTER update on v1 for each row begin delete from t1 WHERE a=old.a+2; diff --git a/test/vacuum.test b/test/vacuum.test index 7ed2051017..8158ece98c 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.14 2003/12/07 00:24:35 drh Exp $ +# $Id: vacuum.test,v 1.15 2004/02/14 16:31:04 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -107,11 +107,8 @@ do_test vacuum-2.2 { catchsql { VACUUM } -} {1 {database schema has changed}} +} {0 {}} do_test vacuum-2.3 { - execsql { - VACUUM; - } cksum } $cksum do_test vacuum-2.4 {