/ Check-in [814e41da]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Remove unnecessary fields from the Parse object.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 814e41da3563eecf5514811bc8ab2df4f5cc0d4b
User & Date: drh 2016-09-30 18:35:36
Context
2016-09-30
19:14
Another simplification to the Parse object. check-in: c1419727 user: drh tags: trunk
18:35
Remove unnecessary fields from the Parse object. check-in: 814e41da user: drh tags: trunk
17:46
Avoid unnecessary Mem initializations when generating a new sqlite3_stmt object. check-in: 47ae1cda user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

   168    168       if( db->mallocFailed==0 
   169    169        && (DbMaskNonZero(pParse->cookieMask) || pParse->pConstExpr)
   170    170       ){
   171    171         int iDb, i;
   172    172         assert( sqlite3VdbeGetOp(v, 0)->opcode==OP_Init );
   173    173         sqlite3VdbeJumpHere(v, 0);
   174    174         for(iDb=0; iDb<db->nDb; iDb++){
          175  +        Schema *pSchema;
   175    176           if( DbMaskTest(pParse->cookieMask, iDb)==0 ) continue;
   176    177           sqlite3VdbeUsesBtree(v, iDb);
          178  +        pSchema = db->aDb[iDb].pSchema;
   177    179           sqlite3VdbeAddOp4Int(v,
   178    180             OP_Transaction,                    /* Opcode */
   179    181             iDb,                               /* P1 */
   180    182             DbMaskTest(pParse->writeMask,iDb), /* P2 */
   181         -          pParse->cookieValue[iDb],          /* P3 */
   182         -          db->aDb[iDb].pSchema->iGeneration  /* P4 */
          183  +          pSchema->schema_cookie,            /* P3 */
          184  +          pSchema->iGeneration               /* P4 */
   183    185           );
   184    186           if( db->init.busy==0 ) sqlite3VdbeChangeP5(v, 1);
   185    187           VdbeComment((v,
   186    188                 "usesStmtJournal=%d", pParse->mayAbort && pParse->isMultiWrite));
   187    189         }
   188    190   #ifndef SQLITE_OMIT_VIRTUALTABLE
   189    191         for(i=0; i<pParse->nVtabLock; i++){
................................................................................
   226    228       *  See ticket [a696379c1f08866] */
   227    229       if( pParse->pAinc!=0 && pParse->nTab==0 ) pParse->nTab = 1;
   228    230       sqlite3VdbeMakeReady(v, pParse);
   229    231       pParse->rc = SQLITE_DONE;
   230    232     }else{
   231    233       pParse->rc = SQLITE_ERROR;
   232    234     }
   233         -
   234         -  /* We are done with this Parse object. There is no need to de-initialize it */
   235         -#if 0
   236         -  pParse->colNamesSet = 0;
   237         -  pParse->nTab = 0;
   238         -  pParse->nMem = 0;
   239         -  pParse->nSet = 0;
   240         -  pParse->nVar = 0;
   241         -  DbMaskZero(pParse->cookieMask);
   242         -#endif
   243    235   }
   244    236   
   245    237   /*
   246    238   ** Run the parser and code generator recursively in order to generate
   247    239   ** code for the SQL statement given onto the end of the pParse context
   248    240   ** currently under construction.  When the parser is run recursively
   249    241   ** this way, the final OP_Halt is not appended and other initialization
................................................................................
  4039   4031   ** Record the fact that the schema cookie will need to be verified
  4040   4032   ** for database iDb.  The code to actually verify the schema cookie
  4041   4033   ** will occur at the end of the top-level VDBE and will be generated
  4042   4034   ** later, by sqlite3FinishCoding().
  4043   4035   */
  4044   4036   void sqlite3CodeVerifySchema(Parse *pParse, int iDb){
  4045   4037     Parse *pToplevel = sqlite3ParseToplevel(pParse);
  4046         -  sqlite3 *db = pToplevel->db;
  4047   4038   
  4048         -  assert( iDb>=0 && iDb<db->nDb );
  4049         -  assert( db->aDb[iDb].pBt!=0 || iDb==1 );
         4039  +  assert( iDb>=0 && iDb<pParse->db->nDb );
         4040  +  assert( pParse->db->aDb[iDb].pBt!=0 || iDb==1 );
  4050   4041     assert( iDb<SQLITE_MAX_ATTACHED+2 );
  4051         -  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
         4042  +  assert( sqlite3SchemaMutexHeld(pParse->db, iDb, 0) );
  4052   4043     if( DbMaskTest(pToplevel->cookieMask, iDb)==0 ){
  4053   4044       DbMaskSet(pToplevel->cookieMask, iDb);
  4054         -    pToplevel->cookieValue[iDb] = db->aDb[iDb].pSchema->schema_cookie;
  4055   4045       if( !OMIT_TEMPDB && iDb==1 ){
  4056   4046         sqlite3OpenTempDatabase(pToplevel);
  4057   4047       }
  4058   4048     }
  4059   4049   }
  4060   4050   
  4061   4051   /*

Changes to src/sqliteInt.h.

  2892   2892     u8 nColCache;        /* Number of entries in aColCache[] */
  2893   2893     int aTempReg[8];     /* Holding area for temporary registers */
  2894   2894     int nRangeReg;       /* Size of the temporary register block */
  2895   2895     int iRangeReg;       /* First register in temporary register block */
  2896   2896     int nErr;            /* Number of errors seen */
  2897   2897     int nTab;            /* Number of previously allocated VDBE cursors */
  2898   2898     int nMem;            /* Number of memory cells used so far */
  2899         -  int nSet;            /* Number of sets used so far */
  2900   2899     int nOpAlloc;        /* Number of slots allocated for Vdbe.aOp[] */
  2901   2900     int szOpAlloc;       /* Bytes of memory space allocated for Vdbe.aOp[] */
  2902   2901     int ckBase;          /* Base register of data during check constraints */
  2903   2902     int iSelfTab;        /* Table of an index whose exprs are being coded */
  2904   2903     int iCacheLevel;     /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
  2905   2904     int iCacheCnt;       /* Counter used to generate aColCache[].lru values */
  2906   2905     int nLabel;          /* Number of labels used */
................................................................................
  2913   2912       int iReg;             /* Reg with value of this column. 0 means none. */
  2914   2913       int lru;              /* Least recently used entry has the smallest value */
  2915   2914     } aColCache[SQLITE_N_COLCACHE];  /* One for each column cache entry */
  2916   2915     ExprList *pConstExpr;/* Constant expressions */
  2917   2916     Token constraintName;/* Name of the constraint currently being parsed */
  2918   2917     yDbMask writeMask;   /* Start a write transaction on these databases */
  2919   2918     yDbMask cookieMask;  /* Bitmask of schema verified databases */
  2920         -  int cookieValue[SQLITE_MAX_ATTACHED+2];  /* Values of cookies to verify */
  2921   2919     int regRowid;        /* Register holding rowid of CREATE TABLE entry */
  2922   2920     int regRoot;         /* Register holding root page number for new objects */
  2923   2921     int nMaxArg;         /* Max args passed to user function by sub-program */
  2924   2922   #if SELECTTRACE_ENABLED
  2925   2923     int nSelect;         /* Number of SELECT statements seen */
  2926   2924     int nSelectIndent;   /* How far to indent SELECTTRACE() output */
  2927   2925   #endif