/ Check-in [696a5a40]
Login

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

Overview
Comment:Allow virtual table constructors to be invoked recursively. A test case for this has been added to TH3.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 696a5a40bb28c4a54c9951f877b67015dc00bf55
User & Date: drh 2012-04-26 22:47:20
Original Comment: All virtual table constructors to be invoked recursively. A test case for this has been added to TH3.
Context
2012-04-27
01:08
Enhance the do_test proc in the test suite so that if the expected result is of the form "/.../" or "~/.../" then regular expression matching is done between result and the "..." part of the expectation. In the ~/.../ case, we expect there to be no match. check-in: c9a73440 user: drh tags: trunk
2012-04-26
22:47
Allow virtual table constructors to be invoked recursively. A test case for this has been added to TH3. check-in: 696a5a40 user: drh tags: trunk
2012-04-24
13:14
New test cases for the ".dump" and ".mode insert" commands of the shell. check-in: dfce8569 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vtab.c.

   443    443   static int vtabCallConstructor(
   444    444     sqlite3 *db, 
   445    445     Table *pTab,
   446    446     Module *pMod,
   447    447     int (*xConstruct)(sqlite3*,void*,int,const char*const*,sqlite3_vtab**,char**),
   448    448     char **pzErr
   449    449   ){
   450         -  VtabCtx sCtx;
          450  +  VtabCtx sCtx, *pPriorCtx;
   451    451     VTable *pVTable;
   452    452     int rc;
   453    453     const char *const*azArg = (const char *const*)pTab->azModuleArg;
   454    454     int nArg = pTab->nModuleArg;
   455    455     char *zErr = 0;
   456    456     char *zModuleName = sqlite3MPrintf(db, "%s", pTab->zName);
   457    457   
................................................................................
   468    468     pVTable->pMod = pMod;
   469    469   
   470    470     /* Invoke the virtual table constructor */
   471    471     assert( &db->pVtabCtx );
   472    472     assert( xConstruct );
   473    473     sCtx.pTab = pTab;
   474    474     sCtx.pVTable = pVTable;
          475  +  pPriorCtx = db->pVtabCtx;
   475    476     db->pVtabCtx = &sCtx;
   476    477     rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVTable->pVtab, &zErr);
   477         -  db->pVtabCtx = 0;
          478  +  db->pVtabCtx = pPriorCtx;
   478    479     if( rc==SQLITE_NOMEM ) db->mallocFailed = 1;
   479    480   
   480    481     if( SQLITE_OK!=rc ){
   481    482       if( zErr==0 ){
   482    483         *pzErr = sqlite3MPrintf(db, "vtable constructor failed: %s", zModuleName);
   483    484       }else {
   484    485         *pzErr = sqlite3MPrintf(db, "%s", zErr);