/ Check-in [4ba45e72]
Login

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

Overview
Comment:Merge the pragma-as-vtab change into this branch.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fkey-missing-indexes
Files: files | file ages | folders
SHA1: 4ba45e722371ca4343e3563e7e1c2896b48c9a87
User & Date: dan 2016-12-16 16:13:45
Context
2016-12-16
16:44
Update .fkey_missing_indexes to use the built-in pragma vtabs. check-in: 3ab05987 user: dan tags: fkey-missing-indexes
16:13
Merge the pragma-as-vtab change into this branch. check-in: 4ba45e72 user: dan tags: fkey-missing-indexes
04:20
Fix an error in the way the "schema" argument to some pragma virtual tables is handled. Closed-Leaf check-in: 546821e2 user: drh tags: pragma-as-vtab
2016-12-15
06:01
Add the -groupbyparent option to the ".fkey_missing_indexes" command. check-in: 976c51b4 user: dan tags: fkey-missing-indexes
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/alter.c.

   500    500       /* If foreign-key support is enabled, rewrite the CREATE TABLE 
   501    501       ** statements corresponding to all child tables of foreign key constraints
   502    502       ** for which the renamed table is the parent table.  */
   503    503       if( (zWhere=whereForeignKeys(pParse, pTab))!=0 ){
   504    504         sqlite3NestedParse(pParse, 
   505    505             "UPDATE \"%w\".%s SET "
   506    506                 "sql = sqlite_rename_parent(sql, %Q, %Q) "
   507         -              "WHERE %s;", zDb, SCHEMA_TABLE(iDb), zTabName, zName, zWhere);
          507  +              "WHERE %s;", zDb, MASTER_NAME, zTabName, zName, zWhere);
   508    508         sqlite3DbFree(db, zWhere);
   509    509       }
   510    510     }
   511    511   #endif
   512    512   
   513    513     /* Modify the sqlite_master table to use the new table name. */
   514    514     sqlite3NestedParse(pParse,
................................................................................
   524    524             "name = CASE "
   525    525               "WHEN type='table' THEN %Q "
   526    526               "WHEN name LIKE 'sqlite_autoindex%%' AND type='index' THEN "
   527    527                "'sqlite_autoindex_' || %Q || substr(name,%d+18) "
   528    528               "ELSE name END "
   529    529         "WHERE tbl_name=%Q COLLATE nocase AND "
   530    530             "(type='table' OR type='index' OR type='trigger');", 
   531         -      zDb, SCHEMA_TABLE(iDb), zName, zName, zName, 
          531  +      zDb, MASTER_NAME, zName, zName, zName, 
   532    532   #ifndef SQLITE_OMIT_TRIGGER
   533    533         zName,
   534    534   #endif
   535    535         zName, nTabName, zTabName
   536    536     );
   537    537   
   538    538   #ifndef SQLITE_OMIT_AUTOINCREMENT
................................................................................
   685    685         *zEnd-- = '\0';
   686    686       }
   687    687       db->flags |= SQLITE_PreferBuiltin;
   688    688       sqlite3NestedParse(pParse, 
   689    689           "UPDATE \"%w\".%s SET "
   690    690             "sql = substr(sql,1,%d) || ', ' || %Q || substr(sql,%d) "
   691    691           "WHERE type = 'table' AND name = %Q", 
   692         -      zDb, SCHEMA_TABLE(iDb), pNew->addColOffset, zCol, pNew->addColOffset+1,
          692  +      zDb, MASTER_NAME, pNew->addColOffset, zCol, pNew->addColOffset+1,
   693    693         zTab
   694    694       );
   695    695       sqlite3DbFree(db, zCol);
   696    696       db->flags = savedDbFlags;
   697    697     }
   698    698   
   699    699     /* Make sure the schema version is at least 3.  But do not upgrade

Changes to src/build.c.

    26     26   
    27     27   #ifndef SQLITE_OMIT_SHARED_CACHE
    28     28   /*
    29     29   ** The TableLock structure is only used by the sqlite3TableLock() and
    30     30   ** codeTableLocks() functions.
    31     31   */
    32     32   struct TableLock {
    33         -  int iDb;             /* The database containing the table to be locked */
    34         -  int iTab;            /* The root page of the table to be locked */
    35         -  u8 isWriteLock;      /* True for write lock.  False for a read lock */
    36         -  const char *zName;   /* Name of the table */
           33  +  int iDb;               /* The database containing the table to be locked */
           34  +  int iTab;              /* The root page of the table to be locked */
           35  +  u8 isWriteLock;        /* True for write lock.  False for a read lock */
           36  +  const char *zLockName; /* Name of the table */
    37     37   };
    38     38   
    39     39   /*
    40     40   ** Record the fact that we want to lock a table at run-time.  
    41     41   **
    42     42   ** The table to be locked has root page iTab and is found in database iDb.
    43     43   ** A read or a write lock can be taken depending on isWritelock.
................................................................................
    73     73     pToplevel->aTableLock =
    74     74         sqlite3DbReallocOrFree(pToplevel->db, pToplevel->aTableLock, nBytes);
    75     75     if( pToplevel->aTableLock ){
    76     76       p = &pToplevel->aTableLock[pToplevel->nTableLock++];
    77     77       p->iDb = iDb;
    78     78       p->iTab = iTab;
    79     79       p->isWriteLock = isWriteLock;
    80         -    p->zName = zName;
           80  +    p->zLockName = zName;
    81     81     }else{
    82     82       pToplevel->nTableLock = 0;
    83     83       sqlite3OomFault(pToplevel->db);
    84     84     }
    85     85   }
    86     86   
    87     87   /*
................................................................................
    95     95     pVdbe = sqlite3GetVdbe(pParse);
    96     96     assert( pVdbe!=0 ); /* sqlite3GetVdbe cannot fail: VDBE already allocated */
    97     97   
    98     98     for(i=0; i<pParse->nTableLock; i++){
    99     99       TableLock *p = &pParse->aTableLock[i];
   100    100       int p1 = p->iDb;
   101    101       sqlite3VdbeAddOp4(pVdbe, OP_TableLock, p1, p->iTab, p->isWriteLock,
   102         -                      p->zName, P4_STATIC);
          102  +                      p->zLockName, P4_STATIC);
   103    103     }
   104    104   }
   105    105   #else
   106    106     #define codeTableLocks(x)
   107    107   #endif
   108    108   
   109    109   /*
................................................................................
   304    304   #if SQLITE_USER_AUTHENTICATION
   305    305     /* Only the admin user is allowed to know that the sqlite_user table
   306    306     ** exists */
   307    307     if( db->auth.authLevel<UAUTH_Admin && sqlite3UserAuthTable(zName)!=0 ){
   308    308       return 0;
   309    309     }
   310    310   #endif
   311         -  for(i=OMIT_TEMPDB; i<db->nDb; i++){
   312         -    int j = (i<2) ? i^1 : i;   /* Search TEMP before MAIN */
   313         -    if( zDatabase==0 || sqlite3StrICmp(zDatabase, db->aDb[j].zDbSName)==0 ){
   314         -      assert( sqlite3SchemaMutexHeld(db, j, 0) );
   315         -      p = sqlite3HashFind(&db->aDb[j].pSchema->tblHash, zName);
   316         -      if( p ) break;
          311  +  while(1){
          312  +    for(i=OMIT_TEMPDB; i<db->nDb; i++){
          313  +      int j = (i<2) ? i^1 : i;   /* Search TEMP before MAIN */
          314  +      if( zDatabase==0 || sqlite3StrICmp(zDatabase, db->aDb[j].zDbSName)==0 ){
          315  +        assert( sqlite3SchemaMutexHeld(db, j, 0) );
          316  +        p = sqlite3HashFind(&db->aDb[j].pSchema->tblHash, zName);
          317  +        if( p ) return p;
          318  +      }
   317    319       }
          320  +    /* Not found.  If the name we were looking for was temp.sqlite_master
          321  +    ** then change the name to sqlite_temp_master and try again. */
          322  +    if( sqlite3StrICmp(zName, MASTER_NAME)!=0 ) break;
          323  +    if( sqlite3_stricmp(zDatabase, db->aDb[1].zDbSName)!=0 ) break;
          324  +    zName = TEMP_MASTER_NAME;
   318    325     }
   319         -  return p;
          326  +  return 0;
   320    327   }
   321    328   
   322    329   /*
   323    330   ** Locate the in-memory structure that describes a particular database
   324    331   ** table given the name of that table and (optionally) the name of the
   325    332   ** database containing the table.  Return NULL if not found.  Also leave an
   326    333   ** error message in pParse->zErrMsg.
................................................................................
   348    355       const char *zMsg = flags & LOCATE_VIEW ? "no such view" : "no such table";
   349    356   #ifndef SQLITE_OMIT_VIRTUALTABLE
   350    357       if( sqlite3FindDbName(pParse->db, zDbase)<1 ){
   351    358         /* If zName is the not the name of a table in the schema created using
   352    359         ** CREATE, then check to see if it is the name of an virtual table that
   353    360         ** can be an eponymous virtual table. */
   354    361         Module *pMod = (Module*)sqlite3HashFind(&pParse->db->aModule, zName);
          362  +      if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){
          363  +        pMod = sqlite3PragmaVtabRegister(pParse->db, zName);
          364  +      }
   355    365         if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
   356    366           return pMod->pEpoTab;
   357    367         }
   358    368       }
   359    369   #endif
   360    370       if( (flags & LOCATE_NOERR)==0 ){
   361    371         if( zDbase ){
................................................................................
   684    694   
   685    695   /*
   686    696   ** Open the sqlite_master table stored in database number iDb for
   687    697   ** writing. The table is opened using cursor 0.
   688    698   */
   689    699   void sqlite3OpenMasterTable(Parse *p, int iDb){
   690    700     Vdbe *v = sqlite3GetVdbe(p);
   691         -  sqlite3TableLock(p, iDb, MASTER_ROOT, 1, SCHEMA_TABLE(iDb));
          701  +  sqlite3TableLock(p, iDb, MASTER_ROOT, 1, MASTER_NAME);
   692    702     sqlite3VdbeAddOp4Int(v, OP_OpenWrite, 0, MASTER_ROOT, iDb, 5);
   693    703     if( p->nTab==0 ){
   694    704       p->nTab = 1;
   695    705     }
   696    706   }
   697    707   
   698    708   /*
................................................................................
  1987   1997       ** SQLITE_MASTER table.  We just need to update that slot with all
  1988   1998       ** the information we've collected.
  1989   1999       */
  1990   2000       sqlite3NestedParse(pParse,
  1991   2001         "UPDATE %Q.%s "
  1992   2002            "SET type='%s', name=%Q, tbl_name=%Q, rootpage=#%d, sql=%Q "
  1993   2003          "WHERE rowid=#%d",
  1994         -      db->aDb[iDb].zDbSName, SCHEMA_TABLE(iDb),
         2004  +      db->aDb[iDb].zDbSName, MASTER_NAME,
  1995   2005         zType,
  1996   2006         p->zName,
  1997   2007         p->zName,
  1998   2008         pParse->regRoot,
  1999   2009         zStmt,
  2000   2010         pParse->regRowid
  2001   2011       );
................................................................................
  2324   2334     **
  2325   2335     ** The "#NNN" in the SQL is a special constant that means whatever value
  2326   2336     ** is in register NNN.  See grammar rules associated with the TK_REGISTER
  2327   2337     ** token for additional information.
  2328   2338     */
  2329   2339     sqlite3NestedParse(pParse, 
  2330   2340        "UPDATE %Q.%s SET rootpage=%d WHERE #%d AND rootpage=#%d",
  2331         -     pParse->db->aDb[iDb].zDbSName, SCHEMA_TABLE(iDb), iTable, r1, r1);
         2341  +     pParse->db->aDb[iDb].zDbSName, MASTER_NAME, iTable, r1, r1);
  2332   2342   #endif
  2333   2343     sqlite3ReleaseTempReg(pParse, r1);
  2334   2344   }
  2335   2345   
  2336   2346   /*
  2337   2347   ** Write VDBE code to erase table pTab and all associated indices on disk.
  2338   2348   ** Code to update the sqlite_master tables and internal schema definitions
................................................................................
  2467   2477     ** every row that refers to a table of the same name as the one being
  2468   2478     ** dropped. Triggers are handled separately because a trigger can be
  2469   2479     ** created in the temp database that refers to a table in another
  2470   2480     ** database.
  2471   2481     */
  2472   2482     sqlite3NestedParse(pParse, 
  2473   2483         "DELETE FROM %Q.%s WHERE tbl_name=%Q and type!='trigger'",
  2474         -      pDb->zDbSName, SCHEMA_TABLE(iDb), pTab->zName);
         2484  +      pDb->zDbSName, MASTER_NAME, pTab->zName);
  2475   2485     if( !isView && !IsVirtual(pTab) ){
  2476   2486       destroyTable(pParse, pTab);
  2477   2487     }
  2478   2488   
  2479   2489     /* Remove the table entry from SQLite's internal schema and modify
  2480   2490     ** the schema cookie.
  2481   2491     */
................................................................................
  3359   3369         zStmt = 0;
  3360   3370       }
  3361   3371   
  3362   3372       /* Add an entry in sqlite_master for this index
  3363   3373       */
  3364   3374       sqlite3NestedParse(pParse, 
  3365   3375           "INSERT INTO %Q.%s VALUES('index',%Q,%Q,#%d,%Q);",
  3366         -        db->aDb[iDb].zDbSName, SCHEMA_TABLE(iDb),
         3376  +        db->aDb[iDb].zDbSName, MASTER_NAME,
  3367   3377           pIndex->zName,
  3368   3378           pTab->zName,
  3369   3379           iMem,
  3370   3380           zStmt
  3371   3381       );
  3372   3382       sqlite3DbFree(db, zStmt);
  3373   3383   
................................................................................
  3511   3521   
  3512   3522     /* Generate code to remove the index and from the master table */
  3513   3523     v = sqlite3GetVdbe(pParse);
  3514   3524     if( v ){
  3515   3525       sqlite3BeginWriteOperation(pParse, 1, iDb);
  3516   3526       sqlite3NestedParse(pParse,
  3517   3527          "DELETE FROM %Q.%s WHERE name=%Q AND type='index'",
  3518         -       db->aDb[iDb].zDbSName, SCHEMA_TABLE(iDb), pIndex->zName
         3528  +       db->aDb[iDb].zDbSName, MASTER_NAME, pIndex->zName
  3519   3529       );
  3520   3530       sqlite3ClearStatTables(pParse, iDb, "idx", pIndex->zName);
  3521   3531       sqlite3ChangeCookie(pParse, iDb);
  3522   3532       destroyRootPage(pParse, pIndex->tnum, iDb);
  3523   3533       sqlite3VdbeAddOp4(v, OP_DropIndex, iDb, 0, 0, pIndex->zName, 0);
  3524   3534     }
  3525   3535   
