From: drh Date: Tue, 11 Jun 2013 22:41:12 +0000 (+0000) Subject: Add the ability to disable future calls to virtual table methods by X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8ddd153856c40e2a41d854aa30274bc83902bd0e;p=thirdparty%2Fsqlite.git 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 --- diff --git a/manifest b/manifest index dbb20a50de..e9a18d18f1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sSQLITE_FTS3_MAX_EXPR_DEPTH\scompile\stime\soption. -D 2013-06-11T14:22:11.456 +C Add\sthe\sability\sto\sdisable\sfuture\scalls\sto\svirtual\stable\smethods\sby\ninvoking\ssqlite3_create_module()\swith\sa\sNULL\ssqlite3_module\spointer. +D 2013-06-11T22:41:12.524 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 b3369dad06b7f9209f4149d72a39d65eef973874 F src/wal.c 436bfceb141b9423c45119e68e444358ee0ed35d F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 4fa43583d0a84b48f93b1e88f11adf2065be4e73 @@ -1093,7 +1093,10 @@ 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 24fc9d4438a5615dd20af5419456166df83a72ea +R ab6302ec8f1453be540887649c9a30d4 +T *branch * disable-vtab +T *sym-disable-vtab * +T -sym-trunk * +U drh +Z d8a8093e91bfc59f02ee5e0368eec812 diff --git a/manifest.uuid b/manifest.uuid index 87e2685a16..45567dbe6a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -24fc9d4438a5615dd20af5419456166df83a72ea \ No newline at end of file +6b77d61adbc52a9d28ad522aa101c2c193942d18 \ No newline at end of file diff --git a/src/vtab.c b/src/vtab.c index 958202c31e..13b4b6e3eb 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -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,17 @@ 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{ + pMod->pModule = &errorModule; + } }else{ - Module *pMod; pMod = (Module *)sqlite3DbMallocRaw(db, sizeof(Module) + nName + 1); if( pMod ){ Module *pDel;