mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Add tests to improve coverage of vtab.c. (CVS 3291)
FossilOrigin-Name: 0c5f4ee39cb76747cf01398867fed2c7ae3edc84
This commit is contained in:
18
manifest
18
manifest
@@ -1,5 +1,5 @@
|
||||
C Ensure\swhitespace\sspecified\sas\spart\sof\sa\svirtual\stable\sconstructor\sargument\sis\scorrectly\spassed\sto\sthe\sconstructor\sfunction.\s(CVS\s3290)
|
||||
D 2006-06-24T08:51:05
|
||||
C Add\stests\sto\simprove\scoverage\sof\svtab.c.\s(CVS\s3291)
|
||||
D 2006-06-24T09:34:23
|
||||
F Makefile.in f839b470345d3cb4b0644068474623fe2464b5d3
|
||||
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
|
||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||
@@ -84,11 +84,11 @@ F src/test4.c 8b784cd82de158a2317cb4ac4bc86f91ad315e25
|
||||
F src/test5.c 7162f8526affb771c4ed256826eee7bb9eca265f
|
||||
F src/test6.c 60a02961ceb7b3edc25f5dc5c1ac2556622a76de
|
||||
F src/test7.c 03fa8d787f6aebc6d1f72504d52f33013ad2c8e3
|
||||
F src/test8.c c7aa1d069087935f3d4eecd685c80a8d4426ece0
|
||||
F src/test8.c 3e0d66d6b82bd2dda88031788a9169e322b3bf5f
|
||||
F src/test_async.c e3deaedd4d86a56391b81808fde9e44fbd92f1d3
|
||||
F src/test_loadext.c 22065d601a18878e5542191001f0eaa5d77c0ed8
|
||||
F src/test_md5.c 6c42bc0a3c0b54be34623ff77a0eec32b2fa96e3
|
||||
F src/test_schema.c 5aeddd60a60c3070de4c5bfa4f5c333c7769109c
|
||||
F src/test_schema.c 06042ea462608aecb6f9a95d5649227121093646
|
||||
F src/test_server.c a6460daed0b92ecbc2531b6dc73717470e7a648c
|
||||
F src/test_tclvar.c c52f67fbe06d32804af2ba9a2d7aadfc15f5910c
|
||||
F src/tokenize.c 7b448440dfd6e984d6bef7ac7fc60f1d26eaf8e7
|
||||
@@ -104,7 +104,7 @@ F src/vdbeapi.c 6af0e7160af260052a7a4500464221a03dada75f
|
||||
F src/vdbeaux.c 1144cee0a5644c26f63e7fa34574dcd9349ac799
|
||||
F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5
|
||||
F src/vdbemem.c 5f0afe3b92bb2c037f8d5d697f7c151fa50783a3
|
||||
F src/vtab.c 1f3d6758eabffa381080b540fbf5ffd2b3b208db
|
||||
F src/vtab.c 1eaa23c1a52c96927076c196c5b19752efd02111
|
||||
F src/where.c 6175449f1ff97a5bfea4068a35c050456c632e89
|
||||
F tclinstaller.tcl 046e3624671962dc50f0481d7c25b38ef803eb42
|
||||
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
||||
@@ -291,7 +291,7 @@ F test/vacuum.test 37f998b841cb335397c26d9bbc3457182af2565f
|
||||
F test/vacuum2.test 5aea8c88a65cb29f7d175296e7c819c6158d838c
|
||||
F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102
|
||||
F test/view.test 16e2774fe35e47a07ac4471b7f0bcc948b1aa6d5
|
||||
F test/vtab1.test 1513060e02136c9ba0a83c201698de7c5846f7e6
|
||||
F test/vtab1.test 566632d6c0e722222679228e4cb5bca72411a9cb
|
||||
F test/vtab2.test e57f9865368df26ef5eb8bc630962d82086f174b
|
||||
F test/vtab3.test f38d6d7d19f08bffdadce4d5b8cba078f8118587
|
||||
F test/vtab4.test 4b4293341443839ef6dc02f8d9e614702a6c67ff
|
||||
@@ -373,7 +373,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
|
||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
||||
P 4acf7594a6c47142e7112d2cd9766a563401879b
|
||||
R beecc5e611a3a30bf373ae1be7ae7d60
|
||||
P 4630e11d9a697a7fa29a0a1bbca91da4ad2bde7b
|
||||
R c24a599dff967aa04649cf25f3993ffe
|
||||
U danielk1977
|
||||
Z 14efa5deb3b9156b894cf23e7d8a3299
|
||||
Z 795fb524dae0f40446874bdb9f8a49ca
|
||||
|
@@ -1 +1 @@
|
||||
4630e11d9a697a7fa29a0a1bbca91da4ad2bde7b
|
||||
0c5f4ee39cb76747cf01398867fed2c7ae3edc84
|
46
src/test8.c
46
src/test8.c
@@ -13,7 +13,7 @@
|
||||
** is not included in the SQLite library. It is used for automated
|
||||
** testing of the SQLite library.
|
||||
**
|
||||
** $Id: test8.c,v 1.35 2006/06/24 06:36:11 danielk1977 Exp $
|
||||
** $Id: test8.c,v 1.36 2006/06/24 09:34:23 danielk1977 Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "tcl.h"
|
||||
@@ -32,6 +32,7 @@ typedef struct echo_cursor echo_cursor;
|
||||
**
|
||||
** $::echo_module
|
||||
** $::echo_module_sync_fail
|
||||
** $::echo_module_begin_fail
|
||||
**
|
||||
** The variable ::echo_module is a list. Each time one of the following
|
||||
** methods is called, one or more elements are appended to the list.
|
||||
@@ -851,7 +852,21 @@ static int echoTransactionCall(sqlite3_vtab *tab, const char *zCall){
|
||||
return SQLITE_OK;
|
||||
}
|
||||
static int echoBegin(sqlite3_vtab *tab){
|
||||
return echoTransactionCall(tab, "xBegin");
|
||||
echo_vtab *pVtab = (echo_vtab *)tab;
|
||||
Tcl_Interp *interp = pVtab->interp;
|
||||
const char *zVal;
|
||||
|
||||
echoTransactionCall(tab, "xBegin");
|
||||
|
||||
/* Check if the $::echo_module_begin_fail variable is defined. If it is,
|
||||
** and it is set to the name of the real table underlying this virtual
|
||||
** echo module table, then cause this xSync operation to fail.
|
||||
*/
|
||||
zVal = Tcl_GetVar(interp, "echo_module_begin_fail", TCL_GLOBAL_ONLY);
|
||||
if( zVal && 0==strcmp(zVal, pVtab->zTableName) ){
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
return SQLITE_OK;
|
||||
}
|
||||
static int echoSync(sqlite3_vtab *tab){
|
||||
echo_vtab *pVtab = (echo_vtab *)tab;
|
||||
@@ -930,6 +945,32 @@ static int register_echo_module(
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** Tcl interface to sqlite3_declare_vtab, invoked as follows from Tcl:
|
||||
**
|
||||
** sqlite3_declare_vtab DB SQL
|
||||
*/
|
||||
static int declare_vtab(
|
||||
ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
|
||||
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
|
||||
int objc, /* Number of arguments */
|
||||
Tcl_Obj *CONST objv[] /* Command arguments */
|
||||
){
|
||||
sqlite3 *db;
|
||||
int rc;
|
||||
if( objc!=3 ){
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "DB SQL");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
|
||||
rc = sqlite3_declare_vtab(db, Tcl_GetString(objv[2]));
|
||||
if( rc!=SQLITE_OK ){
|
||||
Tcl_SetResult(interp, sqlite3_errmsg(db), TCL_VOLATILE);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
#endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */
|
||||
|
||||
/*
|
||||
@@ -943,6 +984,7 @@ int Sqlitetest8_Init(Tcl_Interp *interp){
|
||||
} aObjCmd[] = {
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
{ "register_echo_module", register_echo_module, 0 },
|
||||
{ "sqlite3_declare_vtab", declare_vtab, 0 },
|
||||
#endif
|
||||
};
|
||||
int i;
|
||||
|
@@ -13,7 +13,7 @@
|
||||
** is not included in the SQLite library. It is used for automated
|
||||
** testing of the SQLite library.
|
||||
**
|
||||
** $Id: test_schema.c,v 1.6 2006/06/22 09:53:50 danielk1977 Exp $
|
||||
** $Id: test_schema.c,v 1.7 2006/06/24 09:34:23 danielk1977 Exp $
|
||||
*/
|
||||
|
||||
/* The code in this file defines a sqlite3 virtual-table module that
|
||||
@@ -170,7 +170,7 @@ static int schemaEof(sqlite3_vtab_cursor *cur){
|
||||
** Advance the cursor to the next row.
|
||||
*/
|
||||
static int schemaNext(sqlite3_vtab_cursor *cur){
|
||||
int rc;
|
||||
int rc = SQLITE_OK;
|
||||
schema_cursor *pCur = (schema_cursor *)cur;
|
||||
schema_vtab *pVtab = (schema_vtab *)(cur->pVtab);
|
||||
char *zSql = 0;
|
||||
|
@@ -11,7 +11,7 @@
|
||||
*************************************************************************
|
||||
** This file contains code used to help implement virtual tables.
|
||||
**
|
||||
** $Id: vtab.c,v 1.23 2006/06/24 08:51:05 danielk1977 Exp $
|
||||
** $Id: vtab.c,v 1.24 2006/06/24 09:34:23 danielk1977 Exp $
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
#include "sqliteInt.h"
|
||||
@@ -178,9 +178,6 @@ void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){
|
||||
char *zWhere;
|
||||
int iDb;
|
||||
Vdbe *v;
|
||||
if( !pMod ){
|
||||
sqlite3ErrorMsg(pParse, "no such module: %s", zModule);
|
||||
}
|
||||
|
||||
/* Compute the complete text of the CREATE VIRTUAL TABLE statement */
|
||||
if( pEnd ){
|
||||
|
@@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is creating and dropping virtual tables.
|
||||
#
|
||||
# $Id: vtab1.test,v 1.31 2006/06/24 08:51:05 danielk1977 Exp $
|
||||
# $Id: vtab1.test,v 1.32 2006/06/24 09:34:24 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@@ -775,5 +775,34 @@ do_test vtab1.9-3 {
|
||||
xCommit echo(r) \
|
||||
]
|
||||
|
||||
do_test vtab1.10-1 {
|
||||
execsql {
|
||||
CREATE TABLE del(d);
|
||||
CREATE VIRTUAL TABLE e2 USING echo(del);
|
||||
}
|
||||
db close
|
||||
sqlite3 db test.db
|
||||
register_echo_module [sqlite3_connection_pointer db]
|
||||
execsql {
|
||||
DROP TABLE del;
|
||||
}
|
||||
catchsql {
|
||||
SELECT * FROM e2;
|
||||
}
|
||||
} {1 {vtable constructor failed: e2}}
|
||||
do_test vtab1.10-2 {
|
||||
set rc [catch {
|
||||
set ptr [sqlite3_connection_pointer db]
|
||||
sqlite3_declare_vtab $ptr {CREATE TABLE abc(a, b, c)}
|
||||
} msg]
|
||||
list $rc $msg
|
||||
} {1 {library routine called out of sequence}}
|
||||
do_test vtab1.10-3 {
|
||||
set ::echo_module_begin_fail r
|
||||
catchsql {
|
||||
INSERT INTO e VALUES(1, 2, 3);
|
||||
}
|
||||
} {1 {SQL logic error or missing database}}
|
||||
|
||||
finish_test
|
||||
|
||||
|
Reference in New Issue
Block a user