Add the database name to the parameters passed to virtual table module xCreate and xConnect methods. (CVS 3282)

FossilOrigin-Name: 2d2805785f473afc202df532df84c45e6f0dc0f1
This commit is contained in:
danielk1977 2006-06-21 16:02:42 +00:00
parent d07e543f29
commit 70ba164098
5 changed files with 36 additions and 24 deletions

View File

@ -1,5 +1,5 @@
C Add\sthe\stable\sname\sto\sthe\sarguments\spassed\sto\sthe\svirtual\stable\smethods\sxCreate/xConnect.\s(CVS\s3281)
D 2006-06-21T13:21:51
C Add\sthe\sdatabase\sname\sto\sthe\sparameters\spassed\sto\svirtual\stable\smodule\sxCreate\sand\sxConnect\smethods.\s(CVS\s3282)
D 2006-06-21T16:02:43
F Makefile.in f839b470345d3cb4b0644068474623fe2464b5d3
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@ -84,7 +84,7 @@ F src/test4.c 8b784cd82de158a2317cb4ac4bc86f91ad315e25
F src/test5.c 7162f8526affb771c4ed256826eee7bb9eca265f
F src/test6.c 60a02961ceb7b3edc25f5dc5c1ac2556622a76de
F src/test7.c 03fa8d787f6aebc6d1f72504d52f33013ad2c8e3
F src/test8.c 58134b50229c6703cef5b2a48470502dc3de5c60
F src/test8.c d584dc94c0a62afb21bca311d2958defc6684236
F src/test_async.c e3deaedd4d86a56391b81808fde9e44fbd92f1d3
F src/test_loadext.c 22065d601a18878e5542191001f0eaa5d77c0ed8
F src/test_md5.c 6c42bc0a3c0b54be34623ff77a0eec32b2fa96e3
@ -104,7 +104,7 @@ F src/vdbeapi.c 6af0e7160af260052a7a4500464221a03dada75f
F src/vdbeaux.c 2e4cb97e6d1612c0e108d68e038a7cd612bceb72
F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5
F src/vdbemem.c 5f0afe3b92bb2c037f8d5d697f7c151fa50783a3
F src/vtab.c e65a7fd62d8dd71350c6289afc8e3e9bc8fe3138
F src/vtab.c 99ca599e9e4af1a63a3caf4389410a16adacf9f6
F src/where.c 0a13357175678d51a218326bca389f20bb41e38b
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 482d1a593cf63a730ab4144d53f44b0b9a26d7e4
F test/vtab1.test 5bb366f18287c9b4c8af110a810c10eb713fb58b
F test/vtab2.test e57f9865368df26ef5eb8bc630962d82086f174b
F test/vtab3.test f38d6d7d19f08bffdadce4d5b8cba078f8118587
F test/vtab4.test 4b4293341443839ef6dc02f8d9e614702a6c67ff
@ -372,7 +372,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
P 6c3e8852ffbaf5ab52ffdf7ed3767fa1d4fd5882
R b9b6a3a1cf617e6ce2ebea89762bbd86
P 7dc36d1c798aa8b30b88a528fc9e69b342f278c7
R 766df509631bed98b63389617990a41e
U danielk1977
Z db7ca11b12957a39dfe19b08d7995731
Z e5ccb6373eaa19bb4db62e1fb209d911

View File

@ -1 +1 @@
7dc36d1c798aa8b30b88a528fc9e69b342f278c7
2d2805785f473afc202df532df84c45e6f0dc0f1

View File

