/ Check-in [bf664b20]
Login

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

Overview
Comment:Fix the P4_TRANSIENT constant so that it works correct - so that it really makes a copy of the string for the P4 argument. Use P4_TRANSIENT wherever appropriate. Change P4_STATICs of schema names to P4_TRANSIENT.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: bf664b206bf6f5c1941da1986dfe2c0d1831d5e4
User & Date: drh 2011-04-05 12:25:19
Context
2011-04-05
13:12
Merge the scheme-parse-refactor changes into trunk: (1) added sqlite3SchemaMutexHeld() asserts, (2) Use -1 instead of 0 to mean "all" in sqlite3ResetInternalSchema(), and other cosmetic changes. check-in: 5db4511d user: drh tags: trunk
12:25
Fix the P4_TRANSIENT constant so that it works correct - so that it really makes a copy of the string for the P4 argument. Use P4_TRANSIENT wherever appropriate. Change P4_STATICs of schema names to P4_TRANSIENT. check-in: bf664b20 user: drh tags: trunk
11:26
Improved comment on the sqlite3SrcListLookup function. check-in: bcbc9ff5 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/delete.c.

   541    541     /* Delete the index and table entries. Skip this step if pTab is really
   542    542     ** a view (in which case the only effect of the DELETE statement is to
   543    543     ** fire the INSTEAD OF triggers).  */ 
   544    544     if( pTab->pSelect==0 ){
   545    545       sqlite3GenerateRowIndexDelete(pParse, pTab, iCur, 0);
   546    546       sqlite3VdbeAddOp2(v, OP_Delete, iCur, (count?OPFLAG_NCHANGE:0));
   547    547       if( count ){
   548         -      sqlite3VdbeChangeP4(v, -1, pTab->zName, P4_STATIC);
          548  +      sqlite3VdbeChangeP4(v, -1, pTab->zName, P4_TRANSIENT);
   549    549       }
   550    550     }
   551    551   
   552    552     /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to
   553    553     ** handle rows (possibly in other tables) that refer via a foreign key
   554    554     ** to the row just deleted. */ 
   555    555     sqlite3FkActions(pParse, pTab, 0, iOld);
................................................................................
   632    632       }else{
   633    633         sqlite3VdbeAddOp3(v, OP_Column, iCur, idx, regBase+j);
   634    634         sqlite3ColumnDefault(v, pTab, idx, -1);
   635    635       }
   636    636     }
   637    637     if( doMakeRec ){
   638    638       sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol+1, regOut);
   639         -    sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), 0);
          639  +    sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), P4_TRANSIENT);
   640    640     }
   641    641     sqlite3ReleaseTempRange(pParse, regBase, nCol+1);
   642    642     return regBase;
   643    643   }

Changes to src/expr.c.

  2341   2341   #endif
  2342   2342       case TK_VARIABLE: {
  2343   2343         assert( !ExprHasProperty(pExpr, EP_IntValue) );
  2344   2344         assert( pExpr->u.zToken!=0 );
  2345   2345         assert( pExpr->u.zToken[0]!=0 );
  2346   2346         sqlite3VdbeAddOp2(v, OP_Variable, pExpr->iColumn, target);
  2347   2347         if( pExpr->u.zToken[1]!=0 ){
  2348         -        sqlite3VdbeChangeP4(v, -1, pExpr->u.zToken, 0);
         2348  +        sqlite3VdbeChangeP4(v, -1, pExpr->u.zToken, P4_TRANSIENT);
  2349   2349         }
  2350   2350         break;
  2351   2351       }
  2352   2352       case TK_REGISTER: {
  2353   2353         inReg = pExpr->iTable;
  2354   2354         break;
  2355   2355       }

Changes to src/fkey.c.

   394    394             int iParent = pIdx->aiColumn[i]+1+regData;
   395    395             sqlite3VdbeAddOp3(v, OP_Ne, iChild, iJump, iParent);
   396    396           }
   397    397           sqlite3VdbeAddOp2(v, OP_Goto, 0, iOk);
   398    398         }
   399    399     
   400    400         sqlite3VdbeAddOp3(v, OP_MakeRecord, regTemp, nCol, regRec);
   401         -      sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), 0);
          401  +      sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v,pIdx), P4_TRANSIENT);
   402    402         sqlite3VdbeAddOp4Int(v, OP_Found, iCur, iOk, regRec, 0);
   403    403     
   404    404         sqlite3ReleaseTempReg(pParse, regRec);
   405    405         sqlite3ReleaseTempRange(pParse, regTemp, nCol);
   406    406       }
   407    407     }
   408    408   