................................................................................
  3654   3664     assert( nExtra>=1 );
  3655   3665     assert( pSrc!=0 );
  3656   3666     assert( iStart<=pSrc->nSrc );
  3657   3667   
  3658   3668     /* Allocate additional space if needed */
  3659   3669     if( (u32)pSrc->nSrc+nExtra>pSrc->nAlloc ){
  3660   3670       SrcList *pNew;
  3661         -    int nAlloc = pSrc->nSrc+nExtra;
         3671  +    int nAlloc = pSrc->nSrc*2+nExtra;
  3662   3672       int nGot;
  3663   3673       pNew = sqlite3DbRealloc(db, pSrc,
  3664   3674                  sizeof(*pSrc) + (nAlloc-1)*sizeof(pSrc->a[0]) );
  3665   3675       if( pNew==0 ){
  3666   3676         assert( db->mallocFailed );
  3667   3677         return pSrc;
  3668   3678       }

Changes to src/pragma.c.

   159    159     }
   160    160     db->temp_store = (u8)ts;
   161    161     return SQLITE_OK;
   162    162   }
   163    163   #endif /* SQLITE_PAGER_PRAGMAS */
   164    164   
   165    165   /*
   166         -** Set the names of the first N columns to the values in azCol[]
          166  +** Set result column names for a pragma.
   167    167   */
   168         -static void setAllColumnNames(
   169         -  Vdbe *v,               /* The query under construction */
   170         -  int N,                 /* Number of columns */
   171         -  const char **azCol     /* Names of columns */
          168  +static void setPragmaResultColumnNames(
          169  +  Vdbe *v,                     /* The query under construction */
          170  +  const PragmaName *pPragma    /* The pragma */
   172    171   ){
   173         -  int i;
   174         -  sqlite3VdbeSetNumCols(v, N);
   175         -  for(i=0; i<N; i++){
   176         -    sqlite3VdbeSetColName(v, i, COLNAME_NAME, azCol[i], SQLITE_STATIC);
          172  +  u8 n = pPragma->nPragCName;
          173  +  sqlite3VdbeSetNumCols(v, n==0 ? 1 : n);
          174  +  if( n==0 ){
          175  +    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, pPragma->zName, SQLITE_STATIC);
          176  +  }else{
          177  +    int i, j;
          178  +    for(i=0, j=pPragma->iPragCName; i<n; i++, j++){
          179  +      sqlite3VdbeSetColName(v, i, COLNAME_NAME, pragCName[j], SQLITE_STATIC);
          180  +    }
   177    181     }
   178    182   }
   179         -static void setOneColumnName(Vdbe *v, const char *z){
   180         -  setAllColumnNames(v, 1, &z);
   181         -}
   182    183   
   183    184   /*
   184    185   ** Generate code to return a single integer value.
   185    186   */
   186         -static void returnSingleInt(Vdbe *v, const char *zLabel, i64 value){
          187  +static void returnSingleInt(Vdbe *v, i64 value){
   187    188     sqlite3VdbeAddOp4Dup8(v, OP_Int64, 0, 1, 0, (const u8*)&value, P4_INT64);
   188         -  setOneColumnName(v, zLabel);
   189    189     sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
   190    190   }
   191    191   
   192    192   /*
   193    193   ** Generate code to return a single text value.
   194    194   */
   195    195   static void returnSingleText(
   196    196     Vdbe *v,                /* Prepared statement under construction */
   197         -  const char *zLabel,     /* Name of the result column */
   198    197     const char *zValue      /* Value to be returned */
   199    198   ){
   200    199     if( zValue ){
   201    200       sqlite3VdbeLoadString(v, 1, (const char*)zValue);
   202         -    setOneColumnName(v, zLabel);
   203    201       sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
   204    202     }
   205    203   }
   206    204   
   207    205   
   208    206   /*
   209    207   ** Set the safety_level and pager flags for pager iDb.  Or if iDb<0
................................................................................
   272    270     assert( PAGER_JOURNALMODE_MEMORY==4 );
   273    271     assert( PAGER_JOURNALMODE_WAL==5 );
   274    272     assert( eMode>=0 && eMode<=ArraySize(azModeName) );
   275    273   
   276    274     if( eMode==ArraySize(azModeName) ) return 0;
   277    275     return azModeName[eMode];
   278    276   }
          277  +
          278  +/*
          279  +** Locate a pragma in the aPragmaName[] array.
          280  +*/
          281  +static const PragmaName *pragmaLocate(const char *zName){
          282  +  int upr, lwr, mid, rc;
          283  +  lwr = 0;
          284  +  upr = ArraySize(aPragmaName)-1;
          285  +  while( lwr<=upr ){
          286  +    mid = (lwr+upr)/2;
          287  +    rc = sqlite3_stricmp(zName, aPragmaName[mid].zName);
          288  +    if( rc==0 ) break;
          289  +    if( rc<0 ){
          290  +      upr = mid - 1;
          291  +    }else{
          292  +      lwr = mid + 1;
          293  +    }
          294  +  }
          295  +  return lwr>upr ? 0 : &aPragmaName[mid];
          296  +}
   279    297   
   280    298   /*
   281    299   ** Process a pragma statement.  
   282    300   **
   283    301   ** Pragmas are of this form:
   284    302   **
   285    303   **      PRAGMA [schema.]id [= value]
................................................................................
   301    319   ){
   302    320     char *zLeft = 0;       /* Nul-terminated UTF-8 string <id> */
   303    321     char *zRight = 0;      /* Nul-terminated UTF-8 string <value>, or NULL */
   304    322     const char *zDb = 0;   /* The database name */
   305    323     Token *pId;            /* Pointer to <id> token */
   306    324     char *aFcntl[4];       /* Argument to SQLITE_FCNTL_PRAGMA */
   307    325     int iDb;               /* Database index for <database> */
   308         -  int lwr, upr, mid = 0;       /* Binary search bounds */
   309    326     int rc;                      /* return value form SQLITE_FCNTL_PRAGMA */
   310    327     sqlite3 *db = pParse->db;    /* The database connection */
   311    328     Db *pDb;                     /* The specific database being pragmaed */
   312    329     Vdbe *v = sqlite3GetVdbe(pParse);  /* Prepared statement */
   313         -  const struct sPragmaNames *pPragma;
          330  +  const PragmaName *pPragma;   /* The pragma */
   314    331   
   315    332     if( v==0 ) return;
   316    333     sqlite3VdbeRunOnlyOnce(v);
   317    334     pParse->nMem = 2;
   318    335   
   319    336     /* Interpret the [schema.] part of the pragma statement. iDb is the
   320    337     ** index of the database this pragma is being applied to in db.aDb[]. */
................................................................................
   361    378     aFcntl[0] = 0;
   362    379     aFcntl[1] = zLeft;
   363    380     aFcntl[2] = zRight;
   364    381     aFcntl[3] = 0;
   365    382     db->busyHandler.nBusy = 0;
   366    383     rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_PRAGMA, (void*)aFcntl);
   367    384     if( rc==SQLITE_OK ){
   368         -    returnSingleText(v, "result", aFcntl[0]);
          385  +    sqlite3VdbeSetNumCols(v, 1);
          386  +    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, aFcntl[0], SQLITE_TRANSIENT);
          387  +    returnSingleText(v, aFcntl[0]);
   369    388       sqlite3_free(aFcntl[0]);
   370    389       goto pragma_out;
   371    390     }
   372    391     if( rc!=SQLITE_NOTFOUND ){
   373    392       if( aFcntl[0] ){
   374    393         sqlite3ErrorMsg(pParse, "%s", aFcntl[0]);
   375    394         sqlite3_free(aFcntl[0]);
................................................................................
   376    395       }
   377    396       pParse->nErr++;
   378    397       pParse->rc = rc;
   379    398       goto pragma_out;
   380    399     }
   381    400   
   382    401     /* Locate the pragma in the lookup table */
   383         -  lwr = 0;
   384         -  upr = ArraySize(aPragmaNames)-1;
   385         -  while( lwr<=upr ){
   386         -    mid = (lwr+upr)/2;
   387         -    rc = sqlite3_stricmp(zLeft, aPragmaNames[mid].zName);
   388         -    if( rc==0 ) break;
   389         -    if( rc<0 ){
   390         -      upr = mid - 1;
   391         -    }else{
   392         -      lwr = mid + 1;
   393         -    }
   394         -  }
   395         -  if( lwr>upr ) goto pragma_out;
   396         -  pPragma = &aPragmaNames[mid];
          402  +  pPragma = pragmaLocate(zLeft);
          403  +  if( pPragma==0 ) goto pragma_out;
   397    404   
   398    405     /* Make sure the database schema is loaded if the pragma requires that */
   399         -  if( (pPragma->mPragFlag & PragFlag_NeedSchema)!=0 ){
          406  +  if( (pPragma->mPragFlg & PragFlg_NeedSchema)!=0 ){
   400    407       if( sqlite3ReadSchema(pParse) ) goto pragma_out;
   401    408     }
          409  +
          410  +  /* Register the result column names for pragmas that return results */
          411  +  if( (pPragma->mPragFlg & PragFlg_NoColumns)==0 ){
          412  +    setPragmaResultColumnNames(v, pPragma);
          413  +  }
   402    414   
   403    415     /* Jump to the appropriate pragma handler */
   404    416     switch( pPragma->ePragTyp ){
   405    417     
   406    418   #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
   407    419     /*
   408    420     **  PRAGMA [schema.]default_cache_size
................................................................................
   432    444         { OP_Integer,     0, 1,        0},                         /* 6 */
   433    445         { OP_Noop,        0, 0,        0},
   434    446         { OP_ResultRow,   1, 1,        0},
   435    447       };
   436    448       VdbeOp *aOp;
   437    449       sqlite3VdbeUsesBtree(v, iDb);
   438    450       if( !zRight ){
   439         -      setOneColumnName(v, "cache_size");
   440    451         pParse->nMem += 2;
   441    452         sqlite3VdbeVerifyNoMallocRequired(v, ArraySize(getCacheSize));
   442    453         aOp = sqlite3VdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize, iLn);
   443    454         if( ONLY_IF_REALLOC_STRESS(aOp==0) ) break;
   444    455         aOp[0].p1 = iDb;
   445    456         aOp[1].p1 = iDb;
   446    457         aOp[6].p1 = SQLITE_DEFAULT_CACHE_SIZE;
................................................................................
   467    478     ** the database has not yet been created.
   468    479     */
   469    480     case PragTyp_PAGE_SIZE: {
   470    481       Btree *pBt = pDb->pBt;
   471    482       assert( pBt!=0 );
   472    483       if( !zRight ){
   473    484         int size = ALWAYS(pBt) ? sqlite3BtreeGetPageSize(pBt) : 0;
   474         -      returnSingleInt(v, "page_size", size);
          485  +      returnSingleInt(v, size);
   475    486       }else{
   476    487         /* Malloc may fail when setting the page-size, as there is an internal
   477    488         ** buffer that the pager module resizes using sqlite3_realloc().
   478    489         */
   479    490         db->nextPagesize = sqlite3Atoi(zRight);
   480    491         if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize,-1,0) ){
   481    492           sqlite3OomFault(db);
................................................................................
   502    513       if( pId2->n==0 && b>=0 ){
   503    514         int ii;
   504    515         for(ii=0; ii<db->nDb; ii++){
   505    516           sqlite3BtreeSecureDelete(db->aDb[ii].pBt, b);
   506    517         }
   507    518       }
   508    519       b = sqlite3BtreeSecureDelete(pBt, b);
   509         -    returnSingleInt(v, "secure_delete", b);
          520  +    returnSingleInt(v, b);
   510    521       break;
   511    522     }
   512    523   
   513    524     /*
   514    525     **  PRAGMA [schema.]max_page_count
   515    526     **  PRAGMA [schema.]max_page_count=N
   516    527     **
................................................................................
   534    545       if( sqlite3Tolower(zLeft[0])=='p' ){
   535    546         sqlite3VdbeAddOp2(v, OP_Pagecount, iDb, iReg);
   536    547       }else{
   537    548         sqlite3VdbeAddOp3(v, OP_MaxPgcnt, iDb, iReg, 
   538    549                           sqlite3AbsInt32(sqlite3Atoi(zRight)));
   539    550       }
   540    551       sqlite3VdbeAddOp2(v, OP_ResultRow, iReg, 1);
   541         -    sqlite3VdbeSetNumCols(v, 1);
   542         -    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLeft, SQLITE_TRANSIENT);
   543    552       break;
   544    553     }
   545    554   
   546    555     /*
   547    556     **  PRAGMA [schema.]locking_mode
   548    557     **  PRAGMA [schema.]locking_mode = (normal|exclusive)
   549    558     */
................................................................................
   581    590       }
   582    591   
   583    592       assert( eMode==PAGER_LOCKINGMODE_NORMAL
   584    593               || eMode==PAGER_LOCKINGMODE_EXCLUSIVE );
   585    594       if( eMode==PAGER_LOCKINGMODE_EXCLUSIVE ){
   586    595         zRet = "exclusive";
   587    596       }
   588         -    returnSingleText(v, "locking_mode", zRet);
          597  +    returnSingleText(v, zRet);
   589    598       break;
   590    599     }
   591    600   
   592    601     /*
   593    602     **  PRAGMA [schema.]journal_mode
   594    603     **  PRAGMA [schema.]journal_mode =
   595    604     **                      (delete|persist|off|truncate|memory|wal|off)
   596    605     */
   597    606     case PragTyp_JOURNAL_MODE: {
   598    607       int eMode;        /* One of the PAGER_JOURNALMODE_XXX symbols */
   599    608       int ii;           /* Loop counter */
   600    609   
   601         -    setOneColumnName(v, "journal_mode");
   602    610       if( zRight==0 ){
   603    611         /* If there is no "=MODE" part of the pragma, do a query for the
   604    612         ** current mode */
   605    613         eMode = PAGER_JOURNALMODE_QUERY;
   606    614       }else{
   607    615         const char *zMode;
   608    616         int n = sqlite3Strlen30(zRight);
................................................................................
   640    648       Pager *pPager = sqlite3BtreePager(pDb->pBt);
   641    649       i64 iLimit = -2;
   642    650       if( zRight ){
   643    651         sqlite3DecOrHexToI64(zRight, &iLimit);
   644    652         if( iLimit<-1 ) iLimit = -1;
   645    653       }
   646    654       iLimit = sqlite3PagerJournalSizeLimit(pPager, iLimit);
   647         -    returnSingleInt(v, "journal_size_limit", iLimit);
          655  +    returnSingleInt(v, iLimit);
   648    656       break;
   649    657     }
   650    658   
   651    659   #endif /* SQLITE_OMIT_PAGER_PRAGMAS */
   652    660   
   653    661     /*
   654    662     **  PRAGMA [schema.]auto_vacuum
................................................................................
   658    666     ** The value is one of:  0 NONE 1 FULL 2 INCREMENTAL
   659    667     */
   660    668   #ifndef SQLITE_OMIT_AUTOVACUUM
   661    669     case PragTyp_AUTO_VACUUM: {
   662    670       Btree *pBt = pDb->pBt;
   663    671       assert( pBt!=0 );
   664    672       if( !zRight ){
   665         -      returnSingleInt(v, "auto_vacuum", sqlite3BtreeGetAutoVacuum(pBt));
          673  +      returnSingleInt(v, sqlite3BtreeGetAutoVacuum(pBt));
   666    674       }else{
   667    675         int eAuto = getAutoVacuum(zRight);
   668    676         assert( eAuto>=0 && eAuto<=2 );
   669    677         db->nextAutovac = (u8)eAuto;
   670    678         /* Call SetAutoVacuum() to set initialize the internal auto and
   671    679         ** incr-vacuum flags. This is required in case this connection
   672    680         ** creates the database file. It is important that it is created
................................................................................
   737    745     ** number of pages in the cache.  If N is negative, then the
   738    746     ** number of pages is adjusted so that the cache uses -N kibibytes
   739    747     ** of memory.
   740    748     */
   741    749     case PragTyp_CACHE_SIZE: {
   742    750       assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
   743    751       if( !zRight ){
   744         -      returnSingleInt(v, "cache_size", pDb->pSchema->cache_size);
          752  +      returnSingleInt(v, pDb->pSchema->cache_size);
   745    753       }else{
   746    754         int size = sqlite3Atoi(zRight);
   747    755         pDb->pSchema->cache_size = size;
   748    756         sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);
   749    757       }
   750    758       break;
   751    759     }
................................................................................
   771    779     **
   772    780     ** The cache_spill=BOOLEAN setting applies to all attached schemas,
   773    781     ** not just the schema specified.
   774    782     */
   775    783     case PragTyp_CACHE_SPILL: {
   776    784       assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
   777    785       if( !zRight ){
   778         -      returnSingleInt(v, "cache_spill", 
          786  +      returnSingleInt(v,
   779    787            (db->flags & SQLITE_CacheSpill)==0 ? 0 : 
   780    788               sqlite3BtreeSetSpillSize(pDb->pBt,0));
   781    789       }else{
   782    790         int size = 1;
   783    791         if( sqlite3GetInt32(zRight, &size) ){
   784    792           sqlite3BtreeSetSpillSize(pDb->pBt, size);
   785    793         }
................................................................................
   825    833       sz = -1;
   826    834       rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_MMAP_SIZE, &sz);
   827    835   #else
   828    836       sz = 0;
   829    837       rc = SQLITE_OK;
   830    838   #endif
   831    839       if( rc==SQLITE_OK ){
   832         -      returnSingleInt(v, "mmap_size", sz);
          840  +      returnSingleInt(v, sz);
   833    841       }else if( rc!=SQLITE_NOTFOUND ){
   834    842         pParse->nErr++;
   835    843         pParse->rc = rc;
   836    844       }
   837    845       break;
   838    846     }
   839    847   
................................................................................
   846    854     ** value will be restored the next time the database is opened.
   847    855     **
   848    856     ** Note that it is possible for the library compile-time options to
   849    857     ** override this setting
   850    858     */
   851    859     case PragTyp_TEMP_STORE: {
   852    860       if( !zRight ){
   853         -      returnSingleInt(v, "temp_store", db->temp_store);
          861  +      returnSingleInt(v, db->temp_store);
   854    862       }else{
   855    863         changeTempStorage(pParse, zRight);
   856    864       }
   857    865       break;
   858    866     }
   859    867   
   860    868     /*
................................................................................
   865    873     ** the value sets a specific directory to be used for temporary files.
   866    874     ** Setting to a null string reverts to the default temporary directory search.
   867    875     ** If temporary directory is changed, then invalidateTempStorage.
   868    876     **
   869    877     */
   870    878     case PragTyp_TEMP_STORE_DIRECTORY: {
   871    879       if( !zRight ){
   872         -      returnSingleText(v, "temp_store_directory", sqlite3_temp_directory);
          880  +      returnSingleText(v, sqlite3_temp_directory);
   873    881       }else{
   874    882   #ifndef SQLITE_OMIT_WSD
   875    883         if( zRight[0] ){
   876    884           int res;
   877    885           rc = sqlite3OsAccess(db->pVfs, zRight, SQLITE_ACCESS_READWRITE, &res);
   878    886           if( rc!=SQLITE_OK || res==0 ){
   879    887             sqlite3ErrorMsg(pParse, "not a writable directory");
................................................................................
   909    917     ** a relative path will probably be based on the current directory for the
   910    918     ** process.  Database file specified with an absolute path are not impacted
   911    919     ** by this setting, regardless of its value.
   912    920     **
   913    921     */
   914    922     case PragTyp_DATA_STORE_DIRECTORY: {
   915    923       if( !zRight ){
   916         -      returnSingleText(v, "data_store_directory", sqlite3_data_directory);
          924  +      returnSingleText(v, sqlite3_data_directory);
   917    925       }else{
   918    926   #ifndef SQLITE_OMIT_WSD
   919    927         if( zRight[0] ){
   920    928           int res;
   921    929           rc = sqlite3OsAccess(db->pVfs, zRight, SQLITE_ACCESS_READWRITE, &res);
   922    930           if( rc!=SQLITE_OK || res==0 ){
   923    931             sqlite3ErrorMsg(pParse, "not a writable directory");
................................................................................
   948    956     case PragTyp_LOCK_PROXY_FILE: {
   949    957       if( !zRight ){
   950    958         Pager *pPager = sqlite3BtreePager(pDb->pBt);
   951    959         char *proxy_file_path = NULL;
   952    960         sqlite3_file *pFile = sqlite3PagerFile(pPager);
   953    961         sqlite3OsFileControlHint(pFile, SQLITE_GET_LOCKPROXYFILE, 
   954    962                              &proxy_file_path);
   955         -      returnSingleText(v, "lock_proxy_file", proxy_file_path);
          963  +      returnSingleText(v, proxy_file_path);
   956    964       }else{
   957    965         Pager *pPager = sqlite3BtreePager(pDb->pBt);
   958    966         sqlite3_file *pFile = sqlite3PagerFile(pPager);
   959    967         int res;
   960    968         if( zRight[0] ){
   961    969           res=sqlite3OsFileControl(pFile, SQLITE_SET_LOCKPROXYFILE, 
   962    970                                        zRight);
................................................................................
   980    988     ** Return or set the local value of the synchronous flag.  Changing
   981    989     ** the local value does not make changes to the disk file and the
   982    990     ** default value will be restored the next time the database is
   983    991     ** opened.
   984    992     */
   985    993     case PragTyp_SYNCHRONOUS: {
   986    994       if( !zRight ){
   987         -      returnSingleInt(v, "synchronous", pDb->safety_level-1);
          995  +      returnSingleInt(v, pDb->safety_level-1);
   988    996       }else{
   989    997         if( !db->autoCommit ){
   990    998           sqlite3ErrorMsg(pParse, 
   991    999               "Safety level may not be changed inside a transaction");
   992   1000         }else{
   993   1001           int iLevel = (getSafetyLevel(zRight,0,1)+1) & PAGER_SYNCHRONOUS_MASK;
   994   1002           if( iLevel==0 ) iLevel = 1;
................................................................................
  1000   1008       break;
  1001   1009     }
  1002   1010   #endif /* SQLITE_OMIT_PAGER_PRAGMAS */
  1003   1011   
  1004   1012   #ifndef SQLITE_OMIT_FLAG_PRAGMAS
  1005   1013     case PragTyp_FLAG: {
  1006   1014       if( zRight==0 ){
  1007         -      returnSingleInt(v, pPragma->zName, (db->flags & pPragma->iArg)!=0 );
         1015  +      setPragmaResultColumnNames(v, pPragma);
         1016  +      returnSingleInt(v, (db->flags & pPragma->iArg)!=0 );
  1008   1017       }else{
  1009   1018         int mask = pPragma->iArg;    /* Mask of bits to set or clear. */
  1010   1019         if( db->autoCommit==0 ){
  1011   1020           /* Foreign key support may not be enabled or disabled while not
  1012   1021           ** in auto-commit mode.  */
  1013   1022           mask &= ~(SQLITE_ForeignKeys);
  1014   1023         }
................................................................................
  1050   1059     ** notnull:    True if 'NOT NULL' is part of column declaration
  1051   1060     ** dflt_value: The default value for the column, if any.
  1052   1061     */
  1053   1062     case PragTyp_TABLE_INFO: if( zRight ){
  1054   1063       Table *pTab;
  1055   1064       pTab = sqlite3LocateTable(pParse, LOCATE_NOERR, zRight, zDb);
  1056   1065       if( pTab ){
  1057         -      static const char *azCol[] = {
  1058         -         "cid", "name", "type", "notnull", "dflt_value", "pk"
  1059         -      };
  1060   1066         int i, k;
  1061   1067         int nHidden = 0;
  1062   1068         Column *pCol;
  1063   1069         Index *pPk = sqlite3PrimaryKeyIndex(pTab);
  1064   1070         pParse->nMem = 6;
  1065   1071         sqlite3CodeVerifySchema(pParse, iDb);
  1066         -      setAllColumnNames(v, 6, azCol); assert( 6==ArraySize(azCol) );
  1067   1072         sqlite3ViewGetColumnNames(pParse, pTab);
  1068   1073         for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){
  1069   1074           if( IsHiddenColumn(pCol) ){
  1070   1075             nHidden++;
  1071   1076             continue;
  1072   1077           }
  1073   1078           if( (pCol->colFlags & COLFLAG_PRIMKEY)==0 ){
................................................................................
  1088   1093           sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6);
  1089   1094         }
  1090   1095       }
  1091   1096     }
  1092   1097     break;
  1093   1098   
  1094   1099     case PragTyp_STATS: {
  1095         -    static const char *azCol[] = { "table", "index", "width", "height" };
  1096   1100       Index *pIdx;
  1097   1101       HashElem *i;
  1098         -    v = sqlite3GetVdbe(pParse);
  1099   1102       pParse->nMem = 4;
  1100   1103       sqlite3CodeVerifySchema(pParse, iDb);
  1101         -    setAllColumnNames(v, 4, azCol);  assert( 4==ArraySize(azCol) );
  1102   1104       for(i=sqliteHashFirst(&pDb->pSchema->tblHash); i; i=sqliteHashNext(i)){
  1103   1105         Table *pTab = sqliteHashData(i);
  1104   1106         sqlite3VdbeMultiLoad(v, 1, "ssii",
  1105   1107              pTab->zName,
  1106   1108              0,
  1107   1109              pTab->szTabRow,
  1108   1110              pTab->nRowLogEst);
................................................................................
  1119   1121     break;
  1120   1122   
  1121   1123     case PragTyp_INDEX_INFO: if( zRight ){
  1122   1124       Index *pIdx;
  1123   1125       Table *pTab;
  1124   1126       pIdx = sqlite3FindIndex(db, zRight, zDb);
  1125   1127       if( pIdx ){
  1126         -      static const char *azCol[] = {
  1127         -         "seqno", "cid", "name", "desc", "coll", "key"
  1128         -      };
  1129   1128         int i;
  1130   1129         int mx;
  1131   1130         if( pPragma->iArg ){
  1132   1131           /* PRAGMA index_xinfo (newer version with more rows and columns) */
  1133   1132           mx = pIdx->nColumn;
  1134   1133           pParse->nMem = 6;
  1135   1134         }else{
  1136   1135           /* PRAGMA index_info (legacy version) */
  1137   1136           mx = pIdx->nKeyCol;
  1138   1137           pParse->nMem = 3;
  1139   1138         }
  1140   1139         pTab = pIdx->pTable;
  1141   1140         sqlite3CodeVerifySchema(pParse, iDb);
  1142         -      assert( pParse->nMem<=ArraySize(azCol) );
  1143         -      setAllColumnNames(v, pParse->nMem, azCol);
         1141  +      assert( pParse->nMem<=pPragma->nPragCName );
  1144   1142         for(i=0; i<mx; i++){
  1145   1143           i16 cnum = pIdx->aiColumn[i];
  1146   1144           sqlite3VdbeMultiLoad(v, 1, "iis", i, cnum,
  1147   1145                                cnum<0 ? 0 : pTab->aCol[cnum].zName);
  1148   1146           if( pPragma->iArg ){
  1149   1147             sqlite3VdbeMultiLoad(v, 4, "isi",
  1150   1148               pIdx->aSortOrder[i],
................................................................................
  1159   1157   
  1160   1158     case PragTyp_INDEX_LIST: if( zRight ){
  1161   1159       Index *pIdx;
  1162   1160       Table *pTab;
  1163   1161       int i;
  1164   1162       pTab = sqlite3FindTable(db, zRight, zDb);
  1165   1163       if( pTab ){
  1166         -      static const char *azCol[] = {
  1167         -        "seq", "name", "unique", "origin", "partial"
  1168         -      };
  1169         -      v = sqlite3GetVdbe(pParse);
  1170   1164         pParse->nMem = 5;
  1171   1165         sqlite3CodeVerifySchema(pParse, iDb);
  1172         -      setAllColumnNames(v, 5, azCol);  assert( 5==ArraySize(azCol) );
  1173   1166         for(pIdx=pTab->pIndex, i=0; pIdx; pIdx=pIdx->pNext, i++){
  1174   1167           const char *azOrigin[] = { "c", "u", "pk" };
  1175   1168           sqlite3VdbeMultiLoad(v, 1, "isisi",
  1176   1169              i,
  1177   1170              pIdx->zName,
  1178   1171              IsUniqueIndex(pIdx),
  1179   1172              azOrigin[pIdx->idxType],
................................................................................
  1181   1174           sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 5);
  1182   1175         }
  1183   1176       }
  1184   1177     }
  1185   1178     break;
  1186   1179   
  1187   1180     case PragTyp_DATABASE_LIST: {
  1188         -    static const char *azCol[] = { "seq", "name", "file" };
  1189   1181       int i;
  1190   1182       pParse->nMem = 3;
  1191         -    setAllColumnNames(v, 3, azCol); assert( 3==ArraySize(azCol) );
  1192   1183       for(i=0; i<db->nDb; i++){
  1193   1184         if( db->aDb[i].pBt==0 ) continue;
  1194   1185         assert( db->aDb[i].zDbSName!=0 );
  1195   1186         sqlite3VdbeMultiLoad(v, 1, "iss",
  1196   1187            i,
  1197   1188            db->aDb[i].zDbSName,
  1198   1189            sqlite3BtreeGetFilename(db->aDb[i].pBt));
  1199   1190         sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);
  1200   1191       }
  1201   1192     }
  1202   1193     break;
  1203   1194   
  1204   1195     case PragTyp_COLLATION_LIST: {
  1205         -    static const char *azCol[] = { "seq", "name" };
  1206   1196       int i = 0;
  1207   1197       HashElem *p;
  1208   1198       pParse->nMem = 2;
  1209         -    setAllColumnNames(v, 2, azCol); assert( 2==ArraySize(azCol) );
  1210   1199       for(p=sqliteHashFirst(&db->aCollSeq); p; p=sqliteHashNext(p)){
  1211   1200         CollSeq *pColl = (CollSeq *)sqliteHashData(p);
  1212   1201         sqlite3VdbeMultiLoad(v, 1, "is", i++, pColl->zName);
  1213   1202         sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2);
  1214   1203       }
  1215   1204     }
  1216   1205     break;
................................................................................
  1218   1207   
  1219   1208   #ifndef SQLITE_OMIT_FOREIGN_KEY
  1220   1209     case PragTyp_FOREIGN_KEY_LIST: if( zRight ){
  1221   1210       FKey *pFK;
  1222   1211       Table *pTab;
  1223   1212       pTab = sqlite3FindTable(db, zRight, zDb);
  1224   1213       if( pTab ){
  1225         -      v = sqlite3GetVdbe(pParse);
  1226   1214         pFK = pTab->pFKey;
  1227   1215         if( pFK ){
  1228         -        static const char *azCol[] = {
  1229         -           "id", "seq", "table", "from", "to", "on_update", "on_delete",
  1230         -           "match"
  1231         -        };
  1232   1216           int i = 0; 
  1233   1217           pParse->nMem = 8;
  1234   1218           sqlite3CodeVerifySchema(pParse, iDb);
  1235         -        setAllColumnNames(v, 8, azCol); assert( 8==ArraySize(azCol) );
  1236   1219           while(pFK){
  1237   1220             int j;
  1238   1221             for(j=0; j<pFK->nCol; j++){
  1239   1222               sqlite3VdbeMultiLoad(v, 1, "iissssss",
  1240   1223                      i,
  1241   1224                      j,
  1242   1225                      pFK->zTo,
................................................................................
  1269   1252       int x;                 /* result variable */
  1270   1253       int regResult;         /* 3 registers to hold a result row */
  1271   1254       int regKey;            /* Register to hold key for checking the FK */
  1272   1255       int regRow;            /* Registers to hold a row from pTab */
  1273   1256       int addrTop;           /* Top of a loop checking foreign keys */
  1274   1257       int addrOk;            /* Jump here if the key is OK */
  1275   1258       int *aiCols;           /* child to parent column mapping */
  1276         -    static const char *azCol[] = { "table", "rowid", "parent", "fkid" };
  1277   1259   
  1278   1260       regResult = pParse->nMem+1;
  1279   1261       pParse->nMem += 4;
  1280   1262       regKey = ++pParse->nMem;
  1281   1263       regRow = ++pParse->nMem;
  1282         -    v = sqlite3GetVdbe(pParse);
  1283         -    setAllColumnNames(v, 4, azCol); assert( 4==ArraySize(azCol) );
  1284   1264       sqlite3CodeVerifySchema(pParse, iDb);
  1285   1265       k = sqliteHashFirst(&db->aDb[iDb].pSchema->tblHash);
  1286   1266       while( k ){
  1287   1267         if( zRight ){
  1288   1268           pTab = sqlite3LocateTable(pParse, 0, zRight, zDb);
  1289   1269           k = 0;
  1290   1270         }else{
................................................................................
  1415   1395       ** of all attached databases.  */
  1416   1396       assert( iDb>=0 );
  1417   1397       assert( iDb==0 || pId2->z );
  1418   1398       if( pId2->z==0 ) iDb = -1;
  1419   1399   
  1420   1400       /* Initialize the VDBE program */
  1421   1401       pParse->nMem = 6;
  1422         -    setOneColumnName(v, "integrity_check");
  1423   1402   
  1424   1403       /* Set the maximum error count */
  1425   1404       mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;
  1426   1405       if( zRight ){
  1427   1406         sqlite3GetInt32(zRight, &mxErr);
  1428   1407         if( mxErr<=0 ){
  1429   1408           mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;
................................................................................
  1667   1646       };
  1668   1647       const struct EncName *pEnc;
  1669   1648       if( !zRight ){    /* "PRAGMA encoding" */
  1670   1649         if( sqlite3ReadSchema(pParse) ) goto pragma_out;
  1671   1650         assert( encnames[SQLITE_UTF8].enc==SQLITE_UTF8 );
  1672   1651         assert( encnames[SQLITE_UTF16LE].enc==SQLITE_UTF16LE );
  1673   1652         assert( encnames[SQLITE_UTF16BE].enc==SQLITE_UTF16BE );
  1674         -      returnSingleText(v, "encoding", encnames[ENC(pParse->db)].zName);
         1653  +      returnSingleText(v, encnames[ENC(pParse->db)].zName);
  1675   1654       }else{                        /* "PRAGMA encoding = XXX" */
  1676   1655         /* Only change the value of sqlite.enc if the database handle is not
  1677   1656         ** initialized. If the main database exists, the new sqlite.enc value
  1678   1657         ** will be overwritten when the schema is next loaded. If it does not
  1679   1658         ** already exists, it will be created to use the new encoding value.
  1680   1659         */
  1681   1660         if( 
................................................................................
  1730   1709     **
  1731   1710     ** The user-version is not used internally by SQLite. It may be used by
  1732   1711     ** applications for any purpose.
  1733   1712     */
  1734   1713     case PragTyp_HEADER_VALUE: {
  1735   1714       int iCookie = pPragma->iArg;  /* Which cookie to read or write */
  1736   1715       sqlite3VdbeUsesBtree(v, iDb);
  1737         -    if( zRight && (pPragma->mPragFlag & PragFlag_ReadOnly)==0 ){
         1716  +    if( zRight && (pPragma->mPragFlg & PragFlg_ReadOnly)==0 ){
  1738   1717         /* Write the specified cookie value */
  1739   1718         static const VdbeOpList setCookie[] = {
  1740   1719           { OP_Transaction,    0,  1,  0},    /* 0 */
  1741   1720           { OP_SetCookie,      0,  0,  0},    /* 1 */
  1742   1721         };
  1743   1722         VdbeOp *aOp;
  1744   1723         sqlite3VdbeVerifyNoMallocRequired(v, ArraySize(setCookie));
................................................................................
  1758   1737         VdbeOp *aOp;
  1759   1738         sqlite3VdbeVerifyNoMallocRequired(v, ArraySize(readCookie));
  1760   1739         aOp = sqlite3VdbeAddOpList(v, ArraySize(readCookie),readCookie,0);
  1761   1740         if( ONLY_IF_REALLOC_STRESS(aOp==0) ) break;
  1762   1741         aOp[0].p1 = iDb;
  1763   1742         aOp[1].p1 = iDb;
  1764   1743         aOp[1].p3 = iCookie;
  1765         -      sqlite3VdbeSetNumCols(v, 1);
  1766         -      sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLeft, SQLITE_TRANSIENT);
  1767   1744         sqlite3VdbeReusable(v);
  1768   1745       }
  1769   1746     }
  1770   1747     break;
  1771   1748   #endif /* SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS */
  1772   1749   
  1773   1750   #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
................................................................................
  1777   1754     ** Return the names of all compile-time options used in this build,
  1778   1755     ** one option per row.
  1779   1756     */
  1780   1757     case PragTyp_COMPILE_OPTIONS: {
  1781   1758       int i = 0;
  1782   1759       const char *zOpt;
  1783   1760       pParse->nMem = 1;
  1784         -    setOneColumnName(v, "compile_option");
  1785   1761       while( (zOpt = sqlite3_compileoption_get(i++))!=0 ){
  1786   1762         sqlite3VdbeLoadString(v, 1, zOpt);
  1787   1763         sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
  1788   1764       }
  1789   1765       sqlite3VdbeReusable(v);
  1790   1766     }
  1791   1767     break;
................................................................................
  1794   1770   #ifndef SQLITE_OMIT_WAL
  1795   1771     /*
  1796   1772     **   PRAGMA [schema.]wal_checkpoint = passive|full|restart|truncate
  1797   1773     **
  1798   1774     ** Checkpoint the database.
  1799   1775     */
  1800   1776     case PragTyp_WAL_CHECKPOINT: {
  1801         -    static const char *azCol[] = { "busy", "log", "checkpointed" };
  1802   1777       int iBt = (pId2->z?iDb:SQLITE_MAX_ATTACHED);
  1803   1778       int eMode = SQLITE_CHECKPOINT_PASSIVE;
  1804   1779       if( zRight ){
  1805   1780         if( sqlite3StrICmp(zRight, "full")==0 ){
  1806   1781           eMode = SQLITE_CHECKPOINT_FULL;
  1807   1782         }else if( sqlite3StrICmp(zRight, "restart")==0 ){
  1808   1783           eMode = SQLITE_CHECKPOINT_RESTART;
  1809   1784         }else if( sqlite3StrICmp(zRight, "truncate")==0 ){
  1810   1785           eMode = SQLITE_CHECKPOINT_TRUNCATE;
  1811   1786         }
  1812   1787       }
  1813         -    setAllColumnNames(v, 3, azCol);  assert( 3==ArraySize(azCol) );
  1814   1788       pParse->nMem = 3;
  1815   1789       sqlite3VdbeAddOp3(v, OP_Checkpoint, iBt, eMode, 1);
  1816   1790       sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);
  1817   1791     }
  1818   1792     break;
  1819   1793   
  1820   1794     /*
................................................................................
  1825   1799     ** after accumulating N frames in the log. Or query for the current value
  1826   1800     ** of N.
  1827   1801     */
  1828   1802     case PragTyp_WAL_AUTOCHECKPOINT: {
  1829   1803       if( zRight ){
  1830   1804         sqlite3_wal_autocheckpoint(db, sqlite3Atoi(zRight));
  1831   1805       }
  1832         -    returnSingleInt(v, "wal_autocheckpoint", 
         1806  +    returnSingleInt(v, 
  1833   1807          db->xWalCallback==sqlite3WalDefaultHook ? 
  1834   1808              SQLITE_PTR_TO_INT(db->pWalArg) : 0);
  1835   1809     }
  1836   1810     break;
  1837   1811   #endif
  1838   1812   
  1839   1813     /*
................................................................................
  1858   1832     ** disables the timeout.
  1859   1833     */
  1860   1834     /*case PragTyp_BUSY_TIMEOUT*/ default: {
  1861   1835       assert( pPragma->ePragTyp==PragTyp_BUSY_TIMEOUT );
  1862   1836       if( zRight ){
  1863   1837         sqlite3_busy_timeout(db, sqlite3Atoi(zRight));
  1864   1838       }
  1865         -    returnSingleInt(v, "timeout",  db->busyTimeout);
         1839  +    returnSingleInt(v, db->busyTimeout);
  1866   1840       break;
  1867   1841     }
  1868   1842   
  1869   1843     /*
  1870   1844     **   PRAGMA soft_heap_limit
  1871   1845     **   PRAGMA soft_heap_limit = N
  1872   1846     **
................................................................................
  1878   1852     ** sqlite3_soft_heap_limit64(-1) C-language function.
  1879   1853     */
  1880   1854     case PragTyp_SOFT_HEAP_LIMIT: {
  1881   1855       sqlite3_int64 N;
  1882   1856       if( zRight && sqlite3DecOrHexToI64(zRight, &N)==SQLITE_OK ){
  1883   1857         sqlite3_soft_heap_limit64(N);
  1884   1858       }
  1885         -    returnSingleInt(v, "soft_heap_limit",  sqlite3_soft_heap_limit64(-1));
         1859  +    returnSingleInt(v, sqlite3_soft_heap_limit64(-1));
  1886   1860       break;
  1887   1861     }
  1888   1862   
  1889   1863     /*
  1890   1864     **   PRAGMA threads
  1891   1865     **   PRAGMA threads = N
  1892   1866     **
................................................................................
  1897   1871       sqlite3_int64 N;
  1898   1872       if( zRight
  1899   1873        && sqlite3DecOrHexToI64(zRight, &N)==SQLITE_OK
  1900   1874        && N>=0
  1901   1875       ){
  1902   1876         sqlite3_limit(db, SQLITE_LIMIT_WORKER_THREADS, (int)(N&0x7fffffff));
  1903   1877       }
  1904         -    returnSingleInt(v, "threads",
  1905         -                    sqlite3_limit(db, SQLITE_LIMIT_WORKER_THREADS, -1));
         1878  +    returnSingleInt(v, sqlite3_limit(db, SQLITE_LIMIT_WORKER_THREADS, -1));
  1906   1879       break;
  1907   1880     }
  1908   1881   
  1909   1882   #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
  1910   1883     /*
  1911   1884     ** Report the current state of file logs for all databases
  1912   1885     */
  1913   1886     case PragTyp_LOCK_STATUS: {
  1914   1887       static const char *const azLockName[] = {
  1915   1888         "unlocked", "shared", "reserved", "pending", "exclusive"
  1916   1889       };
  1917         -    static const char *azCol[] = { "database", "status" };
  1918   1890       int i;
  1919         -    setAllColumnNames(v, 2, azCol); assert( 2==ArraySize(azCol) );
  1920   1891       pParse->nMem = 2;
  1921   1892       for(i=0; i<db->nDb; i++){
  1922   1893         Btree *pBt;
  1923   1894         const char *zState = "unknown";
  1924   1895         int j;
  1925   1896         if( db->aDb[i].zDbSName==0 ) continue;
  1926   1897         pBt = db->aDb[i].pBt;
................................................................................
  1982   1953   
  1983   1954     } /* End of the PRAGMA switch */
  1984   1955   
  1985   1956   pragma_out:
  1986   1957     sqlite3DbFree(db, zLeft);
  1987   1958     sqlite3DbFree(db, zRight);
  1988   1959   }
         1960  +#ifndef SQLITE_OMIT_VIRTUALTABLE
         1961  +/*****************************************************************************
         1962  +** Implementation of an eponymous virtual table that runs a pragma.
         1963  +**
         1964  +*/
         1965  +typedef struct PragmaVtab PragmaVtab;
         1966  +typedef struct PragmaVtabCursor PragmaVtabCursor;
         1967  +struct PragmaVtab {
         1968  +  sqlite3_vtab base;        /* Base class.  Must be first */
         1969  +  sqlite3 *db;              /* The database connection to which it belongs */
         1970  +  const PragmaName *pName;  /* Name of the pragma */
         1971  +  u8 nHidden;               /* Number of hidden columns */
         1972  +  u8 iHidden;               /* Index of the first hidden column */
         1973  +};
         1974  +struct PragmaVtabCursor {
         1975  +  sqlite3_vtab_cursor base; /* Base class.  Must be first */
         1976  +  sqlite3_stmt *pPragma;    /* The pragma statement to run */
         1977  +  sqlite_int64 iRowid;      /* Current rowid */
         1978  +  char *azArg[2];           /* Value of the argument and schema */
         1979  +};
         1980  +
         1981  +/* 
         1982  +** Pragma virtual table module xConnect method.
         1983  +*/
         1984  +static int pragmaVtabConnect(
         1985  +  sqlite3 *db,
         1986  +  void *pAux,
         1987  +  int argc, const char *const*argv,
         1988  +  sqlite3_vtab **ppVtab,
         1989  +  char **pzErr
         1990  +){
         1991  +  const PragmaName *pPragma = (const PragmaName*)pAux;
         1992  +  PragmaVtab *pTab = 0;
         1993  +  int rc;
         1994  +  int i, j;
         1995  +  char cSep = '(';
         1996  +  StrAccum acc;
         1997  +  char zBuf[200];
         1998  +
         1999  +  sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);
         2000  +  sqlite3StrAccumAppendAll(&acc, "CREATE TABLE x");
         2001  +  for(i=0, j=pPragma->iPragCName; i<pPragma->nPragCName; i++, j++){
         2002  +    sqlite3XPrintf(&acc, "%c\"%s\"", cSep, pragCName[j]);
         2003  +    cSep = ',';
         2004  +  }
         2005  +  if( i==0 ){
         2006  +    sqlite3XPrintf(&acc, "(\"%s\"", pPragma->zName);
         2007  +    cSep = ',';
         2008  +    i++;
         2009  +  }
         2010  +  j = 0;
         2011  +  if( pPragma->mPragFlg & PragFlg_Result1 ){
         2012  +    sqlite3StrAccumAppendAll(&acc, ",arg HIDDEN");
         2013  +    j++;
         2014  +  }
         2015  +  if( pPragma->mPragFlg & (PragFlg_SchemaOpt|PragFlg_SchemaReq) ){
         2016  +    sqlite3StrAccumAppendAll(&acc, ",schema HIDDEN");
         2017  +    j++;
         2018  +  }
         2019  +  sqlite3StrAccumAppend(&acc, ")", 1);
         2020  +  sqlite3StrAccumFinish(&acc);
         2021  +  assert( strlen(zBuf) < sizeof(zBuf)-1 );
         2022  +  rc = sqlite3_declare_vtab(db, zBuf);
         2023  +  if( rc==SQLITE_OK ){
         2024  +    pTab = (PragmaVtab*)sqlite3_malloc(sizeof(PragmaVtab));
         2025  +    if( pTab==0 ){
         2026  +      rc = SQLITE_NOMEM;
         2027  +    }else{
         2028  +      memset(pTab, 0, sizeof(PragmaVtab));
         2029  +      pTab->pName = pPragma;
         2030  +      pTab->db = db;
         2031  +      pTab->iHidden = i;
         2032  +      pTab->nHidden = j;
         2033  +    }
         2034  +  }else{
         2035  +    *pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(db));
         2036  +  }
         2037  +
         2038  +  *ppVtab = (sqlite3_vtab*)pTab;
         2039  +  return rc;
         2040  +}
         2041  +
         2042  +/* 
         2043  +** Pragma virtual table module xDisconnect method.
         2044  +*/
         2045  +static int pragmaVtabDisconnect(sqlite3_vtab *pVtab){
         2046  +  PragmaVtab *pTab = (PragmaVtab*)pVtab;
         2047  +  sqlite3_free(pTab);
         2048  +  return SQLITE_OK;
         2049  +}
         2050  +
         2051  +/* Figure out the best index to use to search a pragma virtual table.
         2052  +**
         2053  +** There are not really any index choices.  But we want to encourage the
         2054  +** query planner to give == constraints on as many hidden parameters as
         2055  +** possible, and especially on the first hidden parameter.  So return a
         2056  +** high cost if hidden parameters are unconstrained.
         2057  +*/
         2058  +static int pragmaVtabBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
         2059  +  PragmaVtab *pTab = (PragmaVtab*)tab;
         2060  +  const struct sqlite3_index_constraint *pConstraint;
         2061  +  int i, j;
         2062  +  int seen[2];
         2063  +
         2064  +  pIdxInfo->estimatedCost = (double)1;
         2065  +  if( pTab->nHidden==0 ){ return SQLITE_OK; }
         2066  +  pConstraint = pIdxInfo->aConstraint;
         2067  +  seen[0] = 0;
         2068  +  seen[1] = 0;
         2069  +  for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){
         2070  +    if( pConstraint->usable==0 ) continue;
         2071  +    if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;
         2072  +    if( pConstraint->iColumn < pTab->iHidden ) continue;
         2073  +    j = pConstraint->iColumn - pTab->iHidden;
         2074  +    assert( j < 2 );
         2075  +    seen[j] = i+1;
         2076  +  }
         2077  +  if( seen[0]==0 ){
         2078  +    pIdxInfo->estimatedCost = (double)2147483647;
         2079  +    pIdxInfo->estimatedRows = 2147483647;
         2080  +    return SQLITE_OK;
         2081  +  }
         2082  +  j = seen[0]-1;
         2083  +  pIdxInfo->aConstraintUsage[j].argvIndex = 1;
         2084  +  pIdxInfo->aConstraintUsage[j].omit = 1;
         2085  +  if( seen[1]==0 ) return SQLITE_OK;
         2086  +  pIdxInfo->estimatedCost = (double)20;
         2087  +  pIdxInfo->estimatedRows = 20;
         2088  +  j = seen[1]-1;
         2089  +  pIdxInfo->aConstraintUsage[j].argvIndex = 2;
         2090  +  pIdxInfo->aConstraintUsage[j].omit = 1;
         2091  +  return SQLITE_OK;
         2092  +}
         2093  +
         2094  +/* Create a new cursor for the pragma virtual table */
         2095  +static int pragmaVtabOpen(sqlite3_vtab *pVtab, sqlite3_vtab_cursor **ppCursor){
         2096  +  PragmaVtabCursor *pCsr;
         2097  +  pCsr = (PragmaVtabCursor*)sqlite3_malloc(sizeof(*pCsr));
         2098  +  if( pCsr==0 ) return SQLITE_NOMEM;
         2099  +  memset(pCsr, 0, sizeof(PragmaVtabCursor));
         2100  +  pCsr->base.pVtab = pVtab;
         2101  +  *ppCursor = &pCsr->base;
         2102  +  return SQLITE_OK;
         2103  +}
         2104  +
         2105  +/* Clear all content from pragma virtual table cursor. */
         2106  +static void pragmaVtabCursorClear(PragmaVtabCursor *pCsr){
         2107  +  int i;
         2108  +  sqlite3_finalize(pCsr->pPragma);
         2109  +  pCsr->pPragma = 0;
         2110  +  for(i=0; i<ArraySize(pCsr->azArg); i++){
         2111  +    sqlite3_free(pCsr->azArg[i]);
         2112  +    pCsr->azArg[i] = 0;
         2113  +  }
         2114  +}
         2115  +
         2116  +/* Close a pragma virtual table cursor */
         2117  +static int pragmaVtabClose(sqlite3_vtab_cursor *cur){
         2118  +  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)cur;
         2119  +  pragmaVtabCursorClear(pCsr);
         2120  +  sqlite3_free(pCsr);
         2121  +  return SQLITE_OK;
         2122  +}
         2123  +
         2124  +/* Advance the pragma virtual table cursor to the next row */
         2125  +static int pragmaVtabNext(sqlite3_vtab_cursor *pVtabCursor){
         2126  +  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)pVtabCursor;
         2127  +  int rc = SQLITE_OK;
         2128  +
         2129  +  /* Increment the xRowid value */
         2130  +  pCsr->iRowid++;
         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);
         2136  +  }
         2137  +  return rc;
         2138  +}
         2139  +
         2140  +/* 
         2141  +** Pragma virtual table module xFilter method.
         2142  +*/
         2143  +static int pragmaVtabFilter(
         2144  +  sqlite3_vtab_cursor *pVtabCursor, 
         2145  +  int idxNum, const char *idxStr,
         2146  +  int argc, sqlite3_value **argv
         2147  +){
         2148  +  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)pVtabCursor;
         2149  +  PragmaVtab *pTab = (PragmaVtab*)(pVtabCursor->pVtab);
         2150  +  int rc;
         2151  +  int i, j;
         2152  +  StrAccum acc;
         2153  +  char *zSql;
         2154  +
         2155  +  pragmaVtabCursorClear(pCsr);
         2156  +  j = (pTab->pName->mPragFlg & PragFlg_Result1)!=0 ? 0 : 1;
         2157  +  for(i=0; i<argc; i++, j++){
         2158  +    assert( j<ArraySize(pCsr->azArg) );
         2159  +    pCsr->azArg[j] = sqlite3_mprintf("%s", sqlite3_value_text(argv[i]));
         2160  +    if( pCsr->azArg[j]==0 ){
         2161  +      return SQLITE_NOMEM;
         2162  +    }
         2163  +  }
         2164  +  sqlite3StrAccumInit(&acc, 0, 0, 0, pTab->db->aLimit[SQLITE_LIMIT_SQL_LENGTH]);
         2165  +  sqlite3StrAccumAppendAll(&acc, "PRAGMA ");
         2166  +  if( pCsr->azArg[1] ){
         2167  +    sqlite3XPrintf(&acc, "%Q.", pCsr->azArg[1]);
         2168  +  }
         2169  +  sqlite3StrAccumAppendAll(&acc, pTab->pName->zName);
         2170  +  if( pCsr->azArg[0] ){
         2171  +    sqlite3XPrintf(&acc, "=%Q", pCsr->azArg[0]);
         2172  +  }
         2173  +  zSql = sqlite3StrAccumFinish(&acc);
         2174  +  if( zSql==0 ) return SQLITE_NOMEM;
         2175  +  rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pPragma, 0);
         2176  +  sqlite3_free(zSql);
         2177  +  if( rc!=SQLITE_OK ){
         2178  +    pTab->base.zErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pTab->db));
         2179  +    return rc;
         2180  +  }
         2181  +  return pragmaVtabNext(pVtabCursor);
         2182  +}
         2183  +
         2184  +/*
         2185  +** Pragma virtual table module xEof method.
         2186  +*/
         2187  +static int pragmaVtabEof(sqlite3_vtab_cursor *pVtabCursor){
         2188  +  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)pVtabCursor;
         2189  +  return (pCsr->pPragma==0);
         2190  +}
         2191  +
         2192  +/* The xColumn method simply returns the corresponding column from
         2193  +** the PRAGMA.  
         2194  +*/
         2195  +static int pragmaVtabColumn(
         2196  +  sqlite3_vtab_cursor *pVtabCursor, 
         2197  +  sqlite3_context *ctx, 
         2198  +  int i
         2199  +){
         2200  +  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)pVtabCursor;
         2201  +  PragmaVtab *pTab = (PragmaVtab*)(pVtabCursor->pVtab);
         2202  +  if( i<pTab->iHidden ){
         2203  +    sqlite3_result_value(ctx, sqlite3_column_value(pCsr->pPragma, i));
         2204  +  }else{
         2205  +    sqlite3_result_text(ctx, pCsr->azArg[i-pTab->iHidden],-1,SQLITE_TRANSIENT);
         2206  +  }
         2207  +  return SQLITE_OK;
         2208  +}
         2209  +
         2210  +/* 
         2211  +** Pragma virtual table module xRowid method.
         2212  +*/
         2213  +static int pragmaVtabRowid(sqlite3_vtab_cursor *pVtabCursor, sqlite_int64 *p){
         2214  +  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)pVtabCursor;
         2215  +  *p = pCsr->iRowid;
         2216  +  return SQLITE_OK;
         2217  +}
         2218  +
         2219  +/* The pragma virtual table object */
         2220  +static const sqlite3_module pragmaVtabModule = {
         2221  +  0,                           /* iVersion */
         2222  +  0,                           /* xCreate - create a table */
         2223  +  pragmaVtabConnect,           /* xConnect - connect to an existing table */
         2224  +  pragmaVtabBestIndex,         /* xBestIndex - Determine search strategy */
         2225  +  pragmaVtabDisconnect,        /* xDisconnect - Disconnect from a table */
         2226  +  0,                           /* xDestroy - Drop a table */
         2227  +  pragmaVtabOpen,              /* xOpen - open a cursor */
         2228  +  pragmaVtabClose,             /* xClose - close a cursor */
         2229  +  pragmaVtabFilter,            /* xFilter - configure scan constraints */
         2230  +  pragmaVtabNext,              /* xNext - advance a cursor */
         2231  +  pragmaVtabEof,               /* xEof */
         2232  +  pragmaVtabColumn,            /* xColumn - read data */
         2233  +  pragmaVtabRowid,             /* xRowid - read data */
         2234  +  0,                           /* xUpdate - write data */
         2235  +  0,                           /* xBegin - begin transaction */
         2236  +  0,                           /* xSync - sync transaction */
         2237  +  0,                           /* xCommit - commit transaction */
         2238  +  0,                           /* xRollback - rollback transaction */
         2239  +  0,                           /* xFindFunction - function overloading */
         2240  +  0,                           /* xRename - rename the table */
         2241  +  0,                           /* xSavepoint */
         2242  +  0,                           /* xRelease */
         2243  +  0                            /* xRollbackTo */
         2244  +};
         2245  +
         2246  +/*
         2247  +** Check to see if zTabName is really the name of a pragma.  If it is,
         2248  +** then register an eponymous virtual table for that pragma and return
         2249  +** a pointer to the Module object for the new virtual table.
         2250  +*/
         2251  +Module *sqlite3PragmaVtabRegister(sqlite3 *db, const char *zName){
         2252  +  const PragmaName *pName;
         2253  +  assert( sqlite3_strnicmp(zName, "pragma_", 7)==0 );
         2254  +  pName = pragmaLocate(zName+7);
         2255  +  if( pName==0 ) return 0;
         2256  +  if( (pName->mPragFlg & (PragFlg_Result0|PragFlg_Result1))==0 ) return 0;
         2257  +  assert( sqlite3HashFind(&db->aModule, zName)==0 );
         2258  +  return sqlite3VtabCreateModule(db, zName, &pragmaVtabModule, (void*)pName, 0);
         2259  +}
         2260  +
         2261  +#endif /* SQLITE_OMIT_VIRTUALTABLE */
  1989   2262   
  1990   2263   #endif /* SQLITE_OMIT_PRAGMA */

Changes to src/pragma.h.

     1      1   /* DO NOT EDIT!
     2      2   ** This file is automatically generated by the script at
     3      3   ** ../tool/mkpragmatab.tcl.  To update the set of pragmas, edit
     4      4   ** that script and rerun it.
     5      5   */
            6  +
            7  +/* The various pragma types */
     6      8   #define PragTyp_HEADER_VALUE                   0
     7      9   #define PragTyp_AUTO_VACUUM                    1
     8     10   #define PragTyp_FLAG                           2
     9     11   #define PragTyp_BUSY_TIMEOUT                   3
    10     12   #define PragTyp_CACHE_SIZE                     4
    11     13   #define PragTyp_CACHE_SPILL                    5
    12     14   #define PragTyp_CASE_SENSITIVE_LIKE            6
................................................................................
    42     44   #define PragTyp_WAL_CHECKPOINT                36
    43     45   #define PragTyp_ACTIVATE_EXTENSIONS           37
    44     46   #define PragTyp_HEXKEY                        38
    45     47   #define PragTyp_KEY                           39
    46     48   #define PragTyp_REKEY                         40
    47     49   #define PragTyp_LOCK_STATUS                   41
    48     50   #define PragTyp_PARSER_TRACE                  42
    49         -#define PragFlag_NeedSchema           0x01
    50         -#define PragFlag_ReadOnly             0x02
    51         -static const struct sPragmaNames {
    52         -  const char *const zName;  /* Name of pragma */
    53         -  u8 ePragTyp;              /* PragTyp_XXX value */
    54         -  u8 mPragFlag;             /* Zero or more PragFlag_XXX values */
    55         -  u32 iArg;                 /* Extra argument */
    56         -} aPragmaNames[] = {
           51  +
           52  +/* Property flags associated with various pragma. */
           53  +#define PragFlg_NeedSchema 0x01 /* Force schema load before running */
           54  +#define PragFlg_NoColumns  0x02 /* OP_ResultRow called with zero columns */
           55  +#define PragFlg_ReadOnly   0x04 /* Read-only HEADER_VALUE */
           56  +#define PragFlg_Result0    0x08 /* Acts as query when no argument */
           57  +#define PragFlg_Result1    0x10 /* Acts as query when has one argument */
           58  +#define PragFlg_SchemaOpt  0x20 /* Schema restricts name search if present */
           59  +#define PragFlg_SchemaReq  0x40 /* Schema required - "main" is default */
           60  +
           61  +/* Names of columns for pragmas that return multi-column result
           62  +** or that return single-column results where the name of the
           63  +** result column is different from the name of the pragma
           64  +*/
           65  +static const char *const pragCName[] = {
           66  +  /*   0 */ "cache_size",  /* Used by: default_cache_size */
           67  +  /*   1 */ "cid",         /* Used by: table_info */
           68  +  /*   2 */ "name",       
           69  +  /*   3 */ "type",       
           70  +  /*   4 */ "notnull",    
           71  +  /*   5 */ "dflt_value", 
           72  +  /*   6 */ "pk",         
           73  +  /*   7 */ "table",       /* Used by: stats */
           74  +  /*   8 */ "index",      
           75  +  /*   9 */ "width",      
           76  +  /*  10 */ "height",     
           77  +  /*  11 */ "seqno",       /* Used by: index_info */
           78  +  /*  12 */ "cid",        
           79  +  /*  13 */ "name",       
           80  +  /*  14 */ "seqno",       /* Used by: index_xinfo */
           81  +  /*  15 */ "cid",        
           82  +  /*  16 */ "name",       
           83  +  /*  17 */ "desc",       
           84  +  /*  18 */ "coll",       
           85  +  /*  19 */ "key",        
           86  +  /*  20 */ "seq",         /* Used by: index_list */
           87  +  /*  21 */ "name",       
           88  +  /*  22 */ "unique",     
           89  +  /*  23 */ "origin",     
           90  +  /*  24 */ "partial",    
           91  +  /*  25 */ "seq",         /* Used by: database_list */
           92  +  /*  26 */ "name",       
           93  +  /*  27 */ "file",       
           94  +  /*  28 */ "seq",         /* Used by: collation_list */
           95  +  /*  29 */ "name",       
           96  +  /*  30 */ "id",          /* Used by: foreign_key_list */
           97  +  /*  31 */ "seq",        
           98  +  /*  32 */ "table",      
           99  +  /*  33 */ "from",       
          100  +  /*  34 */ "to",         
          101  +  /*  35 */ "on_update",  
          102  +  /*  36 */ "on_delete",  
          103  +  /*  37 */ "match",      
          104  +  /*  38 */ "table",       /* Used by: foreign_key_check */
          105  +  /*  39 */ "rowid",      
          106  +  /*  40 */ "parent",     
          107  +  /*  41 */ "fkid",       
          108  +  /*  42 */ "busy",        /* Used by: wal_checkpoint */
          109  +  /*  43 */ "log",        
          110  +  /*  44 */ "checkpointed",
          111  +  /*  45 */ "timeout",     /* Used by: busy_timeout */
          112  +  /*  46 */ "database",    /* Used by: lock_status */
          113  +  /*  47 */ "status",     
          114  +};
          115  +
          116  +/* Definitions of all built-in pragmas */
          117  +typedef struct PragmaName {
          118  +  const char *const zName; /* Name of pragma */
          119  +  u8 ePragTyp;             /* PragTyp_XXX value */
          120  +  u8 mPragFlg;             /* Zero or more PragFlg_XXX values */
          121  +  u8 iPragCName;           /* Start of column names in pragCName[] */
          122  +  u8 nPragCName;           /* Num of col names. 0 means use pragma name */
          123  +  u32 iArg;                /* Extra argument */
          124  +} PragmaName;
          125  +static const PragmaName aPragmaName[] = {
    57    126   #if defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)
    58         -  { /* zName:     */ "activate_extensions",
    59         -    /* ePragTyp:  */ PragTyp_ACTIVATE_EXTENSIONS,
    60         -    /* ePragFlag: */ 0,
    61         -    /* iArg:      */ 0 },
          127  + {/* zName:     */ "activate_extensions",
          128  +  /* ePragTyp:  */ PragTyp_ACTIVATE_EXTENSIONS,
          129  +  /* ePragFlg:  */ 0,
          130  +  /* ColNames:  */ 0, 0,
          131  +  /* iArg:      */ 0 },
    62    132   #endif
    63    133   #if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
    64         -  { /* zName:     */ "application_id",
    65         -    /* ePragTyp:  */ PragTyp_HEADER_VALUE,
    66         -    /* ePragFlag: */ 0,
    67         -    /* iArg:      */ BTREE_APPLICATION_ID },
          134  + {/* zName:     */ "application_id",
          135  +  /* ePragTyp:  */ PragTyp_HEADER_VALUE,
          136  +  /* ePragFlg:  */ PragFlg_Result0,
          137  +  /* ColNames:  */ 0, 0,
          138  +  /* iArg:      */ BTREE_APPLICATION_ID },
    68    139   #endif
    69    140   #if !defined(SQLITE_OMIT_AUTOVACUUM)
    70         -  { /* zName:     */ "auto_vacuum",
    71         -    /* ePragTyp:  */ PragTyp_AUTO_VACUUM,
    72         -    /* ePragFlag: */ PragFlag_NeedSchema,
    73         -    /* iArg:      */ 0 },
          141  + {/* zName:     */ "auto_vacuum",
          142  +  /* ePragTyp:  */ PragTyp_AUTO_VACUUM,
          143  +  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
          144  +  /* ColNames:  */ 0, 0,
          145  +  /* iArg:      */ 0 },
    74    146   #endif
    75    147   #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
    76    148   #if !defined(SQLITE_OMIT_AUTOMATIC_INDEX)
    77         -  { /* zName:     */ "automatic_index",
    78         -    /* ePragTyp:  */ PragTyp_FLAG,
    79         -    /* ePragFlag: */ 0,
    80         -    /* iArg:      */ SQLITE_AutoIndex },
          149  + {/* zName:     */ "automatic_index",
          150  +  /* ePragTyp:  */ PragTyp_FLAG,
          151  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns,
          152  +  /* ColNames:  */ 0, 0,
          153  +  /* iArg:      */ SQLITE_AutoIndex },
    81    154   #endif
    82    155   #endif
    83         -  { /* zName:     */ "busy_timeout",
    84         -    /* ePragTyp:  */ PragTyp_BUSY_TIMEOUT,
    85         -    /* ePragFlag: */ 0,
    86         -    /* iArg:      */ 0 },
          156  + {/* zName:     */ "busy_timeout",
          157  +  /* ePragTyp:  */ PragTyp_BUSY_TIMEOUT,
          158  +  /* ePragFlg:  */ PragFlg_Result0,
          159  +  /* ColNames:  */ 45, 1,
          160  +  /* iArg:      */ 0 },
    87    161   #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
    88         -  { /* zName:     */ "cache_size",
    89         -    /* ePragTyp:  */ PragTyp_CACHE_SIZE,
    90         -    /* ePragFlag: */ PragFlag_NeedSchema,
    91         -    /* iArg:      */ 0 },
    92         -#endif
    93         -#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
    94         -  { /* zName:     */ "cache_spill",
    95         -    /* ePragTyp:  */ PragTyp_CACHE_SPILL,
    96         -    /* ePragFlag: */ 0,
    97         -    /* iArg:      */ 0 },
    98         -#endif
    99         -  { /* zName:     */ "case_sensitive_like",
   100         -    /* ePragTyp:  */ PragTyp_CASE_SENSITIVE_LIKE,
   101         -    /* ePragFlag: */ 0,
   102         -    /* iArg:      */ 0 },
   103         -  { /* zName:     */ "cell_size_check",
   104         -    /* ePragTyp:  */ PragTyp_FLAG,
   105         -    /* ePragFlag: */ 0,
   106         -    /* iArg:      */ SQLITE_CellSizeCk },
   107         -#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
   108         -  { /* zName:     */ "checkpoint_fullfsync",
   109         -    /* ePragTyp:  */ PragTyp_FLAG,
   110         -    /* ePragFlag: */ 0,
   111         -    /* iArg:      */ SQLITE_CkptFullFSync },
          162  + {/* zName:     */ "cache_size",
          163  +  /* ePragTyp:  */ PragTyp_CACHE_SIZE,
          164  +  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
          165  +  /* ColNames:  */ 0, 0,
          166  +  /* iArg:      */ 0 },
          167  +#endif
          168  +#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
          169  + {/* zName:     */ "cache_spill",
          170  +  /* ePragTyp:  */ PragTyp_CACHE_SPILL,
          171  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_SchemaReq,
          172  +  /* ColNames:  */ 0, 0,
          173  +  /* iArg:      */ 0 },
          174  +#endif
          175  + {/* zName:     */ "case_sensitive_like",
          176  +  /* ePragTyp:  */ PragTyp_CASE_SENSITIVE_LIKE,
          177  +  /* ePragFlg:  */ 0,
          178  +  /* ColNames:  */ 0, 0,
          179  +  /* iArg:      */ 0 },
          180  + {/* zName:     */ "cell_size_check",
          181  +  /* ePragTyp:  */ PragTyp_FLAG,
          182  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns,
          183  +  /* ColNames:  */ 0, 0,
          184  +  /* iArg:      */ SQLITE_CellSizeCk },
          185  +#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
          186  + {/* zName:     */ "checkpoint_fullfsync",
          187  +  /* ePragTyp:  */ PragTyp_FLAG,
          188  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns,
          189  +  /* ColNames:  */ 0, 0,
          190  +  /* iArg:      */ SQLITE_CkptFullFSync },
   112    191   #endif
   113    192   #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
   114         -  { /* zName:     */ "collation_list",
   115         -    /* ePragTyp:  */ PragTyp_COLLATION_LIST,
   116         -    /* ePragFlag: */ 0,
   117         -    /* iArg:      */ 0 },
          193  + {/* zName:     */ "collation_list",
          194  +  /* ePragTyp:  */ PragTyp_COLLATION_LIST,
          195  +  /* ePragFlg:  */ PragFlg_Result0,
          196  +  /* ColNames:  */ 28, 2,
          197  +  /* iArg:      */ 0 },
   118    198   #endif
   119    199   #if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
   120         -  { /* zName:     */ "compile_options",
   121         -    /* ePragTyp:  */ PragTyp_COMPILE_OPTIONS,
   122         -    /* ePragFlag: */ 0,
   123         -    /* iArg:      */ 0 },
          200  + {/* zName:     */ "compile_options",
          201  +  /* ePragTyp:  */ PragTyp_COMPILE_OPTIONS,
          202  +  /* ePragFlg:  */ PragFlg_Result0,
          203  +  /* ColNames:  */ 0, 0,
          204  +  /* iArg:      */ 0 },
   124    205   #endif
   125    206   #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
   126         -  { /* zName:     */ "count_changes",
   127         -    /* ePragTyp:  */ PragTyp_FLAG,
   128         -    /* ePragFlag: */ 0,
   129         -    /* iArg:      */ SQLITE_CountRows },
          207  + {/* zName:     */ "count_changes",
          208  +  /* ePragTyp:  */ PragTyp_FLAG,
          209  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns,
          210  +  /* ColNames:  */ 0, 0,
          211  +  /* iArg:      */ SQLITE_CountRows },
   130    212   #endif
   131    213   #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_OS_WIN
   132         -  { /* zName:     */ "data_store_directory",
   133         -    /* ePragTyp:  */ PragTyp_DATA_STORE_DIRECTORY,
   134         -    /* ePragFlag: */ 0,
   135         -    /* iArg:      */ 0 },
          214  + {/* zName:     */ "data_store_directory",
          215  +  /* ePragTyp:  */ PragTyp_DATA_STORE_DIRECTORY,
          216  +  /* ePragFlg:  */ 0,
          217  +  /* ColNames:  */ 0, 0,
          218  +  /* iArg:      */ 0 },
   136    219   #endif
   137    220   #if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
   138         -  { /* zName:     */ "data_version",
   139         -    /* ePragTyp:  */ PragTyp_HEADER_VALUE,
   140         -    /* ePragFlag: */ PragFlag_ReadOnly,
   141         -    /* iArg:      */ BTREE_DATA_VERSION },
          221  + {/* zName:     */ "data_version",
          222  +  /* ePragTyp:  */ PragTyp_HEADER_VALUE,
          223  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_ReadOnly,
          224  +  /* ColNames:  */ 0, 0,
          225  +  /* iArg:      */ BTREE_DATA_VERSION },
   142    226   #endif
   143    227   #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
   144         -  { /* zName:     */ "database_list",
   145         -    /* ePragTyp:  */ PragTyp_DATABASE_LIST,
   146         -    /* ePragFlag: */ PragFlag_NeedSchema,
   147         -    /* iArg:      */ 0 },
          228  + {/* zName:     */ "database_list",
          229  +  /* ePragTyp:  */ PragTyp_DATABASE_LIST,
          230  +  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0,
          231  +  /* ColNames:  */ 25, 3,
          232  +  /* iArg:      */ 0 },
   148    233   #endif
   149    234   #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
   150         -  { /* zName:     */ "default_cache_size",
   151         -    /* ePragTyp:  */ PragTyp_DEFAULT_CACHE_SIZE,
   152         -    /* ePragFlag: */ PragFlag_NeedSchema,
   153         -    /* iArg:      */ 0 },
          235  + {/* zName:     */ "default_cache_size",
          236  +  /* ePragTyp:  */ PragTyp_DEFAULT_CACHE_SIZE,
          237  +  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
          238  +  /* ColNames:  */ 0, 1,
          239  +  /* iArg:      */ 0 },
          240  +#endif
          241  +#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
          242  +#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
          243  + {/* zName:     */ "defer_foreign_keys",
          244  +  /* ePragTyp:  */ PragTyp_FLAG,
          245  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns,
          246  +  /* ColNames:  */ 0, 0,
          247  +  /* iArg:      */ SQLITE_DeferFKs },
          248  +#endif
          249  +#endif
          250  +#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
          251  + {/* zName:     */ "empty_result_callbacks",
          252  +  /* ePragTyp:  */ PragTyp_FLAG,
          253  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns,
          254  +  /* ColNames:  */ 0, 0,
          255  +  /* iArg:      */ SQLITE_NullCallback },
          256  +#endif
          257  +#if !defined(SQLITE_OMIT_UTF16)
          258  + {/* zName:     */ "encoding",
          259  +  /* ePragTyp:  */ PragTyp_ENCODING,
          260  +  /* ePragFlg:  */ PragFlg_Result0,
          261  +  /* ColNames:  */ 0, 0,
          262  +  /* iArg:      */ 0 },
          263  +#endif
          264  +#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
          265  + {/* zName:     */ "foreign_key_check",
          266  +  /* ePragTyp:  */ PragTyp_FOREIGN_KEY_CHECK,
          267  +  /* ePragFlg:  */ PragFlg_NeedSchema,
          268  +  /* ColNames:  */ 38, 4,
          269  +  /* iArg:      */ 0 },
          270  +#endif
          271  +#if !defined(SQLITE_OMIT_FOREIGN_KEY)
          272  + {/* zName:     */ "foreign_key_list",
          273  +  /* ePragTyp:  */ PragTyp_FOREIGN_KEY_LIST,
          274  +  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
          275  +  /* ColNames:  */ 30, 8,
          276  +  /* iArg:      */ 0 },
   154    277   #endif
   155    278   #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
   156    279   #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
   157         -  { /* zName:     */ "defer_foreign_keys",
   158         -    /* ePragTyp:  */ PragTyp_FLAG,
   159         -    /* ePragFlag: */ 0,
   160         -    /* iArg:      */ SQLITE_DeferFKs },
   161         -#endif
   162         -#endif
   163         -#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
   164         -  { /* zName:     */ "empty_result_callbacks",
   165         -    /* ePragTyp:  */ PragTyp_FLAG,
   166         -    /* ePragFlag: */ 0,
   167         -    /* iArg:      */ SQLITE_NullCallback },
   168         -#endif
   169         -#if !defined(SQLITE_OMIT_UTF16)
   170         -  { /* zName:     */ "encoding",
   171         -    /* ePragTyp:  */ PragTyp_ENCODING,
   172         -    /* ePragFlag: */ 0,
   173         -    /* iArg:      */ 0 },
   174         -#endif
   175         -#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
   176         -  { /* zName:     */ "foreign_key_check",
   177         -    /* ePragTyp:  */ PragTyp_FOREIGN_KEY_CHECK,
   178         -    /* ePragFlag: */ PragFlag_NeedSchema,
   179         -    /* iArg:      */ 0 },
   180         -#endif
   181         -#if !defined(SQLITE_OMIT_FOREIGN_KEY)
   182         -  { /* zName:     */ "foreign_key_list",
   183         -    /* ePragTyp:  */ PragTyp_FOREIGN_KEY_LIST,
   184         -    /* ePragFlag: */ PragFlag_NeedSchema,
   185         -    /* iArg:      */ 0 },
   186         -#endif
   187         -#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
   188         -#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
   189         -  { /* zName:     */ "foreign_keys",
   190         -    /* ePragTyp:  */ PragTyp_FLAG,
   191         -    /* ePragFlag: */ 0,
   192         -    /* iArg:      */ SQLITE_ForeignKeys },
          280  + {/* zName:     */ "foreign_keys",
          281  +  /* ePragTyp:  */ PragTyp_FLAG,
          282  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns,
          283  +  /* ColNames:  */ 0, 0,
          284  +  /* iArg:      */ SQLITE_ForeignKeys },
   193    285   #endif
   194    286   #endif
   195    287   #if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
   196         -  { /* zName:     */ "freelist_count",
   197         -    /* ePragTyp:  */ PragTyp_HEADER_VALUE,
   198         -    /* ePragFlag: */ PragFlag_ReadOnly,
   199         -    /* iArg:      */ BTREE_FREE_PAGE_COUNT },
          288  + {/* zName:     */ "freelist_count",
          289  +  /* ePragTyp:  */ PragTyp_HEADER_VALUE,
          290  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_ReadOnly,
          291  +  /* ColNames:  */ 0, 0,
          292  +  /* iArg:      */ BTREE_FREE_PAGE_COUNT },
   200    293   #endif
   201    294   #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
   202         -  { /* zName:     */ "full_column_names",
   203         -    /* ePragTyp:  */ PragTyp_FLAG,
   204         -    /* ePragFlag: */ 0,
   205         -    /* iArg:      */ SQLITE_FullColNames },
   206         -  { /* zName:     */ "fullfsync",
   207         -    /* ePragTyp:  */ PragTyp_FLAG,
   208         -    /* ePragFlag: */ 0,
   209         -    /* iArg:      */ SQLITE_FullFSync },
          295  + {/* zName:     */ "full_column_names",
          296  +  /* ePragTyp:  */ PragTyp_FLAG,
          297  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns,
          298  +  /* ColNames:  */ 0, 0,
          299  +  /* iArg:      */ SQLITE_FullColNames },
          300  + {/* zName:     */ "fullfsync",
          301  +  /* ePragTyp:  */ PragTyp_FLAG,
          302  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns,
          303  +  /* ColNames:  */ 0, 0,
          304  +  /* iArg:      */ SQLITE_FullFSync },
   210    305   #endif
   211    306   #if defined(SQLITE_HAS_CODEC)
   212         -  { /* zName:     */ "hexkey",
   213         -    /* ePragTyp:  */ PragTyp_HEXKEY,
   214         -    /* ePragFlag: */ 0,
   215         -    /* iArg:      */ 0 },
   216         -  { /* zName:     */ "hexrekey",
   217         -    /* ePragTyp:  */ PragTyp_HEXKEY,
   218         -    /* ePragFlag: */ 0,
   219         -    /* iArg:      */ 0 },
          307  + {/* zName:     */ "hexkey",
          308  +  /* ePragTyp:  */ PragTyp_HEXKEY,
          309  +  /* ePragFlg:  */ 0,
          310  +  /* ColNames:  */ 0, 0,
          311  +  /* iArg:      */ 0 },
          312  + {/* zName:     */ "hexrekey",
          313  +  /* ePragTyp:  */ PragTyp_HEXKEY,
          314  +  /* ePragFlg:  */ 0,
          315  +  /* ColNames:  */ 0, 0,
          316  +  /* iArg:      */ 0 },
   220    317   #endif
   221    318   #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
   222    319   #if !defined(SQLITE_OMIT_CHECK)
   223         -  { /* zName:     */ "ignore_check_constraints",
   224         -    /* ePragTyp:  */ PragTyp_FLAG,
   225         -    /* ePragFlag: */ 0,
   226         -    /* iArg:      */ SQLITE_IgnoreChecks },
          320  + {/* zName:     */ "ignore_check_constraints",
          321  +  /* ePragTyp:  */ PragTyp_FLAG,
          322  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns,
          323  +  /* ColNames:  */ 0, 0,
          324  +  /* iArg:      */ SQLITE_IgnoreChecks },
   227    325   #endif
   228    326   #endif
   229    327   #if !defined(SQLITE_OMIT_AUTOVACUUM)
   230         -  { /* zName:     */ "incremental_vacuum",
   231         -    /* ePragTyp:  */ PragTyp_INCREMENTAL_VACUUM,
   232         -    /* ePragFlag: */ PragFlag_NeedSchema,
   233         -    /* iArg:      */ 0 },
          328  + {/* zName:     */ "incremental_vacuum",
          329  +  /* ePragTyp:  */ PragTyp_INCREMENTAL_VACUUM,
          330  +  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_NoColumns,
          331  +  /* ColNames:  */ 0, 0,
          332  +  /* iArg:      */ 0 },
   234    333   #endif
   235    334   #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
   236         -  { /* zName:     */ "index_info",
   237         -    /* ePragTyp:  */ PragTyp_INDEX_INFO,
   238         -    /* ePragFlag: */ PragFlag_NeedSchema,
   239         -    /* iArg:      */ 0 },
   240         -  { /* zName:     */ "index_list",
   241         -    /* ePragTyp:  */ PragTyp_INDEX_LIST,
   242         -    /* ePragFlag: */ PragFlag_NeedSchema,
   243         -    /* iArg:      */ 0 },
   244         -  { /* zName:     */ "index_xinfo",
   245         -    /* ePragTyp:  */ PragTyp_INDEX_INFO,
   246         -    /* ePragFlag: */ PragFlag_NeedSchema,
   247         -    /* iArg:      */ 1 },
          335  + {/* zName:     */ "index_info",
          336  +  /* ePragTyp:  */ PragTyp_INDEX_INFO,
          337  +  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
          338  +  /* ColNames:  */ 11, 3,
          339  +  /* iArg:      */ 0 },
          340  + {/* zName:     */ "index_list",
          341  +  /* ePragTyp:  */ PragTyp_INDEX_LIST,
          342  +  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
          343  +  /* ColNames:  */ 20, 5,
          344  +  /* iArg:      */ 0 },
          345  + {/* zName:     */ "index_xinfo",
          346  +  /* ePragTyp:  */ PragTyp_INDEX_INFO,
          347  +  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
          348  +  /* ColNames:  */ 14, 6,
          349  +  /* iArg:      */ 1 },
   248    350   #endif
   249    351   #if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
   250         -  { /* zName:     */ "integrity_check",
   251         -    /* ePragTyp:  */ PragTyp_INTEGRITY_CHECK,
   252         -    /* ePragFlag: */ PragFlag_NeedSchema,
   253         -    /* iArg:      */ 0 },
          352  + {/* zName:     */ "integrity_check",
          353  +  /* ePragTyp:  */ PragTyp_INTEGRITY_CHECK,
          354  +  /* ePragFlg:  */ PragFlg_NeedSchema,
          355  +  /* ColNames:  */ 0, 0,
          356  +  /* iArg:      */ 0 },
   254    357   #endif
   255    358   #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
   256         -  { /* zName:     */ "journal_mode",
   257         -    /* ePragTyp:  */ PragTyp_JOURNAL_MODE,
   258         -    /* ePragFlag: */ PragFlag_NeedSchema,
   259         -    /* iArg:      */ 0 },
   260         -  { /* zName:     */ "journal_size_limit",
   261         -    /* ePragTyp:  */ PragTyp_JOURNAL_SIZE_LIMIT,
   262         -    /* ePragFlag: */ 0,
   263         -    /* iArg:      */ 0 },
          359  + {/* zName:     */ "journal_mode",
          360  +  /* ePragTyp:  */ PragTyp_JOURNAL_MODE,
          361  +  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
          362  +  /* ColNames:  */ 0, 0,
          363  +  /* iArg:      */ 0 },
          364  + {/* zName:     */ "journal_size_limit",
          365  +  /* ePragTyp:  */ PragTyp_JOURNAL_SIZE_LIMIT,
          366  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_SchemaReq,
          367  +  /* ColNames:  */ 0, 0,
          368  +  /* iArg:      */ 0 },
   264    369   #endif
   265    370   #if defined(SQLITE_HAS_CODEC)
   266         -  { /* zName:     */ "key",
   267         -    /* ePragTyp:  */ PragTyp_KEY,
   268         -    /* ePragFlag: */ 0,
   269         -    /* iArg:      */ 0 },
          371  + {/* zName:     */ "key",
          372  +  /* ePragTyp:  */ PragTyp_KEY,
          373  +  /* ePragFlg:  */ 0,
          374  +  /* ColNames:  */ 0, 0,
          375  +  /* iArg:      */ 0 },
   270    376   #endif
   271    377   #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
   272         -  { /* zName:     */ "legacy_file_format",
   273         -    /* ePragTyp:  */ PragTyp_FLAG,
   274         -    /* ePragFlag: */ 0,
   275         -    /* iArg:      */ SQLITE_LegacyFileFmt },
          378  + {/* zName:     */ "legacy_file_format",
          379  +  /* ePragTyp:  */ PragTyp_FLAG,
          380  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns,
          381  +  /* ColNames:  */ 0, 0,
          382  +  /* iArg:      */ SQLITE_LegacyFileFmt },
   276    383   #endif
   277    384   #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_ENABLE_LOCKING_STYLE
   278         -  { /* zName:     */ "lock_proxy_file",
   279         -    /* ePragTyp:  */ PragTyp_LOCK_PROXY_FILE,
   280         -    /* ePragFlag: */ 0,
   281         -    /* iArg:      */ 0 },
          385  + {/* zName:     */ "lock_proxy_file",
          386  +  /* ePragTyp:  */ PragTyp_LOCK_PROXY_FILE,
          387  +  /* ePragFlg:  */ 0,
          388  +  /* ColNames:  */ 0, 0,
          389  +  /* iArg:      */ 0 },
   282    390   #endif
   283    391   #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
   284         -  { /* zName:     */ "lock_status",
   285         -    /* ePragTyp:  */ PragTyp_LOCK_STATUS,
   286         -    /* ePragFlag: */ 0,
   287         -    /* iArg:      */ 0 },
          392  + {/* zName:     */ "lock_status",
          393  +  /* ePragTyp:  */ PragTyp_LOCK_STATUS,
          394  +  /* ePragFlg:  */ PragFlg_Result0,
          395  +  /* ColNames:  */ 46, 2,
          396  +  /* iArg:      */ 0 },
   288    397   #endif
   289    398   #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
   290         -  { /* zName:     */ "locking_mode",
   291         -    /* ePragTyp:  */ PragTyp_LOCKING_MODE,
   292         -    /* ePragFlag: */ 0,
   293         -    /* iArg:      */ 0 },
   294         -  { /* zName:     */ "max_page_count",
   295         -    /* ePragTyp:  */ PragTyp_PAGE_COUNT,
   296         -    /* ePragFlag: */ PragFlag_NeedSchema,
   297         -    /* iArg:      */ 0 },
   298         -  { /* zName:     */ "mmap_size",
   299         -    /* ePragTyp:  */ PragTyp_MMAP_SIZE,
   300         -    /* ePragFlag: */ 0,
   301         -    /* iArg:      */ 0 },
   302         -  { /* zName:     */ "page_count",
   303         -    /* ePragTyp:  */ PragTyp_PAGE_COUNT,
   304         -    /* ePragFlag: */ PragFlag_NeedSchema,
   305         -    /* iArg:      */ 0 },
   306         -  { /* zName:     */ "page_size",
   307         -    /* ePragTyp:  */ PragTyp_PAGE_SIZE,
   308         -    /* ePragFlag: */ 0,
   309         -    /* iArg:      */ 0 },
          399  + {/* zName:     */ "locking_mode",
          400  +  /* ePragTyp:  */ PragTyp_LOCKING_MODE,
          401  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_SchemaReq,
          402  +  /* ColNames:  */ 0, 0,
          403  +  /* iArg:      */ 0 },
          404  + {/* zName:     */ "max_page_count",
          405  +  /* ePragTyp:  */ PragTyp_PAGE_COUNT,
          406  +  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
          407  +  /* ColNames:  */ 0, 0,
          408  +  /* iArg:      */ 0 },
          409  + {/* zName:     */ "mmap_size",
          410  +  /* ePragTyp:  */ PragTyp_MMAP_SIZE,
          411  +  /* ePragFlg:  */ 0,
          412  +  /* ColNames:  */ 0, 0,
          413  +  /* iArg:      */ 0 },
          414  + {/* zName:     */ "page_count",
          415  +  /* ePragTyp:  */ PragTyp_PAGE_COUNT,
          416  +  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
          417  +  /* ColNames:  */ 0, 0,
          418  +  /* iArg:      */ 0 },
          419  + {/* zName:     */ "page_size",
          420  +  /* ePragTyp:  */ PragTyp_PAGE_SIZE,
          421  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_SchemaReq,
          422  +  /* ColNames:  */ 0, 0,
          423  +  /* iArg:      */ 0 },
   310    424   #endif
   311    425   #if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_PARSER_TRACE)
   312         -  { /* zName:     */ "parser_trace",
   313         -    /* ePragTyp:  */ PragTyp_PARSER_TRACE,
   314         -    /* ePragFlag: */ 0,
   315         -    /* iArg:      */ 0 },
          426  + {/* zName:     */ "parser_trace",
          427  +  /* ePragTyp:  */ PragTyp_PARSER_TRACE,
          428  +  /* ePragFlg:  */ 0,
          429  +  /* ColNames:  */ 0, 0,
          430  +  /* iArg:      */ 0 },
   316    431   #endif
   317    432   #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
   318         -  { /* zName:     */ "query_only",
   319         -    /* ePragTyp:  */ PragTyp_FLAG,
   320         -    /* ePragFlag: */ 0,
   321         -    /* iArg:      */ SQLITE_QueryOnly },
          433  + {/* zName:     */ "query_only",
          434  +  /* ePragTyp:  */ PragTyp_FLAG,
          435  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns,
          436  +  /* ColNames:  */ 0, 0,
          437  +  /* iArg:      */ SQLITE_QueryOnly },
   322    438   #endif
   323    439   #if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
   324         -  { /* zName:     */ "quick_check",
   325         -    /* ePragTyp:  */ PragTyp_INTEGRITY_CHECK,
   326         -    /* ePragFlag: */ PragFlag_NeedSchema,
   327         -    /* iArg:      */ 0 },
          440  + {/* zName:     */ "quick_check",
          441  +  /* ePragTyp:  */ PragTyp_INTEGRITY_CHECK,
          442  +  /* ePragFlg:  */ PragFlg_NeedSchema,
          443  +  /* ColNames:  */ 0, 0,
          444  +  /* iArg:      */ 0 },
   328    445   #endif
   329    446   #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
   330         -  { /* zName:     */ "read_uncommitted",
   331         -    /* ePragTyp:  */ PragTyp_FLAG,
   332         -    /* ePragFlag: */ 0,
   333         -    /* iArg:      */ SQLITE_ReadUncommitted },
   334         -  { /* zName:     */ "recursive_triggers",
   335         -    /* ePragTyp:  */ PragTyp_FLAG,
   336         -    /* ePragFlag: */ 0,
   337         -    /* iArg:      */ SQLITE_RecTriggers },
          447  + {/* zName:     */ "read_uncommitted",
          448  +  /* ePragTyp:  */ PragTyp_FLAG,
          449  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns,
          450  +  /* ColNames:  */ 0, 0,
          451  +  /* iArg:      */ SQLITE_ReadUncommitted },
          452  + {/* zName:     */ "recursive_triggers",
          453  +  /* ePragTyp:  */ PragTyp_FLAG,
          454  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns,
          455  +  /* ColNames:  */ 0, 0,
          456  +  /* iArg:      */ SQLITE_RecTriggers },
   338    457   #endif
   339    458   #if defined(SQLITE_HAS_CODEC)
   340         -  { /* zName:     */ "rekey",
   341         -    /* ePragTyp:  */ PragTyp_REKEY,
   342         -    /* ePragFlag: */ 0,
   343         -    /* iArg:      */ 0 },
          459  + {/* zName:     */ "rekey",
          460  +  /* ePragTyp:  */ PragTyp_REKEY,
          461  +  /* ePragFlg:  */ 0,
          462  +  /* ColNames:  */ 0, 0,
          463  +  /* iArg:      */ 0 },
   344    464   #endif
   345    465   #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
   346         -  { /* zName:     */ "reverse_unordered_selects",
   347         -    /* ePragTyp:  */ PragTyp_FLAG,
   348         -    /* ePragFlag: */ 0,
   349         -    /* iArg:      */ SQLITE_ReverseOrder },
          466  + {/* zName:     */ "reverse_unordered_selects",
          467  +  /* ePragTyp:  */ PragTyp_FLAG,
          468  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns,
          469  +  /* ColNames:  */ 0, 0,
          470  +  /* iArg:      */ SQLITE_ReverseOrder },
   350    471   #endif
   351    472   #if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
   352         -  { /* zName:     */ "schema_version",
   353         -    /* ePragTyp:  */ PragTyp_HEADER_VALUE,
   354         -    /* ePragFlag: */ 0,
   355         -    /* iArg:      */ BTREE_SCHEMA_VERSION },
          473  + {/* zName:     */ "schema_version",
          474  +  /* ePragTyp:  */ PragTyp_HEADER_VALUE,
          475  +  /* ePragFlg:  */ PragFlg_Result0,
          476  +  /* ColNames:  */ 0, 0,
          477  +  /* iArg:      */ BTREE_SCHEMA_VERSION },
   356    478   #endif
   357    479   #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
   358         -  { /* zName:     */ "secure_delete",
   359         -    /* ePragTyp:  */ PragTyp_SECURE_DELETE,
   360         -    /* ePragFlag: */ 0,
   361         -    /* iArg:      */ 0 },
          480  + {/* zName:     */ "secure_delete",
          481  +  /* ePragTyp:  */ PragTyp_SECURE_DELETE,
          482  +  /* ePragFlg:  */ PragFlg_Result0,
          483  +  /* ColNames:  */ 0, 0,
          484  +  /* iArg:      */ 0 },
   362    485   #endif
   363    486   #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
   364         -  { /* zName:     */ "short_column_names",
   365         -    /* ePragTyp:  */ PragTyp_FLAG,
   366         -    /* ePragFlag: */ 0,
   367         -    /* iArg:      */ SQLITE_ShortColNames },
          487  + {/* zName:     */ "short_column_names",
          488  +  /* ePragTyp:  */ PragTyp_FLAG,
          489  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns,
          490  +  /* ColNames:  */ 0, 0,
          491  +  /* iArg:      */ SQLITE_ShortColNames },
   368    492   #endif
   369         -  { /* zName:     */ "shrink_memory",
   370         -    /* ePragTyp:  */ PragTyp_SHRINK_MEMORY,
   371         -    /* ePragFlag: */ 0,
   372         -    /* iArg:      */ 0 },
   373         -  { /* zName:     */ "soft_heap_limit",
   374         -    /* ePragTyp:  */ PragTyp_SOFT_HEAP_LIMIT,
   375         -    /* ePragFlag: */ 0,
   376         -    /* iArg:      */ 0 },
          493  + {/* zName:     */ "shrink_memory",
          494  +  /* ePragTyp:  */ PragTyp_SHRINK_MEMORY,
          495  +  /* ePragFlg:  */ 0,
          496  +  /* ColNames:  */ 0, 0,
          497  +  /* iArg:      */ 0 },
          498  + {/* zName:     */ "soft_heap_limit",
          499  +  /* ePragTyp:  */ PragTyp_SOFT_HEAP_LIMIT,
          500  +  /* ePragFlg:  */ PragFlg_Result0,
          501  +  /* ColNames:  */ 0, 0,
          502  +  /* iArg:      */ 0 },
   377    503   #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
   378    504   #if defined(SQLITE_DEBUG)
   379         -  { /* zName:     */ "sql_trace",
   380         -    /* ePragTyp:  */ PragTyp_FLAG,
   381         -    /* ePragFlag: */ 0,
   382         -    /* iArg:      */ SQLITE_SqlTrace },
          505  + {/* zName:     */ "sql_trace",
          506  +  /* ePragTyp:  */ PragTyp_FLAG,
          507  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns,
          508  +  /* ColNames:  */ 0, 0,
          509  +  /* iArg:      */ SQLITE_SqlTrace },
   383    510   #endif
   384    511   #endif
   385    512   #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
   386         -  { /* zName:     */ "stats",
   387         -    /* ePragTyp:  */ PragTyp_STATS,
   388         -    /* ePragFlag: */ PragFlag_NeedSchema,
   389         -    /* iArg:      */ 0 },
          513  + {/* zName:     */ "stats",
          514  +  /* ePragTyp:  */ PragTyp_STATS,
          515  +  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
          516  +  /* ColNames:  */ 7, 4,
          517  +  /* iArg:      */ 0 },
   390    518   #endif
   391    519   #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
   392         -  { /* zName:     */ "synchronous",
   393         -    /* ePragTyp:  */ PragTyp_SYNCHRONOUS,
   394         -    /* ePragFlag: */ PragFlag_NeedSchema,
   395         -    /* iArg:      */ 0 },
          520  + {/* zName:     */ "synchronous",
          521  +  /* ePragTyp:  */ PragTyp_SYNCHRONOUS,
          522  +  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
          523  +  /* ColNames:  */ 0, 0,
          524  +  /* iArg:      */ 0 },
   396    525   #endif
   397    526   #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
   398         -  { /* zName:     */ "table_info",
   399         -    /* ePragTyp:  */ PragTyp_TABLE_INFO,
   400         -    /* ePragFlag: */ PragFlag_NeedSchema,
   401         -    /* iArg:      */ 0 },
          527  + {/* zName:     */ "table_info",
          528  +  /* ePragTyp:  */ PragTyp_TABLE_INFO,
          529  +  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
          530  +  /* ColNames:  */ 1, 6,
          531  +  /* iArg:      */ 0 },
   402    532   #endif
   403    533   #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
   404         -  { /* zName:     */ "temp_store",
   405         -    /* ePragTyp:  */ PragTyp_TEMP_STORE,
   406         -    /* ePragFlag: */ 0,
   407         -    /* iArg:      */ 0 },
   408         -  { /* zName:     */ "temp_store_directory",
   409         -    /* ePragTyp:  */ PragTyp_TEMP_STORE_DIRECTORY,
   410         -    /* ePragFlag: */ 0,
   411         -    /* iArg:      */ 0 },
          534  + {/* zName:     */ "temp_store",
          535  +  /* ePragTyp:  */ PragTyp_TEMP_STORE,
          536  +  /* ePragFlg:  */ PragFlg_Result0,
          537  +  /* ColNames:  */ 0, 0,
          538  +  /* iArg:      */ 0 },
          539  + {/* zName:     */ "temp_store_directory",
          540  +  /* ePragTyp:  */ PragTyp_TEMP_STORE_DIRECTORY,
          541  +  /* ePragFlg:  */ 0,
          542  +  /* ColNames:  */ 0, 0,
          543  +  /* iArg:      */ 0 },
   412    544   #endif
   413         -  { /* zName:     */ "threads",
   414         -    /* ePragTyp:  */ PragTyp_THREADS,
   415         -    /* ePragFlag: */ 0,
   416         -    /* iArg:      */ 0 },
          545  + {/* zName:     */ "threads",
          546  +  /* ePragTyp:  */ PragTyp_THREADS,
          547  +  /* ePragFlg:  */ PragFlg_Result0,
          548  +  /* ColNames:  */ 0, 0,
          549  +  /* iArg:      */ 0 },
   417    550   #if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
   418         -  { /* zName:     */ "user_version",
   419         -    /* ePragTyp:  */ PragTyp_HEADER_VALUE,
   420         -    /* ePragFlag: */ 0,
   421         -    /* iArg:      */ BTREE_USER_VERSION },
          551  + {/* zName:     */ "user_version",
          552  +  /* ePragTyp:  */ PragTyp_HEADER_VALUE,
          553  +  /* ePragFlg:  */ PragFlg_Result0,
          554  +  /* ColNames:  */ 0, 0,
          555  +  /* iArg:      */ BTREE_USER_VERSION },
   422    556   #endif
   423    557   #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
   424    558   #if defined(SQLITE_DEBUG)
   425         -  { /* zName:     */ "vdbe_addoptrace",
   426         -    /* ePragTyp:  */ PragTyp_FLAG,
   427         -    /* ePragFlag: */ 0,
   428         -    /* iArg:      */ SQLITE_VdbeAddopTrace },
   429         -  { /* zName:     */ "vdbe_debug",
   430         -    /* ePragTyp:  */ PragTyp_FLAG,
   431         -    /* ePragFlag: */ 0,
   432         -    /* iArg:      */ SQLITE_SqlTrace|SQLITE_VdbeListing|SQLITE_VdbeTrace },
   433         -  { /* zName:     */ "vdbe_eqp",
   434         -    /* ePragTyp:  */ PragTyp_FLAG,
   435         -    /* ePragFlag: */ 0,
   436         -    /* iArg:      */ SQLITE_VdbeEQP },
   437         -  { /* zName:     */ "vdbe_listing",
   438         -    /* ePragTyp:  */ PragTyp_FLAG,
   439         -    /* ePragFlag: */ 0,
   440         -    /* iArg:      */ SQLITE_VdbeListing },
   441         -  { /* zName:     */ "vdbe_trace",
   442         -    /* ePragTyp:  */ PragTyp_FLAG,
   443         -    /* ePragFlag: */ 0,
   444         -    /* iArg:      */ SQLITE_VdbeTrace },
          559  + {/* zName:     */ "vdbe_addoptrace",
          560  +  /* ePragTyp:  */ PragTyp_FLAG,
          561  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns,
          562  +  /* ColNames:  */ 0, 0,
          563  +  /* iArg:      */ SQLITE_VdbeAddopTrace },
          564  + {/* zName:     */ "vdbe_debug",
          565  +  /* ePragTyp:  */ PragTyp_FLAG,
          566  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns,
          567  +  /* ColNames:  */ 0, 0,
          568  +  /* iArg:      */ SQLITE_SqlTrace|SQLITE_VdbeListing|SQLITE_VdbeTrace },
          569  + {/* zName:     */ "vdbe_eqp",
          570  +  /* ePragTyp:  */ PragTyp_FLAG,
          571  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns,
          572  +  /* ColNames:  */ 0, 0,
          573  +  /* iArg:      */ SQLITE_VdbeEQP },
          574  + {/* zName:     */ "vdbe_listing",
          575  +  /* ePragTyp:  */ PragTyp_FLAG,
          576  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns,
          577  +  /* ColNames:  */ 0, 0,
          578  +  /* iArg:      */ SQLITE_VdbeListing },
          579  + {/* zName:     */ "vdbe_trace",
          580  +  /* ePragTyp:  */ PragTyp_FLAG,
          581  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns,
          582  +  /* ColNames:  */ 0, 0,
          583  +  /* iArg:      */ SQLITE_VdbeTrace },
   445    584   #endif
   446    585   #endif
   447    586   #if !defined(SQLITE_OMIT_WAL)
   448         -  { /* zName:     */ "wal_autocheckpoint",
   449         -    /* ePragTyp:  */ PragTyp_WAL_AUTOCHECKPOINT,
   450         -    /* ePragFlag: */ 0,
   451         -    /* iArg:      */ 0 },
   452         -  { /* zName:     */ "wal_checkpoint",
   453         -    /* ePragTyp:  */ PragTyp_WAL_CHECKPOINT,
   454         -    /* ePragFlag: */ PragFlag_NeedSchema,
   455         -    /* iArg:      */ 0 },
          587  + {/* zName:     */ "wal_autocheckpoint",
          588  +  /* ePragTyp:  */ PragTyp_WAL_AUTOCHECKPOINT,
          589  +  /* ePragFlg:  */ 0,
          590  +  /* ColNames:  */ 0, 0,
          591  +  /* iArg:      */ 0 },
          592  + {/* zName:     */ "wal_checkpoint",
          593  +  /* ePragTyp:  */ PragTyp_WAL_CHECKPOINT,
          594  +  /* ePragFlg:  */ PragFlg_NeedSchema,
          595  +  /* ColNames:  */ 42, 3,
          596  +  /* iArg:      */ 0 },
   456    597   #endif
   457    598   #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
   458         -  { /* zName:     */ "writable_schema",
   459         -    /* ePragTyp:  */ PragTyp_FLAG,
   460         -    /* ePragFlag: */ 0,
   461         -    /* iArg:      */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
          599  + {/* zName:     */ "writable_schema",
          600  +  /* ePragTyp:  */ PragTyp_FLAG,
          601  +  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns,
          602  +  /* ColNames:  */ 0, 0,
          603  +  /* iArg:      */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
   462    604   #endif
   463    605   };
   464    606   /* Number of pragmas: 60 on by default, 73 total. */

Changes to src/sqliteInt.h.

  3559   3559   void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);
  3560   3560   void sqlite3ExprListSetSpan(Parse*,ExprList*,ExprSpan*);
  3561   3561   void sqlite3ExprListDelete(sqlite3*, ExprList*);
  3562   3562   u32 sqlite3ExprListFlags(const ExprList*);
  3563   3563   int sqlite3Init(sqlite3*, char**);
  3564   3564   int sqlite3InitCallback(void*, int, char**, char**);
  3565   3565   void sqlite3Pragma(Parse*,Token*,Token*,Token*,int);
         3566  +#ifndef SQLITE_OMIT_VIRTUALTABLE
         3567  +Module *sqlite3PragmaVtabRegister(sqlite3*,const char *zName);
         3568  +#endif
  3566   3569   void sqlite3ResetAllSchemasOfConnection(sqlite3*);
  3567   3570   void sqlite3ResetOneSchema(sqlite3*,int);
  3568   3571   void sqlite3CollapseDatabaseArray(sqlite3*);
  3569   3572   void sqlite3CommitInternalChanges(sqlite3*);
  3570   3573   void sqlite3DeleteColumnNames(sqlite3*,Table*);
  3571   3574   int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**);
  3572   3575   void sqlite3SelectAddColumnTypeAndCollation(Parse*,Table*,Select*);
................................................................................
  4073   4076      int sqlite3VtabCommit(sqlite3 *db);
  4074   4077      void sqlite3VtabLock(VTable *);
  4075   4078      void sqlite3VtabUnlock(VTable *);
  4076   4079      void sqlite3VtabUnlockList(sqlite3*);
  4077   4080      int sqlite3VtabSavepoint(sqlite3 *, int, int);
  4078   4081      void sqlite3VtabImportErrmsg(Vdbe*, sqlite3_vtab*);
  4079   4082      VTable *sqlite3GetVTable(sqlite3*, Table*);
         4083  +   Module *sqlite3VtabCreateModule(
         4084  +     sqlite3*,
         4085  +     const char*,
         4086  +     const sqlite3_module*,
         4087  +     void*,
         4088  +     void(*)(void*)
         4089  +   );
  4080   4090   #  define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0)
  4081   4091   #endif
  4082   4092   int sqlite3VtabEponymousTableInit(Parse*,Module*);
  4083   4093   void sqlite3VtabEponymousTableClear(sqlite3*,Module*);
  4084   4094   void sqlite3VtabMakeWritable(Parse*,Table*);
  4085   4095   void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token*, int);
  4086   4096   void sqlite3VtabFinishParse(Parse*, Token*);

Changes to src/trigger.c.

   304    304       /* Make an entry in the sqlite_master table */
   305    305       v = sqlite3GetVdbe(pParse);
   306    306       if( v==0 ) goto triggerfinish_cleanup;
   307    307       sqlite3BeginWriteOperation(pParse, 0, iDb);
   308    308       z = sqlite3DbStrNDup(db, (char*)pAll->z, pAll->n);
   309    309       sqlite3NestedParse(pParse,
   310    310          "INSERT INTO %Q.%s VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')",
   311         -       db->aDb[iDb].zDbSName, SCHEMA_TABLE(iDb), zName,
          311  +       db->aDb[iDb].zDbSName, MASTER_NAME, zName,
   312    312          pTrig->table, z);
   313    313       sqlite3DbFree(db, z);
   314    314       sqlite3ChangeCookie(pParse, iDb);
   315    315       sqlite3VdbeAddParseSchemaOp(v, iDb,
   316    316           sqlite3MPrintf(db, "type='trigger' AND name='%q'", zName));
   317    317     }
   318    318   
................................................................................
   555    555   
   556    556     /* Generate code to destroy the database record of the trigger.
   557    557     */
   558    558     assert( pTable!=0 );
   559    559     if( (v = sqlite3GetVdbe(pParse))!=0 ){
   560    560       sqlite3NestedParse(pParse,
   561    561          "DELETE FROM %Q.%s WHERE name=%Q AND type='trigger'",
   562         -       db->aDb[iDb].zDbSName, SCHEMA_TABLE(iDb), pTrigger->zName
          562  +       db->aDb[iDb].zDbSName, MASTER_NAME, pTrigger->zName
   563    563       );
   564    564       sqlite3ChangeCookie(pParse, iDb);
   565    565       sqlite3VdbeAddOp4(v, OP_DropTrigger, iDb, 0, 0, pTrigger->zName, 0);
   566    566     }
   567    567   }
   568    568   
   569    569   /*

Changes to src/vdbe.c.

  5475   5475     }
  5476   5476   #endif
  5477   5477   
  5478   5478     iDb = pOp->p1;
  5479   5479     assert( iDb>=0 && iDb<db->nDb );
  5480   5480     assert( DbHasProperty(db, iDb, DB_SchemaLoaded) );
  5481   5481     /* Used to be a conditional */ {
  5482         -    zMaster = SCHEMA_TABLE(iDb);
         5482  +    zMaster = MASTER_NAME;
  5483   5483       initData.db = db;
  5484   5484       initData.iDb = pOp->p1;
  5485   5485       initData.pzErrMsg = &p->zErrMsg;
  5486   5486       zSql = sqlite3MPrintf(db,
  5487   5487          "SELECT name, rootpage, sql FROM '%q'.%s WHERE %s ORDER BY rowid",
  5488   5488          db->aDb[iDb].zDbSName, zMaster, pOp->p4.z);
  5489   5489       if( zSql==0 ){

Changes to src/vtab.c.

    23     23   */
    24     24   struct VtabCtx {
    25     25     VTable *pVTable;    /* The virtual table being constructed */
    26     26     Table *pTab;        /* The Table object to which the virtual table belongs */
    27     27     VtabCtx *pPrior;    /* Parent context (if any) */
    28     28     int bDeclared;      /* True after sqlite3_declare_vtab() is called */
    29     29   };
           30  +
           31  +/*
           32  +** Construct and install a Module object for a virtual table.  When this
           33  +** routine is called, it is guaranteed that all appropriate locks are held
           34  +** and the module is not already part of the connection.
           35  +*/
           36  +Module *sqlite3VtabCreateModule(
           37  +  sqlite3 *db,                    /* Database in which module is registered */
           38  +  const char *zName,              /* Name assigned to this module */
           39  +  const sqlite3_module *pModule,  /* The definition of the module */
           40  +  void *pAux,                     /* Context pointer for xCreate/xConnect */
           41  +  void (*xDestroy)(void *)        /* Module destructor function */
           42  +){
           43  +  Module *pMod;
           44  +  int nName = sqlite3Strlen30(zName);
           45  +  pMod = (Module *)sqlite3DbMallocRawNN(db, sizeof(Module) + nName + 1);
           46  +  if( pMod ){
           47  +    Module *pDel;
           48  +    char *zCopy = (char *)(&pMod[1]);
           49  +    memcpy(zCopy, zName, nName+1);
           50  +    pMod->zName = zCopy;
           51  +    pMod->pModule = pModule;
           52  +    pMod->pAux = pAux;
           53  +    pMod->xDestroy = xDestroy;
           54  +    pMod->pEpoTab = 0;
           55  +    pDel = (Module *)sqlite3HashInsert(&db->aModule,zCopy,(void*)pMod);
           56  +    assert( pDel==0 || pDel==pMod );
           57  +    if( pDel ){
           58  +      sqlite3OomFault(db);
           59  +      sqlite3DbFree(db, pDel);
           60  +      pMod = 0;
           61  +    }
           62  +  }
           63  +  return pMod;
           64  +}
    30     65   
    31     66   /*
    32     67   ** The actual function that does the work of creating a new module.
    33     68   ** This function implements the sqlite3_create_module() and
    34     69   ** sqlite3_create_module_v2() interfaces.
    35     70   */
    36     71   static int createModule(
................................................................................
    37     72     sqlite3 *db,                    /* Database in which module is registered */
    38     73     const char *zName,              /* Name assigned to this module */
    39     74     const sqlite3_module *pModule,  /* The definition of the module */
    40     75     void *pAux,                     /* Context pointer for xCreate/xConnect */
    41     76     void (*xDestroy)(void *)        /* Module destructor function */
    42     77   ){
    43     78     int rc = SQLITE_OK;
    44         -  int nName;
    45     79   
    46     80     sqlite3_mutex_enter(db->mutex);
    47         -  nName = sqlite3Strlen30(zName);
    48     81     if( sqlite3HashFind(&db->aModule, zName) ){
    49     82       rc = SQLITE_MISUSE_BKPT;
    50     83     }else{
    51         -    Module *pMod;
    52         -    pMod = (Module *)sqlite3DbMallocRawNN(db, sizeof(Module) + nName + 1);
    53         -    if( pMod ){
    54         -      Module *pDel;
    55         -      char *zCopy = (char *)(&pMod[1]);
    56         -      memcpy(zCopy, zName, nName+1);
    57         -      pMod->zName = zCopy;
    58         -      pMod->pModule = pModule;
    59         -      pMod->pAux = pAux;
    60         -      pMod->xDestroy = xDestroy;
    61         -      pMod->pEpoTab = 0;
    62         -      pDel = (Module *)sqlite3HashInsert(&db->aModule,zCopy,(void*)pMod);
    63         -      assert( pDel==0 || pDel==pMod );
    64         -      if( pDel ){
    65         -        sqlite3OomFault(db);
    66         -        sqlite3DbFree(db, pDel);
    67         -      }
    68         -    }
           84  +    (void)sqlite3VtabCreateModule(db, zName, pModule, pAux, xDestroy);
    69     85     }
    70     86     rc = sqlite3ApiExit(db, rc);
    71     87     if( rc!=SQLITE_OK && xDestroy ) xDestroy(pAux);
    72         -
    73     88     sqlite3_mutex_leave(db->mutex);
    74     89     return rc;
    75     90   }
    76     91   
    77     92   
    78     93   /*
    79     94   ** External API function used to create a new virtual-table module.
................................................................................
   404    419       ** by sqlite3StartTable().
   405    420       */
   406    421       iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
   407    422       sqlite3NestedParse(pParse,
   408    423         "UPDATE %Q.%s "
   409    424            "SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q "
   410    425          "WHERE rowid=#%d",
   411         -      db->aDb[iDb].zDbSName, SCHEMA_TABLE(iDb),
          426  +      db->aDb[iDb].zDbSName, MASTER_NAME,
   412    427         pTab->zName,
   413    428         pTab->zName,
   414    429         zStmt,
   415    430         pParse->regRowid
   416    431       );
   417    432       sqlite3DbFree(db, zStmt);
   418    433       v = sqlite3GetVdbe(pParse);

Changes to test/alter.test.

    73     73       CREATE $::temp TABLE objlist(type, name, tbl_name);
    74     74       INSERT INTO objlist SELECT type, name, tbl_name 
    75     75           FROM sqlite_master WHERE NAME!='objlist';
    76     76     }]
    77     77     ifcapable tempdb {
    78     78       execsql {
    79     79         INSERT INTO objlist SELECT type, name, tbl_name 
    80         -          FROM sqlite_temp_master WHERE NAME!='objlist';
           80  +          FROM temp.sqlite_master WHERE NAME!='objlist';
    81     81       }
    82     82     }
    83     83   
    84     84     execsql {
    85     85       SELECT type, name, tbl_name FROM objlist ORDER BY tbl_name, type desc, name;
    86     86     }
    87     87   } [list \
................................................................................
   149    149       db close
   150    150       sqlite3 db test.db
   151    151       set DB [sqlite3_connection_pointer db]
   152    152       execsql {
   153    153         CREATE TEMP TABLE objlist(type, name, tbl_name);
   154    154         INSERT INTO objlist SELECT type, name, tbl_name FROM sqlite_master;
   155    155         INSERT INTO objlist 
   156         -          SELECT type, name, tbl_name FROM sqlite_temp_master 
          156  +          SELECT type, name, tbl_name FROM temp.sqlite_master 
   157    157             WHERE NAME!='objlist';
   158    158         SELECT type, name, tbl_name FROM objlist 
   159    159             ORDER BY tbl_name, type desc, name;
   160    160       }
   161    161     } [list \
   162    162          table -t1-                         -t1-           \
   163    163          index t1i1                         -t1-           \
................................................................................
   520    520     execsql {
   521    521       DROP TABLE tbl3;
   522    522     }
   523    523   } {}
   524    524   ifcapable tempdb {
   525    525     do_test alter-3.3.8 {
   526    526       execsql {
   527         -      SELECT * FROM sqlite_temp_master WHERE type = 'trigger';
          527  +      SELECT * FROM temp.sqlite_master WHERE type = 'trigger';
   528    528       }
   529    529     } {}
   530    530   }
   531    531   
   532    532   } ;# ifcapable trigger
   533    533   
   534    534   # If the build does not include AUTOINCREMENT fields, omit alter-4.*.

Changes to test/alter4.test.

    40     40   #
    41     41   
    42     42   do_test alter4-1.1 {
    43     43     execsql {
    44     44       CREATE TEMP TABLE abc(a, b, c);
    45     45       SELECT sql FROM sqlite_temp_master;
    46     46     }
           47  +} {{CREATE TABLE abc(a, b, c)}}
           48  +do_test alter4-1.1b {
           49  +  execsql {
           50  +    SELECT sql FROM temp.sqlite_master;
           51  +  }
    47     52   } {{CREATE TABLE abc(a, b, c)}}
    48     53   do_test alter4-1.2 {
    49     54     execsql {ALTER TABLE abc ADD d INTEGER;}
    50     55     execsql {
    51     56       SELECT sql FROM sqlite_temp_master;
           57  +  }
           58  +} {{CREATE TABLE abc(a, b, c, d INTEGER)}}
           59  +do_test alter4-1.2b {
           60  +  execsql {
           61  +    SELECT sql FROM temp.sqlite_master;
    52     62     }
    53     63   } {{CREATE TABLE abc(a, b, c, d INTEGER)}}
    54     64   do_test alter4-1.3 {
    55     65     execsql {ALTER TABLE abc ADD e}
    56     66     execsql {
    57     67       SELECT sql FROM sqlite_temp_master;
           68  +  }
           69  +} {{CREATE TABLE abc(a, b, c, d INTEGER, e)}}
           70  +do_test alter4-1.3b {
           71  +  execsql {
           72  +    SELECT sql FROM temp.sqlite_master;
    58     73     }
    59     74   } {{CREATE TABLE abc(a, b, c, d INTEGER, e)}}
    60     75   do_test alter4-1.4 {
    61     76     execsql {
    62     77       CREATE TABLE temp.t1(a, b);
    63     78       ALTER TABLE t1 ADD c;
    64     79       SELECT sql FROM sqlite_temp_master WHERE tbl_name = 't1';
    65     80     }
           81  +} {{CREATE TABLE t1(a, b, c)}}
           82  +do_test alter4-1.4b {
           83  +  execsql {
           84  +    SELECT sql FROM temp.sqlite_master WHERE tbl_name = 't1';
           85  +  }
    66     86   } {{CREATE TABLE t1(a, b, c)}}
    67     87   do_test alter4-1.5 {
    68     88     execsql {
    69     89       ALTER TABLE t1 ADD d CHECK (a>d);
    70     90       SELECT sql FROM sqlite_temp_master WHERE tbl_name = 't1';
    71     91     }
    72     92   } {{CREATE TABLE t1(a, b, c, d CHECK (a>d))}}

Changes to test/attach.test.

   189    189   ifcapable schema_pragmas {
   190    190   do_test attach-1.20.2 {
   191    191     db_list db
   192    192   } {0 main 2 db2 3 db3 4 db4 5 db6 6 db7 7 db8 8 db9 9 db10 10 db11}
   193    193   } ;# ifcapable schema_pragmas
   194    194   integrity_check attach-1.20.3
   195    195   ifcapable tempdb {
   196         -  execsql {select * from sqlite_temp_master}
          196  +  execsql {select * from temp.sqlite_master}
   197    197   }
   198    198   do_test attach-1.21 {
   199    199     catchsql {
   200    200       ATTACH 'test.db' as db12;
   201    201     }
   202    202   } {0 {}}
   203    203   if {$SQLITE_MAX_ATTACHED==10} {

Changes to test/attach3.test.

   203    203     do_test attach3-9.0 {
   204    204       execsql {
   205    205         CREATE TABLE main.t4(a, b, c);
   206    206         CREATE TABLE aux.t4(a, b, c);
   207    207         CREATE TEMP TRIGGER tst_trigger BEFORE INSERT ON aux.t4 BEGIN 
   208    208           SELECT 'hello world';
   209    209         END;
   210         -      SELECT count(*) FROM sqlite_temp_master;
          210  +      SELECT count(*) FROM temp.sqlite_master;
   211    211       }
   212    212     } {1}
   213    213     do_test attach3-9.1 {
   214    214       execsql {
   215    215         DROP TABLE main.t4;
   216    216         SELECT count(*) FROM sqlite_temp_master;
   217    217       }
   218    218     } {1}
   219    219     do_test attach3-9.2 {
   220    220       execsql {
   221    221         DROP TABLE aux.t4;
   222         -      SELECT count(*) FROM sqlite_temp_master;
          222  +      SELECT count(*) FROM temp.sqlite_master;
   223    223       }
   224    224     } {0}
   225    225   }
   226    226   } ;# endif trigger
   227    227   
   228    228   # Make sure the aux.sqlite_master table is read-only
   229    229   do_test attach3-10.0 {

Changes to test/auth.test.

    87     87           return SQLITE_DENY
    88     88         }
    89     89         return SQLITE_OK
    90     90       }
    91     91       catchsql {CREATE TEMP TABLE t1(a,b,c)}
    92     92     } {1 {not authorized}}
    93     93     do_test auth-1.6 {
    94         -    execsql {SELECT name FROM sqlite_temp_master}
           94  +    execsql {SELECT name FROM temp.sqlite_master}
    95     95     } {}
    96     96     do_test auth-1.7.1 {
    97     97       proc auth {code arg1 arg2 arg3 arg4 args} {
    98     98         if {$code=="SQLITE_CREATE_TEMP_TABLE"} {
    99     99           set ::authargs [list $arg1 $arg2 $arg3 $arg4]
   100    100           return SQLITE_DENY
   101    101         }
................................................................................
   144    144           return SQLITE_IGNORE
   145    145         }
   146    146         return SQLITE_OK
   147    147       }
   148    148       catchsql {CREATE TEMP TABLE t1(a,b,c)}
   149    149     } {0 {}}
   150    150     do_test auth-1.14 {
   151         -    execsql {SELECT name FROM sqlite_temp_master}
          151  +    execsql {SELECT name FROM temp.sqlite_master}
   152    152     } {}
   153    153     do_test auth-1.15 {
   154    154       proc auth {code arg1 arg2 arg3 arg4 args} {
   155    155         if {$code=="SQLITE_CREATE_TEMP_TABLE"} {
   156    156           set ::authargs [list $arg1 $arg2 $arg3 $arg4]
   157    157           return SQLITE_IGNORE
   158    158         }
................................................................................
   557    557            return SQLITE_IGNORE
   558    558         }
   559    559         return SQLITE_OK
   560    560       }
   561    561       catchsql {DROP TABLE t1}
   562    562     } {0 {}}
   563    563     do_test auth-1.78 {
   564         -    execsql {SELECT name FROM sqlite_temp_master}
          564  +    execsql {SELECT name FROM temp.sqlite_master}
   565    565     } {t1}
   566    566   }
   567    567   
   568    568   # Test cases auth-1.79 to auth-1.124 test creating and dropping views.
   569    569   # Omit these if the library was compiled with views omitted.
   570    570   ifcapable view {
   571    571   do_test auth-1.79 {
................................................................................
   628    628       }
   629    629       catchsql {CREATE TEMPORARY VIEW v1 AS SELECT a+1,b+1 FROM t2}
   630    630     } {0 {}}
   631    631     do_test auth-1.89 {
   632    632       set ::authargs
   633    633     } {v1 {} temp {}}
   634    634     do_test auth-1.90 {
   635         -    execsql {SELECT name FROM sqlite_temp_master}
          635  +    execsql {SELECT name FROM temp.sqlite_master}
   636    636     } {t1}
   637    637   }
   638    638   
   639    639   do_test auth-1.91 {
   640    640     proc auth {code arg1 arg2 arg3 arg4 args} {
   641    641       if {$code=="SQLITE_INSERT" && $arg1=="sqlite_master"} {
   642    642         return SQLITE_DENY
................................................................................
   775    775       }
   776    776       catchsql {
   777    777         CREATE TEMP VIEW v1 AS SELECT a+1,b+1 FROM t1;
   778    778         DROP VIEW v1
   779    779       }
   780    780     } {1 {not authorized}}
   781    781     do_test auth-1.113 {
   782         -    execsql {SELECT name FROM sqlite_temp_master}
          782  +    execsql {SELECT name FROM temp.sqlite_master}
   783    783     } {t1 v1}
   784    784     do_test auth-1.114 {
   785    785       proc auth {code arg1 arg2 arg3 arg4 args} {
   786    786         if {$code=="SQLITE_DROP_TEMP_VIEW"} {
   787    787           set ::authargs [list $arg1 $arg2 $arg3 $arg4]
   788    788           return SQLITE_DENY
   789    789         }
................................................................................
   819    819       }
   820    820       catchsql {DROP VIEW v1}
   821    821     } {0 {}}
   822    822     do_test auth-1.120 {
   823    823       set ::authargs
   824    824     } {v1 {} temp {}}
   825    825     do_test auth-1.121 {
   826         -    execsql {SELECT name FROM sqlite_temp_master}
          826  +    execsql {SELECT name FROM temp.sqlite_master}
   827    827     } {t1 v1}
   828    828     do_test auth-1.122 {
   829    829       proc auth {code arg1 arg2 arg3 arg4 args} {
   830    830         if {$code=="SQLITE_DROP_TEMP_VIEW"} {
   831    831           set ::authargs [list $arg1 $arg2 $arg3 $arg4]
   832    832           return SQLITE_OK
   833    833         }
................................................................................
   976    976       END;
   977    977     }
   978    978   } {1 {not authorized}}
   979    979   do_test auth-1.139 {
   980    980     set ::authargs
   981    981   } {r1 t1 temp {}}
   982    982   do_test auth-1.140 {
   983         -  execsql {SELECT name FROM sqlite_temp_master}
          983  +  execsql {SELECT name FROM temp.sqlite_master}
   984    984   } {t1}
   985    985   do_test auth-1.141 {
   986    986     proc auth {code arg1 arg2 arg3 arg4 args} {
   987    987       if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} {
   988    988         return SQLITE_DENY
   989    989       }
   990    990       return SQLITE_OK
................................................................................
  1012   1012       END;
  1013   1013     }
  1014   1014   } {0 {}}
  1015   1015   do_test auth-1.144 {
  1016   1016     set ::authargs
  1017   1017   } {r1 t1 temp {}}
  1018   1018   do_test auth-1.145 {
  1019         -  execsql {SELECT name FROM sqlite_temp_master}
         1019  +  execsql {SELECT name FROM temp.sqlite_master}
  1020   1020   } {t1}
  1021   1021   do_test auth-1.146 {
  1022   1022     proc auth {code arg1 arg2 arg3 arg4 args} {
  1023   1023       if {$code=="SQLITE_INSERT" && $arg1=="sqlite_temp_master"} {
  1024   1024         return SQLITE_IGNORE
  1025   1025       }
  1026   1026       return SQLITE_OK
................................................................................
  1048   1048       END;
  1049   1049     }
  1050   1050   } {0 {}}
  1051   1051   do_test auth-1.149 {
  1052   1052     set ::authargs
  1053   1053   } {r1 t1 temp {}}
  1054   1054   do_test auth-1.150 {
  1055         -  execsql {SELECT name FROM sqlite_temp_master}
         1055  +  execsql {SELECT name FROM temp.sqlite_master}
  1056   1056   } {t1 r1}
  1057   1057   
  1058   1058   do_test auth-1.151 {
  1059   1059     proc auth {code arg1 arg2 arg3 arg4 args} {
  1060   1060       if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} {
  1061   1061         return SQLITE_DENY
  1062   1062       }
................................................................................
  1138   1138         return SQLITE_DENY
  1139   1139       }
  1140   1140       return SQLITE_OK
  1141   1141     }
  1142   1142     catchsql {DROP TRIGGER r1}
  1143   1143   } {1 {not authorized}}
  1144   1144   do_test auth-1.165 {
  1145         -  execsql {SELECT name FROM sqlite_temp_master}
         1145  +  execsql {SELECT name FROM temp.sqlite_master}
  1146   1146   } {t1 r1}
  1147   1147   do_test auth-1.166 {
  1148   1148     proc auth {code arg1 arg2 arg3 arg4 args} {
  1149   1149       if {$code=="SQLITE_DROP_TEMP_TRIGGER"} {
  1150   1150         set ::authargs [list $arg1 $arg2 $arg3 $arg4]
  1151   1151         return SQLITE_DENY
  1152   1152       }
................................................................................
  1166   1166         return SQLITE_IGNORE
  1167   1167       }
  1168   1168       return SQLITE_OK
  1169   1169     }
  1170   1170     catchsql {DROP TRIGGER r1}
  1171   1171   } {0 {}}
  1172   1172   do_test auth-1.170 {
  1173         -  execsql {SELECT name FROM sqlite_temp_master}
         1173  +  execsql {SELECT name FROM temp.sqlite_master}
  1174   1174   } {t1 r1}
  1175   1175   do_test auth-1.171 {
  1176   1176     proc auth {code arg1 arg2 arg3 arg4 args} {
  1177   1177       if {$code=="SQLITE_DROP_TEMP_TRIGGER"} {
  1178   1178         set ::authargs [list $arg1 $arg2 $arg3 $arg4]
  1179   1179         return SQLITE_IGNORE
  1180   1180       }
................................................................................
  1198   1198     }
  1199   1199     catchsql {DROP TRIGGER r1}
  1200   1200   } {0 {}}
  1201   1201   do_test auth-1.175 {
  1202   1202     set ::authargs
  1203   1203   } {r1 t1 temp {}}
  1204   1204   do_test auth-1.176 {
  1205         -  execsql {SELECT name FROM sqlite_temp_master}
         1205  +  execsql {SELECT name FROM temp.sqlite_master}
  1206   1206   } {t1}
  1207   1207   } ;# ifcapable trigger
  1208   1208   
  1209   1209   do_test auth-1.177 {
  1210   1210     proc auth {code arg1 arg2 arg3 arg4 args} {
  1211   1211       if {$code=="SQLITE_CREATE_INDEX"} {
  1212   1212         set ::authargs [list $arg1 $arg2 $arg3 $arg4]
................................................................................
  1302   1302           return SQLITE_DENY
  1303   1303         }
  1304   1304         return SQLITE_OK
  1305   1305       }
  1306   1306       catchsql {CREATE INDEX i1 ON t1(b)}
  1307   1307     } {1 {not authorized}}
  1308   1308     do_test auth-1.194 {
  1309         -    execsql {SELECT name FROM sqlite_temp_master}
         1309  +    execsql {SELECT name FROM temp.sqlite_master}
  1310   1310     } {t1}
  1311   1311     do_test auth-1.195 {
  1312   1312       proc auth {code arg1 arg2 arg3 arg4 args} {
  1313   1313         if {$code=="SQLITE_CREATE_TEMP_INDEX"} {
  1314   1314           set ::authargs [list $arg1 $arg2 $arg3 $arg4]
  1315   1315           return SQLITE_IGNORE
  1316   1316         }
................................................................................
  1346   1346       }
  1347   1347       catchsql {CREATE INDEX i1 ON t1(a)}
  1348   1348     } {0 {}}
  1349   1349     do_test auth-1.201 {
  1350   1350       set ::authargs
  1351   1351     } {i1 t1 temp {}}
  1352   1352     do_test auth-1.202 {
  1353         -    execsql {SELECT name FROM sqlite_temp_master}
         1353  +    execsql {SELECT name FROM temp.sqlite_master}
  1354   1354     } {t1 i1}
  1355   1355   }
  1356   1356   
  1357   1357   do_test auth-1.203 {
  1358   1358     proc auth {code arg1 arg2 arg3 arg4 args} {
  1359   1359       if {$code=="SQLITE_DELETE" && $arg1=="sqlite_master"} {
  1360   1360         return SQLITE_DENY
................................................................................
  1462   1462           return SQLITE_IGNORE
  1463   1463         }
  1464   1464         return SQLITE_OK
  1465   1465       }
  1466   1466       catchsql {DROP INDEX i1}
  1467   1467     } {0 {}}
  1468   1468     do_test auth-1.222 {
  1469         -    execsql {SELECT name FROM sqlite_temp_master}
         1469  +    execsql {SELECT name FROM temp.sqlite_master}
  1470   1470     } {t1 i1}
  1471   1471     do_test auth-1.223 {
  1472   1472       proc auth {code arg1 arg2 arg3 arg4 args} {
  1473   1473         if {$code=="SQLITE_DROP_TEMP_INDEX"} {
  1474   1474           set ::authargs [list $arg1 $arg2 $arg3 $arg4]
  1475   1475           return SQLITE_IGNORE
  1476   1476         }
................................................................................
  1478   1478       }
  1479   1479       catchsql {DROP INDEX i1}
  1480   1480     } {0 {}}
  1481   1481     do_test auth-1.224 {
  1482   1482       set ::authargs
  1483   1483     } {i1 t1 temp {}}
  1484   1484     do_test auth-1.225 {
  1485         -    execsql {SELECT name FROM sqlite_temp_master}
         1485  +    execsql {SELECT name FROM temp.sqlite_master}
  1486   1486     } {t1 i1}
  1487   1487     do_test auth-1.226 {
  1488   1488       proc auth {code arg1 arg2 arg3 arg4 args} {
  1489   1489         if {$code=="SQLITE_DROP_TEMP_INDEX"} {
  1490   1490           set ::authargs [list $arg1 $arg2 $arg3 $arg4]
  1491   1491           return SQLITE_OK
  1492   1492         }
................................................................................
  1494   1494       }
  1495   1495       catchsql {DROP INDEX i1}
  1496   1496     } {0 {}}
  1497   1497     do_test auth-1.227 {
  1498   1498       set ::authargs
  1499   1499     } {i1 t1 temp {}}
  1500   1500     do_test auth-1.228 {
  1501         -    execsql {SELECT name FROM sqlite_temp_master}
         1501  +    execsql {SELECT name FROM temp.sqlite_master}
  1502   1502     } {t1}
  1503   1503   }
  1504   1504   
  1505   1505   do_test auth-1.229 {
  1506   1506     proc auth {code arg1 arg2 arg3 arg4 args} {
  1507   1507       if {$code=="SQLITE_PRAGMA"} {
  1508   1508         set ::authargs [list $arg1 $arg2 $arg3 $arg4]
................................................................................
  1761   1761             return SQLITE_OK
  1762   1762           }
  1763   1763           catchsql {
  1764   1764             ALTER TABLE t1x RENAME TO t1
  1765   1765           }
  1766   1766         } {0 {}}
  1767   1767         do_test auth-1.267 {
  1768         -        execsql {SELECT name FROM sqlite_temp_master WHERE type='table'}
         1768  +        execsql {SELECT name FROM temp.sqlite_master WHERE type='table'}
  1769   1769         } {t1x}
  1770   1770         do_test auth-1.268 {
  1771   1771           set authargs
  1772   1772         } {temp t1x {} {}}
  1773   1773         do_test auth-1.269 {
  1774   1774           proc auth {code arg1 arg2 arg3 arg4 args} {
  1775   1775             if {$code=="SQLITE_ALTER_TABLE"} {
................................................................................
  2066   2066         return SQLITE_OK
  2067   2067       }
  2068   2068       catchsql {
  2069   2069         ALTER TABLE t5 ADD COLUMN new_col_3
  2070   2070       }
  2071   2071     } {1 {not authorized}}
  2072   2072     do_test auth-1.307 {
  2073         -    set x [execsql {SELECT sql FROM sqlite_temp_master WHERE type='t5'}]
         2073  +    set x [execsql {SELECT sql FROM temp.sqlite_master WHERE type='t5'}]
  2074   2074       regexp new_col_3 $x
  2075   2075     } {0}
  2076   2076   
  2077   2077     do_test auth-1.308 {
  2078   2078       set authargs
  2079   2079     } {main t5 {} {}}
  2080   2080     execsql {DROP TABLE t5}
................................................................................
  2369   2369       } else {
  2370   2370         set stat4 ""
  2371   2371       }
  2372   2372     }
  2373   2373     do_test auth-5.2 {
  2374   2374       execsql {
  2375   2375         SELECT name FROM (
  2376         -        SELECT * FROM sqlite_master UNION ALL SELECT * FROM sqlite_temp_master)
         2376  +        SELECT * FROM sqlite_master UNION ALL SELECT * FROM temp.sqlite_master)
  2377   2377         WHERE type='table'
  2378   2378         ORDER BY name
  2379   2379       }
  2380   2380     } "sqlite_stat1 ${stat4}t1 t2 t3 t4"
  2381   2381   }
  2382   2382   
  2383   2383   # Ticket #3944

