/ Check-in [80236e81]
Login

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

Overview
Comment:Remove more column-cache residue: The OP_SetColTab and OP_VerifyColTab opcodes and the associated SQLITE_DEBUG_COLUMNCACHE logic.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | omit-column-cache
Files: files | file ages | folders
SHA3-256: 80236e81cefdf3d3cda3dbdb6de1575c38e4e248cc4b72ca9ee96d3aa0464bfd
User & Date: drh 2018-08-04 16:54:53
Context
2018-08-04
17:15
Fix comments that were made obsolete by the removal of the column cache. check-in: 2041231d user: drh tags: omit-column-cache
16:54
Remove more column-cache residue: The OP_SetColTab and OP_VerifyColTab opcodes and the associated SQLITE_DEBUG_COLUMNCACHE logic. check-in: 80236e81 user: drh tags: omit-column-cache
15:53
Further logic simplifications that flow out of the omission of the column cache. check-in: 7d9072b0 user: drh tags: omit-column-cache
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/sqliteInt.h.

   363    363   #if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
   364    364   # define NDEBUG 1
   365    365   #endif
   366    366   #if defined(NDEBUG) && defined(SQLITE_DEBUG)
   367    367   # undef NDEBUG
   368    368   #endif
   369    369   
   370         -/* SQLITE_DEBUG_COLUMNCACHE is synomous with SQLITE_DEBUG.  The 
   371         -** SQLITE_DEBUG_COLUMNCACHE symbol only exists to provide a convenient
   372         -** way to search for all code that deals with verifying correct behavior
   373         -** of the column cache.
   374         -*/
   375         -#ifdef SQLITE_DEBUG
   376         -# define SQLITE_DEBUG_COLUMNCACHE 1
   377         -#else
   378         -# undef SQLIT_DEBUG_COLUMNCACHE
   379         -#endif
   380         -
   381    370   /*
   382    371   ** Enable SQLITE_ENABLE_EXPLAIN_COMMENTS if SQLITE_DEBUG is turned on.
   383    372   */
   384    373   #if !defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) && defined(SQLITE_DEBUG)
   385    374   # define SQLITE_ENABLE_EXPLAIN_COMMENTS 1
   386    375   #endif
   387    376   

Changes to src/vdbe.c.

    32     32   */
    33     33   #ifdef SQLITE_DEBUG
    34     34   # define memAboutToChange(P,M) sqlite3VdbeMemAboutToChange(P,M)
    35     35   #else
    36     36   # define memAboutToChange(P,M)
    37     37   #endif
    38     38   
    39         -/*
    40         -** Given a cursor number and a column for a table or index, compute a
    41         -** hash value for use in the Mem.iTabColHash value.  The iTabColHash
    42         -** column is only used for verification - it is omitted from production
    43         -** builds.  Collisions are harmless in the sense that the correct answer
    44         -** still results.  The only harm of collisions is that they can potential
    45         -** reduce column-cache error detection during SQLITE_DEBUG builds.
    46         -**
    47         -** No valid hash should be 0.
    48         -*/
    49         -#define TableColumnHash(T,C)  (((u32)(T)<<16)^(u32)(C+2))
    50         -
    51     39   /*
    52     40   ** The following global variable is incremented every time a cursor
    53     41   ** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes.  The test
    54     42   ** procedures use this information to make sure that indices are
    55     43   ** working correctly.  This variable has no function other than to
    56     44   ** help verify the correct operation of the library.
    57     45   */
................................................................................
  1304   1292     assert( pOut!=pIn1 );
  1305   1293     while( 1 ){
  1306   1294       memAboutToChange(p, pOut);
  1307   1295       sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);
  1308   1296       Deephemeralize(pOut);
  1309   1297   #ifdef SQLITE_DEBUG
  1310   1298       pOut->pScopyFrom = 0;
  1311         -    pOut->iTabColHash = 0;
  1312   1299   #endif
  1313   1300       REGISTER_TRACE(pOp->p2+pOp->p3-n, pOut);
  1314   1301       if( (n--)==0 ) break;
  1315   1302       pOut++;
  1316   1303       pIn1++;
  1317   1304     }
  1318   1305     break;
