context: using System;
  using System.Diagnostics;
  using System.Text;
  
  using i64 = System.Int64;
  using u8 = System.Byte;
  
  using Pgno = System.UInt32;
  using sqlite3_int64 = System.Int64;
  using System.Globalization;
  
  namespace Community.CsharpSqlite
  {
    public partial class Sqlite3
    {
      /*
      ** 2003 April 6
      **
      ** The author disclaims copyright to this source code.  In place of
      ** a legal notice, here is a blessing:
      **
      **    May you do good and not evil.
      **    May you find forgiveness for yourself and forgive others.
      **    May you share freely, never taking more than you give.
      **
      *************************************************************************
      ** This file contains code used to implement the PRAGMA command.
      *************************************************************************
      **  Included in SQLite3 port to C#-SQLite;  2008 Noah B Hart
      **  C#-SQLite is an independent reimplementation of the SQLite software library
      **
      **  SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2
      **
      *************************************************************************
      */
      //#include "sqliteInt.h"
  
      /*
  ** Interpret the given string as a safety level.  Return 0 for OFF,
  ** 1 for ON or NORMAL and 2 for FULL.  Return 1 for an empty or
  ** unrecognized string argument.
  **
  ** Note that the values returned are one less that the values that
  ** should be passed into sqlite3BtreeSetSafetyLevel().  The is done
  ** to support legacy SQL code.  The safety level used to be boolean
  ** and older scripts may have used numbers 0 for OFF and 1 for ON.
  */
      static u8 getSafetyLevel( string z )
      {
        //                             /* 123456789 123456789 */
        string zText = "onoffalseyestruefull";
        int[] iOffset = new int[] { 0, 1, 2, 4, 9, 12, 16 };
        int[] iLength = new int[] { 2, 2, 3, 5, 3, 4, 4 };
        u8[] iValue = new u8[] { 1, 0, 0, 0, 1, 1, 2 };
        int i, n;
        if ( sqlite3Isdigit( z[0] ) )
        {
          return (u8)sqlite3Atoi( z );
        }
        n = sqlite3Strlen30( z );
        for ( i = 0; i < ArraySize( iLength ); i++ )
        {
          if ( iLength[i] == n && sqlite3StrNICmp( zText.Substring( iOffset[i] ), z, n ) == 0 )
          {
            return iValue[i];
          }
        }
        return 1;
      }
  
      /*
      ** Interpret the given string as a boolean value.
      */
      static u8 sqlite3GetBoolean(string z){
    return (u8)( getSafetyLevel( z ) & 1 );//return getSafetyLevel(z)&1;
  }
  
  /* The sqlite3GetBoolean() function is used by other modules but the
  ** remainder of this file is specific to PRAGMA processing.  So omit
  ** the rest of the file if PRAGMAs are omitted from the build.
  */
  #if !(SQLITE_OMIT_PRAGMA)
  
      /*
      ** Interpret the given string as a locking mode value.
      */
      static int getLockingMode( string z )
      {
        if ( z != null )
        {
          if ( z.Equals( "exclusive" ,StringComparison.InvariantCultureIgnoreCase ) )
            return PAGER_LOCKINGMODE_EXCLUSIVE;
          if ( z.Equals( "normal" ,StringComparison.InvariantCultureIgnoreCase ) )
            return PAGER_LOCKINGMODE_NORMAL;
        }
        return PAGER_LOCKINGMODE_QUERY;
      }
  
  #if !SQLITE_OMIT_AUTOVACUUM
      /*
  ** Interpret the given string as an auto-vacuum mode value.
  **
  ** The following strings, "none", "full" and "incremental" are
  ** acceptable, as are their numeric equivalents: 0, 1 and 2 respectively.
  */
      static u8 getAutoVacuum( string z )
      {
        int i;
        if ( z.Equals( "none" ,StringComparison.InvariantCultureIgnoreCase ) )
          return BTREE_AUTOVACUUM_NONE;
        if ( z.Equals( "full" ,StringComparison.InvariantCultureIgnoreCase ) )
          return BTREE_AUTOVACUUM_FULL;
        if ( z.Equals( "incremental" ,StringComparison.InvariantCultureIgnoreCase ) )
          return BTREE_AUTOVACUUM_INCR;
        i = atoi( z );
        return (u8)( ( i >= 0 && i <= 2 ) ? i : 0 );
      }
  #endif // * if !SQLITE_OMIT_AUTOVACUUM */
  
  #if !SQLITE_OMIT_PAGER_PRAGMAS
      /*
  ** Interpret the given string as a temp db location. Return 1 for file
  ** backed temporary databases, 2 for the Red-Black tree in memory database
  ** and 0 to use the compile-time default.
  */
      static int getTempStore( string z )
      {
        if ( z[0] >= '0' && z[0] <= '2' )
        {
          return z[0] - '0';
        }
        else if ( z.Equals( "file" ,StringComparison.InvariantCultureIgnoreCase )  )
        {
          return 1;
        }
        else if ( z.Equals( "memory" ,StringComparison.InvariantCultureIgnoreCase )  )
        {
          return 2;
        }
        else
        {
          return 0;
        }
      }
  #endif // * SQLITE_PAGER_PRAGMAS */
  
  #if !SQLITE_OMIT_PAGER_PRAGMAS
      /*
  ** Invalidate temp storage, either when the temp storage is changed
  ** from default, or when 'file' and the temp_store_directory has changed
  */
      static int invalidateTempStorage( Parse pParse )
      {
        sqlite3 db = pParse.db;
        if ( db.aDb[1].pBt != null )
        {
          if ( 0 == db.autoCommit || sqlite3BtreeIsInReadTrans( db.aDb[1].pBt ) )
          {
            sqlite3ErrorMsg( pParse, "temporary storage cannot be changed " +
            "from within a transaction" );
            return SQLITE_ERROR;
          }
          sqlite3BtreeClose( ref db.aDb[1].pBt );
          db.aDb[1].pBt = null;
          sqlite3ResetInternalSchema( db, -1 );
        }
        return SQLITE_OK;
      }
  #endif // * SQLITE_PAGER_PRAGMAS */
  
  #if !SQLITE_OMIT_PAGER_PRAGMAS
      /*
  ** If the TEMP database is open, close it and mark the database schema
  ** as needing reloading.  This must be done when using the SQLITE_TEMP_STORE
  ** or DEFAULT_TEMP_STORE pragmas.
  */
      static int changeTempStorage( Parse pParse, string zStorageType )
      {
        int ts = getTempStore( zStorageType );
        sqlite3 db = pParse.db;
        if ( db.temp_store == ts )
          return SQLITE_OK;
        if ( invalidateTempStorage( pParse ) != SQLITE_OK )
        {
          return SQLITE_ERROR;
        }
        db.temp_store = (u8)ts;
        return SQLITE_OK;
      }
  #endif // * SQLITE_PAGER_PRAGMAS */
  
      /*
  ** Generate code to return a single integer value.
  */
      static void returnSingleInt( Parse pParse, string zLabel, i64 value )
      {
        Vdbe v = sqlite3GetVdbe( pParse );
        int mem = ++pParse.nMem;
        //i64* pI64 = sqlite3DbMallocRaw( pParse->db, sizeof( value ) );
        //if ( pI64 )
        //{
        //  memcpy( pI64, &value, sizeof( value ) );
        //}
        //sqlite3VdbeAddOp4( v, OP_Int64, 0, mem, 0, (char*)pI64, P4_INT64 );
        sqlite3VdbeAddOp4( v, OP_Int64, 0, mem, 0, value, P4_INT64 );
        sqlite3VdbeSetNumCols( v, 1 );
        sqlite3VdbeSetColName( v, 0, COLNAME_NAME, zLabel, SQLITE_STATIC );
        sqlite3VdbeAddOp2( v, OP_ResultRow, mem, 1 );
      }
  
  #if !SQLITE_OMIT_FLAG_PRAGMAS
      /*
  ** Check to see if zRight and zLeft refer to a pragma that queries
  ** or changes one of the flags in db.flags.  Return 1 if so and 0 if not.
  ** Also, implement the pragma.
  */
      struct sPragmaType
      {
        public string zName;  /* Name of the pragma */
        public int mask;           /* Mask for the db.flags value */
        public sPragmaType( string zName, int mask )
        {
          this.zName = zName;
          this.mask = mask;
        }
      }
      static int flagPragma( Parse pParse, string zLeft, string zRight )
      {
        sPragmaType[] aPragma = new sPragmaType[]{
  new sPragmaType( "full_column_names",        SQLITE_FullColNames  ),
  new sPragmaType( "short_column_names",       SQLITE_ShortColNames ),
  new sPragmaType( "count_changes",            SQLITE_CountRows     ),
  new sPragmaType( "empty_result_callbacks",   SQLITE_NullCallback  ),
  new sPragmaType( "legacy_file_format",       SQLITE_LegacyFileFmt ),
  new sPragmaType( "fullfsync",                SQLITE_FullFSync     ),
  new sPragmaType( "checkpoint_fullfsync",     SQLITE_CkptFullFSync ),
  new sPragmaType(  "reverse_unordered_selects", SQLITE_ReverseOrder),
  #if !SQLITE_OMIT_AUTOMATIC_INDEX
  new sPragmaType(  "automatic_index",          SQLITE_AutoIndex    ),
  #endif
  #if SQLITE_DEBUG
  new sPragmaType( "sql_trace",                SQLITE_SqlTrace      ),
  new sPragmaType( "vdbe_listing",             SQLITE_VdbeListing   ),
  new sPragmaType( "vdbe_trace",               SQLITE_VdbeTrace     ),
  #endif
  #if !SQLITE_OMIT_CHECK
  new sPragmaType( "ignore_check_constraints", SQLITE_IgnoreChecks  ),
  #endif
  /* The following is VERY experimental */
  new sPragmaType( "writable_schema",          SQLITE_WriteSchema|SQLITE_RecoveryMode ),
  new sPragmaType( "omit_readlock",            SQLITE_NoReadlock    ),
  
  /* TODO: Maybe it shouldn't be possible to change the ReadUncommitted
  ** flag if there are any active statements. */
  new sPragmaType( "read_uncommitted",         SQLITE_ReadUncommitted ),
  new sPragmaType( "recursive_triggers",       SQLITE_RecTriggers ),
  
  /* This flag may only be set if both foreign-key and trigger support
  ** are present in the build.  */
  #if !(SQLITE_OMIT_FOREIGN_KEY) && !(SQLITE_OMIT_TRIGGER)
  new sPragmaType( "foreign_keys",             SQLITE_ForeignKeys ),
  #endif
  };
        int i;
        sPragmaType p;
        for ( i = 0; i < ArraySize( aPragma ); i++ )//, p++)
        {
          p = aPragma[i];
          if ( zLeft.Equals( p.zName ,StringComparison.InvariantCultureIgnoreCase )  )
          {
            sqlite3 db = pParse.db;
            Vdbe v;
            v = sqlite3GetVdbe( pParse );
            Debug.Assert( v != null );  /* Already allocated by sqlite3Pragma() */
            if ( ALWAYS( v ) )
            {
              if ( null == zRight )
              {
                returnSingleInt( pParse, p.zName, ( ( db.flags & p.mask ) != 0 ) ? 1 : 0 );
              }
              else
              {
                int mask = p.mask;          /* Mask of bits to set or clear. */
                if ( db.autoCommit == 0 )
                {
                  /* Foreign key support may not be enabled or disabled while not
                  ** in auto-commit mode.  */
                  mask &= ~( SQLITE_ForeignKeys );
                }
                if ( sqlite3GetBoolean( zRight ) != 0 )
                {
                  db.flags |= mask;
                }
                else
                {
                  db.flags &= ~mask;
                }
  
                /* Many of the flag-pragmas modify the code generated by the SQL
                ** compiler (eg. count_changes). So add an opcode to expire all
                ** compiled SQL statements after modifying a pragma value.
                */
                sqlite3VdbeAddOp2( v, OP_Expire, 0, 0 );
              }
            }
  
            return 1;
          }
        }
        return 0;
      }
  #endif // * SQLITE_OMIT_FLAG_PRAGMAS */
  
      /*
  ** Return a human-readable name for a constraint resolution action.
  */
  #if !SQLITE_OMIT_FOREIGN_KEY
      static string actionName( int action )
      {
        string zName;
        switch ( action )
        {
          case OE_SetNull:
            zName = "SET NULL";
            break;
          case OE_SetDflt:
            zName = "SET DEFAULT";
            break;
          case OE_Cascade:
            zName = "CASCADE";
            break;
          case OE_Restrict:
            zName = "RESTRICT";
            break;
          default:
            zName = "NO ACTION";
            Debug.Assert( action == OE_None );
            break;
        }
        return zName;
      }
  #endif
  
      /*
  ** Parameter eMode must be one of the PAGER_JOURNALMODE_XXX constants
  ** defined in pager.h. This function returns the associated lowercase
  ** journal-mode name.
  */
      static string sqlite3JournalModename( int eMode )
      {
        string[] azModeName = {
  "delete", "persist", "off", "truncate", "memory"
  #if !SQLITE_OMIT_WAL
  , "wal"
  #endif
  };
        Debug.Assert( PAGER_JOURNALMODE_DELETE == 0 );
        Debug.Assert( PAGER_JOURNALMODE_PERSIST == 1 );
        Debug.Assert( PAGER_JOURNALMODE_OFF == 2 );
        Debug.Assert( PAGER_JOURNALMODE_TRUNCATE == 3 );
        Debug.Assert( PAGER_JOURNALMODE_MEMORY == 4 );
        Debug.Assert( PAGER_JOURNALMODE_WAL == 5 );
        Debug.Assert( eMode >= 0 && eMode <= ArraySize( azModeName ) );
  
        if ( eMode == ArraySize( azModeName ) )
          return null;
        return azModeName[eMode];
      }
  
      /*
      ** Process a pragma statement.
      **
      ** Pragmas are of this form:
      **
      **      PRAGMA [database.]id [= value]
      **
      ** The identifier might also be a string.  The value is a string, and
      ** identifier, or a number.  If minusFlag is true, then the value is
      ** a number that was preceded by a minus sign.
      **
      ** If the left side is "database.id" then pId1 is the database name
      ** and pId2 is the id.  If the left side is just "id" then pId1 is the
      ** id and pId2 is any empty string.
      */
      class EncName
      {
        public string zName;
        public u8 enc;
  
        public EncName( string zName, u8 enc )
        {
          this.zName = zName;
          this.enc = enc;
        }
      };
  
      static EncName[] encnames = new EncName[]  {
  new EncName( "UTF8",     SQLITE_UTF8        ),
  new EncName( "UTF-8",    SQLITE_UTF8        ),/* Must be element [1] */
  new EncName( "UTF-16le (not supported)", SQLITE_UTF16LE     ),/* Must be element [2] */
  new EncName( "UTF-16be (not supported)", SQLITE_UTF16BE     ), /* Must be element [3] */
  new EncName( "UTF16le (not supported)",  SQLITE_UTF16LE     ),
  new EncName( "UTF16be (not supported)",  SQLITE_UTF16BE     ),
  new EncName( "UTF-16 (not supported)",   0                  ), /* SQLITE_UTF16NATIVE */
  new EncName( "UTF16",    0                  ), /* SQLITE_UTF16NATIVE */
  new EncName( null, 0 )
  };
      
      // OVERLOADS, so I don't need to rewrite parse.c
      static void sqlite3Pragma( Parse pParse, Token pId1, Token pId2, int null_4, int minusFlag )
      {
        sqlite3Pragma( pParse, pId1, pId2, null, minusFlag );
      }
      static void sqlite3Pragma(
      Parse pParse,
      Token pId1,        /* First part of [database.]id field */
      Token pId2,        /* Second part of [database.]id field, or NULL */
      Token pValue,      /* Token for <value>, or NULL */
      int minusFlag     /* True if a '-' sign preceded <value> */
      )
      {
        string zLeft = null;    /* Nul-terminated UTF-8 string <id> */
        string zRight = null;   /* Nul-terminated UTF-8 string <value>, or NULL */
        string zDb = null;      /* The database name */
        Token pId = new Token();/* Pointer to <id> token */
        int iDb;                /* Database index for <database> */
        sqlite3 db = pParse.db;
        Db pDb;
        Vdbe v = pParse.pVdbe = sqlite3VdbeCreate( db );
        if ( v == null )
          return;
        sqlite3VdbeRunOnlyOnce( v );
        pParse.nMem = 2;
  
        /* Interpret the [database.] part of the pragma statement. iDb is the
        ** index of the database this pragma is being applied to in db.aDb[]. */
        iDb = sqlite3TwoPartName( pParse, pId1, pId2, ref pId );
        if ( iDb < 0 )
          return;
        pDb = db.aDb[iDb];
  
        /* If the temp database has been explicitly named as part of the
        ** pragma, make sure it is open.
        */
        if ( iDb == 1 && sqlite3OpenTempDatabase( pParse ) != 0 )
        {
          return;
        }
  
        zLeft = sqlite3NameFromToken( db, pId );
        if ( zLeft == "" )
          return;
        if ( minusFlag != 0 )
        {
          zRight = ( pValue == null ) ? "" : sqlite3MPrintf( db, "-%T", pValue );
        }
        else
        {
          zRight = sqlite3NameFromToken( db, pValue );
        }
  
        Debug.Assert( pId2 != null );
        zDb = pId2.n > 0 ? pDb.zName : null;
  #if !SQLITE_OMIT_AUTHORIZATION
  if ( sqlite3AuthCheck( pParse, SQLITE_PRAGMA, zLeft, zRight, zDb ) )
  {
  goto pragma_out;
  }
  #endif
  #if !SQLITE_OMIT_PAGER_PRAGMAS
        /*
  **  PRAGMA [database.]default_cache_size
  **  PRAGMA [database.]default_cache_size=N
  **
  ** The first form reports the current persistent setting for the
  ** page cache size.  The value returned is the maximum number of
  ** pages in the page cache.  The second form sets both the current
  ** page cache size value and the persistent page cache size value
  ** stored in the database file.
  **
  ** Older versions of SQLite would set the default cache size to a
  ** negative number to indicate synchronous=OFF.  These days, synchronous
  ** is always on by default regardless of the sign of the default cache
  ** size.  But continue to take the absolute value of the default cache
  ** size of historical compatibility.
  */
        if ( zLeft.Equals( "default_cache_size" ,StringComparison.InvariantCultureIgnoreCase )  )
        {
          VdbeOpList[] getCacheSize = new VdbeOpList[]{
  new VdbeOpList( OP_Transaction, 0, 0,        0),                         /* 0 */
  new VdbeOpList( OP_ReadCookie,  0, 1,        BTREE_DEFAULT_CACHE_SIZE),  /* 1 */
  new VdbeOpList( OP_IfPos,       1, 7,        0),
  new VdbeOpList( OP_Integer,     0, 2,        0),
  new VdbeOpList( OP_Subtract,    1, 2,        1),
  new VdbeOpList( OP_IfPos,       1, 7,        0),
  new VdbeOpList( OP_Integer,     0, 1,        0),  /* 6 */
  new VdbeOpList( OP_ResultRow,   1, 1,        0),
  };
          int addr;
          if ( sqlite3ReadSchema( pParse ) != 0 )
            goto pragma_out;
          sqlite3VdbeUsesBtree( v, iDb );
          if ( null == zRight )
          {
            sqlite3VdbeSetNumCols( v, 1 );
            sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "cache_size", SQLITE_STATIC );
            pParse.nMem += 2;
            addr = sqlite3VdbeAddOpList( v, getCacheSize.Length, getCacheSize );
            sqlite3VdbeChangeP1( v, addr, iDb );
            sqlite3VdbeChangeP1( v, addr + 1, iDb );
            sqlite3VdbeChangeP1( v, addr + 6, SQLITE_DEFAULT_CACHE_SIZE );
          }
          else
          {
            int size = sqlite3AbsInt32(sqlite3Atoi( zRight ));
            sqlite3BeginWriteOperation( pParse, 0, iDb );
            sqlite3VdbeAddOp2( v, OP_Integer, size, 1 );
            sqlite3VdbeAddOp3( v, OP_SetCookie, iDb, BTREE_DEFAULT_CACHE_SIZE, 1 );
            Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) );
            pDb.pSchema.cache_size = size;
            sqlite3BtreeSetCacheSize( pDb.pBt, pDb.pSchema.cache_size );
          }
        }
        else
  
          /*
          **  PRAGMA [database.]page_size
          **  PRAGMA [database.]page_size=N
          **
          ** The first form reports the current setting for the
          ** database page size in bytes.  The second form sets the
          ** database page size value.  The value can only be set if
          ** the database has not yet been created.
          */
          if ( zLeft.Equals( "page_size" ,StringComparison.InvariantCultureIgnoreCase )  )
          {
            Btree pBt = pDb.pBt;
            Debug.Assert( pBt != null );
            if ( null == zRight )
            {
              int size = ALWAYS( pBt ) ? sqlite3BtreeGetPageSize( pBt ) : 0;
              returnSingleInt( pParse, "page_size", size );
            }
            else
            {
              /* Malloc may fail when setting the page-size, as there is an internal
              ** buffer that the pager module resizes using sqlite3_realloc().
              */
              db.nextPagesize = sqlite3Atoi( zRight );
              if ( SQLITE_NOMEM == sqlite3BtreeSetPageSize( pBt, db.nextPagesize, -1, 0 ) )
              {
                ////        db.mallocFailed = 1;
              }
            }
          }
          else
  
            /*
            **  PRAGMA [database.]secure_delete
            **  PRAGMA [database.]secure_delete=ON/OFF
            **
            ** The first form reports the current setting for the
            ** secure_delete flag.  The second form changes the secure_delete
            ** flag setting and reports thenew value.
            */
            if ( zLeft.Equals( "secure_delete" ,StringComparison.InvariantCultureIgnoreCase )  )
            {
              Btree pBt = pDb.pBt;
              int b = -1;
              Debug.Assert( pBt != null );
              if ( zRight != null )
              {
                b = sqlite3GetBoolean( zRight );
              }
              if ( pId2.n == 0 && b >= 0 )
              {
                int ii;
                for ( ii = 0; ii < db.nDb; ii++ )
                {
                  sqlite3BtreeSecureDelete( db.aDb[ii].pBt, b );
                }
              }
              b = sqlite3BtreeSecureDelete( pBt, b );
              returnSingleInt( pParse, "secure_delete", b );
            }
            else
              /*
              **  PRAGMA [database.]max_page_count
              **  PRAGMA [database.]max_page_count=N
              **
              ** The first form reports the current setting for the
              ** maximum number of pages in the database file.  The 
              ** second form attempts to change this setting.  Both
              ** forms return the current setting.
              **
              **  PRAGMA [database.]page_count
              **
              ** Return the number of pages in the specified database.
              */
              if ( zLeft.Equals( "page_count" ,StringComparison.InvariantCultureIgnoreCase ) 
              || zLeft.Equals( "max_page_count" ,StringComparison.InvariantCultureIgnoreCase ) 
              )
              {
                int iReg;
                if ( sqlite3ReadSchema( pParse ) != 0 )
                  goto pragma_out;
                sqlite3CodeVerifySchema( pParse, iDb );
                iReg = ++pParse.nMem;
                if ( zLeft[0] == 'p' )
                {
                  sqlite3VdbeAddOp2( v, OP_Pagecount, iDb, iReg );
                }
                else
                {
                  sqlite3VdbeAddOp3( v, OP_MaxPgcnt, iDb, iReg, sqlite3Atoi( zRight ) );
                }
                sqlite3VdbeAddOp2( v, OP_ResultRow, iReg, 1 );
                sqlite3VdbeSetNumCols( v, 1 );
                sqlite3VdbeSetColName( v, 0, COLNAME_NAME, zLeft, SQLITE_TRANSIENT );
              }
              else
  
                /*
                **  PRAGMA [database.]page_count
                **
                ** Return the number of pages in the specified database.
                */
                if ( zLeft == "page_count" )
                {
                  Vdbe _v;
                  int iReg;
                  _v = sqlite3GetVdbe( pParse );
                  if ( _v == null || sqlite3ReadSchema( pParse ) != 0 )
                    goto pragma_out;
                  sqlite3CodeVerifySchema( pParse, iDb );
                  iReg = ++pParse.nMem;
                  sqlite3VdbeAddOp2( _v, OP_Pagecount, iDb, iReg );
                  sqlite3VdbeAddOp2( _v, OP_ResultRow, iReg, 1 );
                  sqlite3VdbeSetNumCols( _v, 1 );
                  sqlite3VdbeSetColName( _v, 0, COLNAME_NAME, "page_count", SQLITE_STATIC );
                }
                else
  
                  /*
                  **  PRAGMA [database.]locking_mode
                  **  PRAGMA [database.]locking_mode = (normal|exclusive)
                  */
                  if ( zLeft.Equals( "locking_mode" ,StringComparison.InvariantCultureIgnoreCase )  )
                  {
                    string zRet = "normal";
                    int eMode = getLockingMode( zRight );
  
                    if ( pId2.n == 0 && eMode == PAGER_LOCKINGMODE_QUERY )
                    {
                      /* Simple "PRAGMA locking_mode;" statement. This is a query for
                      ** the current default locking mode (which may be different to
                      ** the locking-mode of the main database).
                      */
                      eMode = db.dfltLockMode;
                    }
                    else
                    {
                      Pager pPager;
                      if ( pId2.n == 0 )
                      {
                        /* This indicates that no database name was specified as part
                        ** of the PRAGMA command. In this case the locking-mode must be
                        ** set on all attached databases, as well as the main db file.
                        **
                        ** Also, the sqlite3.dfltLockMode variable is set so that
                        ** any subsequently attached databases also use the specified
                        ** locking mode.
                        */
                        int ii;
                        Debug.Assert( pDb == db.aDb[0] );
                        for ( ii = 2; ii < db.nDb; ii++ )
                        {
                          pPager = sqlite3BtreePager( db.aDb[ii].pBt );
                          sqlite3PagerLockingMode( pPager, eMode );
                        }
                        db.dfltLockMode = (u8)eMode;
                      }
                      pPager = sqlite3BtreePager( pDb.pBt );
                      eMode = sqlite3PagerLockingMode( pPager, eMode ) ? 1 : 0;
                    }
  
                    Debug.Assert( eMode == PAGER_LOCKINGMODE_NORMAL || eMode == PAGER_LOCKINGMODE_EXCLUSIVE );
                    if ( eMode == PAGER_LOCKINGMODE_EXCLUSIVE )
                    {
                      zRet = "exclusive";
                    }
                    sqlite3VdbeSetNumCols( v, 1 );
                    sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "locking_mode", SQLITE_STATIC );
                    sqlite3VdbeAddOp4( v, OP_String8, 0, 1, 0, zRet, 0 );
                    sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 1 );
                  }
                  else
                    /*
                    **  PRAGMA [database.]journal_mode
                    **  PRAGMA [database.]journal_mode =
                    **                      (delete|persist|off|truncate|memory|wal|off)
                    */
                    if ( zLeft == "journal_mode" )
                    {
                      int eMode;        /* One of the PAGER_JOURNALMODE_XXX symbols */
                      int ii;           /* Loop counter */
  
                      /* Force the schema to be loaded on all databases.  This cases all
                      ** database files to be opened and the journal_modes set. */
                      if ( sqlite3ReadSchema( pParse ) != 0 )
                      {
                        goto pragma_out;
                      }
  
                      sqlite3VdbeSetNumCols( v, 1 );
                      sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "journal_mode", SQLITE_STATIC );
                      if ( null == zRight )
                      {
                        /* If there is no "=MODE" part of the pragma, do a query for the
                        ** current mode */
                        eMode = PAGER_JOURNALMODE_QUERY;
                      }
                      else
                      {
                        string zMode;
                        int n = sqlite3Strlen30( zRight );
                        for ( eMode = 0; ( zMode = sqlite3JournalModename( eMode ) ) != null; eMode++ )
                        {
                          if ( sqlite3StrNICmp( zRight, zMode, n ) == 0 )
                            break;
                        }
                        if ( null == zMode )
                        {
                          /* If the "=MODE" part does not match any known journal mode,
                          ** then do a query */
                          eMode = PAGER_JOURNALMODE_QUERY;
                        }
                      }
                      if ( eMode == PAGER_JOURNALMODE_QUERY && pId2.n == 0 )
                      {
                        /* Convert "PRAGMA journal_mode" into "PRAGMA main.journal_mode" */
                        iDb = 0;
                        pId2.n = 1;
                      }
                      for ( ii = db.nDb - 1; ii >= 0; ii-- )
                      {
                        if ( db.aDb[ii].pBt != null && ( ii == iDb || pId2.n == 0 ) )
                        {
                          sqlite3VdbeUsesBtree( v, ii );
                          sqlite3VdbeAddOp3( v, OP_JournalMode, ii, 1, eMode );
                        }
                      }
                      sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 1 );
                    }
                    else
  
                      /*
                      **  PRAGMA [database.]journal_size_limit
                      **  PRAGMA [database.]journal_size_limit=N
                      **
                      ** Get or set the size limit on rollback journal files.
                      */
                      if ( zLeft.Equals( "journal_size_limit" ,StringComparison.InvariantCultureIgnoreCase )  )
                      {
                        Pager pPager = sqlite3BtreePager( pDb.pBt );
                        i64 iLimit = -2;
                        if ( !String.IsNullOrEmpty( zRight ) )
                        {
                          sqlite3Atoi64( zRight, ref iLimit, 1000000, SQLITE_UTF8 );
                          if ( iLimit < -1 )
                            iLimit = -1;
                        }
                        iLimit = sqlite3PagerJournalSizeLimit( pPager, iLimit );
                        returnSingleInt( pParse, "journal_size_limit", iLimit );
                      }
                      else
  
  #endif // * SQLITE_OMIT_PAGER_PRAGMAS */
  
                        /*
  **  PRAGMA [database.]auto_vacuum
  **  PRAGMA [database.]auto_vacuum=N
  **
  ** Get or set the value of the database 'auto-vacuum' parameter.
  ** The value is one of:  0 NONE 1 FULL 2 INCREMENTAL
  */
  #if !SQLITE_OMIT_AUTOVACUUM
                        if ( zLeft.Equals( "auto_vacuum" ,StringComparison.InvariantCultureIgnoreCase )  )
                        {
                          Btree pBt = pDb.pBt;
                          Debug.Assert( pBt != null );
                          if ( sqlite3ReadSchema( pParse ) != 0 )
                          {
                            goto pragma_out;
                          }
                          if ( null == zRight )
                          {
                            int auto_vacuum;
                            if ( ALWAYS( pBt ) )
                            {
                              auto_vacuum = sqlite3BtreeGetAutoVacuum( pBt );
                            }
                            else
                            {
                              auto_vacuum = SQLITE_DEFAULT_AUTOVACUUM;
                            }
                            returnSingleInt( pParse, "auto_vacuum", auto_vacuum );
                          }
                          else
                          {
                            int eAuto = getAutoVacuum( zRight );
                            Debug.Assert( eAuto >= 0 && eAuto <= 2 );
                            db.nextAutovac = (u8)eAuto;
                            if ( ALWAYS( eAuto >= 0 ) )
                            {
                              /* Call SetAutoVacuum() to set initialize the internal auto and
                              ** incr-vacuum flags. This is required in case this connection
                              ** creates the database file. It is important that it is created
                              ** as an auto-vacuum capable db.
                              */
                              int rc = sqlite3BtreeSetAutoVacuum( pBt, eAuto );
                              if ( rc == SQLITE_OK && ( eAuto == 1 || eAuto == 2 ) )
                              {
                                /* When setting the auto_vacuum mode to either "full" or
                                ** "incremental", write the value of meta[6] in the database
                                ** file. Before writing to meta[6], check that meta[3] indicates
                                ** that this really is an auto-vacuum capable database.
                                */
                                VdbeOpList[] setMeta6 = new VdbeOpList[] {
  new VdbeOpList( OP_Transaction,    0,               1,        0),    /* 0 */
  new VdbeOpList( OP_ReadCookie,     0,               1,        BTREE_LARGEST_ROOT_PAGE),    /* 1 */
  new VdbeOpList( OP_If,             1,               0,        0),    /* 2 */
  new VdbeOpList( OP_Halt,           SQLITE_OK,       OE_Abort, 0),    /* 3 */
  new VdbeOpList( OP_Integer,        0,               1,        0),    /* 4 */
  new VdbeOpList( OP_SetCookie,      0,               BTREE_INCR_VACUUM, 1),    /* 5 */
  };
                                int iAddr;
                                iAddr = sqlite3VdbeAddOpList( v, ArraySize( setMeta6 ), setMeta6 );
                                sqlite3VdbeChangeP1( v, iAddr, iDb );
                                sqlite3VdbeChangeP1( v, iAddr + 1, iDb );
                                sqlite3VdbeChangeP2( v, iAddr + 2, iAddr + 4 );
                                sqlite3VdbeChangeP1( v, iAddr + 4, eAuto - 1 );
                                sqlite3VdbeChangeP1( v, iAddr + 5, iDb );
                                sqlite3VdbeUsesBtree( v, iDb );
                              }
                            }
                          }
                        }
                        else
  #endif
  
                          /*
  **  PRAGMA [database.]incremental_vacuum(N)
  **
  ** Do N steps of incremental vacuuming on a database.
  */
  #if !SQLITE_OMIT_AUTOVACUUM
                          if ( zLeft.Equals( "incremental_vacuum" ,StringComparison.InvariantCultureIgnoreCase )  )
                          {
                            int iLimit = 0, addr;
                            if ( sqlite3ReadSchema( pParse ) != 0 )
                            {
                              goto pragma_out;
                            }
                            if ( zRight == null || !sqlite3GetInt32( zRight, ref iLimit ) || iLimit <= 0 )
                            {
                              iLimit = 0x7fffffff;
                            }
                            sqlite3BeginWriteOperation( pParse, 0, iDb );
                            sqlite3VdbeAddOp2( v, OP_Integer, iLimit, 1 );
                            addr = sqlite3VdbeAddOp1( v, OP_IncrVacuum, iDb );
                            sqlite3VdbeAddOp1( v, OP_ResultRow, 1 );
                            sqlite3VdbeAddOp2( v, OP_AddImm, 1, -1 );
                            sqlite3VdbeAddOp2( v, OP_IfPos, 1, addr );
                            sqlite3VdbeJumpHere( v, addr );
                          }
                          else
  #endif
  
  #if !SQLITE_OMIT_PAGER_PRAGMAS
                            /*
  **  PRAGMA [database.]cache_size
  **  PRAGMA [database.]cache_size=N
  **
  ** The first form reports the current local setting for the
  ** page cache size.  The local setting can be different from
  ** the persistent cache size value that is stored in the database
  ** file itself.  The value returned is the maximum number of
  ** pages in the page cache.  The second form sets the local
  ** page cache size value.  It does not change the persistent
  ** cache size stored on the disk so the cache size will revert
  ** to its default value when the database is closed and reopened.
  ** N should be a positive integer.
  */
                            if ( zLeft.Equals( "cache_size" ,StringComparison.InvariantCultureIgnoreCase )  )
                            {
                              if ( sqlite3ReadSchema( pParse ) != 0 )
                                goto pragma_out;
                              Debug.Assert( sqlite3SchemaMutexHeld( db, iDb, null ) );
                              if ( null == zRight )
                              {
                                returnSingleInt( pParse, "cache_size", pDb.pSchema.cache_size );
                              }
                              else
                              {
                                int size = sqlite3AbsInt32(sqlite3Atoi( zRight ));
                                pDb.pSchema.cache_size = size;
                                sqlite3BtreeSetCacheSize( pDb.pBt, pDb.pSchema.cache_size );
                              }
                            }
                            else
  
                              /*
                              **   PRAGMA temp_store
                              **   PRAGMA temp_store = "default"|"memory"|"file"
                              **
                              ** Return or set the local value of the temp_store flag.  Changing
                              ** the local value does not make changes to the disk file and the default
                              ** value will be restored the next time the database is opened.
                              **
                              ** Note that it is possible for the library compile-time options to
                              ** override this setting
                              */
                              if ( zLeft.Equals( "temp_store" ,StringComparison.InvariantCultureIgnoreCase )  )
                              {
                                if ( zRight == null )
                                {
                                  returnSingleInt( pParse, "temp_store", db.temp_store );
                                }
                                else
                                {
                                  changeTempStorage( pParse, zRight );
                                }
                              }
                              else
  
                                /*
                                **   PRAGMA temp_store_directory
                                **   PRAGMA temp_store_directory = ""|"directory_name"
                                **
                                ** Return or set the local value of the temp_store_directory flag.  Changing
                                ** the value sets a specific directory to be used for temporary files.
                                ** Setting to a null string reverts to the default temporary directory search.
                                ** If temporary directory is changed, then invalidateTempStorage.
                                **
                                */
                                if ( zLeft.Equals( "temp_store_directory" ,StringComparison.InvariantCultureIgnoreCase )  )
                                {
                                  if ( null == zRight )
                                  {
                                    if ( sqlite3_temp_directory != "" )
                                    {
                                      sqlite3VdbeSetNumCols( v, 1 );
                                      sqlite3VdbeSetColName( v, 0, COLNAME_NAME,
                                          "temp_store_directory", SQLITE_STATIC );
                                      sqlite3VdbeAddOp4( v, OP_String8, 0, 1, 0, sqlite3_temp_directory, 0 );
                                      sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 1 );
                                    }
                                  }
                                  else
                                  {
  #if !SQLITE_OMIT_WSD
                                    if ( zRight.Length > 0 )
                                    {
                                      int rc;
                                      int res = 0;
                                      rc = sqlite3OsAccess( db.pVfs, zRight, SQLITE_ACCESS_READWRITE, ref res );
                                      if ( rc != SQLITE_OK || res == 0 )
                                      {
                                        sqlite3ErrorMsg( pParse, "not a writable directory" );
                                        goto pragma_out;
                                      }
                                    }
                                    if ( SQLITE_TEMP_STORE == 0
                                     || ( SQLITE_TEMP_STORE == 1 && db.temp_store <= 1 )
                                     || ( SQLITE_TEMP_STORE == 2 && db.temp_store == 1 )
                                    )
                                    {
                                      invalidateTempStorage( pParse );
                                    }
                                    //sqlite3_free( ref sqlite3_temp_directory );
                                    if ( zRight.Length > 0 )
                                    {
                                      sqlite3_temp_directory = zRight;//sqlite3_mprintf("%s", zRight);
                                    }
                                    else
                                    {
                                      sqlite3_temp_directory = "";
                                    }
  #endif //* SQLITE_OMIT_WSD */
                                  }
                                }
                                else
  
  #if !(SQLITE_ENABLE_LOCKING_STYLE)
  #  if (__APPLE__)
  //#    define SQLITE_ENABLE_LOCKING_STYLE 1
  #  else
                                  //#    define SQLITE_ENABLE_LOCKING_STYLE 0
  #  endif
  #endif
  #if SQLITE_ENABLE_LOCKING_STYLE
  /*
  **   PRAGMA [database.]lock_proxy_file
  **   PRAGMA [database.]lock_proxy_file = ":auto:"|"lock_file_path"
  **
  ** Return or set the value of the lock_proxy_file flag.  Changing
  ** the value sets a specific file to be used for database access locks.
  **
  */
  if ( zLeft.Equals( "lock_proxy_file" ,StringComparison.InvariantCultureIgnoreCase )  )
  {
  if ( zRight !="")
  {
  Pager pPager = sqlite3BtreePager( pDb.pBt );
  int proxy_file_path = 0;
  sqlite3_file pFile = sqlite3PagerFile( pPager );
  sqlite3OsFileControl( pFile, SQLITE_GET_LOCKPROXYFILE,
  ref proxy_file_path );
  
  if ( proxy_file_path!=0 )
  {
  sqlite3VdbeSetNumCols( v, 1 );
  sqlite3VdbeSetColName( v, 0, COLNAME_NAME,
  "lock_proxy_file", SQLITE_STATIC );
  sqlite3VdbeAddOp4( v, OP_String8, 0, 1, 0, proxy_file_path, 0 );
  sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 1 );
  }
  }
  else
  {
  Pager pPager = sqlite3BtreePager( pDb.pBt );
  sqlite3_file pFile = sqlite3PagerFile( pPager );
  int res;
  int iDummy = 0;
  if ( zRight[0]!=0 )
  {
  iDummy = zRight[0];
  res = sqlite3OsFileControl( pFile, SQLITE_SET_LOCKPROXYFILE,
  ref iDummy );
  }
  else
  {
  res = sqlite3OsFileControl( pFile, SQLITE_SET_LOCKPROXYFILE,
  ref iDummy );
  }
  if ( res != SQLITE_OK )
  {
  sqlite3ErrorMsg( pParse, "failed to set lock proxy file" );
  goto pragma_out;
  }
  }
  }
  else
  #endif //* SQLITE_ENABLE_LOCKING_STYLE */
  
                                  /*
  **   PRAGMA [database.]synchronous
  **   PRAGMA [database.]synchronous=OFF|ON|NORMAL|FULL
  **
  ** Return or set the local value of the synchronous flag.  Changing
  ** the local value does not make changes to the disk file and the
  ** default value will be restored the next time the database is
  ** opened.
  */
                                  if ( zLeft.Equals( "synchronous" ,StringComparison.InvariantCultureIgnoreCase )  )
                                  {
                                    if ( sqlite3ReadSchema( pParse ) != 0 )
                                      goto pragma_out;
                                    if ( null == zRight )
                                    {
                                      returnSingleInt( pParse, "synchronous", pDb.safety_level - 1 );
                                    }
                                    else
                                    {
                                      if ( 0 == db.autoCommit )
                                      {
                                        sqlite3ErrorMsg( pParse,
                                          "Safety level may not be changed inside a transaction" );
                                      }
                                      else
                                      {
                                        pDb.safety_level = (byte)( getSafetyLevel( zRight ) + 1 );
                                      }
                                    }
                                  }
                                  else
  #endif // * SQLITE_OMIT_PAGER_PRAGMAS */
  
  #if !SQLITE_OMIT_FLAG_PRAGMAS
                                    if ( flagPragma( pParse, zLeft, zRight ) != 0 )
                                    {
                                      /* The flagPragma() subroutine also generates any necessary code
                                      ** there is nothing more to do here */
                                    }
                                    else
  #endif // * SQLITE_OMIT_FLAG_PRAGMAS */
  
  #if !SQLITE_OMIT_SCHEMA_PRAGMAS
                                      /*
  **   PRAGMA table_info(<table>)
  **
  ** Return a single row for each column of the named table. The columns of
  ** the returned data set are:
  **
  ** cid:        Column id (numbered from left to right, starting at 0)
  ** name:       Column name
  ** type:       Column declaration type.
  ** notnull:    True if 'NOT NULL' is part of column declaration
  ** dflt_value: The default value for the column, if any.
  */
                                      if ( zLeft.Equals( "table_info" ,StringComparison.InvariantCultureIgnoreCase )  && zRight != null )
                                      {
                                        Table pTab;
                                        if ( sqlite3ReadSchema( pParse ) != 0 )
                                          goto pragma_out;
                                        pTab = sqlite3FindTable( db, zRight, zDb );
                                        if ( pTab != null )
                                        {
                                          int i;
                                          int nHidden = 0;
                                          Column pCol;
                                          sqlite3VdbeSetNumCols( v, 6 );
                                          pParse.nMem = 6;
                                          sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "cid", SQLITE_STATIC );
                                          sqlite3VdbeSetColName( v, 1, COLNAME_NAME, "name", SQLITE_STATIC );
                                          sqlite3VdbeSetColName( v, 2, COLNAME_NAME, "type", SQLITE_STATIC );
                                          sqlite3VdbeSetColName( v, 3, COLNAME_NAME, "notnull", SQLITE_STATIC );
                                          sqlite3VdbeSetColName( v, 4, COLNAME_NAME, "dflt_value", SQLITE_STATIC );
                                          sqlite3VdbeSetColName( v, 5, COLNAME_NAME, "pk", SQLITE_STATIC );
                                          sqlite3ViewGetColumnNames( pParse, pTab );
                                          for ( i = 0; i < pTab.nCol; i++ )//, pCol++)
                                          {
                                            pCol = pTab.aCol[i];
                                            if ( IsHiddenColumn( pCol ) )
                                            {
                                              nHidden++;
                                              continue;
                                            }
                                            sqlite3VdbeAddOp2( v, OP_Integer, i - nHidden, 1 );
                                            sqlite3VdbeAddOp4( v, OP_String8, 0, 2, 0, pCol.zName, 0 );
                                            sqlite3VdbeAddOp4( v, OP_String8, 0, 3, 0,
                                               pCol.zType != null ? pCol.zType : "", 0 );
                                            sqlite3VdbeAddOp2( v, OP_Integer, ( pCol.notNull != 0 ? 1 : 0 ), 4 );
                                            if ( pCol.zDflt != null )
                                            {
                                              sqlite3VdbeAddOp4( v, OP_String8, 0, 5, 0, pCol.zDflt, 0 );
                                            }
                                            else
                                            {
                                              sqlite3VdbeAddOp2( v, OP_Null, 0, 5 );
                                            }
                                            sqlite3VdbeAddOp2( v, OP_Integer, pCol.isPrimKey != 0 ? 1 : 0, 6 );
                                            sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 6 );
                                          }
                                        }
                                      }
                                      else
  
                                        if ( zLeft.Equals( "index_info" ,StringComparison.InvariantCultureIgnoreCase )  && zRight != null )
                                        {
                                          Index pIdx;
                                          Table pTab;
                                          if ( sqlite3ReadSchema( pParse ) != 0 )
                                            goto pragma_out;
                                          pIdx = sqlite3FindIndex( db, zRight, zDb );
                                          if ( pIdx != null )
                                          {
                                            int i;
                                            pTab = pIdx.pTable;
                                            sqlite3VdbeSetNumCols( v, 3 );
                                            pParse.nMem = 3;
                                            sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "seqno", SQLITE_STATIC );
                                            sqlite3VdbeSetColName( v, 1, COLNAME_NAME, "cid", SQLITE_STATIC );
                                            sqlite3VdbeSetColName( v, 2, COLNAME_NAME, "name", SQLITE_STATIC );
                                            for ( i = 0; i < pIdx.nColumn; i++ )
                                            {
                                              int cnum = pIdx.aiColumn[i];
                                              sqlite3VdbeAddOp2( v, OP_Integer, i, 1 );
                                              sqlite3VdbeAddOp2( v, OP_Integer, cnum, 2 );
                                              Debug.Assert( pTab.nCol > cnum );
                                              sqlite3VdbeAddOp4( v, OP_String8, 0, 3, 0, pTab.aCol[cnum].zName, 0 );
                                              sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 3 );
                                            }
                                          }
                                        }
                                        else
  
                                          if ( zLeft.Equals( "index_list" ,StringComparison.InvariantCultureIgnoreCase )  && zRight != null )
                                          {
                                            Index pIdx;
                                            Table pTab;
                                            if ( sqlite3ReadSchema( pParse ) != 0 )
                                              goto pragma_out;
                                            pTab = sqlite3FindTable( db, zRight, zDb );
                                            if ( pTab != null )
                                            {
                                              v = sqlite3GetVdbe( pParse );
                                              pIdx = pTab.pIndex;
                                              if ( pIdx != null )
                                              {
                                                int i = 0;
                                                sqlite3VdbeSetNumCols( v, 3 );
                                                pParse.nMem = 3;
                                                sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "seq", SQLITE_STATIC );
                                                sqlite3VdbeSetColName( v, 1, COLNAME_NAME, "name", SQLITE_STATIC );
                                                sqlite3VdbeSetColName( v, 2, COLNAME_NAME, "unique", SQLITE_STATIC );
                                                while ( pIdx != null )
                                                {
                                                  sqlite3VdbeAddOp2( v, OP_Integer, i, 1 );
                                                  sqlite3VdbeAddOp4( v, OP_String8, 0, 2, 0, pIdx.zName, 0 );
                                                  sqlite3VdbeAddOp2( v, OP_Integer, ( pIdx.onError != OE_None ) ? 1 : 0, 3 );
                                                  sqlite3VdbeAddOp2( v, OP_ResultRow, 1, 3 );
                                                  ++i;
                                                  pIdx = pIdx.pNext;
                                                }
                                              }
                                            }
                                          }
                                          else
  
                                            if ( zLeft.Equals( "database_list" ,StringComparison.InvariantCultureIgnoreCase )  )
                                            {
                                              int i;
                                              if ( sqlite3ReadSchema( pParse ) != 0 )
                                                goto pragma_out;
                                              sqlite3VdbeSetNumCols( v, 3 );
                                              pParse.nMem = 3;
                                              sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "seq", SQLITE_STATIC );
                                              sqlite3VdbeSetColName( v, 1, COLNAME_NAME, "name", SQLITE_STATIC );
                                              sqlite3VdbeSetColName( v, 2, COLNAME_NAME, "file", SQLITE_STATIC );
                                              for ( i = 0; i < db.nDb; i++ )
                                              {
                                                if ( db.aDb[i].pBt == null )
                                                  continue;
                                                Debug.Assert( db.aDb[i].zName != null );
                                                sqlite3VdbeAddOp2( v, OP_Integer, i, 1 );
  
gt:                                               sqlite3VdbeAddOp4( v, OP_String8, 0, 2, 0, db.aDb[i].zName, 0 );