Changes to test/auth3.test.

   118    118     return SQLITE_OK
   119    119   }
   120    120   do_execsql_test auth3-3.0 {
   121    121     CREATE TEMPORARY TABLE TempTable (
   122    122         key TEXT NOT NULL ON CONFLICT FAIL UNIQUE ON CONFLICT REPLACE,
   123    123         value TEXT NOT NULL ON CONFLICT FAIL);
   124    124     ALTER TABLE TempTable RENAME TO DoNotRead;
   125         -  SELECT name FROM sqlite_temp_master;
          125  +  SELECT name FROM temp.sqlite_master;
   126    126   } {DoNotRead sqlite_autoindex_DoNotRead_1}
   127    127   
   128    128   finish_test

Changes to test/autoinc.test.

   340    340   
   341    341   # AUTOINCREMENT on TEMP tables.
   342    342   #
   343    343   ifcapable tempdb {
   344    344     do_test autoinc-4.1 {
   345    345       execsql {
   346    346         SELECT 1, name FROM sqlite_master WHERE type='table';
   347         -      SELECT 2, name FROM sqlite_temp_master WHERE type='table';
          347  +      SELECT 2, name FROM temp.sqlite_master WHERE type='table';
   348    348       }
   349    349     } {1 sqlite_sequence}
   350    350     do_test autoinc-4.2 {
   351    351       execsql {
   352    352         CREATE TABLE t1(x INTEGER PRIMARY KEY AUTOINCREMENT, y);
   353    353         CREATE TEMP TABLE t3(a INTEGER PRIMARY KEY AUTOINCREMENT, b);
   354    354         SELECT 1, name FROM sqlite_master WHERE type='table';

Changes to test/bestindex3.test.

   168    168     }
   169    169   }
   170    170   
   171    171   do_execsql_test 3.1 { CREATE VIRTUAL TABLE t3 USING tcl('vvv_command') }
   172    172   do_execsql_test 3.2 { CREATE VIRTUAL TABLE t4 USING tcl('yyy_command') }
   173    173   
   174    174   finish_test
   175         -

Changes to test/bestindex4.test.

   114    114         }
   115    115       }
   116    116   
   117    117     }
   118    118   }
   119    119   
   120    120   finish_test
   121         -