................................................................................
  7440   7427   ** An Abort is safe if either there have been no writes, or if there is
  7441   7428   ** an active statement journal.
  7442   7429   */
  7443   7430   case OP_Abortable: {
  7444   7431     sqlite3VdbeAssertAbortable(p);
  7445   7432     break;
  7446   7433   }
  7447         -#endif
  7448         -
  7449         -#ifdef SQLITE_DEBUG_COLUMNCACHE
  7450         -/* Opcode:  SetTabCol   P1 P2 P3 * *
  7451         -**
  7452         -** Set a flag in register REG[P3] indicating that it holds the value
  7453         -** of column P2 from the table on cursor P1.  This flag is checked
  7454         -** by a subsequent VerifyTabCol opcode.
  7455         -**
  7456         -** This opcode only appears SQLITE_DEBUG builds.  It is used to verify
  7457         -** that the expression table column cache is working correctly.
  7458         -*/
  7459         -case OP_SetTabCol: {
  7460         -  aMem[pOp->p3].iTabColHash = TableColumnHash(pOp->p1,pOp->p2);
  7461         -  break;
  7462         -}
  7463         -/* Opcode:  VerifyTabCol   P1 P2 P3 * *
  7464         -**
  7465         -** Verify that register REG[P3] contains the value of column P2 from
  7466         -** cursor P1.  Assert() if this is not the case.
  7467         -**
  7468         -** This opcode only appears SQLITE_DEBUG builds.  It is used to verify
  7469         -** that the expression table column cache is working correctly.
  7470         -*/
  7471         -case OP_VerifyTabCol: {
  7472         -  assert( aMem[pOp->p3].iTabColHash == TableColumnHash(pOp->p1,pOp->p2) );
  7473         -  break;
  7474         -}
  7475   7434   #endif
  7476   7435   
  7477   7436   /* Opcode: Noop * * * * *
  7478   7437   **
  7479   7438   ** Do nothing.  This instruction is often useful as a jump
  7480   7439   ** destination.
  7481   7440   */

Changes to src/vdbeInt.h.

   207    207     u32 uTemp;          /* Transient storage for serial_type in OP_MakeRecord */
   208    208     sqlite3 *db;        /* The associated database connection */
   209    209     void (*xDel)(void*);/* Destructor for Mem.z - only valid if MEM_Dyn */
   210    210   #ifdef SQLITE_DEBUG
   211    211     Mem *pScopyFrom;    /* This Mem is a shallow copy of pScopyFrom */
   212    212     u16 mScopyFlags;    /* flags value immediately after the shallow copy */
   213    213   #endif
   214         -#ifdef SQLITE_DEBUG_COLUMNCACHE
   215         -  u32 iTabColHash;    /* Hash of table.column that is origin of this value */
   216         -  u32 iPadding;       /* sqlite3_value objects must be 8-byte aligned */
   217         -#endif
   218    214   };
   219    215   
   220    216   /*
   221    217   ** Size of struct Mem not including the Mem.zMalloc member or anything that
   222    218   ** follows.
   223    219   */
   224    220   #define MEMCELLSIZE offsetof(Mem,zMalloc)