@ -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.29 2006/06/21 13:21:51 danielk1977 Exp $
** $Id: test8.c,v 1.30 2006/06/21 16:02:43 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
@ -194,12 +194,12 @@ static int echoDeclareVtab(
){
int rc = SQLITE_OK;
if( argc==3 ){
if( argc==4 ){
sqlite3_stmt *pStmt = 0;
sqlite3_prepare(db,
"SELECT sql FROM sqlite_master WHERE type = 'table' AND name = ?",
-1, &pStmt, 0);
sqlite3_bind_text(pStmt, 1, argv[2], -1, 0);
sqlite3_bind_text(pStmt, 1, argv[3], -1, 0);
if( sqlite3_step(pStmt)==SQLITE_ROW ){
const char *zCreateTable = sqlite3_column_text(pStmt, 0);
#ifndef SQLITE_OMIT_VIRTUALTABLE
@ -210,10 +210,10 @@ static int echoDeclareVtab(
}
sqlite3_finalize(pStmt);
if( rc==SQLITE_OK ){
rc = getIndexArray(db, argv[2], &pVtab->aIndex);
rc = getIndexArray(db, argv[3], &pVtab->aIndex);
}
if( rc==SQLITE_OK ){
rc = getColumnNames(db, argv[2], &pVtab->aCol, &pVtab->nCol);
rc = getColumnNames(db, argv[3], &pVtab->aCol, &pVtab->nCol);
}
}
@ -245,7 +245,7 @@ static int echoConstructor(
pVtab = sqliteMalloc( sizeof(*pVtab) );
pVtab->interp = (Tcl_Interp *)pAux;
pVtab->db = db;
pVtab->zTableName = sqlite3MPrintf("%s", argv[2]);
pVtab->zTableName = sqlite3MPrintf("%s", argv[3]);
for(i=0; i<argc; i++){
appendToEchoModule(pVtab->interp, argv[i]);
}

View File

@ -11,7 +11,7 @@
*************************************************************************
** This file contains code used to help implement virtual tables.
**
** $Id: vtab.c,v 1.19 2006/06/21 13:21:51 danielk1977 Exp $
** $Id: vtab.c,v 1.20 2006/06/21 16:02:43 danielk1977 Exp $
*/
#ifndef SQLITE_OMIT_VIRTUALTABLE
#include "sqliteInt.h"
@ -92,18 +92,20 @@ void sqlite3VtabBeginParse(
int iDb; /* The database the table is being created in */
Table *pTable; /* The new virtual table */
Token *pDummy; /* Dummy arg for sqlite3TwoPartName() */
char *zTab;
sqlite3StartTable(pParse, pName1, pName2, 0, 0, 1, 0);
pTable = pParse->pNewTable;
if( pTable==0 || pParse->nErr ) return;
assert( 0==pTable->pIndex );
iDb = sqlite3SchemaToIndex(pParse->db, pTable->pSchema);
assert( iDb>=0 );
pTable->isVirtual = 1;
pTable->nModuleArg = 0;
addModuleArgument(pTable, sqlite3NameFromToken(pModuleName));
zTab = sqlite3NameFromToken((pName2&&pName2->z)?pName2:pName1);
addModuleArgument(pTable, zTab);
addModuleArgument(pTable, sqlite3StrDup(pParse->db->aDb[iDb].zName));
addModuleArgument(pTable, sqlite3StrDup(pTable->zName));
pParse->sNameToken.n = pModuleName->z + pModuleName->n - pName1->z;
#ifndef SQLITE_OMIT_AUTHORIZATION
@ -112,8 +114,6 @@ void sqlite3VtabBeginParse(
** sqlite_master table, has already been made by sqlite3StartTable().
** The second call, to obtain permission to create the table, is made now.
*/
iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pDummy);
assert( iDb>=0 );
if( sqlite3AuthCheck(pParse, SQLITE_CREATE_VTABLE, pTable->zName,
pTable->azModuleArg[0], pParse->db->aDb[iDb].zName)
){

View File

@ -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.27 2006/06/21 13:21:51 danielk1977 Exp $
# $Id: vtab1.test,v 1.28 2006/06/21 16:02:44 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -239,7 +239,7 @@ do_test vtab1.2.7 {
]
do_test vtab1.2.8 {
set echo_module
} {xConnect echo t1 template}
} {xConnect echo main t1 template}
# Drop table t1. This should cause the xDestroy (but not xDisconnect) method
# to be invoked.
@ -281,7 +281,7 @@ do_test vtab1-3.1 {
CREATE VIRTUAL TABLE t1 USING echo(treal);
}
set echo_module
} [list xCreate echo t1 treal \
} [list xCreate echo main t1 treal \
xSync echo(treal) \
xCommit echo(treal) \
]
@ -727,5 +727,17 @@ do_test vtab1.7-13 {
}
} {}
do_test vtab1.8-1 {
set echo_module ""
execsql {
ATTACH 'test2.db' AS aux;
CREATE VIRTUAL TABLE aux.e2 USING echo(real_abc);
}
set echo_module
} [list xCreate echo aux e2 real_abc \
xSync echo(real_abc) \
xCommit echo(real_abc) \
]
finish_test