/ Check-in [322ab1fc]
Login

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

Overview
Comment:Ensure that the OP_VColumn opcode does set sqlite3_vtab_nochange() unless the OPFLAG_NOCHNG bit is set in P5. Fix for ticket [69d642332d25aa3b7315a6d385]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 322ab1fc613f616e9f07dc94ef74a29572a21cc476d88e97b4ce865500a47b62
User & Date: drh 2018-09-27 20:20:01
Context
2018-10-01
11:00
Ensure that the OP_VColumn opcode does set sqlite3_vtab_nochange() unless the OPFLAG_NOCHNG bit is set in P5. Fix for ticket [69d642332d25aa3b7315a6d385] check-in: 31ac8dba user: drh tags: branch-3.25
2018-09-27
20:37
Enhance the GeoPOLY extension so that it always stores its polygons in the binary format, which is faster and more compact. check-in: dc35f7b1 user: drh tags: trunk
20:20
Ensure that the OP_VColumn opcode does set sqlite3_vtab_nochange() unless the OPFLAG_NOCHNG bit is set in P5. Fix for ticket [69d642332d25aa3b7315a6d385] check-in: 322ab1fc user: drh tags: trunk
17:33
Another minor tweak to memstat.c so that it may be built against older versions of SQLite. check-in: 4c1fed60 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/sqliteInt.h.

  3176   3176   **    OPFLAG_SEEKEQ       == BTREE_SEEK_EQ
  3177   3177   **    OPFLAG_FORDELETE    == BTREE_FORDELETE
  3178   3178   **    OPFLAG_SAVEPOSITION == BTREE_SAVEPOSITION
  3179   3179   **    OPFLAG_AUXDELETE    == BTREE_AUXDELETE
  3180   3180   */
  3181   3181   #define OPFLAG_NCHANGE       0x01    /* OP_Insert: Set to update db->nChange */
  3182   3182                                        /* Also used in P2 (not P5) of OP_Delete */
         3183  +#define OPFLAG_NOCHNG        0x01    /* OP_VColumn nochange for UPDATE */
  3183   3184   #define OPFLAG_EPHEM         0x01    /* OP_Column: Ephemeral output is ok */
  3184   3185   #define OPFLAG_LASTROWID     0x20    /* Set to update db->lastRowid */
  3185   3186   #define OPFLAG_ISUPDATE      0x04    /* This OP_Insert is an sql UPDATE */
  3186   3187   #define OPFLAG_APPEND        0x08    /* This is likely to be an append */
  3187   3188   #define OPFLAG_USESEEKRESULT 0x10    /* Try to avoid a seek in BtreeInsert() */
  3188   3189   #define OPFLAG_ISNOOP        0x40    /* OP_Delete does pre-update-hook only */
  3189   3190   #define OPFLAG_LENGTHARG     0x40    /* OP_Column only used for length() */

Changes to src/update.c.

   909    909   
   910    910     /* Populate the argument registers. */
   911    911     for(i=0; i<pTab->nCol; i++){
   912    912       if( aXRef[i]>=0 ){
   913    913         sqlite3ExprCode(pParse, pChanges->a[aXRef[i]].pExpr, regArg+2+i);
   914    914       }else{
   915    915         sqlite3VdbeAddOp3(v, OP_VColumn, iCsr, i, regArg+2+i);
   916         -      sqlite3VdbeChangeP5(v, 1); /* Enable sqlite3_vtab_nochange() */
          916  +      sqlite3VdbeChangeP5(v, OPFLAG_NOCHNG);/* Enable sqlite3_vtab_nochange() */
   917    917       }
   918    918     }
   919    919     if( HasRowid(pTab) ){
   920    920       sqlite3VdbeAddOp2(v, OP_Rowid, iCsr, regArg);
   921    921       if( pRowid ){
   922    922         sqlite3ExprCode(pParse, pRowid, regArg+1);
   923    923       }else{

Changes to src/vdbe.c.

  6961   6961   ** Synopsis: r[P3]=vcolumn(P2)
  6962   6962   **
  6963   6963   ** Store in register P3 the value of the P2-th column of
  6964   6964   ** the current row of the virtual-table of cursor P1.
  6965   6965   **
  6966   6966   ** If the VColumn opcode is being used to fetch the value of
  6967   6967   ** an unchanging column during an UPDATE operation, then the P5
  6968         -** value is 1.  Otherwise, P5 is 0.  The P5 value is returned
  6969         -** by sqlite3_vtab_nochange() routine and can be used
  6970         -** by virtual table implementations to return special "no-change"
  6971         -** marks which can be more efficient, depending on the virtual table.
         6968  +** value is OPFLAG_NOCHNG.  This will cause the sqlite3_vtab_nochange()
         6969  +** function to return true inside the xColumn method of the virtual
         6970  +** table implementation.  The P5 column might also contain other
         6971  +** bits (OPFLAG_LENGTHARG or OPFLAG_TYPEOFARG) but those bits are
         6972  +** unused by OP_VColumn.
  6972   6973   */
  6973   6974   case OP_VColumn: {
  6974   6975     sqlite3_vtab *pVtab;
  6975   6976     const sqlite3_module *pModule;
  6976   6977     Mem *pDest;
  6977   6978     sqlite3_context sContext;
  6978   6979   
................................................................................
  6986   6987       break;
  6987   6988     }
  6988   6989     pVtab = pCur->uc.pVCur->pVtab;
  6989   6990     pModule = pVtab->pModule;
  6990   6991     assert( pModule->xColumn );
  6991   6992     memset(&sContext, 0, sizeof(sContext));
  6992   6993     sContext.pOut = pDest;
  6993         -  if( pOp->p5 ){
         6994  +  testcase( (pOp->p5 & OPFLAG_NOCHNG)==0 && pOp->p5!=0 );
         6995  +  if( pOp->p5 & OPFLAG_NOCHNG ){
  6994   6996       sqlite3VdbeMemSetNull(pDest);
  6995   6997       pDest->flags = MEM_Null|MEM_Zero;
  6996   6998       pDest->u.nZero = 0;
  6997   6999     }else{
  6998   7000       MemSetTypeFlag(pDest, MEM_Null);
  6999   7001     }
  7000   7002     rc = pModule->xColumn(pCur->uc.pVCur, &sContext, pOp->p2);