Changes to src/vdbeapi.c.

   968    968           /* .uTemp      = */ (u32)0,
   969    969           /* .db         = */ (sqlite3*)0,
   970    970           /* .xDel       = */ (void(*)(void*))0,
   971    971   #ifdef SQLITE_DEBUG
   972    972           /* .pScopyFrom = */ (Mem*)0,
   973    973           /* .mScopyFlags= */ 0,
   974    974   #endif
   975         -#ifdef SQLITE_DEBUG_COLUMNCACHE
   976         -        /* .iTabColHash= */ 0,
   977         -#endif
   978    975         };
   979    976     return &nullMem;
   980    977   }
   981    978   
   982    979   /*
   983    980   ** Check to see if column iCol of the given statement is valid.  If
   984    981   ** it is, return a pointer to the Mem for the value of that column.

Changes to src/vdbeaux.c.

  1635   1635     while( (N--)>0 ){
  1636   1636       p->db = db;
  1637   1637       p->flags = flags;
  1638   1638       p->szMalloc = 0;
  1639   1639   #ifdef SQLITE_DEBUG
  1640   1640       p->pScopyFrom = 0;
  1641   1641   #endif
  1642         -#ifdef SQLITE_DEBUG_COLUMNCACHE
  1643         -    p->iTabColHash = 0;
  1644         -#endif
  1645   1642       p++;
  1646   1643     }
  1647   1644   }
  1648   1645   
  1649   1646   /*
  1650   1647   ** Release an array of N Mem elements
  1651   1648   */

Changes to src/vdbemem.c.

   930    930         /* pMem is the register that is changing.  But also mark pX as
   931    931         ** undefined so that we can quickly detect the shallow-copy error */
   932    932         pX->flags = MEM_Undefined;
   933    933         pX->pScopyFrom = 0;
   934    934       }
   935    935     }
   936    936     pMem->pScopyFrom = 0;
   937         -#ifdef SQLITE_DEBUG_COLUMN_CACHE
   938         -  pMem->iTabColHash = 0;
   939         -#endif
   940    937   }
   941    938   #endif /* SQLITE_DEBUG */
   942    939   
   943    940   
   944    941   /*
   945    942   ** Make an shallow copy of pFrom into pTo.  Prior contents of
   946    943   ** pTo are freed.  The pFrom->z field is not duplicated.  If
................................................................................
   953    950     sqlite3VdbeMemShallowCopy(pTo, pFrom, eType);
   954    951   }
   955    952   void sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom, int srcType){
   956    953     assert( (pFrom->flags & MEM_RowSet)==0 );
   957    954     assert( pTo->db==pFrom->db );
   958    955     if( VdbeMemDynamic(pTo) ){ vdbeClrCopy(pTo,pFrom,srcType); return; }
   959    956     memcpy(pTo, pFrom, MEMCELLSIZE);
   960         -#ifdef SQLITE_DEBUG_COLUMNCACHE
   961         -  pTo->iTabColHash = pFrom->iTabColHash;
   962         -#endif
   963    957     if( (pFrom->flags&MEM_Static)==0 ){
   964    958       pTo->flags &= ~(MEM_Dyn|MEM_Static|MEM_Ephem);
   965    959       assert( srcType==MEM_Ephem || srcType==MEM_Static );
   966    960       pTo->flags |= srcType;
   967    961     }
   968    962   }
   969    963   
................................................................................
   973    967   */
   974    968   int sqlite3VdbeMemCopy(Mem *pTo, const Mem *pFrom){
   975    969     int rc = SQLITE_OK;
   976    970   
   977    971     assert( (pFrom->flags & MEM_RowSet)==0 );
   978    972     if( VdbeMemDynamic(pTo) ) vdbeMemClearExternAndSetNull(pTo);
   979    973     memcpy(pTo, pFrom, MEMCELLSIZE);
   980         -#ifdef SQLITE_DEBUG_COLUMNCACHE
   981         -  pTo->iTabColHash = pFrom->iTabColHash;
   982         -#endif
   983    974     pTo->flags &= ~MEM_Dyn;
   984    975     if( pTo->flags&(MEM_Str|MEM_Blob) ){
   985    976       if( 0==(pFrom->flags&MEM_Static) ){
   986    977         pTo->flags |= MEM_Ephem;
   987    978         rc = sqlite3VdbeMemMakeWriteable(pTo);
   988    979       }
   989    980     }