Changes to test/e_dropview.test.

    41     41     }
    42     42   }
    43     43   
    44     44   proc list_all_views {{db db}} {
    45     45     set res [list]
    46     46     $db eval { PRAGMA database_list } {
    47     47       set tbl "$name.sqlite_master"
    48         -    if {$name == "temp"} { set tbl sqlite_temp_master }
           48  +    if {$name == "temp"} { set tbl temp.sqlite_master }
    49     49   
    50     50       set sql "SELECT '$name.' || name FROM $tbl WHERE type = 'view'"
    51     51       lappend res {*}[$db eval $sql]
    52     52     }
    53     53     set res
    54     54   }
    55     55   

Changes to test/fkey2.test.

  1058   1058       catchsql { ALTER TABLE t2 ADD COLUMN g DEFAULT CURRENT_TIME REFERENCES t1 }
  1059   1059     } {1 {Cannot add a REFERENCES column with non-NULL default value}}
  1060   1060     do_test fkey2-14.1tmp.6 {
  1061   1061       execsql { 
  1062   1062         PRAGMA foreign_keys = off;
  1063   1063         ALTER TABLE t2 ADD COLUMN h DEFAULT 'text' REFERENCES t1;
  1064   1064         PRAGMA foreign_keys = on;
  1065         -      SELECT sql FROM sqlite_temp_master WHERE name='t2';
         1065  +      SELECT sql FROM temp.sqlite_master WHERE name='t2';
  1066   1066       }
  1067   1067     } {{CREATE TABLE t2(a, b, c REFERENCES t1, d DEFAULT NULL REFERENCES t1, e REFERENCES t1 DEFAULT NULL, h DEFAULT 'text' REFERENCES t1)}}
  1068   1068   
  1069   1069     do_test fkey2-14.2tmp.1.1 {
  1070   1070       test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t2 t3
  1071   1071     } {{CREATE TABLE t1(a REFERENCES "t3")}}
  1072   1072     do_test fkey2-14.2tmp.1.2 {
................................................................................
  1089   1089     } [list \
  1090   1090       {CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1)}                     \
  1091   1091       {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2)}    \
  1092   1092       {CREATE TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1)}  \
  1093   1093     ]
  1094   1094     do_test fkey2-14.2tmp.2.2 {
  1095   1095       execsql { ALTER TABLE t1 RENAME TO t4 }
  1096         -    execsql { SELECT sql FROM sqlite_temp_master WHERE type = 'table'}
         1096  +    execsql { SELECT sql FROM temp.sqlite_master WHERE type = 'table'}
  1097   1097     } [list \
  1098   1098       {CREATE TABLE "t4"(a PRIMARY KEY, b REFERENCES "t4")}                    \
  1099   1099       {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES "t4", c REFERENCES t2)}     \
  1100   1100       {CREATE TABLE t3(a REFERENCES "t4", b REFERENCES t2, c REFERENCES "t4")} \
  1101   1101     ]
  1102   1102     do_test fkey2-14.2tmp.2.3 {
  1103   1103       catchsql { INSERT INTO t3 VALUES(1, 2, 3) }

Changes to test/incrblob4.test.

   103    103   } {1 {database table is locked}}
   104    104   do_test 4.4 {
   105    105     sqlite3_extended_errcode db
   106    106   } {SQLITE_LOCKED}
   107    107   close $blob
   108    108   
   109    109   finish_test
   110         -

