/ Check-in [860e4f8a]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:In sqlite3_declare_vtab(), avoid accessing the database structure until after the "api-armour" safety-check has completed and the db mutex has been obtained.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 860e4f8a94901d451fac3954960c1d2f589e8882
User & Date: dan 2015-04-10 16:05:33
Context
2015-04-10
21:16
Minor build enhancements for MSVC. check-in: 40c417a7 user: mistachkin tags: trunk
19:41
Work toward adding the --changeset option to the sqldiff utility program. Changes are incomplete. This is an incremental check-in. check-in: 463e38d7 user: drh tags: sqldiff-changeset
16:05
In sqlite3_declare_vtab(), avoid accessing the database structure until after the "api-armour" safety-check has completed and the db mutex has been obtained. check-in: 860e4f8a user: dan tags: trunk
12:04
Fix foreign key CASCADE for cases where the parent key is an INTEGER PRIMARY KEY and the parent table contains other columns named "rowid", "_rowid_", and "oid". check-in: ed3cbaab user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vtab.c.

   718    718   
   719    719   /*
   720    720   ** This function is used to set the schema of a virtual table.  It is only
   721    721   ** valid to call this function from within the xCreate() or xConnect() of a
   722    722   ** virtual table module.
   723    723   */
   724    724   int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
   725         -  VtabCtx *pCtx = db->pVtabCtx;
          725  +  VtabCtx *pCtx;
   726    726     Parse *pParse;
   727    727     int rc = SQLITE_OK;
   728    728     Table *pTab;
   729    729     char *zErr = 0;
   730    730   
   731    731   #ifdef SQLITE_ENABLE_API_ARMOR
   732    732     if( !sqlite3SafetyCheckOk(db) || zCreateTable==0 ){
   733    733       return SQLITE_MISUSE_BKPT;
   734    734     }
   735    735   #endif
   736    736     sqlite3_mutex_enter(db->mutex);
          737  +  pCtx = db->pVtabCtx;
   737    738     if( !pCtx || pCtx->bDeclared ){
   738    739       sqlite3Error(db, SQLITE_MISUSE);
   739    740       sqlite3_mutex_leave(db->mutex);
   740    741       return SQLITE_MISUSE_BKPT;
   741    742     }
   742    743     pTab = pCtx->pTab;
   743    744     assert( (pTab->tabFlags & TF_Virtual)!=0 );