1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-06 15:49:35 +03:00

Refactor field names in the SelectDest object to make them distinct and easier

to grep for.

FossilOrigin-Name: b589f1efb3907a68058bf2ee981dca126d083e83
This commit is contained in:
drh
2012-07-23 21:43:19 +00:00
parent 5373b76bdc
commit 2b596da8b7
6 changed files with 83 additions and 82 deletions

View File

@@ -1,5 +1,5 @@
C Ensure\sthat\sthere\sis\salways\sat\sleast\sone\saReadMark\sslot\susable\sby\san\sunprivileged\sreader\swhile\sa\scheckpoint\sis\srunning.\sAlso,\sif\sone\sor\smore\stransactions\sare\srecovered\sfrom\sa\slog\sfile,\sinitialize\sone\sof\sthe\saReadMark\sslots\sto\scontain\smxFrame\sas\spart\sof\sthe\srecovery\sprocess. C Refactor\sfield\snames\sin\sthe\sSelectDest\sobject\sto\smake\sthem\sdistinct\sand\seasier\nto\sgrep\sfor.
D 2012-07-17T14:37:12.494 D 2012-07-23T21:43:19.390
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -132,7 +132,7 @@ F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac
F src/ctime.c 500d019da966631ad957c37705642be87524463b F src/ctime.c 500d019da966631ad957c37705642be87524463b
F src/date.c 067a81c9942c497aafd2c260e13add8a7d0c7dd4 F src/date.c 067a81c9942c497aafd2c260e13add8a7d0c7dd4
F src/delete.c 4c20ea4f6213b3bc1c6a510586864b679946e05e F src/delete.c 4c20ea4f6213b3bc1c6a510586864b679946e05e
F src/expr.c 06a7733d19dc725dc46ba51afd9feadb4b85d991 F src/expr.c e2927abf9c69ce4ff9a931bd201946961c34819a
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
F src/fkey.c 657212460bf5cfd3ae607d12ea62092844c227b5 F src/fkey.c 657212460bf5cfd3ae607d12ea62092844c227b5
F src/func.c 18dfedfb857e100b05755a1b12e88b389f957879 F src/func.c 18dfedfb857e100b05755a1b12e88b389f957879
@@ -140,7 +140,7 @@ F src/global.c 4cfdca5cb0edd33c4d021baec4ede958cb2c793b
F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af
F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970
F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08
F src/insert.c 0bbffe75c254c62a5686ab5e7f88e29235e16174 F src/insert.c 770ed633830fb49d73d90c3fdf20b703973e1e84
F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e
F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f
F src/lempar.c 0ee69fca0be54cd93939df98d2aca4ca46f44416 F src/lempar.c 0ee69fca0be54cd93939df98d2aca4ca46f44416
@@ -176,11 +176,11 @@ F src/printf.c 4a9f882f1c1787a8b494a2987765acf9d97ac21f
F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
F src/resolve.c b3c70ab28cac60de33684c9aa9e5138dcf71d6dd F src/resolve.c b3c70ab28cac60de33684c9aa9e5138dcf71d6dd
F src/rowset.c f6a49f3e9579428024662f6e2931832511f831a1 F src/rowset.c f6a49f3e9579428024662f6e2931832511f831a1
F src/select.c f6c4833c4d8e94714761d99013d74f381e084f1d F src/select.c eecb852bc7d8c00253b9b9cbab9e528f0d4dd9a5
F src/shell.c 076e1c90d594644f36027c8ecff9a392cf2d3a06 F src/shell.c 076e1c90d594644f36027c8ecff9a392cf2d3a06
F src/sqlite.h.in 310ae7e538883fa1619ab0638c775ce11ad43015 F src/sqlite.h.in 310ae7e538883fa1619ab0638c775ce11ad43015
F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477
F src/sqliteInt.h 2bc2ebc2ff1a2b530ee5ed9ffd46c6fce93b244c F src/sqliteInt.h ed41801550b0b8fb8217fcfd2e362118062b30c0
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
F src/status.c 35939e7e03abf1b7577ce311f48f682c40de3208 F src/status.c 35939e7e03abf1b7577ce311f48f682c40de3208
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
@@ -1005,7 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
P 8c9ee1d78f99394eef73a177141ca9e1c67e4e07 P e4163596339c2166f9c4356ab824fff8bda8d0b0
R 21a0c6942de3e9593e3e93f462c443c7 R adb51909ed26f080ecf60f96fb1f4ac0
U dan U drh
Z a98d8c358c03bd601d60af308961371e Z 14fefb32c4db69f21df1898d6655f0c2

