-C Merge\schanges\sfrom\strunk.
-D 2017-04-10T23:42:04.790
+C Improved\scomments.\s\sFix\sa\sproblem\swhen\san\sindexed\sexpression\sis\sused\sin\san\nORDER\sBY\sclause.
+D 2017-04-11T01:01:27.332
F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc a4c0613a18663bda56d8cf76079ab6590a7c3602e54befb4bbdef76bcaa38b6a
F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
F src/resolve.c 3e518b962d932a997fae373366880fc028c75706
F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
-F src/select.c b24e628a2b76800171f4c86e38b5d93e27f2c40e603b24733aa8e471029e6ecd
+F src/select.c 9228235fdefe6de138ac01c4c68d07fd95d78780ef85112a76e63e260a6f5897
F src/shell.c 70f4957b988572315e97c56941fdc81fd35907fee36b7b2e7be5ec4c7e9d065d
F src/sqlite.h.in 40233103e3e4e10f8a63523498d0259d232e42aba478e2d3fb914799185aced6
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/walker.c b71a992b413b3a022572eccf29ef4b4890223791
F src/where.c 1d14e18f32231fa7969e718e7b60ef749b0065e2a7e1b6b00883b20732d280f1
F src/whereInt.h 7a21ef633e26acbf46df04add2eba6e0a2100c78dc5879049e93f981fc3344df
-F src/wherecode.c 38d171e309c7b54d5bdc7d8b663ec16249ad8888e01a77f6c55e9350de8e8349
+F src/wherecode.c 943e32e9dccd0af802e0683ae11071c8bd808364e5908a5fb66758bd404c8681
F src/whereexpr.c 130cdd1a43af71b19755270fb1224874cf55158c
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 13a422230dcf4a8a80434af97434d57e456dcaa6bf0c41e6859f37ded6fa96ca e052436d9f54b785facd661adc648512356b831c0547aa8f347ebf4bd8ef1254
-R a0a3c2f64645982d19356fee9ed1bee3
+P 8978465f335925378d3aa99df6190ce6a1ee6b130205ccc493f2399803844760
+R 1b0a9c05391f59848f876fd33c1876bb
U drh
-Z 41de53ab744a90538b62b8272746f983
+Z 21e604ae631dfab7b9082f6214d51689
-8978465f335925378d3aa99df6190ce6a1ee6b130205ccc493f2399803844760
\ No newline at end of file
+c59eaf2b7cd2596733f349fc0fe979f71fd29bd73152a0c57066e0b69d5b7a4a
\ No newline at end of file
NameContext sNC;
sNC.pSrcList = pTabList;
sNC.pParse = pParse;
+ sNC.pNext = 0;
for(i=0; i<pEList->nExpr; i++){
Expr *p = pEList->a[i].pExpr;
const char *zType;
#endif /* !defined(SQLITE_OMIT_DECLTYPE) */
}
+/*
+** Return the Table objecct in the SrcList that has cursor iCursor.
+** Or return NULL if no such Table object exists in the SrcList.
+*/
+static Table *tableWithCursor(SrcList *pList, int iCursor){
+ int j;
+ for(j=0; j<pList->nSrc; j++){
+ if( pList->a[j].iCursor==iCursor ) return pList->a[j].pTab;
+ }
+ return 0;
+}
+
+
/*
** Generate code that will tell the VDBE the names of columns
** in the result set. This information is used to provide the
ExprList *pEList /* Expressions defining the result set */
){
Vdbe *v = pParse->pVdbe;
- int i, j;
+ int i;
+ Table *pTab;
sqlite3 *db = pParse->db;
int fullNames, shortNames;
if( pEList->a[i].zName ){
char *zName = pEList->a[i].zName;
sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_TRANSIENT);
- }else if( p->op==TK_COLUMN || p->op==TK_AGG_COLUMN ){
- Table *pTab;
+ }else if( (p->op==TK_COLUMN || p->op==TK_AGG_COLUMN)
+ && (pTab = tableWithCursor(pTabList, p->iTable))!=0
+ ){
char *zCol;
int iCol = p->iColumn;
- for(j=0; ALWAYS(j<pTabList->nSrc); j++){
- if( pTabList->a[j].iCursor==p->iTable ) break;
- }
- assert( j<pTabList->nSrc );
- pTab = pTabList->a[j].pTab;
if( iCol<0 ) iCol = pTab->iPKey;
assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) );
if( iCol<0 ){
}
}
-#if 1 /* INDEXEXPRTRANS */
+/* An instance of the IdxExprTrans object carries information about a
+** mapping from an expression on table columns into a column in an index
+** down through the Walker.
+*/
typedef struct IdxExprTrans {
Expr *pIdxExpr; /* The index expression */
int iTabCur; /* The cursor of the corresponding table */
int iIdxCol; /* The column for the index */
} IdxExprTrans;
+/* The walker node callback used to transform matching expressions into
+** a reference to an index column for an index on an expression.
+**
+** If pExpr matches, then transform it into a reference to the index column
+** that contains the value of pExpr.
+*/
static int whereIndexExprTransNode(Walker *p, Expr *pExpr){
IdxExprTrans *pX = p->u.pIdxTrans;
if( sqlite3ExprCompare(pExpr, pX->pIdxExpr, pX->iTabCur)==0 ){
sqlite3WalkExprList(&w, pWInfo->pResultSet);
}
}
-#endif
/*
** Generate code for the start of the iLevel-th loop in the WHERE clause
iRowidReg, pPk->nKeyCol); VdbeCoverage(v);
}
-#if 1 /* INDEXEXPRTANS */
+ /* If pIdx is an index on one or more expressions, then look through
+ ** all the expressions in pWInfo and try to transform matching expressions
+ ** into reference to index columns.
+ */
whereIndexExprTrans(pIdx, iCur, iIdxCur, pWInfo);
-#endif
+
/* Record the instruction used to terminate the loop. */
if( pLoop->wsFlags & WHERE_ONEROW ){