mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-04 04:42:17 +03:00
Add void* argument to sqlite3_create_module to replace sqlite3_module.pAux. (CVS 3251)
FossilOrigin-Name: 470a3a0b20775be1226fb4d477c798d8da2d5708
This commit is contained in:
26
manifest
26
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Changes\sto\stest8.c\sto\ssupport\sUPDATE\soperations\son\sxUpdate.\s(CVS\s3250)
|
C Add\svoid*\sargument\sto\ssqlite3_create_module\sto\sreplace\ssqlite3_module.pAux.\s(CVS\s3251)
|
||||||
D 2006-06-14T23:43:31
|
D 2006-06-15T04:28:13
|
||||||
F Makefile.in 200f6dc376ecfd9b01e5359c4e0c10c02f649b34
|
F Makefile.in 200f6dc376ecfd9b01e5359c4e0c10c02f649b34
|
||||||
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
|
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
|
||||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||||
@@ -40,7 +40,7 @@ F src/build.c 076619b2a5cbdbdabf5201fc45dda488d7f3cbe6
|
|||||||
F src/callback.c fd9bb39f7ff6b52bad8365617abc61c720640429
|
F src/callback.c fd9bb39f7ff6b52bad8365617abc61c720640429
|
||||||
F src/complete.c 7d1a44be8f37de125fcafd3d3a018690b3799675
|
F src/complete.c 7d1a44be8f37de125fcafd3d3a018690b3799675
|
||||||
F src/date.c cd2bd5d1ebc6fa12d6312f69789ae5b0a2766f2e
|
F src/date.c cd2bd5d1ebc6fa12d6312f69789ae5b0a2766f2e
|
||||||
F src/delete.c d529fe3e20d87af628c0078fc33a3e717bb511cf
|
F src/delete.c f34599f681d291d5b5762ff162a4b10214809aef
|
||||||
F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b
|
F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b
|
||||||
F src/expr.c 78b521337d628b1fd9d87b12dbbe771247aab585
|
F src/expr.c 78b521337d628b1fd9d87b12dbbe771247aab585
|
||||||
F src/func.c 01e559893b5e43bea85135ad3e481d86c447942a
|
F src/func.c 01e559893b5e43bea85135ad3e481d86c447942a
|
||||||
@@ -49,7 +49,7 @@ F src/hash.h 1b3f7e2609141fd571f62199fc38687d262e9564
|
|||||||
F src/insert.c bda00a0e4be8bf4e591186e710075662781293d0
|
F src/insert.c bda00a0e4be8bf4e591186e710075662781293d0
|
||||||
F src/legacy.c fa15d505dd4e45044177ee4d1c6aeaf8c836d390
|
F src/legacy.c fa15d505dd4e45044177ee4d1c6aeaf8c836d390
|
||||||
F src/loadext.c d8c7bd14e6ebc4e9f1ff269475bf63e131919449
|
F src/loadext.c d8c7bd14e6ebc4e9f1ff269475bf63e131919449
|
||||||
F src/main.c 4e48472d06ac3fc0250023e2eb406fc7d8d0a27c
|
F src/main.c 7875e8835539d4f16e8b62fad1dee9bda2091272
|
||||||
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,9 +72,9 @@ F src/random.c d40f8d356cecbd351ccfab6eaedd7ec1b54f5261
|
|||||||
F src/select.c 38eda11d950ed5e631ea9054f84a4a8b9e9b39d8
|
F src/select.c 38eda11d950ed5e631ea9054f84a4a8b9e9b39d8
|
||||||
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 b1ecebd3154cf49ba189193f7bdc10a78a9394a2
|
F src/sqlite.h.in 1dc44da025da28a011d11ad1608c11a951047fab
|
||||||
F src/sqlite3ext.h 127bd394c8eea481f2ac9b754bf399dbfc818b75
|
F src/sqlite3ext.h 127bd394c8eea481f2ac9b754bf399dbfc818b75
|
||||||
F src/sqliteInt.h 5a806625f0e9400419d60f74dccef44569dd7871
|
F src/sqliteInt.h 5eb64f1dd9a8b237d147962bc57637d87e044ff4
|
||||||
F src/table.c f64ec4fbfe333f8df925bc6ba494f55e05b0e75e
|
F src/table.c f64ec4fbfe333f8df925bc6ba494f55e05b0e75e
|
||||||
F src/tclsqlite.c 4ad22f354b6e4e137889000e9f585a0590ca39c5
|
F src/tclsqlite.c 4ad22f354b6e4e137889000e9f585a0590ca39c5
|
||||||
F src/test1.c 40f20775903bc76d3be3e7c026dddcbc221c1cb0
|
F src/test1.c 40f20775903bc76d3be3e7c026dddcbc221c1cb0
|
||||||
@@ -84,12 +84,12 @@ 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 2f38a6c295f15dd9dbb3db954be21aa8ea3c284b
|
F src/test8.c c8da12c237a507273dba8cb11a9f88d2252bd031
|
||||||
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_server.c a6460daed0b92ecbc2531b6dc73717470e7a648c
|
F src/test_server.c a6460daed0b92ecbc2531b6dc73717470e7a648c
|
||||||
F src/test_tclvar.c d434037c1730cfffbf007ac82f1c405d7155a92a
|
F src/test_tclvar.c c52f67fbe06d32804af2ba9a2d7aadfc15f5910c
|
||||||
F src/tokenize.c 6ebcafa6622839968dda4418a7b6945f277a128f
|
F src/tokenize.c 6ebcafa6622839968dda4418a7b6945f277a128f
|
||||||
F src/trigger.c 0fc40125820409a6274834a6e04ad804d96e2793
|
F src/trigger.c 0fc40125820409a6274834a6e04ad804d96e2793
|
||||||
F src/update.c 5e638a61102776c0f0333994e18361b40598b44f
|
F src/update.c 5e638a61102776c0f0333994e18361b40598b44f
|
||||||
@@ -103,7 +103,7 @@ F src/vdbeapi.c 6af0e7160af260052a7a4500464221a03dada75f
|
|||||||
F src/vdbeaux.c de49c1943146ad97538bc2bb0bce7f2c5e5db4f2
|
F src/vdbeaux.c de49c1943146ad97538bc2bb0bce7f2c5e5db4f2
|
||||||
F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5
|
F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5
|
||||||
F src/vdbemem.c 5f0afe3b92bb2c037f8d5d697f7c151fa50783a3
|
F src/vdbemem.c 5f0afe3b92bb2c037f8d5d697f7c151fa50783a3
|
||||||
F src/vtab.c 507cbb4e2101900339ce88e57144cc01dafa374e
|
F src/vtab.c 3b58aa4a54288efe7b1b0cddcdeac239ffa3f071
|
||||||
F src/where.c d7c3cc011834882b2d58ebb3a6a1a569ead7ebd7
|
F src/where.c d7c3cc011834882b2d58ebb3a6a1a569ead7ebd7
|
||||||
F tclinstaller.tcl 046e3624671962dc50f0481d7c25b38ef803eb42
|
F tclinstaller.tcl 046e3624671962dc50f0481d7c25b38ef803eb42
|
||||||
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
||||||
@@ -366,7 +366,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 c996185a9e0671e46bed06e5803b1ca3b42d61e2
|
P 9e96511f83476e489fa62a05241393a851cbac5c
|
||||||
R ee3ad5273671026614072c99f84a0525
|
R 3b2eab4f54e22efb7b510b16ba4f9657
|
||||||
U drh
|
U danielk1977
|
||||||
Z bbafadf19467cae14bf8a8d2edcf9481
|
Z 15129ea2cdd7a9095da7badd4764cc47
|
||||||
|
@@ -1 +1 @@
|
|||||||
9e96511f83476e489fa62a05241393a851cbac5c
|
470a3a0b20775be1226fb4d477c798d8da2d5708
|
@@ -12,7 +12,7 @@
|
|||||||
** This file contains C code routines that are called by the parser
|
** This file contains C code routines that are called by the parser
|
||||||
** in order to generate code for DELETE FROM statements.
|
** in order to generate code for DELETE FROM statements.
|
||||||
**
|
**
|
||||||
** $Id: delete.c,v 1.124 2006/06/14 19:00:21 drh Exp $
|
** $Id: delete.c,v 1.125 2006/06/15 04:28:13 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ int sqlite3IsReadOnly(Parse *pParse, Table *pTab, int viewOk){
|
|||||||
if( (pTab->readOnly && (pParse->db->flags & SQLITE_WriteSchema)==0
|
if( (pTab->readOnly && (pParse->db->flags & SQLITE_WriteSchema)==0
|
||||||
&& pParse->nested==0)
|
&& pParse->nested==0)
|
||||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||||
|| (pTab->pModule && pTab->pModule->xUpdate==0)
|
|| (pTab->pMod && pTab->pMod->pModule->xUpdate==0)
|
||||||
#endif
|
#endif
|
||||||
){
|
){
|
||||||
sqlite3ErrorMsg(pParse, "table %s may not be modified", pTab->zName);
|
sqlite3ErrorMsg(pParse, "table %s may not be modified", pTab->zName);
|
||||||
|
@@ -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.343 2006/06/14 15:35:37 drh Exp $
|
** $Id: main.c,v 1.344 2006/06/15 04:28:13 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
@@ -160,6 +160,10 @@ int sqlite3_close(sqlite3 *db){
|
|||||||
}
|
}
|
||||||
sqlite3HashClear(&db->aCollSeq);
|
sqlite3HashClear(&db->aCollSeq);
|
||||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||||
|
for(i=sqliteHashFirst(&db->aModule); i; i=sqliteHashNext(i)){
|
||||||
|
Module *pMod = (Module *)sqliteHashData(i);
|
||||||
|
sqliteFree(pMod);
|
||||||
|
}
|
||||||
sqlite3HashClear(&db->aModule);
|
sqlite3HashClear(&db->aModule);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -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.176 2006/06/14 13:03:23 danielk1977 Exp $
|
** @(#) $Id: sqlite.h.in,v 1.177 2006/06/15 04:28:13 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef _SQLITE3_H_
|
#ifndef _SQLITE3_H_
|
||||||
#define _SQLITE3_H_
|
#define _SQLITE3_H_
|
||||||
@@ -1536,7 +1536,6 @@ typedef struct sqlite3_module sqlite3_module;
|
|||||||
struct sqlite3_module {
|
struct sqlite3_module {
|
||||||
int iVersion;
|
int iVersion;
|
||||||
const char *zName;
|
const char *zName;
|
||||||
void *pAux;
|
|
||||||
int (*xCreate)(sqlite3*, void *pAux,
|
int (*xCreate)(sqlite3*, void *pAux,
|
||||||
int argc, char **argv,
|
int argc, char **argv,
|
||||||
sqlite3_vtab **ppVTab);
|
sqlite3_vtab **ppVTab);
|
||||||
@@ -1649,7 +1648,8 @@ struct sqlite3_index_info {
|
|||||||
int sqlite3_create_module(
|
int sqlite3_create_module(
|
||||||
sqlite3 *db, /* SQLite connection to register module with */
|
sqlite3 *db, /* SQLite connection to register module with */
|
||||||
const char *zName, /* Name of the module */
|
const char *zName, /* Name of the module */
|
||||||
const sqlite3_module * /* Methods for the module */
|
const sqlite3_module *, /* Methods for the module */
|
||||||
|
void * /* Client data for xCreate/xConnect */
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
*************************************************************************
|
*************************************************************************
|
||||||
** Internal interface definitions for SQLite.
|
** Internal interface definitions for SQLite.
|
||||||
**
|
**
|
||||||
** @(#) $Id: sqliteInt.h,v 1.505 2006/06/14 19:00:21 drh Exp $
|
** @(#) $Id: sqliteInt.h,v 1.506 2006/06/15 04:28:13 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef _SQLITEINT_H_
|
#ifndef _SQLITEINT_H_
|
||||||
#define _SQLITEINT_H_
|
#define _SQLITEINT_H_
|
||||||
@@ -343,6 +343,7 @@ typedef struct IdList IdList;
|
|||||||
typedef struct Index Index;
|
typedef struct Index Index;
|
||||||
typedef struct KeyClass KeyClass;
|
typedef struct KeyClass KeyClass;
|
||||||
typedef struct KeyInfo KeyInfo;
|
typedef struct KeyInfo KeyInfo;
|
||||||
|
typedef struct Module Module;
|
||||||
typedef struct NameContext NameContext;
|
typedef struct NameContext NameContext;
|
||||||
typedef struct Parse Parse;
|
typedef struct Parse Parse;
|
||||||
typedef struct Select Select;
|
typedef struct Select Select;
|
||||||
@@ -566,6 +567,17 @@ struct FuncDef {
|
|||||||
char zName[1]; /* SQL name of the function. MUST BE LAST */
|
char zName[1]; /* SQL name of the function. MUST BE LAST */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Each SQLite module (virtual table definition) is defined by an
|
||||||
|
** instance of the following structure, stored in the sqlite3.aModule
|
||||||
|
** hash table.
|
||||||
|
*/
|
||||||
|
struct Module {
|
||||||
|
const sqlite3_module *pModule; /* Callback pointers */
|
||||||
|
const char *zName; /* Name passed to create_module() */
|
||||||
|
void *pAux; /* pAux passed to create_module() */
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Possible values for FuncDef.flags
|
** Possible values for FuncDef.flags
|
||||||
*/
|
*/
|
||||||
@@ -705,7 +717,7 @@ struct Table {
|
|||||||
int addColOffset; /* Offset in CREATE TABLE statement to add a new column */
|
int addColOffset; /* Offset in CREATE TABLE statement to add a new column */
|
||||||
#endif
|
#endif
|
||||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||||
sqlite3_module *pModule; /* Pointer to the implementation of the module */
|
Module *pMod; /* Pointer to the implementation of the module */
|
||||||
sqlite3_vtab *pVtab; /* Pointer to the module instance */
|
sqlite3_vtab *pVtab; /* Pointer to the module instance */
|
||||||
u8 isVirtual; /* True if this is a virtual table */
|
u8 isVirtual; /* True if this is a virtual table */
|
||||||
int nModuleArg; /* Number of arguments to the module */
|
int nModuleArg; /* Number of arguments to the module */
|
||||||
|
@@ -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.19 2006/06/14 23:43:31 drh Exp $
|
** $Id: test8.c,v 1.20 2006/06/15 04:28:13 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "tcl.h"
|
#include "tcl.h"
|
||||||
@@ -622,7 +622,6 @@ int echoUpdate(sqlite3_vtab *tab, int nData, sqlite3_value **apData){
|
|||||||
static sqlite3_module echoModule = {
|
static sqlite3_module echoModule = {
|
||||||
0, /* iVersion */
|
0, /* iVersion */
|
||||||
"echo", /* zName */
|
"echo", /* zName */
|
||||||
0, /* pAux */
|
|
||||||
echoCreate,
|
echoCreate,
|
||||||
echoConnect,
|
echoConnect,
|
||||||
echoBestIndex,
|
echoBestIndex,
|
||||||
@@ -661,9 +660,8 @@ static int register_echo_module(
|
|||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
|
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
|
||||||
echoModule.pAux = interp;
|
|
||||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||||
sqlite3_create_module(db, "echo", &echoModule);
|
sqlite3_create_module(db, "echo", &echoModule, (void *)interp);
|
||||||
#endif
|
#endif
|
||||||
return TCL_OK;
|
return TCL_OK;
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
** The emphasis of this file is a virtual table that provides
|
** The emphasis of this file is a virtual table that provides
|
||||||
** access to TCL variables.
|
** access to TCL variables.
|
||||||
**
|
**
|
||||||
** $Id: test_tclvar.c,v 1.2 2006/06/14 06:58:16 danielk1977 Exp $
|
** $Id: test_tclvar.c,v 1.3 2006/06/15 04:28:13 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "tcl.h"
|
#include "tcl.h"
|
||||||
@@ -65,6 +65,7 @@ static int tclvarConnect(
|
|||||||
** methods are identical. */
|
** methods are identical. */
|
||||||
static int tclvarDisconnect(sqlite3_vtab *pVtab){
|
static int tclvarDisconnect(sqlite3_vtab *pVtab){
|
||||||
free(pVtab);
|
free(pVtab);
|
||||||
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
/* The xDisconnect and xDestroy methods are also the same */
|
/* The xDisconnect and xDestroy methods are also the same */
|
||||||
|
|
||||||
@@ -126,7 +127,6 @@ static int tclvarBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
|
|||||||
static sqlite3_module tclvarModule = {
|
static sqlite3_module tclvarModule = {
|
||||||
0, /* iVersion */
|
0, /* iVersion */
|
||||||
"tclvar", /* zName */
|
"tclvar", /* zName */
|
||||||
0, /* pAux */
|
|
||||||
tclvarConnect,
|
tclvarConnect,
|
||||||
tclvarConnect,
|
tclvarConnect,
|
||||||
tclvarBestIndex,
|
tclvarBestIndex,
|
||||||
@@ -164,9 +164,8 @@ static int register_tclvar_module(
|
|||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
|
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
|
||||||
tclvarModule.pAux = interp;
|
|
||||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||||
sqlite3_create_module(db, "tclvar", &tclvarModule);
|
sqlite3_create_module(db, "tclvar", &tclvarModule, (void *)interp);
|
||||||
#endif
|
#endif
|
||||||
return TCL_OK;
|
return TCL_OK;
|
||||||
}
|
}
|
||||||
|
62
src/vtab.c
62
src/vtab.c
@@ -11,7 +11,7 @@
|
|||||||
*************************************************************************
|
*************************************************************************
|
||||||
** This file contains code used to help implement virtual tables.
|
** This file contains code used to help implement virtual tables.
|
||||||
**
|
**
|
||||||
** $Id: vtab.c,v 1.11 2006/06/14 13:03:24 danielk1977 Exp $
|
** $Id: vtab.c,v 1.12 2006/06/15 04:28:13 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
@@ -22,11 +22,22 @@
|
|||||||
int sqlite3_create_module(
|
int sqlite3_create_module(
|
||||||
sqlite3 *db, /* Database in which module is registered */
|
sqlite3 *db, /* Database in which module is registered */
|
||||||
const char *zName, /* Name assigned to this module */
|
const char *zName, /* Name assigned to this module */
|
||||||
const sqlite3_module *pModule /* The definition of the module */
|
const sqlite3_module *pModule, /* The definition of the module */
|
||||||
|
void *pAux /* Context pointer for xCreate/xConnect */
|
||||||
){
|
){
|
||||||
sqlite3HashInsert(&db->aModule, zName, strlen(zName), (void*)pModule);
|
int nName = strlen(zName);
|
||||||
sqlite3ResetInternalSchema(db, 0);
|
Module *pMod = (Module *)sqliteMallocRaw(sizeof(Module) + nName + 1);
|
||||||
return SQLITE_OK;
|
if( pMod ){
|
||||||
|
char *zCopy = (char *)(&pMod[1]);
|
||||||
|
strcpy(zCopy, zName);
|
||||||
|
pMod->zName = zCopy;
|
||||||
|
pMod->pModule = pModule;
|
||||||
|
pMod->pAux = pAux;
|
||||||
|
pMod = (Module *)sqlite3HashInsert(&db->aModule, zCopy, nName, (void*)pMod);
|
||||||
|
sqliteFree(pMod);
|
||||||
|
sqlite3ResetInternalSchema(db, 0);
|
||||||
|
}
|
||||||
|
return sqlite3ApiExit(db, SQLITE_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -36,8 +47,8 @@ int sqlite3_create_module(
|
|||||||
*/
|
*/
|
||||||
void sqlite3VtabClear(Table *p){
|
void sqlite3VtabClear(Table *p){
|
||||||
if( p->pVtab ){
|
if( p->pVtab ){
|
||||||
assert( p->pModule!=0 );
|
assert( p->pMod && p->pMod->pModule );
|
||||||
p->pModule->xDisconnect(p->pVtab);
|
p->pMod->pModule->xDisconnect(p->pVtab);
|
||||||
}
|
}
|
||||||
if( p->azModuleArg ){
|
if( p->azModuleArg ){
|
||||||
int i;
|
int i;
|
||||||
@@ -116,6 +127,7 @@ void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){
|
|||||||
Table *pTab; /* The table being constructed */
|
Table *pTab; /* The table being constructed */
|
||||||
sqlite3 *db; /* The database connection */
|
sqlite3 *db; /* The database connection */
|
||||||
char *zModule; /* The module name of the table: USING modulename */
|
char *zModule; /* The module name of the table: USING modulename */
|
||||||
|
Module *pMod = 0;
|
||||||
|
|
||||||
addArgumentToVtab(pParse);
|
addArgumentToVtab(pParse);
|
||||||
sqliteFree(pParse->zArg);
|
sqliteFree(pParse->zArg);
|
||||||
@@ -128,8 +140,8 @@ void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){
|
|||||||
db = pParse->db;
|
db = pParse->db;
|
||||||
if( pTab->nModuleArg<1 ) return;
|
if( pTab->nModuleArg<1 ) return;
|
||||||
zModule = pTab->azModuleArg[0];
|
zModule = pTab->azModuleArg[0];
|
||||||
pTab->pModule = (sqlite3_module*)sqlite3HashFind(&db->aModule,
|
pMod = (Module *)sqlite3HashFind(&db->aModule, zModule, strlen(zModule));
|
||||||
zModule, strlen(zModule));
|
pTab->pMod = pMod;
|
||||||
|
|
||||||
/* If the CREATE VIRTUAL TABLE statement is being entered for the
|
/* If the CREATE VIRTUAL TABLE statement is being entered for the
|
||||||
** first time (in other words if the virtual table is actually being
|
** first time (in other words if the virtual table is actually being
|
||||||
@@ -142,7 +154,7 @@ void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){
|
|||||||
char *zWhere;
|
char *zWhere;
|
||||||
int iDb;
|
int iDb;
|
||||||
Vdbe *v;
|
Vdbe *v;
|
||||||
if( pTab->pModule==0 ){
|
if( !pMod ){
|
||||||
sqlite3ErrorMsg(pParse, "no such module: %s", zModule);
|
sqlite3ErrorMsg(pParse, "no such module: %s", zModule);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,7 +253,7 @@ void sqlite3VtabArgExtend(Parse *pParse, Token *p){
|
|||||||
static int vtabCallConstructor(
|
static int vtabCallConstructor(
|
||||||
sqlite3 *db,
|
sqlite3 *db,
|
||||||
Table *pTab,
|
Table *pTab,
|
||||||
sqlite3_module *pModule,
|
Module *pMod,
|
||||||
int (*xConstruct)(sqlite3*, void *, int, char **, sqlite3_vtab **),
|
int (*xConstruct)(sqlite3*, void *, int, char **, sqlite3_vtab **),
|
||||||
char **pzErr
|
char **pzErr
|
||||||
){
|
){
|
||||||
@@ -256,10 +268,10 @@ static int vtabCallConstructor(
|
|||||||
db->pVTab = pTab;
|
db->pVTab = pTab;
|
||||||
rc = sqlite3SafetyOff(db);
|
rc = sqlite3SafetyOff(db);
|
||||||
assert( rc==SQLITE_OK );
|
assert( rc==SQLITE_OK );
|
||||||
rc = xConstruct(db, pModule->pAux, nArg, azArg, &pTab->pVtab);
|
rc = xConstruct(db, pMod->pAux, nArg, azArg, &pTab->pVtab);
|
||||||
rc2 = sqlite3SafetyOn(db);
|
rc2 = sqlite3SafetyOn(db);
|
||||||
if( pTab->pVtab ){
|
if( pTab->pVtab ){
|
||||||
pTab->pVtab->pModule = pModule;
|
pTab->pVtab->pModule = pMod->pModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( SQLITE_OK!=rc ){
|
if( SQLITE_OK!=rc ){
|
||||||
@@ -284,7 +296,7 @@ static int vtabCallConstructor(
|
|||||||
** This call is a no-op if table pTab is not a virtual table.
|
** This call is a no-op if table pTab is not a virtual table.
|
||||||
*/
|
*/
|
||||||
int sqlite3VtabCallConnect(Parse *pParse, Table *pTab){
|
int sqlite3VtabCallConnect(Parse *pParse, Table *pTab){
|
||||||
sqlite3_module *pModule;
|
Module *pMod;
|
||||||
const char *zModule;
|
const char *zModule;
|
||||||
int rc = SQLITE_OK;
|
int rc = SQLITE_OK;
|
||||||
|
|
||||||
@@ -292,15 +304,16 @@ int sqlite3VtabCallConnect(Parse *pParse, Table *pTab){
|
|||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
pModule = pTab->pModule;
|
pMod = pTab->pMod;
|
||||||
zModule = pTab->azModuleArg[0];
|
zModule = pTab->azModuleArg[0];
|
||||||
if( !pModule ){
|
if( !pMod ){
|
||||||
const char *zModule = pTab->azModuleArg[0];
|
const char *zModule = pTab->azModuleArg[0];
|
||||||
sqlite3ErrorMsg(pParse, "no such module: %s", zModule);
|
sqlite3ErrorMsg(pParse, "no such module: %s", zModule);
|
||||||
rc = SQLITE_ERROR;
|
rc = SQLITE_ERROR;
|
||||||
} else {
|
} else {
|
||||||
char *zErr = 0;
|
char *zErr = 0;
|
||||||
rc = vtabCallConstructor(pParse->db,pTab,pModule,pModule->xConnect,&zErr);
|
sqlite3 *db = pParse->db;
|
||||||
|
rc = vtabCallConstructor(db, pTab, pMod, pMod->pModule->xConnect, &zErr);
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc!=SQLITE_OK ){
|
||||||
sqlite3ErrorMsg(pParse, "%s", zErr);
|
sqlite3ErrorMsg(pParse, "%s", zErr);
|
||||||
}
|
}
|
||||||
@@ -321,23 +334,23 @@ int sqlite3VtabCallConnect(Parse *pParse, Table *pTab){
|
|||||||
int sqlite3VtabCallCreate(sqlite3 *db, int iDb, const char *zTab, char **pzErr){
|
int sqlite3VtabCallCreate(sqlite3 *db, int iDb, const char *zTab, char **pzErr){
|
||||||
int rc = SQLITE_OK;
|
int rc = SQLITE_OK;
|
||||||
Table *pTab;
|
Table *pTab;
|
||||||
sqlite3_module *pModule;
|
Module *pMod;
|
||||||
const char *zModule;
|
const char *zModule;
|
||||||
|
|
||||||
pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);
|
pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);
|
||||||
assert(pTab && pTab->isVirtual && !pTab->pVtab);
|
assert(pTab && pTab->isVirtual && !pTab->pVtab);
|
||||||
pModule = pTab->pModule;
|
pMod = pTab->pMod;
|
||||||
zModule = pTab->azModuleArg[0];
|
zModule = pTab->azModuleArg[0];
|
||||||
|
|
||||||
/* If the module has been registered and includes a Create method,
|
/* If the module has been registered and includes a Create method,
|
||||||
** invoke it now. If the module has not been registered, return an
|
** invoke it now. If the module has not been registered, return an
|
||||||
** error. Otherwise, do nothing.
|
** error. Otherwise, do nothing.
|
||||||
*/
|
*/
|
||||||
if( !pModule ){
|
if( !pMod ){
|
||||||
*pzErr = sqlite3MPrintf("no such module: %s", zModule);
|
*pzErr = sqlite3MPrintf("no such module: %s", zModule);
|
||||||
rc = SQLITE_ERROR;
|
rc = SQLITE_ERROR;
|
||||||
}else{
|
}else{
|
||||||
rc = vtabCallConstructor(db, pTab, pModule, pModule->xCreate, pzErr);
|
rc = vtabCallConstructor(db, pTab, pMod, pMod->pModule->xCreate, pzErr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
@@ -401,15 +414,16 @@ int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab)
|
|||||||
{
|
{
|
||||||
int rc = SQLITE_OK;
|
int rc = SQLITE_OK;
|
||||||
Table *pTab;
|
Table *pTab;
|
||||||
sqlite3_module *pModule;
|
|
||||||
|
|
||||||
pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);
|
pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);
|
||||||
pModule = pTab->pModule;
|
|
||||||
assert(pTab);
|
assert(pTab);
|
||||||
if( pTab->pVtab ){
|
if( pTab->pVtab ){
|
||||||
|
int (*xDestroy)(sqlite3_vtab *pVTab) = pTab->pMod->pModule->xDestroy;
|
||||||
rc = sqlite3SafetyOff(db);
|
rc = sqlite3SafetyOff(db);
|
||||||
assert( rc==SQLITE_OK );
|
assert( rc==SQLITE_OK );
|
||||||
rc = pModule->xDestroy(pTab->pVtab);
|
if( xDestroy ){
|
||||||
|
rc = xDestroy(pTab->pVtab);
|
||||||
|
}
|
||||||
sqlite3SafetyOn(db);
|
sqlite3SafetyOn(db);
|
||||||
if( rc==SQLITE_OK ){
|
if( rc==SQLITE_OK ){
|
||||||
pTab->pVtab = 0;
|
pTab->pVtab = 0;
|
||||||
|
Reference in New Issue
Block a user