Changes to src/insert.c.

   119    119         zColAff[i] = pTab->aCol[i].affinity;
   120    120       }
   121    121       zColAff[pTab->nCol] = '\0';
   122    122   
   123    123       pTab->zColAff = zColAff;
   124    124     }
   125    125   
   126         -  sqlite3VdbeChangeP4(v, -1, pTab->zColAff, 0);
          126  +  sqlite3VdbeChangeP4(v, -1, pTab->zColAff, P4_TRANSIENT);
   127    127   }
   128    128   
   129    129   /*
   130    130   ** Return non-zero if the table pTab in database iDb or any of its indices
   131    131   ** have been opened at any point in the VDBE program beginning at location
   132    132   ** iStartAddr throught the end of the program.  This is used to see if 
   133    133   ** a statement of the form  "INSERT INTO <iDb, pTab> SELECT ..." can 
................................................................................
  1323   1323           sqlite3VdbeAddOp2(v, OP_SCopy, regRowid, regIdx+i);
  1324   1324         }else{
  1325   1325           sqlite3VdbeAddOp2(v, OP_SCopy, regData+idx, regIdx+i);
  1326   1326         }
  1327   1327       }
  1328   1328       sqlite3VdbeAddOp2(v, OP_SCopy, regRowid, regIdx+i);
  1329   1329       sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn+1, aRegIdx[iCur]);
  1330         -    sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), 0);
         1330  +    sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), P4_TRANSIENT);
  1331   1331       sqlite3ExprCacheAffinityChange(pParse, regIdx, pIdx->nColumn+1);
  1332   1332   
  1333   1333   #ifdef SQLITE_OMIT_UNIQUE_ENFORCEMENT
  1334   1334       sqlite3ReleaseTempRange(pParse, regIdx, pIdx->nColumn+1);
  1335   1335       continue;  /* Treat pIdx as if it is not a UNIQUE index */
  1336   1336   #else
  1337   1337   
