/ Check-in [3f8f4615]
Login

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

Overview
Comment:Minor bug fixes and enhancements to the pragma eponymous virtual tables.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | pragma-as-vtab
Files: files | file ages | folders
SHA1: 3f8f461504139a4efea0e033e3a274cc4b2d3072
User & Date: drh 2016-12-16 02:14:15
Context
2016-12-16
02:31
Simplifications to facilitate full test coverage. check-in: 01afc515 user: drh tags: pragma-as-vtab
02:14
Minor bug fixes and enhancements to the pragma eponymous virtual tables. check-in: 3f8f4615 user: drh tags: pragma-as-vtab
01:09
Merge enhancements from trunk, and especially the ability to use temp.sqlite_master as an alias for sqlite_temp_master. check-in: 994a4401 user: drh tags: pragma-as-vtab
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pragma.c.

  1998   1998   
  1999   1999     sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);
  2000   2000     sqlite3StrAccumAppendAll(&acc, "CREATE TABLE x");
  2001   2001     for(i=0, j=pPragma->iPragCName; i<pPragma->nPragCName; i++, j++){
  2002   2002       sqlite3XPrintf(&acc, "%c\"%s\"", cSep, pragCName[j]);
  2003   2003       cSep = ',';
  2004   2004     }
         2005  +  if( i==0 ){
         2006  +    sqlite3XPrintf(&acc, "(\"%s\"", pPragma->zName);
         2007  +    cSep = ',';
         2008  +    i++;
         2009  +  }
  2005   2010     j = 0;
  2006   2011     if( pPragma->mPragFlg & PragFlg_Result1 ){
  2007   2012       sqlite3StrAccumAppendAll(&acc, ",arg HIDDEN");
  2008   2013       j++;
  2009   2014     }
  2010   2015     if( pPragma->mPragFlg & (PragFlg_SchemaOpt|PragFlg_SchemaReq) ){
  2011   2016       sqlite3StrAccumAppendAll(&acc, ",schema HIDDEN");
................................................................................
  2063   2068     seen[1] = 0;
  2064   2069     for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){
  2065   2070       if( pConstraint->usable==0 ) continue;
  2066   2071       if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;
  2067   2072       if( pConstraint->iColumn < pTab->iHidden ) continue;
  2068   2073       j = pConstraint->iColumn - pTab->iHidden;
  2069   2074       assert( j < 2 );
  2070         -    if( seen[j] ) continue;
  2071   2075       seen[j] = i+1;
  2072   2076     }
  2073   2077     if( seen[0]==0 ){
  2074   2078       pIdxInfo->estimatedCost = (double)2147483647;
  2075   2079       pIdxInfo->estimatedRows = 2147483647;
  2076   2080       return SQLITE_OK;
  2077   2081     }
................................................................................
  2109   2113     }
  2110   2114   }
  2111   2115   
  2112   2116   /* Close a pragma virtual table cursor */
  2113   2117   static int pragmaVtabClose(sqlite3_vtab_cursor *cur){
  2114   2118     PragmaVtabCursor *pCsr = (PragmaVtabCursor*)cur;
  2115   2119     pragmaVtabCursorClear(pCsr);
         2120  +  sqlite3_free(pCsr);
  2116   2121     return SQLITE_OK;
  2117   2122   }
  2118   2123   
  2119   2124   /* Advance the pragma virtual table cursor to the next row */
  2120   2125   static int pragmaVtabNext(sqlite3_vtab_cursor *pVtabCursor){
  2121   2126     PragmaVtabCursor *pCsr = (PragmaVtabCursor*)pVtabCursor;
  2122   2127     int rc = SQLITE_OK;
  2123   2128   
  2124   2129     /* Increment the xRowid value */
  2125   2130     pCsr->iRowid++;
  2126         -  if( pCsr->pPragma ){
  2127         -    if( SQLITE_ROW!=sqlite3_step(pCsr->pPragma) ){
  2128         -      rc = sqlite3_finalize(pCsr->pPragma);
  2129         -      pCsr->pPragma = 0;
  2130         -      pragmaVtabCursorClear(pCsr);
  2131         -    }
         2131  +  assert( pCsr->pPragma );
         2132  +  if( SQLITE_ROW!=sqlite3_step(pCsr->pPragma) ){
         2133  +    rc = sqlite3_finalize(pCsr->pPragma);
         2134  +    pCsr->pPragma = 0;
         2135  +    pragmaVtabCursorClear(pCsr);
  2132   2136     }
  2133   2137     return rc;
  2134   2138   }
  2135   2139   
  2136   2140   /* 
  2137   2141   ** Pragma virtual table module xFilter method.
  2138   2142   */

Changes to src/vtab.c.

    53     53       pMod->xDestroy = xDestroy;
    54     54       pMod->pEpoTab = 0;
    55     55       pDel = (Module *)sqlite3HashInsert(&db->aModule,zCopy,(void*)pMod);
    56     56       assert( pDel==0 || pDel==pMod );
    57     57       if( pDel ){
    58     58         sqlite3OomFault(db);
    59     59         sqlite3DbFree(db, pDel);
           60  +      pMod = 0;
    60     61       }
    61     62     }
    62     63     return pMod;
    63     64   }
    64     65   
    65     66   /*
    66     67   ** The actual function that does the work of creating a new module.