View File

@@ -1 +1 @@
e4163596339c2166f9c4356ab824fff8bda8d0b0 b589f1efb3907a68058bf2ee981dca126d083e83

View File

@@ -1701,7 +1701,7 @@ int sqlite3CodeSubselect(
assert( !isRowid ); assert( !isRowid );
sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable); sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
dest.affinity = (u8)affinity; dest.affSdst = (u8)affinity;
assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable ); assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );
pExpr->x.pSelect->iLimit = 0; pExpr->x.pSelect->iLimit = 0;
if( sqlite3Select(pParse, pExpr->x.pSelect, &dest) ){ if( sqlite3Select(pParse, pExpr->x.pSelect, &dest) ){
@@ -1794,11 +1794,11 @@ int sqlite3CodeSubselect(
sqlite3SelectDestInit(&dest, 0, ++pParse->nMem); sqlite3SelectDestInit(&dest, 0, ++pParse->nMem);
if( pExpr->op==TK_SELECT ){ if( pExpr->op==TK_SELECT ){
dest.eDest = SRT_Mem; dest.eDest = SRT_Mem;
sqlite3VdbeAddOp2(v, OP_Null, 0, dest.iParm); sqlite3VdbeAddOp2(v, OP_Null, 0, dest.iSDParm);
VdbeComment((v, "Init subquery result")); VdbeComment((v, "Init subquery result"));
}else{ }else{
dest.eDest = SRT_Exists; dest.eDest = SRT_Exists;
sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iParm); sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iSDParm);
VdbeComment((v, "Init EXISTS result")); VdbeComment((v, "Init EXISTS result"));
} }
sqlite3ExprDelete(pParse->db, pSel->pLimit); sqlite3ExprDelete(pParse->db, pSel->pLimit);
@@ -1808,7 +1808,7 @@ int sqlite3CodeSubselect(
if( sqlite3Select(pParse, pSel, &dest) ){ if( sqlite3Select(pParse, pSel, &dest) ){
return 0; return 0;
} }
rReg = dest.iParm; rReg = dest.iSDParm;
ExprSetIrreducible(pExpr); ExprSetIrreducible(pExpr);
break; break;
} }

View File