Changes to test/intarray.test.

    38     38   
    39     39   do_test intarray-1.1 {
    40     40     set ia1 [sqlite3_intarray_create db ia1]
    41     41     set ia2 [sqlite3_intarray_create db ia2]
    42     42     set ia3 [sqlite3_intarray_create db ia3]
    43     43     set ia4 [sqlite3_intarray_create db ia4]
    44     44     db eval {
    45         -    SELECT type, name FROM sqlite_temp_master
           45  +    SELECT type, name FROM temp.sqlite_master
    46     46        ORDER BY name
    47     47     }
    48     48   } {table ia1 table ia2 table ia3 table ia4}
    49     49   
    50     50   do_test intarray-1.2 {
    51     51     db eval {
    52     52       SELECT b FROM t1 WHERE a IN ia3 ORDER BY a

Changes to test/interrupt.test.

   124    124         set ::sqlite_interrupt_count $::i
   125    125         catchsql {
   126    126           INSERT INTO t2 SELECT * FROM t1;
   127    127         }
   128    128       } {1 interrupted}
   129    129       do_test interrupt-3.$i.3 {
   130    130         execsql {
   131         -        SELECT name FROM sqlite_temp_master;
          131  +        SELECT name FROM temp.sqlite_master;
   132    132         }
   133    133       } {}
   134    134       do_test interrupt-3.$i.4 {
   135    135         catchsql {
   136    136           ROLLBACK
   137    137         }
   138    138       } {1 {cannot rollback - no transaction is active}}
   139    139       do_test interrupt-3.$i.5 {
   140    140         catchsql {SELECT name FROM sqlite_temp_master};
   141    141         execsql {
   142         -        SELECT name FROM sqlite_temp_master;
          142  +        SELECT name FROM temp.sqlite_master;
   143    143         }
   144    144       } {}
   145    145     }
   146    146   }
   147    147   
   148    148   # There are reports of a memory leak if an interrupt occurs during
   149    149   # the beginning of a complex query - before the first callback.  We

