/ Check-in [b9727e6b]
Login

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

Overview
Comment:The SRT_Table type for the SelectDest object is now just an SRT_EphemTab for which the ephemeral table has already been allocated.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b9727e6bbfc3c62c601227e86e62f2f39792fd1d
User & Date: drh 2015-05-22 17:29:27
References
2017-01-05
16:34 New ticket [190c2507] Assertion fault on a query against a view. artifact: 5c889138 user: drh
Context
2015-05-22
21:12
Add the sqlite3_value_dup() and sqlite3_value_free() interfaces. Use these interfaces to enhance R-Tree to add the sqlite3_rtree_query_info.apSqlParam field. check-in: c1814242 user: drh tags: trunk
18:40
Update with fixes and enhancements from trunk. check-in: 9605d008 user: drh tags: value-dup
17:29
The SRT_Table type for the SelectDest object is now just an SRT_EphemTab for which the ephemeral table has already been allocated. check-in: b9727e6b user: drh tags: trunk
16:08
Have r-tree prefer to use the constraint "col MATCH ?" over "rowid = ?". check-in: b9fb9519 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/select.c.

   812    812       case SRT_Fifo:
   813    813       case SRT_DistFifo:
   814    814       case SRT_Table:
   815    815       case SRT_EphemTab: {
   816    816         int r1 = sqlite3GetTempRange(pParse, nPrefixReg+1);
   817    817         testcase( eDest==SRT_Table );
   818    818         testcase( eDest==SRT_EphemTab );
          819  +      testcase( eDest==SRT_Fifo );
          820  +      testcase( eDest==SRT_DistFifo );
   819    821         sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nResultCol, r1+nPrefixReg);
   820    822   #ifndef SQLITE_OMIT_CTE
   821    823         if( eDest==SRT_DistFifo ){
   822    824           /* If the destination is DistFifo, then cursor (iParm+1) is open
   823    825           ** on an ephemeral index. If the current row is already present
   824    826           ** in the index, do not write it to the output. If not, add the
   825    827           ** current row to the index and proceed with writing it to the
................................................................................
  1227   1229       bSeq = 1;
  1228   1230     }
  1229   1231     for(i=0; i<nSortData; i++){
  1230   1232       sqlite3VdbeAddOp3(v, OP_Column, iSortTab, nKey+bSeq+i, regRow+i);
  1231   1233       VdbeComment((v, "%s", aOutEx[i].zName ? aOutEx[i].zName : aOutEx[i].zSpan));
  1232   1234     }
  1233   1235     switch( eDest ){
  1234         -    case SRT_Table:
  1235   1236       case SRT_EphemTab: {
  1236         -      testcase( eDest==SRT_Table );
  1237         -      testcase( eDest==SRT_EphemTab );
  1238   1237         sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, regRowid);
  1239   1238         sqlite3VdbeAddOp3(v, OP_Insert, iParm, regRow, regRowid);
  1240   1239         sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
  1241   1240         break;
  1242   1241       }
  1243   1242   #ifndef SQLITE_OMIT_SUBQUERY
  1244   1243       case SRT_Set: {
................................................................................
  2579   2578     }
  2580   2579     if( pParse->db->mallocFailed ) return 0;
  2581   2580   
  2582   2581     /* Suppress the first OFFSET entries if there is an OFFSET clause
  2583   2582     */
  2584   2583     codeOffset(v, p->iOffset, iContinue);
  2585   2584   
         2585  +  assert( pDest->eDest!=SRT_Exists );
         2586  +  assert( pDest->eDest!=SRT_Table );
  2586   2587     switch( pDest->eDest ){
  2587   2588       /* Store the result as data using a unique key.
  2588   2589       */
  2589         -    case SRT_Table:
  2590   2590       case SRT_EphemTab: {
  2591   2591         int r1 = sqlite3GetTempReg(pParse);
  2592   2592         int r2 = sqlite3GetTempReg(pParse);
  2593         -      testcase( pDest->eDest==SRT_Table );
  2594         -      testcase( pDest->eDest==SRT_EphemTab );
  2595   2593         sqlite3VdbeAddOp3(v, OP_MakeRecord, pIn->iSdst, pIn->nSdst, r1);
  2596   2594         sqlite3VdbeAddOp2(v, OP_NewRowid, pDest->iSDParm, r2);
  2597   2595         sqlite3VdbeAddOp3(v, OP_Insert, pDest->iSDParm, r1, r2);
  2598   2596         sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
  2599   2597         sqlite3ReleaseTempReg(pParse, r2);
  2600   2598         sqlite3ReleaseTempReg(pParse, r1);
  2601   2599         break;
................................................................................
  2615   2613         sqlite3VdbeAddOp4(v, OP_MakeRecord, pIn->iSdst, 1, r1, &pDest->affSdst,1);
  2616   2614         sqlite3ExprCacheAffinityChange(pParse, pIn->iSdst, 1);
  2617   2615         sqlite3VdbeAddOp2(v, OP_IdxInsert, pDest->iSDParm, r1);
  2618   2616         sqlite3ReleaseTempReg(pParse, r1);
  2619   2617         break;
  2620   2618       }
  2621   2619   
  2622         -#if 0  /* Never occurs on an ORDER BY query */
  2623         -    /* If any row exist in the result set, record that fact and abort.
  2624         -    */
  2625         -    case SRT_Exists: {
  2626         -      sqlite3VdbeAddOp2(v, OP_Integer, 1, pDest->iSDParm);
  2627         -      /* The LIMIT clause will terminate the loop for us */
  2628         -      break;
  2629         -    }
  2630         -#endif
  2631         -
  2632   2620       /* If this is a scalar select that is part of an expression, then
  2633   2621       ** store the results in the appropriate memory cell and break out
  2634   2622       ** of the scan loop.
  2635   2623       */
  2636   2624       case SRT_Mem: {
  2637   2625         assert( pIn->nSdst==1 || pParse->nErr>0 );  testcase( pIn->nSdst!=1 );
  2638   2626         sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSDParm, 1);

Changes to src/update.c.

   739    739     pSelect = sqlite3SelectNew(pParse, pEList, pSrc, pWhere, 0, 0, 0, 0, 0, 0);
   740    740     
   741    741     /* Create the ephemeral table into which the update results will
   742    742     ** be stored.
   743    743     */
   744    744     assert( v );
   745    745     ephemTab = pParse->nTab++;
   746         -  sqlite3VdbeAddOp2(v, OP_OpenEphemeral, ephemTab, pTab->nCol+1+(pRowid!=0));
   747         -  sqlite3VdbeChangeP5(v, BTREE_UNORDERED);
   748    746   
   749    747     /* fill the ephemeral table 
   750    748     */
   751         -  sqlite3SelectDestInit(&dest, SRT_Table, ephemTab);
          749  +  sqlite3SelectDestInit(&dest, SRT_EphemTab, ephemTab);
   752    750     sqlite3Select(pParse, pSelect, &dest);
   753    751   
   754    752     /* Generate code to scan the ephemeral table and call VUpdate. */
   755    753     iReg = ++pParse->nMem;
   756    754     pParse->nMem += pTab->nCol+1;
   757    755     addr = sqlite3VdbeAddOp2(v, OP_Rewind, ephemTab, 0); VdbeCoverage(v);
   758    756     sqlite3VdbeAddOp3(v, OP_Column,  ephemTab, 0, iReg);