@@ -597,7 +597,7 @@ void sqlite3Insert(
VdbeComment((v, "SELECT eof flag")); VdbeComment((v, "SELECT eof flag"));
sqlite3SelectDestInit(&dest, SRT_Coroutine, ++pParse->nMem); sqlite3SelectDestInit(&dest, SRT_Coroutine, ++pParse->nMem);
addrSelect = sqlite3VdbeCurrentAddr(v)+2; addrSelect = sqlite3VdbeCurrentAddr(v)+2;
sqlite3VdbeAddOp2(v, OP_Integer, addrSelect-1, dest.iParm); sqlite3VdbeAddOp2(v, OP_Integer, addrSelect-1, dest.iSDParm);
j1 = sqlite3VdbeAddOp2(v, OP_Goto, 0, 0); j1 = sqlite3VdbeAddOp2(v, OP_Goto, 0, 0);
VdbeComment((v, "Jump over SELECT coroutine")); VdbeComment((v, "Jump over SELECT coroutine"));
@@ -608,15 +608,15 @@ void sqlite3Insert(
goto insert_cleanup; goto insert_cleanup;
} }
sqlite3VdbeAddOp2(v, OP_Integer, 1, regEof); /* EOF <- 1 */ sqlite3VdbeAddOp2(v, OP_Integer, 1, regEof); /* EOF <- 1 */
sqlite3VdbeAddOp1(v, OP_Yield, dest.iParm); /* yield X */ sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm); /* yield X */
sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_INTERNAL, OE_Abort); sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_INTERNAL, OE_Abort);
VdbeComment((v, "End of SELECT coroutine")); VdbeComment((v, "End of SELECT coroutine"));
sqlite3VdbeJumpHere(v, j1); /* label B: */ sqlite3VdbeJumpHere(v, j1); /* label B: */
regFromSelect = dest.iMem; regFromSelect = dest.iSdst;
assert( pSelect->pEList ); assert( pSelect->pEList );
nColumn = pSelect->pEList->nExpr; nColumn = pSelect->pEList->nExpr;
assert( dest.nMem==nColumn ); assert( dest.nSdst==nColumn );
/* Set useTempTable to TRUE if the result of the SELECT statement /* Set useTempTable to TRUE if the result of the SELECT statement
** should be written into a temporary table (template 4). Set to ** should be written into a temporary table (template 4). Set to
@@ -652,7 +652,7 @@ void sqlite3Insert(
regRec = sqlite3GetTempReg(pParse); regRec = sqlite3GetTempReg(pParse);
regTempRowid = sqlite3GetTempReg(pParse); regTempRowid = sqlite3GetTempReg(pParse);
sqlite3VdbeAddOp2(v, OP_OpenEphemeral, srcTab, nColumn); sqlite3VdbeAddOp2(v, OP_OpenEphemeral, srcTab, nColumn);
addrTop = sqlite3VdbeAddOp1(v, OP_Yield, dest.iParm); addrTop = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm);
addrIf = sqlite3VdbeAddOp1(v, OP_If, regEof); addrIf = sqlite3VdbeAddOp1(v, OP_If, regEof);
sqlite3VdbeAddOp3(v, OP_MakeRecord, regFromSelect, nColumn, regRec); sqlite3VdbeAddOp3(v, OP_MakeRecord, regFromSelect, nColumn, regRec);
sqlite3VdbeAddOp2(v, OP_NewRowid, srcTab, regTempRowid); sqlite3VdbeAddOp2(v, OP_NewRowid, srcTab, regTempRowid);
@@ -789,7 +789,7 @@ void sqlite3Insert(
** goto C ** goto C
** D: ... ** D: ...
*/ */
addrCont = sqlite3VdbeAddOp1(v, OP_Yield, dest.iParm); addrCont = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm);
addrInsTop = sqlite3VdbeAddOp1(v, OP_If, regEof); addrInsTop = sqlite3VdbeAddOp1(v, OP_If, regEof);
} }

View File