Changes to test/regexp2.test.

   118    118   
   119    119     DELETE FROM t5;
   120    120     SELECT * FROM t6;
   121    121   } {eab dea}
   122    122   
   123    123   
   124    124   finish_test
   125         -

Changes to test/rowvalue.test.

   313    313       set err "sub-select returns $n columns - expected 1"
   314    314     }
   315    315     do_catchsql_test 14.2.$tn $sql [list 1 $err]
   316    316   }
   317    317   
   318    318   
   319    319   finish_test
   320         -
   321         -

Changes to test/rowvalue9.test.

   295    295     SELECT * FROM g2 WHERE (x, y) IN (
   296    296       SELECT a, b FROM g1 ORDER BY 1, 2 LIMIT 10
   297    297     );
   298    298   } { 1 4 1 5 }
   299    299   
   300    300   
   301    301   finish_test
   302         -

Changes to test/rowvaluefault.test.

    65     65       SELECT fou FROM xyz 
    66     66       WHERE (one, two, thr) BETWEEN ('B', 'B', 'B') AND ('C', 'C', 'C') }
    67     67   } -test {
    68     68     faultsim_test_result {0 {2 3}} 
    69     69   }
    70     70   
    71     71   finish_test
    72         -

Changes to test/schema4.test.

   145    145       END;
   146    146   
   147    147       CREATE TEMP TABLE x1(x);
   148    148       INSERT INTO x1 VALUES(123);
   149    149     } {}
   150    150   
   151    151     do_execsql_test schema4-2.8 {
   152         -    select sql from sqlite_temp_master WHERE type='table';
          152  +    select sql from temp.sqlite_master WHERE type='table';
   153    153     } {{CREATE TABLE x1(x)}}
   154    154   
   155    155     do_execsql_test schema4-2.7 { ALTER TABLE tbl RENAME TO tbl2 } {}
   156    156   
   157    157     do_execsql_test schema4-2.9 {
   158    158       select sql from sqlite_temp_master WHERE type='table';
   159    159     } {{CREATE TABLE x1(x)}}

