mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-11 01:42:22 +03:00
Fix various bugs in new feature on this branch.
FossilOrigin-Name: 823ba94e29dece1687e28711e503a1f56d392c306b0cbc0a20548180834530d1
This commit is contained in:
31
src/select.c
31
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: {
|
||||
|
||||
Reference in New Issue
Block a user