1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Test the handling of errors in virtual table methods. (CVS 3284)

FossilOrigin-Name: 51b729d9d9f8a60cdfb552809e4aa10012f4eb68
This commit is contained in:
danielk1977
2006-06-22 09:53:48 +00:00
parent f7e678d6e9
commit a298e90d50
9 changed files with 163 additions and 42 deletions

View File

@@ -1,5 +1,5 @@
C Make\sthe\slast_insert_rowid\smethod\sin\sthe\sTCL\sinterface\swork\swith\n64-bit\srowids.\s(CVS\s3283) C Test\sthe\shandling\sof\serrors\sin\svirtual\stable\smethods.\s(CVS\s3284)
D 2006-06-21T19:30:34 D 2006-06-22T09:53:49
F Makefile.in f839b470345d3cb4b0644068474623fe2464b5d3 F Makefile.in f839b470345d3cb4b0644068474623fe2464b5d3
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -49,7 +49,7 @@ F src/hash.h 1b3f7e2609141fd571f62199fc38687d262e9564
F src/insert.c 63f01d3f4e0ba7ed171934a24aece2191824faec F src/insert.c 63f01d3f4e0ba7ed171934a24aece2191824faec
F src/legacy.c fa15d505dd4e45044177ee4d1c6aeaf8c836d390 F src/legacy.c fa15d505dd4e45044177ee4d1c6aeaf8c836d390
F src/loadext.c b08c5f5a57b78afd8cd0dd1677e98519e18db56f F src/loadext.c b08c5f5a57b78afd8cd0dd1677e98519e18db56f
F src/main.c 7101314a365120465bf5e308caaf518b7776430c F src/main.c 645a02be048d60ead33e53e10e0b84fb002bf7ca
F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217 F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
F src/os.c 59f05de8c5777c34876607114a2fbe55ae578235 F src/os.c 59f05de8c5777c34876607114a2fbe55ae578235
F src/os.h ac2ccb4f48902c1611a7e1f171eb81d17e3b8eb2 F src/os.h ac2ccb4f48902c1611a7e1f171eb81d17e3b8eb2
@@ -72,7 +72,7 @@ F src/random.c d40f8d356cecbd351ccfab6eaedd7ec1b54f5261
F src/select.c 380fa06c99ae01050c0054c4b1db91e9f1d8322d F src/select.c 380fa06c99ae01050c0054c4b1db91e9f1d8322d
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96 F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
F src/shell.c ad73192b30a338a58fe81183d4a5d5a1d4e51d36 F src/shell.c ad73192b30a338a58fe81183d4a5d5a1d4e51d36
F src/sqlite.h.in 7855b46387f3f6ac1925301f450df9cbd7a1269b F src/sqlite.h.in b8c6139b3af13a2c361a8a5aeabb28aa3eef1ae1
F src/sqlite3ext.h e334107f6cad0d00c0414e04189742a45ce916b1 F src/sqlite3ext.h e334107f6cad0d00c0414e04189742a45ce916b1
F src/sqliteInt.h d79b031593462dfcbc8c122a5f698a00e6b124fa F src/sqliteInt.h d79b031593462dfcbc8c122a5f698a00e6b124fa
F src/table.c f64ec4fbfe333f8df925bc6ba494f55e05b0e75e F src/table.c f64ec4fbfe333f8df925bc6ba494f55e05b0e75e
@@ -84,11 +84,11 @@ F src/test4.c 8b784cd82de158a2317cb4ac4bc86f91ad315e25
F src/test5.c 7162f8526affb771c4ed256826eee7bb9eca265f F src/test5.c 7162f8526affb771c4ed256826eee7bb9eca265f
F src/test6.c 60a02961ceb7b3edc25f5dc5c1ac2556622a76de F src/test6.c 60a02961ceb7b3edc25f5dc5c1ac2556622a76de
F src/test7.c 03fa8d787f6aebc6d1f72504d52f33013ad2c8e3 F src/test7.c 03fa8d787f6aebc6d1f72504d52f33013ad2c8e3
F src/test8.c d584dc94c0a62afb21bca311d2958defc6684236 F src/test8.c b8014836e18b9f42d0ac5c190efcc8318694c14e
F src/test_async.c e3deaedd4d86a56391b81808fde9e44fbd92f1d3 F src/test_async.c e3deaedd4d86a56391b81808fde9e44fbd92f1d3
F src/test_loadext.c 22065d601a18878e5542191001f0eaa5d77c0ed8 F src/test_loadext.c 22065d601a18878e5542191001f0eaa5d77c0ed8
F src/test_md5.c 6c42bc0a3c0b54be34623ff77a0eec32b2fa96e3 F src/test_md5.c 6c42bc0a3c0b54be34623ff77a0eec32b2fa96e3
F src/test_schema.c 741238e40158a4ff88e450bdcf60836570283a71 F src/test_schema.c 5aeddd60a60c3070de4c5bfa4f5c333c7769109c
F src/test_server.c a6460daed0b92ecbc2531b6dc73717470e7a648c F src/test_server.c a6460daed0b92ecbc2531b6dc73717470e7a648c
F src/test_tclvar.c c52f67fbe06d32804af2ba9a2d7aadfc15f5910c F src/test_tclvar.c c52f67fbe06d32804af2ba9a2d7aadfc15f5910c
F src/tokenize.c 6ebcafa6622839968dda4418a7b6945f277a128f F src/tokenize.c 6ebcafa6622839968dda4418a7b6945f277a128f
@@ -97,7 +97,7 @@ F src/update.c 686b13db8b28a129a2407aaffc8b7588d1104e0b
F src/utf.c ab81ac59084ff1c07d421eb1a0a84ec809603b44 F src/utf.c ab81ac59084ff1c07d421eb1a0a84ec809603b44
F src/util.c ca6ee72772c0f5dc04d2e0ab1973fd3b6a9bf79d F src/util.c ca6ee72772c0f5dc04d2e0ab1973fd3b6a9bf79d
F src/vacuum.c 5b37d0f436f8e1ffacd17934e44720b38d2247f9 F src/vacuum.c 5b37d0f436f8e1ffacd17934e44720b38d2247f9
F src/vdbe.c 4b55bfea65855201b8f2e07102ad70ea1d21b7f6 F src/vdbe.c 2c36e0badc0bcc14f099e95ec84470c479fbd399
F src/vdbe.h 258b5d1c0aaa72192f09ff0568ce42b383f156fa F src/vdbe.h 258b5d1c0aaa72192f09ff0568ce42b383f156fa
F src/vdbeInt.h 6ccb7eaae76ebd761470f6a035501ff33aa92c20 F src/vdbeInt.h 6ccb7eaae76ebd761470f6a035501ff33aa92c20
F src/vdbeapi.c 6af0e7160af260052a7a4500464221a03dada75f F src/vdbeapi.c 6af0e7160af260052a7a4500464221a03dada75f
@@ -291,12 +291,13 @@ F test/vacuum.test 37f998b841cb335397c26d9bbc3457182af2565f
F test/vacuum2.test 5aea8c88a65cb29f7d175296e7c819c6158d838c F test/vacuum2.test 5aea8c88a65cb29f7d175296e7c819c6158d838c
F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102 F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102
F test/view.test 16e2774fe35e47a07ac4471b7f0bcc948b1aa6d5 F test/view.test 16e2774fe35e47a07ac4471b7f0bcc948b1aa6d5
F test/vtab1.test 5bb366f18287c9b4c8af110a810c10eb713fb58b F test/vtab1.test 3f21d81e599afd100e60830f5f0426c1f74febda
F test/vtab2.test e57f9865368df26ef5eb8bc630962d82086f174b F test/vtab2.test e57f9865368df26ef5eb8bc630962d82086f174b
F test/vtab3.test f38d6d7d19f08bffdadce4d5b8cba078f8118587 F test/vtab3.test f38d6d7d19f08bffdadce4d5b8cba078f8118587
F test/vtab4.test 4b4293341443839ef6dc02f8d9e614702a6c67ff F test/vtab4.test 4b4293341443839ef6dc02f8d9e614702a6c67ff
F test/vtab5.test 9fb8f335651afe8f870011e2f68e5b00c5ad03cd F test/vtab5.test 9fb8f335651afe8f870011e2f68e5b00c5ad03cd
F test/vtab6.test 0b4fe07e421b2b9a334bec8781e75cbd8e230bd3 F test/vtab6.test 0b4fe07e421b2b9a334bec8781e75cbd8e230bd3
F test/vtab_err.test 7b435152e5555ca01645cbd15864430a80c44765
F test/where.test ee7c9a6659b07e1ee61177f6e7ff71565ee2c9df F test/where.test ee7c9a6659b07e1ee61177f6e7ff71565ee2c9df
F test/where2.test a16476a5913e75cf65b38f2daa6157a6b7791394 F test/where2.test a16476a5913e75cf65b38f2daa6157a6b7791394
F test/where3.test 3b5ad2c58069e12be2bd86bc5e211a82810521aa F test/where3.test 3b5ad2c58069e12be2bd86bc5e211a82810521aa
@@ -372,7 +373,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
P 2d2805785f473afc202df532df84c45e6f0dc0f1 P d50c37975de7639627422cbed40eb03a431874d5
R d6693457ff045b088af9dc2f8803cb5d R deba37635ada8fb35f1bc556c53eccea
U drh U danielk1977
Z ebff9741f160eff78cf3357f860940cd Z fb72a1410426354cd3d1ca1870332bcd