Changes to test/snapshot2.test.

   194    194     execsql {
   195    195       PRAGMA aux.journal_mode = delete;
   196    196     }
   197    197     list [catch { sqlite3_snapshot_recover db aux } msg] $msg
   198    198   } {1 SQLITE_ERROR}
   199    199   
   200    200   finish_test
   201         -
   202         -

Changes to test/tempdb2.test.

    70     70   }
    71     71   
    72     72   do_execsql_test 1.4 {
    73     73     SELECT b=int2str(2) FROM t1
    74     74   } {1 1 1}
    75     75   
    76     76   finish_test
    77         -

Changes to test/temptrigger.test.

   232    232   do_test 5.1 {
   233    233     sqlite3 db2 test.db
   234    234     execsql { DROP TABLE t1 } db2
   235    235   } {}
   236    236   
   237    237   do_execsql_test 5.2 {
   238    238     SELECT * FROM sqlite_master;
   239         -  SELECT * FROM sqlite_temp_master;
          239  +  SELECT * FROM temp.sqlite_master;
   240    240   } {
   241    241     trigger tr1 t1 0 
   242    242     {CREATE TRIGGER tr1 BEFORE INSERT ON t1 BEGIN SELECT 1,2,3; END}
   243    243   }
   244    244   db2 close
   245    245   
   246    246   #-------------------------------------------------------------------------

