diff options
Diffstat (limited to 'src/select.c')
-rw-r--r-- | src/select.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/select.c b/src/select.c index f6b48b5a0..fdffe9163 100644 --- a/src/select.c +++ b/src/select.c @@ -117,6 +117,7 @@ static void clearSelect(sqlite3 *db, Select *p, int bFree){ void sqlite3SelectDestInit(SelectDest *pDest, int eDest, int iParm){ pDest->eDest = (u8)eDest; pDest->iSDParm = iParm; + pDest->iSDParm2 = 0; pDest->zAffSdst = 0; pDest->iSdst = 0; pDest->nSdst = 0; @@ -1154,11 +1155,24 @@ static void selectInnerLoop( break; } + case SRT_Upfrom: { + assert( pSort==0 ); + int i2 = pDest->iSDParm2; + int r1 = sqlite3GetTempReg(pParse); + sqlite3VdbeAddOp3(v, OP_MakeRecord,regResult+(i2<0),nResultCol-(i2<0),r1); + if( i2<0 ){ + sqlite3VdbeAddOp3(v, OP_Insert, iParm, r1, regResult); + }else{ + sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm, r1, regResult, i2); + } + break; + } + +#ifndef SQLITE_OMIT_SUBQUERY /* If we are creating a set for an "expr IN (SELECT ...)" construct, ** then there should be a single item on the stack. Write this ** item into the set table with bogus data. */ - case SRT_ISet: case SRT_Set: { if( pSort ){ /* At first glance you would think we could optimize out the @@ -1168,22 +1182,17 @@ static void selectInnerLoop( pushOntoSorter( pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg); }else{ - int bITab = (eDest==SRT_ISet); int r1 = sqlite3GetTempReg(pParse); - sqlite3VdbeAddOp4(v, OP_MakeRecord, regResult+bITab, nResultCol-bITab, - r1, pDest->zAffSdst, 0 - ); - if( bITab ){ - sqlite3VdbeAddOp3(v, OP_Insert, iParm, r1, regResult); - }else{ - sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm, r1,regResult,nResultCol); - } + assert( sqlite3Strlen30(pDest->zAffSdst)==nResultCol ); + sqlite3VdbeAddOp4(v, OP_MakeRecord, regResult, nResultCol, + r1, pDest->zAffSdst, nResultCol); + sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm, r1, regResult, nResultCol); sqlite3ReleaseTempReg(pParse, r1); } break; } -#ifndef SQLITE_OMIT_SUBQUERY + /* If any row exist in the result set, record that fact and abort. */ case SRT_Exists: { |