@@ -36,10 +36,10 @@ static void clearSelect(sqlite3 *db, Select *p){
*/ */
void sqlite3SelectDestInit(SelectDest *pDest, int eDest, int iParm){ void sqlite3SelectDestInit(SelectDest *pDest, int eDest, int iParm){
pDest->eDest = (u8)eDest; pDest->eDest = (u8)eDest;
pDest->iParm = iParm; pDest->iSDParm = iParm;
pDest->affinity = 0; pDest->affSdst = 0;
pDest->iMem = 0; pDest->iSdst = 0;
pDest->nMem = 0; pDest->nSdst = 0;
} }
@@ -551,7 +551,7 @@ static void selectInnerLoop(
int hasDistinct; /* True if the DISTINCT keyword is present */ int hasDistinct; /* True if the DISTINCT keyword is present */
int regResult; /* Start of memory holding result set */ int regResult; /* Start of memory holding result set */
int eDest = pDest->eDest; /* How to dispose of results */ int eDest = pDest->eDest; /* How to dispose of results */
int iParm = pDest->iParm; /* First argument to disposal method */ int iParm = pDest->iSDParm; /* First argument to disposal method */
int nResultCol; /* Number of result columns */ int nResultCol; /* Number of result columns */
assert( v ); assert( v );
@@ -569,14 +569,14 @@ static void selectInnerLoop(
}else{ }else{
nResultCol = pEList->nExpr; nResultCol = pEList->nExpr;
} }
if( pDest->iMem==0 ){ if( pDest->iSdst==0 ){
pDest->iMem = pParse->nMem+1; pDest->iSdst = pParse->nMem+1;
pDest->nMem = nResultCol; pDest->nSdst = nResultCol;
pParse->nMem += nResultCol; pParse->nMem += nResultCol;
}else{ }else{
assert( pDest->nMem==nResultCol ); assert( pDest->nSdst==nResultCol );
} }
regResult = pDest->iMem; regResult = pDest->iSdst;
if( nColumn>0 ){ if( nColumn>0 ){
for(i=0; i<nColumn; i++){ for(i=0; i<nColumn; i++){
sqlite3VdbeAddOp3(v, OP_Column, srcTab, i, regResult+i); sqlite3VdbeAddOp3(v, OP_Column, srcTab, i, regResult+i);
@@ -655,7 +655,7 @@ static void selectInnerLoop(
*/ */
case SRT_Set: { case SRT_Set: {
assert( nColumn==1 ); assert( nColumn==1 );
p->affinity = sqlite3CompareAffinity(pEList->a[0].pExpr, pDest->affinity); p->affinity = sqlite3CompareAffinity(pEList->a[0].pExpr, pDest->affSdst);
if( pOrderBy ){ if( pOrderBy ){
/* At first glance you would think we could optimize out the /* At first glance you would think we could optimize out the
** ORDER BY in this case since the order of entries in the set ** ORDER BY in this case since the order of entries in the set
@@ -710,7 +710,7 @@ static void selectInnerLoop(
pushOntoSorter(pParse, pOrderBy, p, r1); pushOntoSorter(pParse, pOrderBy, p, r1);
sqlite3ReleaseTempReg(pParse, r1); sqlite3ReleaseTempReg(pParse, r1);
}else if( eDest==SRT_Coroutine ){ }else if( eDest==SRT_Coroutine ){
sqlite3VdbeAddOp1(v, OP_Yield, pDest->iParm); sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm);
}else{ }else{
sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, nColumn); sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, nColumn);
sqlite3ExprCacheAffinityChange(pParse, regResult, nColumn); sqlite3ExprCacheAffinityChange(pParse, regResult, nColumn);
@@ -890,7 +890,7 @@ static void generateSortTail(
ExprList *pOrderBy = p->pOrderBy; ExprList *pOrderBy = p->pOrderBy;
int eDest = pDest->eDest; int eDest = pDest->eDest;
int iParm = pDest->iParm; int iParm = pDest->iSDParm;
int regRow; int regRow;
int regRowid; int regRowid;
@@ -949,17 +949,17 @@ static void generateSortTail(
testcase( eDest==SRT_Output ); testcase( eDest==SRT_Output );
testcase( eDest==SRT_Coroutine ); testcase( eDest==SRT_Coroutine );
for(i=0; i<nColumn; i++){ for(i=0; i<nColumn; i++){
assert( regRow!=pDest->iMem+i ); assert( regRow!=pDest->iSdst+i );
sqlite3VdbeAddOp3(v, OP_Column, pseudoTab, i, pDest->iMem+i); sqlite3VdbeAddOp3(v, OP_Column, pseudoTab, i, pDest->iSdst+i);
if( i==0 ){ if( i==0 ){
sqlite3VdbeChangeP5(v, OPFLAG_CLEARCACHE); sqlite3VdbeChangeP5(v, OPFLAG_CLEARCACHE);
} }
} }
if( eDest==SRT_Output ){ if( eDest==SRT_Output ){
sqlite3VdbeAddOp2(v, OP_ResultRow, pDest->iMem, nColumn); sqlite3VdbeAddOp2(v, OP_ResultRow, pDest->iSdst, nColumn);
sqlite3ExprCacheAffinityChange(pParse, pDest->iMem, nColumn); sqlite3ExprCacheAffinityChange(pParse, pDest->iSdst, nColumn);
}else{ }else{
sqlite3VdbeAddOp1(v, OP_Yield, pDest->iParm); sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm);
} }
break; break;
} }
@@ -1610,7 +1610,7 @@ static int multiSelect(
*/ */
if( dest.eDest==SRT_EphemTab ){ if( dest.eDest==SRT_EphemTab ){
assert( p->pEList ); assert( p->pEList );
sqlite3VdbeAddOp2(v, OP_OpenEphemeral, dest.iParm, p->pEList->nExpr); sqlite3VdbeAddOp2(v, OP_OpenEphemeral, dest.iSDParm, p->pEList->nExpr);
sqlite3VdbeChangeP5(v, BTREE_UNORDERED); sqlite3VdbeChangeP5(v, BTREE_UNORDERED);
dest.eDest = SRT_Table; dest.eDest = SRT_Table;
} }
@@ -1696,7 +1696,7 @@ static int multiSelect(
** of a 3-way or more compound */ ** of a 3-way or more compound */
assert( p->pLimit==0 ); /* Not allowed on leftward elements */ assert( p->pLimit==0 ); /* Not allowed on leftward elements */
assert( p->pOffset==0 ); /* Not allowed on leftward elements */ assert( p->pOffset==0 ); /* Not allowed on leftward elements */
unionTab = dest.iParm; unionTab = dest.iSDParm;
}else{ }else{
/* We will need to create our own temporary table to hold the /* We will need to create our own temporary table to hold the
** intermediate results. ** intermediate results.
@@ -1753,7 +1753,7 @@ static int multiSelect(
/* Convert the data in the temporary table into whatever form /* Convert the data in the temporary table into whatever form
** it is that we currently need. ** it is that we currently need.
*/ */
assert( unionTab==dest.iParm || dest.eDest!=priorOp ); assert( unionTab==dest.iSDParm || dest.eDest!=priorOp );
if( dest.eDest!=priorOp ){ if( dest.eDest!=priorOp ){
int iCont, iBreak, iStart; int iCont, iBreak, iStart;
assert( p->pEList ); assert( p->pEList );
@@ -1817,7 +1817,7 @@ static int multiSelect(
p->pLimit = 0; p->pLimit = 0;
pOffset = p->pOffset; pOffset = p->pOffset;
p->pOffset = 0; p->pOffset = 0;
intersectdest.iParm = tab2; intersectdest.iSDParm = tab2;
explainSetInteger(iSub2, pParse->iNextSelectId); explainSetInteger(iSub2, pParse->iNextSelectId);
rc = sqlite3Select(pParse, p, &intersectdest); rc = sqlite3Select(pParse, p, &intersectdest);
testcase( rc!=SQLITE_OK ); testcase( rc!=SQLITE_OK );
@@ -1911,8 +1911,8 @@ static int multiSelect(
} }
multi_select_end: multi_select_end:
pDest->iMem = dest.iMem; pDest->iSdst = dest.iSdst;
pDest->nMem = dest.nMem; pDest->nSdst = dest.nSdst;
sqlite3SelectDelete(db, pDelete); sqlite3SelectDelete(db, pDelete);
return rc; return rc;
} }
@@ -1922,8 +1922,8 @@ multi_select_end:
** Code an output subroutine for a coroutine implementation of a ** Code an output subroutine for a coroutine implementation of a
** SELECT statment. ** SELECT statment.
** **
** The data to be output is contained in pIn->iMem. There are ** The data to be output is contained in pIn->iSdst. There are
** pIn->nMem columns to be output. pDest is where the output should ** pIn->nSdst columns to be output. pDest is where the output should
** be sent. ** be sent.
** **
** regReturn is the number of the register holding the subroutine ** regReturn is the number of the register holding the subroutine
@@ -1961,11 +1961,11 @@ static int generateOutputSubroutine(
if( regPrev ){ if( regPrev ){
int j1, j2; int j1, j2;
j1 = sqlite3VdbeAddOp1(v, OP_IfNot, regPrev); j1 = sqlite3VdbeAddOp1(v, OP_IfNot, regPrev);
j2 = sqlite3VdbeAddOp4(v, OP_Compare, pIn->iMem, regPrev+1, pIn->nMem, j2 = sqlite3VdbeAddOp4(v, OP_Compare, pIn->iSdst, regPrev+1, pIn->nSdst,
(char*)pKeyInfo, p4type); (char*)pKeyInfo, p4type);
sqlite3VdbeAddOp3(v, OP_Jump, j2+2, iContinue, j2+2); sqlite3VdbeAddOp3(v, OP_Jump, j2+2, iContinue, j2+2);
sqlite3VdbeJumpHere(v, j1); sqlite3VdbeJumpHere(v, j1);
sqlite3ExprCodeCopy(pParse, pIn->iMem, regPrev+1, pIn->nMem); sqlite3ExprCodeCopy(pParse, pIn->iSdst, regPrev+1, pIn->nSdst);
sqlite3VdbeAddOp2(v, OP_Integer, 1, regPrev); sqlite3VdbeAddOp2(v, OP_Integer, 1, regPrev);
} }
if( pParse->db->mallocFailed ) return 0; if( pParse->db->mallocFailed ) return 0;
@@ -1983,9 +1983,9 @@ static int generateOutputSubroutine(
int r2 = sqlite3GetTempReg(pParse); int r2 = sqlite3GetTempReg(pParse);
testcase( pDest->eDest==SRT_Table ); testcase( pDest->eDest==SRT_Table );
testcase( pDest->eDest==SRT_EphemTab ); testcase( pDest->eDest==SRT_EphemTab );
sqlite3VdbeAddOp3(v, OP_MakeRecord, pIn->iMem, pIn->nMem, r1); sqlite3VdbeAddOp3(v, OP_MakeRecord, pIn->iSdst, pIn->nSdst, r1);
sqlite3VdbeAddOp2(v, OP_NewRowid, pDest->iParm, r2); sqlite3VdbeAddOp2(v, OP_NewRowid, pDest->iSDParm, r2);
sqlite3VdbeAddOp3(v, OP_Insert, pDest->iParm, r1, r2); sqlite3VdbeAddOp3(v, OP_Insert, pDest->iSDParm, r1, r2);
sqlite3VdbeChangeP5(v, OPFLAG_APPEND); sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
sqlite3ReleaseTempReg(pParse, r2); sqlite3ReleaseTempReg(pParse, r2);
sqlite3ReleaseTempReg(pParse, r1); sqlite3ReleaseTempReg(pParse, r1);
@@ -1999,13 +1999,13 @@ static int generateOutputSubroutine(
*/ */
case SRT_Set: { case SRT_Set: {
int r1; int r1;
assert( pIn->nMem==1 ); assert( pIn->nSdst==1 );
p->affinity = p->affinity =
sqlite3CompareAffinity(p->pEList->a[0].pExpr, pDest->affinity); sqlite3CompareAffinity(p->pEList->a[0].pExpr, pDest->affSdst);
r1 = sqlite3GetTempReg(pParse); r1 = sqlite3GetTempReg(pParse);
sqlite3VdbeAddOp4(v, OP_MakeRecord, pIn->iMem, 1, r1, &p->affinity, 1); sqlite3VdbeAddOp4(v, OP_MakeRecord, pIn->iSdst, 1, r1, &p->affinity, 1);
sqlite3ExprCacheAffinityChange(pParse, pIn->iMem, 1); sqlite3ExprCacheAffinityChange(pParse, pIn->iSdst, 1);
sqlite3VdbeAddOp2(v, OP_IdxInsert, pDest->iParm, r1); sqlite3VdbeAddOp2(v, OP_IdxInsert, pDest->iSDParm, r1);
sqlite3ReleaseTempReg(pParse, r1); sqlite3ReleaseTempReg(pParse, r1);
break; break;
} }
@@ -2014,7 +2014,7 @@ static int generateOutputSubroutine(
/* If any row exist in the result set, record that fact and abort. /* If any row exist in the result set, record that fact and abort.
*/ */
case SRT_Exists: { case SRT_Exists: {
sqlite3VdbeAddOp2(v, OP_Integer, 1, pDest->iParm); sqlite3VdbeAddOp2(v, OP_Integer, 1, pDest->iSDParm);
/* The LIMIT clause will terminate the loop for us */ /* The LIMIT clause will terminate the loop for us */
break; break;
} }
@@ -2025,23 +2025,23 @@ static int generateOutputSubroutine(
** of the scan loop. ** of the scan loop.
*/ */
case SRT_Mem: { case SRT_Mem: {
assert( pIn->nMem==1 ); assert( pIn->nSdst==1 );
sqlite3ExprCodeMove(pParse, pIn->iMem, pDest->iParm, 1); sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSDParm, 1);
/* The LIMIT clause will jump out of the loop for us */ /* The LIMIT clause will jump out of the loop for us */
break; break;
} }
#endif /* #ifndef SQLITE_OMIT_SUBQUERY */ #endif /* #ifndef SQLITE_OMIT_SUBQUERY */
/* The results are stored in a sequence of registers /* The results are stored in a sequence of registers
** starting at pDest->iMem. Then the co-routine yields. ** starting at pDest->iSdst. Then the co-routine yields.
*/ */
case SRT_Coroutine: { case SRT_Coroutine: {
if( pDest->iMem==0 ){ if( pDest->iSdst==0 ){
pDest->iMem = sqlite3GetTempRange(pParse, pIn->nMem); pDest->iSdst = sqlite3GetTempRange(pParse, pIn->nSdst);
pDest->nMem = pIn->nMem; pDest->nSdst = pIn->nSdst;
} }
sqlite3ExprCodeMove(pParse, pIn->iMem, pDest->iMem, pDest->nMem); sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSdst, pDest->nSdst);
sqlite3VdbeAddOp1(v, OP_Yield, pDest->iParm); sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm);
break; break;
} }
@@ -2055,8 +2055,8 @@ static int generateOutputSubroutine(
*/ */
default: { default: {
assert( pDest->eDest==SRT_Output ); assert( pDest->eDest==SRT_Output );
sqlite3VdbeAddOp2(v, OP_ResultRow, pIn->iMem, pIn->nMem); sqlite3VdbeAddOp2(v, OP_ResultRow, pIn->iSdst, pIn->nSdst);
sqlite3ExprCacheAffinityChange(pParse, pIn->iMem, pIn->nMem); sqlite3ExprCacheAffinityChange(pParse, pIn->iSdst, pIn->nSdst);
break; break;
} }
} }
@@ -2475,7 +2475,7 @@ static int multiSelectOrderBy(
*/ */
sqlite3VdbeResolveLabel(v, labelCmpr); sqlite3VdbeResolveLabel(v, labelCmpr);
sqlite3VdbeAddOp4(v, OP_Permutation, 0, 0, 0, (char*)aPermute, P4_INTARRAY); sqlite3VdbeAddOp4(v, OP_Permutation, 0, 0, 0, (char*)aPermute, P4_INTARRAY);
sqlite3VdbeAddOp4(v, OP_Compare, destA.iMem, destB.iMem, nOrderBy, sqlite3VdbeAddOp4(v, OP_Compare, destA.iSdst, destB.iSdst, nOrderBy,
(char*)pKeyMerge, P4_KEYINFO_HANDOFF); (char*)pKeyMerge, P4_KEYINFO_HANDOFF);
sqlite3VdbeAddOp3(v, OP_Jump, addrAltB, addrAeqB, addrAgtB); sqlite3VdbeAddOp3(v, OP_Jump, addrAltB, addrAeqB, addrAgtB);
@@ -3721,23 +3721,24 @@ static void explainSimpleCount(
** **
** SRT_Mem Only valid if the result is a single column. ** SRT_Mem Only valid if the result is a single column.
** Store the first column of the first result row ** Store the first column of the first result row
** in register pDest->iParm then abandon the rest ** in register pDest->iSDParm then abandon the rest
** of the query. This destination implies "LIMIT 1". ** of the query. This destination implies "LIMIT 1".
** **
** SRT_Set The result must be a single column. Store each ** SRT_Set The result must be a single column. Store each
** row of result as the key in table pDest->iParm. ** row of result as the key in table pDest->iSDParm.
** Apply the affinity pDest->affinity before storing ** Apply the affinity pDest->affinity before storing
** results. Used to implement "IN (SELECT ...)". ** results. Used to implement "IN (SELECT ...)".
** **
** SRT_Union Store results as a key in a temporary table pDest->iParm. ** SRT_Union Store results as a key in a temporary table
** identified by pDest->iSDParm.
** **
** SRT_Except Remove results from the temporary table pDest->iParm. ** SRT_Except Remove results from the temporary table pDest->iSDParm.
** **
** SRT_Table Store results in temporary table pDest->iParm. ** SRT_Table Store results in temporary table pDest->iSDParm.
** This is like SRT_EphemTab except that the table ** This is like SRT_EphemTab except that the table
** is assumed to already be open. ** is assumed to already be open.
** **
** SRT_EphemTab Create an temporary table pDest->iParm and store ** SRT_EphemTab Create an temporary table pDest->iSDParm and store
** the result there. The cursor is left open after ** the result there. The cursor is left open after
** returning. This is like SRT_Table except that ** returning. This is like SRT_Table except that
** this destination uses OP_OpenEphemeral to create ** this destination uses OP_OpenEphemeral to create
@@ -3745,9 +3746,9 @@ static void explainSimpleCount(
** **
** SRT_Coroutine Generate a co-routine that returns a new row of ** SRT_Coroutine Generate a co-routine that returns a new row of
** results each time it is invoked. The entry point ** results each time it is invoked. The entry point
** of the co-routine is stored in register pDest->iParm. ** of the co-routine is stored in register pDest->iSDParm.
** **
** SRT_Exists Store a 1 in memory cell pDest->iParm if the result ** SRT_Exists Store a 1 in memory cell pDest->iSDParm if the result
** set is not empty. ** set is not empty.
** **
** SRT_Discard Throw the results away. This is used by SELECT ** SRT_Discard Throw the results away. This is used by SELECT
@@ -3991,7 +3992,7 @@ int sqlite3Select(
/* If the output is destined for a temporary table, open that table. /* If the output is destined for a temporary table, open that table.
*/ */
if( pDest->eDest==SRT_EphemTab ){ if( pDest->eDest==SRT_EphemTab ){
sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pDest->iParm, pEList->nExpr); sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pDest->iSDParm, pEList->nExpr);
} }
/* Set the limiter. /* Set the limiter.

View File

@@ -2118,10 +2118,10 @@ struct Select {
typedef struct SelectDest SelectDest; typedef struct SelectDest SelectDest;
struct SelectDest { struct SelectDest {
u8 eDest; /* How to dispose of the results */ u8 eDest; /* How to dispose of the results */
u8 affinity; /* Affinity used when eDest==SRT_Set */ u8 affSdst; /* Affinity used when eDest==SRT_Set */
int iParm; /* A parameter used by the eDest disposal method */ int iSDParm; /* A parameter used by the eDest disposal method */
int iMem; /* Base register where results are written */ int iSdst; /* Base register where results are written */
int nMem; /* Number of registers allocated */ int nSdst; /* Number of registers allocated */
}; };
/* /*