................................................................................
  1469   1469       pik_flags |= OPFLAG_APPEND;
  1470   1470     }
  1471   1471     if( useSeekResult ){
  1472   1472       pik_flags |= OPFLAG_USESEEKRESULT;
  1473   1473     }
  1474   1474     sqlite3VdbeAddOp3(v, OP_Insert, baseCur, regRec, regRowid);
  1475   1475     if( !pParse->nested ){
  1476         -    sqlite3VdbeChangeP4(v, -1, pTab->zName, P4_STATIC);
         1476  +    sqlite3VdbeChangeP4(v, -1, pTab->zName, P4_TRANSIENT);
  1477   1477     }
  1478   1478     sqlite3VdbeChangeP5(v, pik_flags);
  1479   1479   }
  1480   1480   
  1481   1481   /*
  1482   1482   ** Generate code that will open cursors for a table and for all
  1483   1483   ** indices of that table.  The "baseCur" parameter is the cursor number used

Changes to src/pragma.c.

  1171   1171               { OP_Halt,        0,  0,  0},
  1172   1172             };
  1173   1173             r1 = sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 0);
  1174   1174             jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, j+2, 0, r1, pIdx->nColumn+1);
  1175   1175             addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr);
  1176   1176             sqlite3VdbeChangeP4(v, addr+1, "rowid ", P4_STATIC);
  1177   1177             sqlite3VdbeChangeP4(v, addr+3, " missing from index ", P4_STATIC);
  1178         -          sqlite3VdbeChangeP4(v, addr+4, pIdx->zName, P4_STATIC);
         1178  +          sqlite3VdbeChangeP4(v, addr+4, pIdx->zName, P4_TRANSIENT);
  1179   1179             sqlite3VdbeJumpHere(v, addr+9);
  1180   1180             sqlite3VdbeJumpHere(v, jmp2);
  1181   1181           }
  1182   1182           sqlite3VdbeAddOp2(v, OP_Next, 1, loopTop+1);
  1183   1183           sqlite3VdbeJumpHere(v, loopTop);
  1184   1184           for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
  1185   1185             static const VdbeOpList cntIdx[] = {
................................................................................
  1201   1201             sqlite3VdbeChangeP1(v, addr+1, j+2);
  1202   1202             sqlite3VdbeChangeP2(v, addr+1, addr+4);
  1203   1203             sqlite3VdbeChangeP1(v, addr+3, j+2);
  1204   1204             sqlite3VdbeChangeP2(v, addr+3, addr+2);
  1205   1205             sqlite3VdbeJumpHere(v, addr+4);
  1206   1206             sqlite3VdbeChangeP4(v, addr+6, 
  1207   1207                        "wrong # of entries in index ", P4_STATIC);
  1208         -          sqlite3VdbeChangeP4(v, addr+7, pIdx->zName, P4_STATIC);
         1208  +          sqlite3VdbeChangeP4(v, addr+7, pIdx->zName, P4_TRANSIENT);
  1209   1209           }
  1210   1210         } 
  1211   1211       }
  1212   1212       addr = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode);
  1213   1213       sqlite3VdbeChangeP2(v, addr, -mxErr);
  1214   1214       sqlite3VdbeJumpHere(v, addr+1);
  1215   1215       sqlite3VdbeChangeP4(v, addr+2, "ok", P4_STATIC);

Changes to src/trigger.c.

   557    557         { OP_Delete,     0, 0,        0},
   558    558         { OP_Next,       0, ADDR(1),  0}, /* 8 */
   559    559       };
   560    560   
   561    561       sqlite3BeginWriteOperation(pParse, 0, iDb);
   562    562       sqlite3OpenMasterTable(pParse, iDb);
   563    563       base = sqlite3VdbeAddOpList(v,  ArraySize(dropTrigger), dropTrigger);
   564         -    sqlite3VdbeChangeP4(v, base+1, pTrigger->zName, 0);
          564  +    sqlite3VdbeChangeP4(v, base+1, pTrigger->zName, P4_TRANSIENT);
   565    565       sqlite3VdbeChangeP4(v, base+4, "trigger", P4_STATIC);
   566    566       sqlite3ChangeCookie(pParse, iDb);
   567    567       sqlite3VdbeAddOp2(v, OP_Close, 0, 0);
   568    568       sqlite3VdbeAddOp4(v, OP_DropTrigger, iDb, 0, 0, pTrigger->zName, 0);
   569    569       if( pParse->nMem<3 ){
   570    570         pParse->nMem = 3;
   571    571       }

Changes to src/vdbe.h.

   104    104   #define P4_DYNAMIC  (-1)  /* Pointer to a string obtained from sqliteMalloc() */
   105    105   #define P4_STATIC   (-2)  /* Pointer to a static string */
   106    106   #define P4_COLLSEQ  (-4)  /* P4 is a pointer to a CollSeq structure */
   107    107   #define P4_FUNCDEF  (-5)  /* P4 is a pointer to a FuncDef structure */
   108    108   #define P4_KEYINFO  (-6)  /* P4 is a pointer to a KeyInfo structure */
   109    109   #define P4_VDBEFUNC (-7)  /* P4 is a pointer to a VdbeFunc structure */
   110    110   #define P4_MEM      (-8)  /* P4 is a pointer to a Mem*    structure */
   111         -#define P4_TRANSIENT (-9) /* P4 is a pointer to a transient string */
          111  +#define P4_TRANSIENT  0   /* P4 is a pointer to a transient string */
   112    112   #define P4_VTAB     (-10) /* P4 is a pointer to an sqlite3_vtab structure */
   113    113   #define P4_MPRINTF  (-11) /* P4 is a string obtained from sqlite3_mprintf() */
   114    114   #define P4_REAL     (-12) /* P4 is a 64-bit floating point value */
   115    115   #define P4_INT64    (-13) /* P4 is a 64-bit signed integer */
   116    116   #define P4_INT32    (-14) /* P4 is a 32-bit signed integer */
   117    117   #define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */
   118    118   #define P4_SUBPROGRAM  (-18) /* P4 is a pointer to a SubProgram structure */