Compare commits

...

2 Commits

Author SHA1 Message Date
drh 52bc07a4c6 Another attempt at disabling virtual tables. This one leaks memory.
FossilOrigin-Name: 399e28283bca5ec20b6201adf2f09509667fa9f2
2013-06-12 02:53:39 +00:00
drh 8ddd153856 Add the ability to disable future calls to virtual table methods by
invoking sqlite3_create_module() with a NULL sqlite3_module pointer.

FossilOrigin-Name: 6b77d61adbc52a9d28ad522aa101c2c193942d18
2013-06-11 22:41:12 +00:00
3 changed files with 70 additions and 11 deletions
+7 -7
View File
@@ -1,5 +1,5 @@
C Add\sthe\sSQLITE_FTS3_MAX_EXPR_DEPTH\scompile\stime\soption.
D 2013-06-11T14:22:11.456
C Another\sattempt\sat\sdisabling\svirtual\stables.\s\sThis\sone\sleaks\smemory.
D 2013-06-12T02:53:39.933
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -285,7 +285,7 @@ F src/vdbeblob.c 5dc79627775bd9a9b494dd956e26297946417d69
F src/vdbemem.c 833005f1cbbf447289f1973dba2a0c2228c7b8ab
F src/vdbesort.c 3937e06b2a0e354500e17dc206ef4c35770a5017
F src/vdbetrace.c 18cc59cb475e6115129bfde224367d13a35a7d13
F src/vtab.c b05e5f1f4902461ba9f5fc49bb7eb7c3a0741a83
F src/vtab.c 7f7bf6e1815a655147f96d589e6e2bc2e1c5066d
F src/wal.c 436bfceb141b9423c45119e68e444358ee0ed35d
F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
F src/walker.c 4fa43583d0a84b48f93b1e88f11adf2065be4e73
@@ -1093,7 +1093,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
P 7e3820e5b989426c64af46f6bf862b91366ae954
R 5f94a46cd24d5603b852ca86ea7eaf5a
U dan
Z 30f6897d1a48f4a9b1a79c1749e033ce
P 6b77d61adbc52a9d28ad522aa101c2c193942d18
R 524671b2110c91977daec3a3bb4e211f
U drh
Z 258a1822bfbdfa95500fab6f167bf2fe
+1 -1
View File
@@ -1 +1 @@
24fc9d4438a5615dd20af5419456166df83a72ea
399e28283bca5ec20b6201adf2f09509667fa9f2
+62 -3
View File
@@ -26,6 +26,47 @@ struct VtabCtx {
Table *pTab; /* The Table object to which the virtual table belongs */
};
/*
** A place-holder virtual table method that always fails.
*/
static int errorMethod(void){ return SQLITE_ERROR; }
/*
** A dummy virtual table implementation in which every method fails.
*/
static const sqlite3_module errorModule = {
/* iVersion */ 2,
/* xCreate */ (int(*)(sqlite3*,void*,int,const char*const*,
sqlite3_vtab**,char**))errorMethod,
/* xConnect */ (int(*)(sqlite3*,void*,int,const char*const*,
sqlite3_vtab**,char**))errorMethod,
/* xBestIndex */ (int(*)(sqlite3_vtab*, sqlite3_index_info*))errorMethod,
/* xDisconnect */ (int(*)(sqlite3_vtab*))errorMethod,
/* xDestroy */ (int(*)(sqlite3_vtab*))errorMethod,
/* xOpen */ (int(*)(sqlite3_vtab*,sqlite3_vtab_cursor**))errorMethod,
/* xClose */ (int(*)(sqlite3_vtab_cursor*))errorMethod,
/* xFilter */ (int(*)(sqlite3_vtab_cursor*,int,const char*,int,
sqlite3_value**))errorMethod,
/* xNext */ (int(*)(sqlite3_vtab_cursor*))errorMethod,
/* xEof */ (int(*)(sqlite3_vtab_cursor*))errorMethod,
/* xColumn */ (int(*)(sqlite3_vtab_cursor*,sqlite3_context*,int))
errorMethod,
/* xRowid */ (int(*)(sqlite3_vtab_cursor*,sqlite3_int64*))errorMethod,
/* xUpdate */ (int(*)(sqlite3_vtab*,int,sqlite3_value**,
sqlite3_int64*))errorMethod,
/* xBegin */ (int(*)(sqlite3_vtab*))errorMethod,
/* xSync */ (int(*)(sqlite3_vtab*))errorMethod,
/* xCommit */ (int(*)(sqlite3_vtab*))errorMethod,
/* xRollback */ (int(*)(sqlite3_vtab*))errorMethod,
/* xFindFunction */ (int(*)(sqlite3_vtab*,int,const char*,
void(**)(sqlite3_context*,int,sqlite3_value**),
void**))errorMethod,
/* xRename */ (int(*)(sqlite3_vtab*,const char*))errorMethod,
/* xSavepoint */ (int(*)(sqlite3_vtab*,int))errorMethod,
/* xRelease */ (int(*)(sqlite3_vtab*,int))errorMethod,
/* xRollbackTo */ (int(*)(sqlite3_vtab*,int))errorMethod
};
/*
** The actual function that does the work of creating a new module.
** This function implements the sqlite3_create_module() and
@@ -40,13 +81,31 @@ static int createModule(
){
int rc = SQLITE_OK;
int nName;
Module *pMod;
sqlite3_mutex_enter(db->mutex);
nName = sqlite3Strlen30(zName);
if( sqlite3HashFind(&db->aModule, zName, nName) ){
rc = SQLITE_MISUSE_BKPT;
if( (pMod = sqlite3HashFind(&db->aModule, zName, nName))!=0 ){
if( pModule!=0 ){
rc = SQLITE_MISUSE_BKPT;
}else{
int iDb;
HashElem *j;
VTable *pVTab;
for(iDb=0; iDb<db->nDb; iDb++){
Schema *pSchema = db->aDb[iDb].pSchema;
for(j=sqliteHashFirst(&pSchema->tblHash); j; j=sqliteHashNext(j)){
Table *pTab = (Table*)sqliteHashData(j);
if( !IsVirtual(pTab) ) continue;
pVTab = pTab->pVTable;
if( pVTab->pMod!=pMod ) continue;
pVTab->pVtab->pModule = &errorModule;
}
}
if( pMod->xDestroy ) pMod->xDestroy(pMod->pAux);
pMod->pModule = &errorModule;
}
}else{
Module *pMod;
pMod = (Module *)sqlite3DbMallocRaw(db, sizeof(Module) + nName + 1);
if( pMod ){
Module *pDel;