Changes to test/tkt3630.test.

    19     19   set testdir [file dirname $argv0]
    20     20   
    21     21   source $testdir/tester.tcl
    22     22   
    23     23   do_test tkt3630-1 {
    24     24     db eval {
    25     25       CREATE TEMP TABLE temp1(a,b,c);
    26         -    SELECT * FROM sqlite_temp_master WHERE sql GLOB '*TEMP*';
           26  +    SELECT * FROM temp.sqlite_master WHERE sql GLOB '*TEMP*';
    27     27     }
    28     28   } {}
    29     29   do_test tkt3630-2 {
    30     30     db eval {
    31     31       CREATE TABLE main1(a,b,c);
    32     32       CREATE TEMP TABLE temp2 AS SELECT * FROM main1;
    33     33       SELECT * FROM sqlite_temp_master WHERE sql GLOB '*TEMP*';
................................................................................
    35     35   } {}
    36     36   
    37     37   ifcapable altertable {
    38     38     do_test tkt3630-3 {
    39     39       db eval {
    40     40         ALTER TABLE temp2 ADD COLUMN d;
    41     41         ALTER TABLE temp2 RENAME TO temp2rn;
    42         -      SELECT name FROM sqlite_temp_master WHERE name LIKE 'temp2%';
           42  +      SELECT name FROM temp.sqlite_master WHERE name LIKE 'temp2%';
    43     43       }
    44     44     } {temp2rn}
    45     45   }
    46     46   
    47     47   finish_test

Changes to test/tkt3810.test.

    58     58     }
    59     59   } {0 {}}
    60     60   
    61     61   # Trigger still exists in the sqlite_temp_master table, but now it is
    62     62   # an orphan.
    63     63   #
    64     64   do_test tkt3810-4 {
    65         -  execsql {SELECT name FROM sqlite_temp_master ORDER BY name}
           65  +  execsql {SELECT name FROM temp.sqlite_master ORDER BY name}
    66     66   } {r1}
    67     67   
    68     68   # Because it is an orphan, it cannot be dropped.
    69     69   #
    70     70   do_test tkt3810-5 {
    71     71     catchsql {DROP TRIGGER r1}
    72     72   } {1 {no such trigger: r1}}

Changes to test/without_rowid3.test.

  1027   1027       catchsql { ALTER TABLE t2 ADD COLUMN g DEFAULT CURRENT_TIME REFERENCES t1 }
  1028   1028     } {1 {Cannot add a REFERENCES column with non-NULL default value}}
  1029   1029     do_test without_rowid3-14.1tmp.6 {
  1030   1030       execsql { 
  1031   1031         PRAGMA foreign_keys = off;
  1032   1032         ALTER TABLE t2 ADD COLUMN h DEFAULT 'text' REFERENCES t1;
  1033   1033         PRAGMA foreign_keys = on;
  1034         -      SELECT sql FROM sqlite_temp_master WHERE name='t2';
         1034  +      SELECT sql FROM temp.sqlite_master WHERE name='t2';
  1035   1035       }
  1036   1036     } {{CREATE TABLE t2(a, b, c REFERENCES t1, d DEFAULT NULL REFERENCES t1, e REFERENCES t1 DEFAULT NULL, h DEFAULT 'text' REFERENCES t1)}}
  1037   1037   
  1038   1038     do_test without_rowid3-14.2tmp.1.1 {
  1039   1039       test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t2 t3
  1040   1040     } {{CREATE TABLE t1(a REFERENCES "t3")}}
  1041   1041     do_test without_rowid3-14.2tmp.1.2 {
................................................................................
  1060   1060       {CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1) WITHOUT rowid}       \
  1061   1061       {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2)
  1062   1062               WITHOUT rowid}    \
  1063   1063       {CREATE TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1)}  \
  1064   1064     ]
  1065   1065     do_test without_rowid3-14.2tmp.2.2 {
  1066   1066       execsql { ALTER TABLE t1 RENAME TO t4 }
  1067         -    execsql { SELECT sql FROM sqlite_temp_master WHERE type = 'table'}
         1067  +    execsql { SELECT sql FROM temp.sqlite_master WHERE type = 'table'}
  1068   1068     } [list \
  1069   1069       {CREATE TABLE "t4"(a PRIMARY KEY, b REFERENCES "t4") WITHOUT rowid}      \
  1070   1070       {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES "t4", c REFERENCES t2)
  1071   1071               WITHOUT rowid}     \
  1072   1072       {CREATE TABLE t3(a REFERENCES "t4", b REFERENCES t2, c REFERENCES "t4")} \
  1073   1073     ]
  1074   1074     do_test without_rowid3-14.2tmp.2.3 {

Changes to tool/mkpragmatab.tcl.

     6      6   # of the pragma to the "pragma_def" object below.  Then run this script
     7      7   # to generate the ../src/pragma.h header file that contains macros and
     8      8   # the lookup table needed for pragma name lookup in the pragma.c module.
     9      9   # Then add the extra "case PragTyp_XXXXX:" and subsequent code for the
    10     10   # new pragma in ../src/pragma.c.
    11     11   #
    12     12   
           13  +# Flag meanings:
           14  +set flagMeaning(NeedSchema) {Force schema load before running}
           15  +set flagMeaning(ReadOnly)   {Read-only HEADER_VALUE}
           16  +set flagMeaning(Result0)    {Acts as query when no argument}
           17  +set flagMeaning(Result1)    {Acts as query when has one argument}
           18  +set flagMeaning(SchemaReq)  {Schema required - "main" is default}
           19  +set flagMeaning(SchemaOpt)  {Schema restricts name search if present}
           20  +set flagMeaning(NoColumns)  {OP_ResultRow called with zero columns}
           21  +
    13     22   set pragma_def {
    14     23     NAME: full_column_names
    15     24     TYPE: FLAG
    16     25     ARG:  SQLITE_FullColNames
    17     26     IF:   !defined(SQLITE_OMIT_FLAG_PRAGMAS)
    18     27   
    19     28     NAME: short_column_names
................................................................................
    43     52   
    44     53     NAME: checkpoint_fullfsync
    45     54     TYPE: FLAG
    46     55     ARG:  SQLITE_CkptFullFSync
    47     56     IF:   !defined(SQLITE_OMIT_FLAG_PRAGMAS)
    48     57   
    49     58     NAME: cache_spill
           59  +  FLAG: Result0 SchemaReq
    50     60     IF:   !defined(SQLITE_OMIT_FLAG_PRAGMAS)
    51     61   
    52     62     NAME: reverse_unordered_selects
    53     63     TYPE: FLAG
    54     64     ARG:  SQLITE_ReverseOrder
    55     65     IF:   !defined(SQLITE_OMIT_FLAG_PRAGMAS)
    56     66   
................................................................................
   135    145     IF:   !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
   136    146   
   137    147     NAME: cell_size_check
   138    148     TYPE: FLAG
   139    149     ARG:  SQLITE_CellSizeCk
   140    150   
   141    151     NAME: default_cache_size
   142         -  FLAG: NeedSchema
          152  +  FLAG: NeedSchema Result0 SchemaReq
          153  +  COLS: cache_size
   143    154     IF:   !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
   144    155   
   145    156     NAME: page_size
          157  +  FLAG: Result0 SchemaReq
   146    158     IF:   !defined(SQLITE_OMIT_PAGER_PRAGMAS)
   147    159   
   148    160     NAME: secure_delete
          161  +  FLAG: Result0
   149    162     IF:   !defined(SQLITE_OMIT_PAGER_PRAGMAS)
   150    163   
   151    164     NAME: page_count
   152         -  FLAG: NeedSchema
          165  +  FLAG: NeedSchema Result0 SchemaReq
   153    166     IF:   !defined(SQLITE_OMIT_PAGER_PRAGMAS)
   154    167   
   155    168     NAME: max_page_count
   156    169     TYPE: PAGE_COUNT
   157         -  FLAG: NeedSchema
          170  +  FLAG: NeedSchema Result0 SchemaReq
   158    171     IF:   !defined(SQLITE_OMIT_PAGER_PRAGMAS)
   159    172   
   160    173     NAME: locking_mode
          174  +  FLAG: Result0 SchemaReq
   161    175     IF:   !defined(SQLITE_OMIT_PAGER_PRAGMAS)
   162    176   
   163    177     NAME: journal_mode
   164         -  FLAG: NeedSchema
          178  +  FLAG: NeedSchema Result0 SchemaReq
   165    179     IF:   !defined(SQLITE_OMIT_PAGER_PRAGMAS)
   166    180   
   167    181     NAME: journal_size_limit
          182  +  FLAG: Result0 SchemaReq
   168    183     IF:   !defined(SQLITE_OMIT_PAGER_PRAGMAS)
   169    184   
   170    185     NAME: cache_size
   171         -  FLAG: NeedSchema
          186  +  FLAG: NeedSchema Result0 SchemaReq
   172    187     IF:   !defined(SQLITE_OMIT_PAGER_PRAGMAS)
   173    188   
   174    189     NAME: mmap_size
   175    190     IF:   !defined(SQLITE_OMIT_PAGER_PRAGMAS)
   176    191   
   177    192     NAME: auto_vacuum
   178         -  FLAG: NeedSchema
          193  +  FLAG: NeedSchema Result0 SchemaReq
   179    194     IF:   !defined(SQLITE_OMIT_AUTOVACUUM)
   180    195   
   181    196     NAME: incremental_vacuum
   182         -  FLAG: NeedSchema
          197  +  FLAG: NeedSchema NoColumns
   183    198     IF:   !defined(SQLITE_OMIT_AUTOVACUUM)
   184    199   
   185    200     NAME: temp_store
          201  +  FLAG: Result0
   186    202     IF:   !defined(SQLITE_OMIT_PAGER_PRAGMAS)
   187    203   
   188    204     NAME: temp_store_directory
   189    205     IF:   !defined(SQLITE_OMIT_PAGER_PRAGMAS)
   190    206   
   191    207     NAME: data_store_directory
   192    208     IF:   !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_OS_WIN
   193    209   
   194    210     NAME: lock_proxy_file
   195    211     IF:   !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_ENABLE_LOCKING_STYLE
   196    212   
   197    213     NAME: synchronous
   198         -  FLAG: NeedSchema
          214  +  FLAG: NeedSchema Result0 SchemaReq
   199    215     IF:   !defined(SQLITE_OMIT_PAGER_PRAGMAS)
   200    216   
   201    217     NAME: table_info
   202         -  FLAG: NeedSchema
          218  +  FLAG: NeedSchema Result1 SchemaOpt
          219  +  COLS: cid name type notnull dflt_value pk
   203    220     IF:   !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
   204    221   
   205    222     NAME: stats
   206         -  FLAG: NeedSchema
          223  +  FLAG: NeedSchema Result0 SchemaReq
          224  +  COLS: table index width height
   207    225     IF:   !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
   208    226   
   209    227     NAME: index_info
   210    228     TYPE: INDEX_INFO
   211    229     ARG:  0
   212         -  FLAG: NeedSchema
          230  +  FLAG: NeedSchema Result1 SchemaOpt
          231  +  COLS: seqno cid name
   213    232     IF:   !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
   214    233   
   215    234     NAME: index_xinfo
   216    235     TYPE: INDEX_INFO
   217    236     ARG:  1
   218         -  FLAG: NeedSchema
          237  +  FLAG: NeedSchema Result1 SchemaOpt
          238  +  COLS: seqno cid name desc coll key
   219    239     IF:   !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
   220    240   
   221    241     NAME: index_list
   222         -  FLAG: NeedSchema
          242  +  FLAG: NeedSchema Result1 SchemaOpt
          243  +  COLS: seq name unique origin partial
   223    244     IF:   !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
   224    245   
   225    246     NAME: database_list
   226         -  FLAG: NeedSchema
          247  +  FLAG: NeedSchema Result0
          248  +  COLS: seq name file
   227    249     IF:   !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
   228    250   
   229    251     NAME: collation_list
          252  +  FLAG: Result0
          253  +  COLS: seq name
   230    254     IF:   !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
   231    255   
   232    256     NAME: foreign_key_list
   233         -  FLAG: NeedSchema
          257  +  FLAG: NeedSchema Result1 SchemaOpt
          258  +  COLS: id seq table from to on_update on_delete match
   234    259     IF:   !defined(SQLITE_OMIT_FOREIGN_KEY)
   235    260   
   236    261     NAME: foreign_key_check
   237    262     FLAG: NeedSchema
          263  +  COLS: table rowid parent fkid
   238    264     IF:   !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
   239    265   
   240    266     NAME: parser_trace
   241    267     IF:   defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_PARSER_TRACE)
   242    268   
   243    269     NAME: case_sensitive_like
   244    270   
................................................................................
   248    274   
   249    275     NAME: quick_check
   250    276     TYPE: INTEGRITY_CHECK
   251    277     FLAG: NeedSchema
   252    278     IF:   !defined(SQLITE_OMIT_INTEGRITY_CHECK)
   253    279   
   254    280     NAME: encoding
          281  +  FLAG: Result0
   255    282     IF:   !defined(SQLITE_OMIT_UTF16)
   256    283   
   257    284     NAME: schema_version
   258    285     TYPE: HEADER_VALUE
   259    286     ARG:  BTREE_SCHEMA_VERSION
   260    287     IF:   !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
   261    288   
................................................................................
   278    305   
   279    306     NAME: application_id
   280    307     TYPE: HEADER_VALUE
   281    308     ARG:  BTREE_APPLICATION_ID
   282    309     IF:   !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
   283    310   
   284    311     NAME: compile_options
          312  +  FLAG: Result0
   285    313     IF:   !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
   286    314   
   287    315     NAME: wal_checkpoint
   288    316     FLAG: NeedSchema
          317  +  COLS: busy log checkpointed
   289    318     IF:   !defined(SQLITE_OMIT_WAL)
   290    319   
   291    320     NAME: wal_autocheckpoint
   292    321     IF:   !defined(SQLITE_OMIT_WAL)
   293    322   
   294    323     NAME: shrink_memory
   295    324   
   296    325     NAME: busy_timeout
          326  +  FLAG: Result0
          327  +  COLS: timeout
   297    328   
   298    329     NAME: lock_status
          330  +  FLAG: Result0
          331  +  COLS: database status
   299    332     IF:   defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
   300    333   
   301    334     NAME: key
   302    335     IF:   defined(SQLITE_HAS_CODEC)
   303    336   
   304    337     NAME: rekey
   305    338     IF:   defined(SQLITE_HAS_CODEC)
................................................................................
   311    344     TYPE: HEXKEY
   312    345     IF:   defined(SQLITE_HAS_CODEC)
   313    346   
   314    347     NAME: activate_extensions
   315    348     IF:   defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)
   316    349   
   317    350     NAME: soft_heap_limit
          351  +  FLAG: Result0
   318    352   
   319    353     NAME: threads
          354  +  FLAG: Result0
   320    355   }
   321    356   
   322    357   # Open the output file
   323    358   #
   324    359   set destfile "[file dir [file dir [file normal $argv0]]]/src/pragma.h"
   325    360   puts "Overwriting $destfile with new pragma table..."
   326    361   set fd [open $destfile wb]
................................................................................
   332    367   
   333    368   # Parse the PRAGMA table above.
   334    369   #
   335    370   set name {}
   336    371   set type {}
   337    372   set if {}
   338    373   set flags {}
          374  +set cols {}
          375  +set cols_list {}
   339    376   set arg 0
   340    377   proc record_one {} {
   341         -  global name type if arg allbyname typebyif flags
          378  +  global name type if arg allbyname typebyif flags cols allcols
          379  +  global cols_list colUsedBy
   342    380     if {$name==""} return
   343         -  set allbyname($name) [list $type $arg $if $flags]
          381  +  if {$cols!=""} {
          382  +    if {![info exists allcols($cols)]} {
          383  +      lappend cols_list $cols
          384  +      set allcols($cols) [llength $cols_list]
          385  +    }
          386  +    set cx $allcols($cols)
          387  +    lappend colUsedBy($cols) $name
          388  +  } else {
          389  +    set cx 0
          390  +  }
          391  +  set allbyname($name) [list $type $arg $if $flags $cx]
   344    392     set name {}
   345    393     set type {}
   346    394     set if {}
   347    395     set flags {}
          396  +  set cols {}
   348    397     set arg 0
   349    398   }
   350    399   foreach line [split $pragma_def \n] {
   351    400     set line [string trim $line]
   352    401     if {$line==""} continue
   353    402     foreach {id val} [split $line :] break
   354    403     set val [string trim $val]
   355    404     if {$id=="NAME"} {
   356    405       record_one    
   357    406       set name $val
   358    407       set type [string toupper $val]
   359    408     } elseif {$id=="TYPE"} {
   360    409       set type $val
          410  +    if {$type=="FLAG"} {
          411  +      lappend flags Result0 NoColumns
          412  +    }
          413  +    if {$type=="HEADER_VALUE"} {
          414  +      lappend flags Result0
          415  +    }
   361    416     } elseif {$id=="ARG"} {
   362    417       set arg $val
          418  +  } elseif {$id=="COLS"} {
          419  +    set cols $val
   363    420     } elseif {$id=="IF"} {
   364    421       lappend if $val
   365    422     } elseif {$id=="FLAG"} {
   366    423       foreach term [split $val] {
   367    424         lappend flags $term
   368    425         set allflags($term) 1
   369    426       }
................................................................................
   374    431   record_one
   375    432   set allnames [lsort [array names allbyname]]
   376    433   
   377    434   # Generate #defines for all pragma type names.  Group the pragmas that are
   378    435   # omit in default builds (defined(SQLITE_DEBUG) and defined(SQLITE_HAS_CODEC))
   379    436   # at the end.
   380    437   #
          438  +puts $fd "\n/* The various pragma types */"
   381    439   set pnum 0
   382    440   foreach name $allnames {
   383    441     set type [lindex $allbyname($name) 0]
   384    442     if {[info exists seentype($type)]} continue
   385    443     set if [lindex $allbyname($name) 2]
   386    444     if {[regexp SQLITE_DEBUG $if] || [regexp SQLITE_HAS_CODEC $if]} continue
   387    445     set seentype($type) 1
................................................................................
   403    461     set seentype($type) 1
   404    462     puts $fd [format {#define %-35s %4d} PragTyp_$type $pnum]
   405    463     incr pnum
   406    464   }
   407    465   
   408    466   # Generate #defines for flags
   409    467   #
          468  +puts $fd "\n/* Property flags associated with various pragma. */"
   410    469   set fv 1
   411    470   foreach f [lsort [array names allflags]] {
   412         -  puts $fd [format {#define PragFlag_%-20s 0x%02x} $f $fv]
          471  +  puts $fd [format {#define PragFlg_%-10s 0x%02x /* %s */} \
          472  +             $f $fv $flagMeaning($f)]
   413    473     set fv [expr {$fv*2}]
   414    474   }
          475  +
          476  +# Generate the array of column names used by pragmas that act like
          477  +# queries.
          478  +#
          479  +puts $fd "\n/* Names of columns for pragmas that return multi-column result"
          480  +puts $fd "** or that return single-column results where the name of the"
          481  +puts $fd "** result column is different from the name of the pragma\n*/"
          482  +puts $fd "static const char *const pragCName\[\] = {"
          483  +set offset 0
          484  +foreach cols $cols_list {
          485  +  set cols_offset($allcols($cols)) $offset
          486  +  set ub " /* Used by: $colUsedBy($cols) */"
          487  +  foreach c $cols {
          488  +    puts $fd [format "  /* %3d */ %-14s%s" $offset \"$c\", $ub]
          489  +    set ub ""
          490  +    incr offset
          491  +  }
          492  +}
          493  +puts $fd "\175;"
   415    494   
   416    495   # Generate the lookup table
   417    496   #
   418         -puts $fd "static const struct sPragmaNames \173"
   419         -puts $fd "  const char *const zName;  /* Name of pragma */"
   420         -puts $fd "  u8 ePragTyp;              /* PragTyp_XXX value */"
   421         -puts $fd "  u8 mPragFlag;             /* Zero or more PragFlag_XXX values */"
   422         -puts $fd "  u32 iArg;                 /* Extra argument */"
   423         -puts $fd "\175 aPragmaNames\[\] = \173"
          497  +puts $fd "\n/* Definitions of all built-in pragmas */"
          498  +puts $fd "typedef struct PragmaName \173"
          499  +puts $fd "  const char *const zName; /* Name of pragma */"
          500  +puts $fd "  u8 ePragTyp;             /* PragTyp_XXX value */"
          501  +puts $fd "  u8 mPragFlg;             /* Zero or more PragFlg_XXX values */"
          502  +puts $fd {  u8 iPragCName;           /* Start of column names in pragCName[] */}
          503  +puts $fd "  u8 nPragCName;          \
          504  +/* Num of col names. 0 means use pragma name */"
          505  +puts $fd "  u32 iArg;                /* Extra argument */"
          506  +puts $fd "\175 PragmaName;"
          507  +puts $fd "static const PragmaName aPragmaName\[\] = \173"
   424    508   
   425    509   set current_if {}
   426    510   set spacer [format {    %26s } {}]
   427    511   foreach name $allnames {
   428         -  foreach {type arg if flag} $allbyname($name) break
          512  +  foreach {type arg if flag cx} $allbyname($name) break
          513  +  if {$cx==0} {
          514  +    set cy 0
          515  +    set nx 0
          516  +  } else {
          517  +    set cy $cols_offset($cx)
          518  +    set nx [llength [lindex $cols_list [expr {$cx-1}]]]
          519  +  }
   429    520     if {$if!=$current_if} {
   430    521       if {$current_if!=""} {
   431    522         foreach this_if $current_if {
   432    523           puts $fd "#endif"
   433    524         }
   434    525       }
   435    526       set current_if $if
................................................................................
   439    530         }
   440    531       }
   441    532     }
   442    533     set typex [format PragTyp_%-23s $type,]
   443    534     if {$flag==""} {
   444    535       set flagx "0"
   445    536     } else {
   446         -    set flagx PragFlag_[join $flag {|PragFlag_}]
          537  +    set flagx PragFlg_[join $flag {|PragFlg_}]
   447    538     }
   448         -  puts $fd "  \173 /* zName:     */ \"$name\","
   449         -  puts $fd "    /* ePragTyp:  */ PragTyp_$type,"
   450         -  puts $fd "    /* ePragFlag: */ $flagx,"
   451         -  puts $fd "    /* iArg:      */ $arg \175,"
          539  +  puts $fd " \173/* zName:     */ \"$name\","
          540  +  puts $fd "  /* ePragTyp:  */ PragTyp_$type,"
          541  +  puts $fd "  /* ePragFlg:  */ $flagx,"
          542  +  puts $fd "  /* ColNames:  */ $cy, $nx,"
          543  +  puts $fd "  /* iArg:      */ $arg \175,"
   452    544   }
   453    545   if {$current_if!=""} {
   454    546     foreach this_if $current_if {
   455    547       puts $fd "#endif"
   456    548     }
   457    549   }
   458    550   puts $fd "\175;"