Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add the ability to disable future calls to virtual table methods by invoking sqlite3_create_module() with a NULL sqlite3_module pointer. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | disable-vtab |
Files: | files | file ages | folders |
SHA1: |
6b77d61adbc52a9d28ad522aa101c2c1 |
User & Date: | drh 2013-06-11 22:41:12.524 |
Context
2013-06-12
| ||
02:53 | Another attempt at disabling virtual tables. This one leaks memory. (Closed-Leaf check-in: 399e28283b user: drh tags: disable-vtab) | |
2013-06-11
| ||
22:41 | Add the ability to disable future calls to virtual table methods by invoking sqlite3_create_module() with a NULL sqlite3_module pointer. (check-in: 6b77d61adb user: drh tags: disable-vtab) | |
14:22 | Add the SQLITE_FTS3_MAX_EXPR_DEPTH compile time option. (check-in: 24fc9d4438 user: dan tags: trunk) | |
Changes
Changes to src/vtab.c.
︙ | ︙ | |||
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | ** are invoked only from within xCreate and xConnect methods. */ struct VtabCtx { VTable *pVTable; /* The virtual table being constructed */ Table *pTab; /* The Table object to which the virtual table belongs */ }; /* ** The actual function that does the work of creating a new module. ** This function implements the sqlite3_create_module() and ** sqlite3_create_module_v2() interfaces. */ static int createModule( sqlite3 *db, /* Database in which module is registered */ const char *zName, /* Name assigned to this module */ const sqlite3_module *pModule, /* The definition of the module */ void *pAux, /* Context pointer for xCreate/xConnect */ void (*xDestroy)(void *) /* Module destructor function */ ){ int rc = SQLITE_OK; int nName; sqlite3_mutex_enter(db->mutex); nName = sqlite3Strlen30(zName); | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > | | | > > | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | ** are invoked only from within xCreate and xConnect methods. */ struct VtabCtx { VTable *pVTable; /* The virtual table being constructed */ 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 ** sqlite3_create_module_v2() interfaces. */ static int createModule( sqlite3 *db, /* Database in which module is registered */ const char *zName, /* Name assigned to this module */ const sqlite3_module *pModule, /* The definition of the module */ void *pAux, /* Context pointer for xCreate/xConnect */ void (*xDestroy)(void *) /* Module destructor function */ ){ int rc = SQLITE_OK; int nName; Module *pMod; sqlite3_mutex_enter(db->mutex); nName = sqlite3Strlen30(zName); if( (pMod = sqlite3HashFind(&db->aModule, zName, nName))!=0 ){ if( pModule!=0 ){ rc = SQLITE_MISUSE_BKPT; }else{ pMod->pModule = &errorModule; } }else{ pMod = (Module *)sqlite3DbMallocRaw(db, sizeof(Module) + nName + 1); if( pMod ){ Module *pDel; char *zCopy = (char *)(&pMod[1]); memcpy(zCopy, zName, nName+1); pMod->zName = zCopy; pMod->pModule = pModule; |
︙ | ︙ |