View File

@@ -1 +1 @@
d50c37975de7639627422cbed40eb03a431874d5 51b729d9d9f8a60cdfb552809e4aa10012f4eb68

View File

@@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be ** other files are for internal use by SQLite and should not be
** accessed by users of the library. ** accessed by users of the library.
** **
** $Id: main.c,v 1.345 2006/06/16 16:08:55 danielk1977 Exp $ ** $Id: main.c,v 1.346 2006/06/22 09:53:49 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include "os.h" #include "os.h"
@@ -203,10 +203,10 @@ void sqlite3RollbackAll(sqlite3 *db){
db->aDb[i].inTrans = 0; db->aDb[i].inTrans = 0;
} }
} }
sqlite3VtabRollback(db);
if( db->flags&SQLITE_InternChanges ){ if( db->flags&SQLITE_InternChanges ){
sqlite3ResetInternalSchema(db, 0); sqlite3ResetInternalSchema(db, 0);
} }
sqlite3VtabRollback(db);
/* If one has been configured, invoke the rollback-hook callback */ /* If one has been configured, invoke the rollback-hook callback */
if( db->xRollbackCallback && (inTrans || !db->autoCommit) ){ if( db->xRollbackCallback && (inTrans || !db->autoCommit) ){

View File

@@ -12,7 +12,7 @@
** This header file defines the interface that the SQLite library ** This header file defines the interface that the SQLite library
** presents to client programs. ** presents to client programs.
** **
** @(#) $Id: sqlite.h.in,v 1.180 2006/06/17 09:39:56 danielk1977 Exp $ ** @(#) $Id: sqlite.h.in,v 1.181 2006/06/22 09:53:50 danielk1977 Exp $
*/ */
#ifndef _SQLITE3_H_ #ifndef _SQLITE3_H_
#define _SQLITE3_H_ #define _SQLITE3_H_
@@ -1551,6 +1551,7 @@ struct sqlite3_module {
int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr, int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr,
int argc, sqlite3_value **argv); int argc, sqlite3_value **argv);
int (*xNext)(sqlite3_vtab_cursor*); int (*xNext)(sqlite3_vtab_cursor*);
int (*xEof)(sqlite3_vtab_cursor*);
int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int); int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int);
int (*xRowid)(sqlite3_vtab_cursor*, sqlite_int64 *pRowid); int (*xRowid)(sqlite3_vtab_cursor*, sqlite_int64 *pRowid);
int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite_int64 *); int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite_int64 *);

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: test8.c,v 1.30 2006/06/21 16:02:43 danielk1977 Exp $ ** $Id: test8.c,v 1.31 2006/06/22 09:53:50 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include "tcl.h" #include "tcl.h"
@@ -49,6 +49,7 @@ struct echo_vtab {
sqlite3 *db; sqlite3 *db;
char *zTableName; /* Name of the real table */ char *zTableName; /* Name of the real table */
char *zLogName; /* Name of the log table */
int nCol; /* Number of columns in the real table */ int nCol; /* Number of columns in the real table */
int *aIndex; /* Array of size nCol. True if column has an index */ int *aIndex; /* Array of size nCol. True if column has an index */
char **aCol; /* Array of size nCol. Column names */ char **aCol; /* Array of size nCol. Column names */
@@ -194,7 +195,7 @@ static int echoDeclareVtab(
){ ){
int rc = SQLITE_OK; int rc = SQLITE_OK;
if( argc==4 ){ if( argc>=4 ){
sqlite3_stmt *pStmt = 0; sqlite3_stmt *pStmt = 0;
sqlite3_prepare(db, sqlite3_prepare(db,
"SELECT sql FROM sqlite_master WHERE type = 'table' AND name = ?", "SELECT sql FROM sqlite_master WHERE type = 'table' AND name = ?",
@@ -266,8 +267,20 @@ static int echoCreate(
int argc, char **argv, int argc, char **argv,
sqlite3_vtab **ppVtab sqlite3_vtab **ppVtab
){ ){
int rc = SQLITE_OK;
appendToEchoModule((Tcl_Interp *)(pAux), "xCreate"); appendToEchoModule((Tcl_Interp *)(pAux), "xCreate");
return echoConstructor(db, pAux, argc, argv, ppVtab); rc = echoConstructor(db, pAux, argc, argv, ppVtab);
#if 0
if( rc==SQLITE_OK && argc==5 ){
char *zSql;
echo_vtab *pVtab = *(echo_vtab **)ppVtab;
pVtab->zLogName = sqlite3MPrintf("%s", argv[4]);
zSql = sqlite3MPrintf("CREATE TABLE %Q(logmsg)", pVtab->zLogName);
rc = sqlite3_exec(db, zSql, 0, 0, 0);
sqliteFree(zSql);
}
#endif
return rc;
} }
static int echoConnect( static int echoConnect(
sqlite3 *db, sqlite3 *db,
@@ -284,8 +297,21 @@ static int echoDisconnect(sqlite3_vtab *pVtab){
return echoDestructor(pVtab); return echoDestructor(pVtab);
} }
static int echoDestroy(sqlite3_vtab *pVtab){ static int echoDestroy(sqlite3_vtab *pVtab){
int rc = SQLITE_OK;
echo_vtab *p = (echo_vtab *)pVtab;
appendToEchoModule(((echo_vtab *)pVtab)->interp, "xDestroy"); appendToEchoModule(((echo_vtab *)pVtab)->interp, "xDestroy");
return echoDestructor(pVtab); #if 0
if( p && p->zLogName ){
char *zSql;
zSql = sqlite3MPrintf("DROP TABLE %Q", p->zLogName);
rc = sqlite3_exec(p->db, zSql, 0, 0, 0);
sqliteFree(zSql);
}
#endif
if( rc==SQLITE_OK ){
rc = echoDestructor(pVtab);
}
return rc;
} }
static int echoOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ static int echoOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){
@@ -302,6 +328,14 @@ static int echoClose(sqlite3_vtab_cursor *cur){
return SQLITE_OK; return SQLITE_OK;
} }
/*
** Return non-zero if the cursor does not currently point to a valid record
** (i.e if the scan has finished), or zero otherwise.
*/
static int echoEof(sqlite3_vtab_cursor *cur){
return (((echo_cursor *)cur)->pStmt ? 0 : 1);
}
static int echoNext(sqlite3_vtab_cursor *cur){ static int echoNext(sqlite3_vtab_cursor *cur){
int rc; int rc;
echo_cursor *pCur = (echo_cursor *)cur; echo_cursor *pCur = (echo_cursor *)cur;
@@ -309,11 +343,10 @@ static int echoNext(sqlite3_vtab_cursor *cur){
rc = sqlite3_step(pCur->pStmt); rc = sqlite3_step(pCur->pStmt);
if( rc==SQLITE_ROW ){ if( rc==SQLITE_ROW ){
rc = 1; rc = SQLITE_OK;
} else { }else{
pCur->errcode = sqlite3_finalize(pCur->pStmt); rc = sqlite3_finalize(pCur->pStmt);
pCur->pStmt = 0; pCur->pStmt = 0;
rc = 0;
} }
return rc; return rc;
@@ -406,6 +439,7 @@ static int echoFilter(
if( rc==SQLITE_OK ){ if( rc==SQLITE_OK ){
ret = echoNext(pVtabCursor); ret = echoNext(pVtabCursor);
}else{ }else{
assert( !pCur->pStmt );
ret = 0; ret = 0;
pCur->errcode = rc; pCur->errcode = rc;
} }
@@ -723,6 +757,7 @@ static sqlite3_module echoModule = {
echoClose, /* xClose - close a cursor */ echoClose, /* xClose - close a cursor */
echoFilter, /* xFilter - configure scan constraints */ echoFilter, /* xFilter - configure scan constraints */
echoNext, /* xNext - advance a cursor */ echoNext, /* xNext - advance a cursor */
echoEof, /* xEof */
echoColumn, /* xColumn - read data */ echoColumn, /* xColumn - read data */
echoRowid, /* xRowid - read data */ echoRowid, /* xRowid - read data */
echoUpdate, /* xUpdate - write data */ echoUpdate, /* xUpdate - write data */

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: test_schema.c,v 1.5 2006/06/20 11:01:08 danielk1977 Exp $ ** $Id: test_schema.c,v 1.6 2006/06/22 09:53:50 danielk1977 Exp $
*/ */
/* The code in this file defines a sqlite3 virtual-table module that /* The code in this file defines a sqlite3 virtual-table module that
@@ -161,6 +161,11 @@ static int finalize(sqlite3_stmt **ppStmt){
return rc; return rc;
} }
static int schemaEof(sqlite3_vtab_cursor *cur){
schema_cursor *pCur = (schema_cursor *)cur;
return (pCur->pDbList ? 0 : 1);
}
/* /*
** Advance the cursor to the next row. ** Advance the cursor to the next row.
*/ */
@@ -171,15 +176,15 @@ static int schemaNext(sqlite3_vtab_cursor *cur){
char *zSql = 0; char *zSql = 0;
while( !pCur->pColumnList || SQLITE_ROW!=sqlite3_step(pCur->pColumnList) ){ while( !pCur->pColumnList || SQLITE_ROW!=sqlite3_step(pCur->pColumnList) ){
if( SQLITE_OK!=(rc = finalize(&pCur->pColumnList)) ) goto fail; if( SQLITE_OK!=(rc = finalize(&pCur->pColumnList)) ) goto next_exit;
while( !pCur->pTableList || SQLITE_ROW!=sqlite3_step(pCur->pTableList) ){ while( !pCur->pTableList || SQLITE_ROW!=sqlite3_step(pCur->pTableList) ){
if( SQLITE_OK!=(rc = finalize(&pCur->pTableList)) ) goto fail; if( SQLITE_OK!=(rc = finalize(&pCur->pTableList)) ) goto next_exit;
assert(pCur->pDbList); assert(pCur->pDbList);
while( SQLITE_ROW!=sqlite3_step(pCur->pDbList) ){ while( SQLITE_ROW!=sqlite3_step(pCur->pDbList) ){
if( SQLITE_OK!=(rc = finalize(&pCur->pDbList)) ) goto fail; rc = finalize(&pCur->pDbList);
return 0; goto next_exit;
} }
/* Set zSql to the SQL to pull the list of tables from the /* Set zSql to the SQL to pull the list of tables from the
@@ -200,12 +205,12 @@ static int schemaNext(sqlite3_vtab_cursor *cur){
} }
if( !zSql ){ if( !zSql ){
rc = SQLITE_NOMEM; rc = SQLITE_NOMEM;
goto fail; goto next_exit;
} }
rc = sqlite3_prepare(pVtab->db, zSql, -1, &pCur->pTableList, 0); rc = sqlite3_prepare(pVtab->db, zSql, -1, &pCur->pTableList, 0);
sqlite3_free(zSql); sqlite3_free(zSql);
if( rc!=SQLITE_OK ) goto fail; if( rc!=SQLITE_OK ) goto next_exit;
} }
/* Set zSql to the SQL to the table_info pragma for the table currently /* Set zSql to the SQL to the table_info pragma for the table currently
@@ -219,17 +224,17 @@ static int schemaNext(sqlite3_vtab_cursor *cur){
if( !zSql ){ if( !zSql ){
rc = SQLITE_NOMEM; rc = SQLITE_NOMEM;
goto fail; goto next_exit;
} }
rc = sqlite3_prepare(pVtab->db, zSql, -1, &pCur->pColumnList, 0); rc = sqlite3_prepare(pVtab->db, zSql, -1, &pCur->pColumnList, 0);
sqlite3_free(zSql); sqlite3_free(zSql);
if( rc!=SQLITE_OK ) goto fail; if( rc!=SQLITE_OK ) goto next_exit;
} }
pCur->rowid++; pCur->rowid++;
fail: next_exit:
/* TODO: Handle rc */ /* TODO: Handle rc */
return 1; return rc;
} }
/* /*
@@ -274,6 +279,7 @@ static sqlite3_module schemaModule = {
schemaClose, /* xClose - close a cursor */ schemaClose, /* xClose - close a cursor */
schemaFilter, /* xFilter - configure scan constraints */ schemaFilter, /* xFilter - configure scan constraints */
schemaNext, /* xNext - advance a cursor */ schemaNext, /* xNext - advance a cursor */
schemaEof, /* xEof */
schemaColumn, /* xColumn - read data */ schemaColumn, /* xColumn - read data */
schemaRowid, /* xRowid - read data */ schemaRowid, /* xRowid - read data */
}; };

View File

@@ -43,7 +43,7 @@
** in this file for details. If in doubt, do not deviate from existing ** in this file for details. If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code. ** commenting and indentation practices when changing or adding code.
** **
** $Id: vdbe.c,v 1.564 2006/06/16 21:13:22 drh Exp $ ** $Id: vdbe.c,v 1.565 2006/06/22 09:53:50 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include "os.h" #include "os.h"
@@ -4651,10 +4651,13 @@ case OP_VFilter: { /* no-push */
} }
if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse;
res = pModule->xFilter(pCur->pVtabCursor, pTos->i, pOp->p3, nArg, apArg); rc = pModule->xFilter(pCur->pVtabCursor, pTos->i, pOp->p3, nArg, apArg);
if( rc==SQLITE_OK ){
res = pModule->xEof(pCur->pVtabCursor);
}
if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse; if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
if( res==0 ){ if( res ){
pc = pOp->p2 - 1; pc = pOp->p2 - 1;
} }
} }
@@ -4759,11 +4762,14 @@ case OP_VNext: { /* no-push */
** some other method is next invoked on the save virtual table cursor. ** some other method is next invoked on the save virtual table cursor.
*/ */
if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse;
res = pModule->xNext(pCur->pVtabCursor); rc = pModule->xNext(pCur->pVtabCursor);
if( rc==SQLITE_OK ){
res = pModule->xEof(pCur->pVtabCursor);
}
if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse; if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
if( res ){ if( !res ){
/* If there is data (or an error), jump to P2 */ /* If there is data, jump to P2 */
pc = pOp->p2 - 1; pc = pOp->p2 - 1;
} }
} }

View File

@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The # This file implements regression tests for SQLite library. The
# focus of this file is creating and dropping virtual tables. # focus of this file is creating and dropping virtual tables.
# #
# $Id: vtab1.test,v 1.28 2006/06/21 16:02:44 danielk1977 Exp $ # $Id: vtab1.test,v 1.29 2006/06/22 09:53:50 danielk1977 Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@@ -738,6 +738,36 @@ do_test vtab1.8-1 {
xSync echo(real_abc) \ xSync echo(real_abc) \
xCommit echo(real_abc) \ xCommit echo(real_abc) \
] ]
do_test vtab1.8-2 {
execsql {
DROP TABLE aux.e2;
DROP TABLE treal;
DROP TABLE techo;
DROP TABLE echo_abc;
DROP TABLE real_abc;
}
} {}
if 0 {
do_test vtab1.9-1 {
set echo_module ""
execsql {
CREATE TABLE r(a, b, c);
CREATE VIRTUAL TABLE e USING echo(r, e_log);
SELECT name FROM sqlite_master;
}
} {r e e_log}
do_test vtab1.9-2 {
explain {
DROP TABLE e;
}
execsql {
PRAGMA vdbe_trace = 1;
DROP TABLE e;
SELECT name FROM sqlite_master;
}
} {r}
}
finish_test finish_test

42
test/vtab_err.test Normal file
View File

@@ -0,0 +1,42 @@
# 2006 June 10
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
#
# $Id: vtab_err.test,v 1.1 2006/06/22 09:53:50 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !vtab {
finish_test
return
}
do_ioerr_test vtab_err-1 -tclprep {
register_echo_module [sqlite3_connection_pointer db]
} -sqlbody {
BEGIN;
CREATE TABLE r(a PRIMARY KEY, b, c);
CREATE VIRTUAL TABLE e USING echo(r);
INSERT INTO e VALUES(1, 2, 3);
INSERT INTO e VALUES('a', 'b', 'c');
UPDATE e SET c = 10;
DELETE FROM e WHERE a = 'a';
COMMIT;
BEGIN;
CREATE TABLE r2(a, b, c);
INSERT INTO r2 SELECT * FROM e;
INSERT INTO e SELECT a||'x', b, c FROM r2;
COMMIT;
}
finish_test