/ Check-in [b2973f23]
Login

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

Overview
Comment:Improvements to SCopy correctness tracking when SQLITE_DEBUG is enabled.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b2973f2357a2c5e22e0d612c970adbc6d51cbc5e4ff7ac6d2b678722e553e8ec
User & Date: drh 2018-06-12 13:52:23
Context
2018-06-12
19:22
Documentation updates: clarify the behavior of sqlite3_column and sqlite3_value interfaces following an OOM error. check-in: 428c581e user: drh tags: trunk
13:52
Improvements to SCopy correctness tracking when SQLITE_DEBUG is enabled. check-in: b2973f23 user: drh tags: trunk
13:16
Fix the "Synopsis" on the OP_BitNot opcode. check-in: acd78df6 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

  1272   1272     int n;
  1273   1273   
  1274   1274     n = pOp->p3;
  1275   1275     pIn1 = &aMem[pOp->p1];
  1276   1276     pOut = &aMem[pOp->p2];
  1277   1277     assert( pOut!=pIn1 );
  1278   1278     while( 1 ){
         1279  +    memAboutToChange(p, pOut);
  1279   1280       sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);
  1280   1281       Deephemeralize(pOut);
  1281   1282   #ifdef SQLITE_DEBUG
  1282   1283       pOut->pScopyFrom = 0;
         1284  +    pOut->iTabColHash = 0;
  1283   1285   #endif
  1284   1286       REGISTER_TRACE(pOp->p2+pOp->p3-n, pOut);
  1285   1287       if( (n--)==0 ) break;
  1286   1288       pOut++;
  1287   1289       pIn1++;
  1288   1290     }
  1289   1291     break;
................................................................................
  1304   1306   */
  1305   1307   case OP_SCopy: {            /* out2 */
  1306   1308     pIn1 = &aMem[pOp->p1];
  1307   1309     pOut = &aMem[pOp->p2];
  1308   1310     assert( pOut!=pIn1 );
  1309   1311     sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);
  1310   1312   #ifdef SQLITE_DEBUG
  1311         -  if( pOut->pScopyFrom==0 ) pOut->pScopyFrom = pIn1;
         1313  +  pOut->pScopyFrom = pIn1;
         1314  +  pOut->mScopyFlags = pIn1->flags;
  1312   1315   #endif
  1313   1316     break;
  1314   1317   }
  1315   1318   
  1316   1319   /* Opcode: IntCopy P1 P2 * * *
  1317   1320   ** Synopsis: r[P2]=r[P1]
  1318   1321   **

Changes to src/vdbeInt.h.

   205    205     char *zMalloc;      /* Space to hold MEM_Str or MEM_Blob if szMalloc>0 */
   206    206     int szMalloc;       /* Size of the zMalloc allocation */
   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         -  void *pFiller;      /* So that sizeof(Mem) is a multiple of 8 */
          212  +  u16 mScopyFlags;    /* flags value immediately after the shallow copy */
   213    213   #endif
   214    214   #ifdef SQLITE_DEBUG_COLUMNCACHE
   215    215     u32 iTabColHash;    /* Hash of table.column that is origin of this value */
   216    216   #endif
   217    217   };
   218    218   
   219    219   /*

Changes to src/vdbeapi.c.

   966    966           /* .zMalloc    = */ (char*)0,
   967    967           /* .szMalloc   = */ (int)0,
   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         -        /* .pFiller    = */ (void*)0,
          973  +        /* .mScopyFlags= */ 0,
          974  +#endif
          975  +#ifdef SQLITE_DEBUG_COLUMNCACHE
          976  +        /* .iTabColHash= */ 0,
   974    977   #endif
   975    978         };
   976    979     return &nullMem;
   977    980   }
   978    981   
   979    982   /*
   980    983   ** Check to see if column iCol of the given statement is valid.  If

Changes to src/vdbeaux.c.

  1642   1642   static void initMemArray(Mem *p, int N, sqlite3 *db, u16 flags){
  1643   1643     while( (N--)>0 ){
  1644   1644       p->db = db;
  1645   1645       p->flags = flags;
  1646   1646       p->szMalloc = 0;
  1647   1647   #ifdef SQLITE_DEBUG
  1648   1648       p->pScopyFrom = 0;
         1649  +#endif
         1650  +#ifdef SQLITE_DEBUG_COLUMNCACHE
         1651  +    p->iTabColHash = 0;
  1649   1652   #endif
  1650   1653       p++;
  1651   1654     }
  1652   1655   }
  1653   1656   
  1654   1657   /*
  1655   1658   ** Release an array of N Mem elements

Changes to src/vdbemem.c.

   888    888       if( pX->pScopyFrom==pMem ){
   889    889         /* If pX is marked as a shallow copy of pMem, then verify that
   890    890         ** no significant changes have been made to pX since the OP_SCopy.
   891    891         ** A significant change would indicated a missed call to this
   892    892         ** function for pX.  Minor changes, such as adding or removing a
   893    893         ** dual type, are allowed, as long as the underlying value is the
   894    894         ** same. */
   895         -      u16 mFlags = pMem->flags & pX->flags;
          895  +      u16 mFlags = pMem->flags & pX->flags & pX->mScopyFlags;
   896    896         assert( (mFlags&MEM_Int)==0 || pMem->u.i==pX->u.i );
   897    897         assert( (mFlags&MEM_Real)==0 || pMem->u.r==pX->u.r );
   898    898         assert( (mFlags&MEM_Str)==0  || (pMem->n==pX->n && pMem->z==pX->z) );
   899    899         assert( (mFlags&MEM_Blob)==0  || sqlite3BlobCompare(pMem,pX)==0 );
   900    900         
   901    901         /* pMem is the register that is changing.  But also mark pX as
   902    902         ** undefined so that we can quickly detect the shallow-copy error */