mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Remove terms with operator TK_AS from the expression tree. Ticket #2356. (CVS 3991)
FossilOrigin-Name: 5627ff74be9242418434a06fe5c104d1f9128cab
This commit is contained in:
18
manifest
18
manifest
@ -1,5 +1,5 @@
|
|||||||
C Make\sREINDEX\srobust\sin\sthe\sface\sof\smalloc()\serrors.\s(CVS\s3990)
|
C Remove\sterms\swith\soperator\sTK_AS\sfrom\sthe\sexpression\stree.\s\sTicket\s#2356.\s(CVS\s3991)
|
||||||
D 2007-05-12T15:00:15
|
D 2007-05-14T11:34:47
|
||||||
F Makefile.in 87b200ad9970907f76df734d29dff3d294c10935
|
F Makefile.in 87b200ad9970907f76df734d29dff3d294c10935
|
||||||
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
|
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
|
||||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||||
@ -60,7 +60,7 @@ F sqlite3.pc.in 985b9bf34192a549d7d370e0f0b6b34a4f61369a
|
|||||||
F src/alter.c ca8fc4a3c7359379598dc12589b65c32eb88defd
|
F src/alter.c ca8fc4a3c7359379598dc12589b65c32eb88defd
|
||||||
F src/analyze.c e8fcb1c35ace8418615eb18d9601f321ac86b2ec
|
F src/analyze.c e8fcb1c35ace8418615eb18d9601f321ac86b2ec
|
||||||
F src/attach.c ba628db0c2b6a362f036d017bf1196cdfe4ebb37
|
F src/attach.c ba628db0c2b6a362f036d017bf1196cdfe4ebb37
|
||||||
F src/auth.c 902f4722661c796b97f007d9606bd7529c02597f
|
F src/auth.c 5ea90bc93dfea46e9fe4bf531e14c7cd98219ecb
|
||||||
F src/btree.c 0c2f9b06c90d7c59925c03153c9d47fd739c8ca5
|
F src/btree.c 0c2f9b06c90d7c59925c03153c9d47fd739c8ca5
|
||||||
F src/btree.h 1d527bf61ed176f980c34999d5793a0fd45dcf8c
|
F src/btree.h 1d527bf61ed176f980c34999d5793a0fd45dcf8c
|
||||||
F src/btreeInt.h cb3c0e9eb842d06079a62cdf3492c90c5db7ba75
|
F src/btreeInt.h cb3c0e9eb842d06079a62cdf3492c90c5db7ba75
|
||||||
@ -70,7 +70,7 @@ F src/complete.c 7d1a44be8f37de125fcafd3d3a018690b3799675
|
|||||||
F src/date.c 6049db7d5a8fdf2c677ff7d58fa31d4f6593c988
|
F src/date.c 6049db7d5a8fdf2c677ff7d58fa31d4f6593c988
|
||||||
F src/delete.c 5c0d89b3ef7d48fe1f5124bfe8341f982747fe29
|
F src/delete.c 5c0d89b3ef7d48fe1f5124bfe8341f982747fe29
|
||||||
F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b
|
F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b
|
||||||
F src/expr.c 2283be0ae4186fa9bb2a8a3f6b545a51ea7632bd
|
F src/expr.c bad06f783d2daf1884a922859c8e7427323e7dc3
|
||||||
F src/func.c b6586f83c141859c103dd4954de66efc3fbd101b
|
F src/func.c b6586f83c141859c103dd4954de66efc3fbd101b
|
||||||
F src/hash.c 67b23e14f0257b69a3e8aa663e4eeadc1a2b6fd5
|
F src/hash.c 67b23e14f0257b69a3e8aa663e4eeadc1a2b6fd5
|
||||||
F src/hash.h 1b3f7e2609141fd571f62199fc38687d262e9564
|
F src/hash.h 1b3f7e2609141fd571f62199fc38687d262e9564
|
||||||
@ -99,7 +99,7 @@ F src/pragma.c 6d5eb19feef9e84117b9b17a4c38b12b8c1c6897
|
|||||||
F src/prepare.c 87c23644986b5e41a58bc76f05abebd899e00089
|
F src/prepare.c 87c23644986b5e41a58bc76f05abebd899e00089
|
||||||
F src/printf.c 05b233c7a39aec4c54c79ef87af24f0a6591175d
|
F src/printf.c 05b233c7a39aec4c54c79ef87af24f0a6591175d
|
||||||
F src/random.c 6119474a6f6917f708c1dee25b9a8e519a620e88
|
F src/random.c 6119474a6f6917f708c1dee25b9a8e519a620e88
|
||||||
F src/select.c d43bbdedb843a91b728531c831f3ed04846b920d
|
F src/select.c 3f563bb096c5768ac99d4b762084e86d5b227230
|
||||||
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
|
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
|
||||||
F src/shell.c d07ae326b3815d80f71c69b3c7584382e47f6447
|
F src/shell.c d07ae326b3815d80f71c69b3c7584382e47f6447
|
||||||
F src/sqlite.h.in 664b8702c27dc742584788823c548491ac8935d6
|
F src/sqlite.h.in 664b8702c27dc742584788823c548491ac8935d6
|
||||||
@ -410,7 +410,7 @@ F test/vtab8.test e19fa4a538fcd1bb66c22825fa8f71618fb13583
|
|||||||
F test/vtab9.test ea58d2b95d61955f87226381716b2d0b1d4e4f9b
|
F test/vtab9.test ea58d2b95d61955f87226381716b2d0b1d4e4f9b
|
||||||
F test/vtab_err.test 9eabf98b26838fed8bac4aea986580be0a2bd52e
|
F test/vtab_err.test 9eabf98b26838fed8bac4aea986580be0a2bd52e
|
||||||
F test/vtab_shared.test d631d1f820c38c18939d53aab1fc35db5f0a8094
|
F test/vtab_shared.test d631d1f820c38c18939d53aab1fc35db5f0a8094
|
||||||
F test/where.test 1d020f50c77f37b2dbab9766ca959e6e3278ecdb
|
F test/where.test 5c342d6ad0d777275d4740ea5cbeaf5173b6eda4
|
||||||
F test/where2.test 3249d426b3fc7a106713d784e1628307fc308d2e
|
F test/where2.test 3249d426b3fc7a106713d784e1628307fc308d2e
|
||||||
F test/where3.test 0a30fe9808b0fa01c46d0fcf4fac0bf6cf75bb30
|
F test/where3.test 0a30fe9808b0fa01c46d0fcf4fac0bf6cf75bb30
|
||||||
F test/where4.test b68496500bff496e83e76ae4ffb493b99064eac6
|
F test/where4.test b68496500bff496e83e76ae4ffb493b99064eac6
|
||||||
@ -490,7 +490,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
|
|||||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||||
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
|
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
|
||||||
P c08658e1f8598941ebddddb98942b98cfcb86e7a
|
P dbe417745d3d4ed875715ad7083d7345d1b6a56f
|
||||||
R 72a1de25bc540615c732aa41aeba85b0
|
R 6fe321bd341ad3acbb13e0750cc6f8e7
|
||||||
U drh
|
U drh
|
||||||
Z 5ad3bb426ed54207061f91dbb90ceab1
|
Z e5ed06d7f6549ae20b899f9b0e3f9c4d
|
||||||
|
@ -1 +1 @@
|
|||||||
dbe417745d3d4ed875715ad7083d7345d1b6a56f
|
5627ff74be9242418434a06fe5c104d1f9128cab
|
@ -14,7 +14,7 @@
|
|||||||
** systems that do not need this facility may omit it by recompiling
|
** systems that do not need this facility may omit it by recompiling
|
||||||
** the library with -DSQLITE_OMIT_AUTHORIZATION=1
|
** the library with -DSQLITE_OMIT_AUTHORIZATION=1
|
||||||
**
|
**
|
||||||
** $Id: auth.c,v 1.25 2006/06/16 08:01:03 danielk1977 Exp $
|
** $Id: auth.c,v 1.26 2007/05/14 11:34:47 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
@ -115,8 +115,7 @@ void sqlite3AuthRead(
|
|||||||
int iDb; /* The index of the database the expression refers to */
|
int iDb; /* The index of the database the expression refers to */
|
||||||
|
|
||||||
if( db->xAuth==0 ) return;
|
if( db->xAuth==0 ) return;
|
||||||
if( pExpr->op==TK_AS ) return;
|
if( pExpr->op!=TK_COLUMN ) return;
|
||||||
assert( pExpr->op==TK_COLUMN );
|
|
||||||
iDb = sqlite3SchemaToIndex(pParse->db, pExpr->pSchema);
|
iDb = sqlite3SchemaToIndex(pParse->db, pExpr->pSchema);
|
||||||
if( iDb<0 ){
|
if( iDb<0 ){
|
||||||
/* An attempt to read a column out of a subquery or other
|
/* An attempt to read a column out of a subquery or other
|
||||||
|
27
src/expr.c
27
src/expr.c
@ -12,7 +12,7 @@
|
|||||||
** This file contains routines used for analyzing expressions and
|
** This file contains routines used for analyzing expressions and
|
||||||
** for generating VDBE code that evaluates expressions in SQLite.
|
** for generating VDBE code that evaluates expressions in SQLite.
|
||||||
**
|
**
|
||||||
** $Id: expr.c,v 1.292 2007/05/12 06:11:12 danielk1977 Exp $
|
** $Id: expr.c,v 1.293 2007/05/14 11:34:47 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@ -35,9 +35,6 @@
|
|||||||
*/
|
*/
|
||||||
char sqlite3ExprAffinity(Expr *pExpr){
|
char sqlite3ExprAffinity(Expr *pExpr){
|
||||||
int op = pExpr->op;
|
int op = pExpr->op;
|
||||||
if( op==TK_AS ){
|
|
||||||
return sqlite3ExprAffinity(pExpr->pLeft);
|
|
||||||
}
|
|
||||||
if( op==TK_SELECT ){
|
if( op==TK_SELECT ){
|
||||||
return sqlite3ExprAffinity(pExpr->pSelect->pEList->a[0].pExpr);
|
return sqlite3ExprAffinity(pExpr->pSelect->pEList->a[0].pExpr);
|
||||||
}
|
}
|
||||||
@ -75,7 +72,7 @@ CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){
|
|||||||
CollSeq *pColl = 0;
|
CollSeq *pColl = 0;
|
||||||
if( pExpr ){
|
if( pExpr ){
|
||||||
pColl = pExpr->pColl;
|
pColl = pExpr->pColl;
|
||||||
if( (pExpr->op==TK_AS || pExpr->op==TK_CAST) && !pColl ){
|
if( pExpr->op==TK_CAST && !pColl ){
|
||||||
return sqlite3ExprCollSeq(pParse, pExpr->pLeft);
|
return sqlite3ExprCollSeq(pParse, pExpr->pLeft);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -481,10 +478,6 @@ Expr *sqlite3ExprDup(Expr *p){
|
|||||||
pNew->pRight = sqlite3ExprDup(p->pRight);
|
pNew->pRight = sqlite3ExprDup(p->pRight);
|
||||||
pNew->pList = sqlite3ExprListDup(p->pList);
|
pNew->pList = sqlite3ExprListDup(p->pList);
|
||||||
pNew->pSelect = sqlite3SelectDup(p->pSelect);
|
pNew->pSelect = sqlite3SelectDup(p->pSelect);
|
||||||
pNew->pTab = p->pTab;
|
|
||||||
#if SQLITE_MAX_EXPR_DEPTH>0
|
|
||||||
pNew->nHeight = p->nHeight;
|
|
||||||
#endif
|
|
||||||
return pNew;
|
return pNew;
|
||||||
}
|
}
|
||||||
void sqlite3TokenCopy(Token *pTo, Token *pFrom){
|
void sqlite3TokenCopy(Token *pTo, Token *pFrom){
|
||||||
@ -1114,10 +1107,17 @@ static int lookupName(
|
|||||||
for(j=0; j<pEList->nExpr; j++){
|
for(j=0; j<pEList->nExpr; j++){
|
||||||
char *zAs = pEList->a[j].zName;
|
char *zAs = pEList->a[j].zName;
|
||||||
if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){
|
if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){
|
||||||
|
Expr *pDup;
|
||||||
assert( pExpr->pLeft==0 && pExpr->pRight==0 );
|
assert( pExpr->pLeft==0 && pExpr->pRight==0 );
|
||||||
pExpr->op = TK_AS;
|
assert( pExpr->pList==0 );
|
||||||
pExpr->iColumn = j;
|
assert( pExpr->pSelect==0 );
|
||||||
pExpr->pLeft = sqlite3ExprDup(pEList->a[j].pExpr);
|
pDup = sqlite3ExprDup(pEList->a[j].pExpr);
|
||||||
|
if( pExpr->flags & EP_ExpCollate ){
|
||||||
|
pDup->pColl = pExpr->pColl;
|
||||||
|
pDup->flags |= EP_ExpCollate;
|
||||||
|
}
|
||||||
|
memcpy(pExpr, pDup, sizeof(*pExpr));
|
||||||
|
sqliteFree(pDup);
|
||||||
cnt = 1;
|
cnt = 1;
|
||||||
assert( zTab==0 && zDb==0 );
|
assert( zTab==0 && zDb==0 );
|
||||||
goto lookupname_end_2;
|
goto lookupname_end_2;
|
||||||
@ -1960,8 +1960,7 @@ void sqlite3ExprCode(Parse *pParse, Expr *pExpr){
|
|||||||
sqlite3VdbeAddOp(v, OP_And, 0, 0);
|
sqlite3VdbeAddOp(v, OP_And, 0, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TK_UPLUS:
|
case TK_UPLUS: {
|
||||||
case TK_AS: {
|
|
||||||
sqlite3ExprCode(pParse, pExpr->pLeft);
|
sqlite3ExprCode(pParse, pExpr->pLeft);
|
||||||
stackChng = 0;
|
stackChng = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
** This file contains C code routines that are called by the parser
|
** This file contains C code routines that are called by the parser
|
||||||
** to handle SELECT statements in SQLite.
|
** to handle SELECT statements in SQLite.
|
||||||
**
|
**
|
||||||
** $Id: select.c,v 1.344 2007/05/10 10:46:57 danielk1977 Exp $
|
** $Id: select.c,v 1.345 2007/05/14 11:34:47 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
@ -822,12 +822,6 @@ static const char *columnType(
|
|||||||
int j;
|
int j;
|
||||||
if( pExpr==0 || pNC->pSrcList==0 ) return 0;
|
if( pExpr==0 || pNC->pSrcList==0 ) return 0;
|
||||||
|
|
||||||
/* The TK_AS operator can only occur in ORDER BY, GROUP BY, HAVING,
|
|
||||||
** and LIMIT clauses. But pExpr originates in the result set of a
|
|
||||||
** SELECT. So pExpr can never contain an AS operator.
|
|
||||||
*/
|
|
||||||
assert( pExpr->op!=TK_AS );
|
|
||||||
|
|
||||||
switch( pExpr->op ){
|
switch( pExpr->op ){
|
||||||
case TK_AGG_COLUMN:
|
case TK_AGG_COLUMN:
|
||||||
case TK_COLUMN: {
|
case TK_COLUMN: {
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
# This file implements regression tests for SQLite library. The
|
# This file implements regression tests for SQLite library. The
|
||||||
# focus of this file is testing the use of indices in WHERE clases.
|
# focus of this file is testing the use of indices in WHERE clases.
|
||||||
#
|
#
|
||||||
# $Id: where.test,v 1.41 2007/02/06 23:41:34 drh Exp $
|
# $Id: where.test,v 1.42 2007/05/14 11:34:47 drh Exp $
|
||||||
|
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
@ -62,24 +62,42 @@ proc count sql {
|
|||||||
# and Next operators in the VDBE. By verifing that the search count is
|
# and Next operators in the VDBE. By verifing that the search count is
|
||||||
# small we can be assured that indices are being used properly.
|
# small we can be assured that indices are being used properly.
|
||||||
#
|
#
|
||||||
do_test where-1.1 {
|
do_test where-1.1.1 {
|
||||||
count {SELECT x, y FROM t1 WHERE w=10}
|
count {SELECT x, y, w FROM t1 WHERE w=10}
|
||||||
} {3 121 3}
|
} {3 121 10 3}
|
||||||
do_test where-1.1.2 {
|
do_test where-1.1.2 {
|
||||||
set sqlite_query_plan
|
set sqlite_query_plan
|
||||||
} {t1 i1w}
|
} {t1 i1w}
|
||||||
do_test where-1.2 {
|
do_test where-1.1.3 {
|
||||||
count {SELECT x, y FROM t1 WHERE w=11}
|
count {SELECT x, y, w AS abc FROM t1 WHERE abc=10}
|
||||||
} {3 144 3}
|
} {3 121 10 3}
|
||||||
do_test where-1.3 {
|
do_test where-1.1.4 {
|
||||||
count {SELECT x, y FROM t1 WHERE 11=w}
|
set sqlite_query_plan
|
||||||
} {3 144 3}
|
} {t1 i1w}
|
||||||
do_test where-1.4 {
|
do_test where-1.2.1 {
|
||||||
count {SELECT x, y FROM t1 WHERE 11=w AND x>2}
|
count {SELECT x, y, w FROM t1 WHERE w=11}
|
||||||
} {3 144 3}
|
} {3 144 11 3}
|
||||||
|
do_test where-1.2.2 {
|
||||||
|
count {SELECT x, y, w AS abc FROM t1 WHERE abc=11}
|
||||||
|
} {3 144 11 3}
|
||||||
|
do_test where-1.3.1 {
|
||||||
|
count {SELECT x, y, w AS abc FROM t1 WHERE 11=w}
|
||||||
|
} {3 144 11 3}
|
||||||
|
do_test where-1.3.2 {
|
||||||
|
count {SELECT x, y, w AS abc FROM t1 WHERE 11=abc}
|
||||||
|
} {3 144 11 3}
|
||||||
|
do_test where-1.4.1 {
|
||||||
|
count {SELECT w, x, y FROM t1 WHERE 11=w AND x>2}
|
||||||
|
} {11 3 144 3}
|
||||||
do_test where-1.4.2 {
|
do_test where-1.4.2 {
|
||||||
set sqlite_query_plan
|
set sqlite_query_plan
|
||||||
} {t1 i1w}
|
} {t1 i1w}
|
||||||
|
do_test where-1.4.3 {
|
||||||
|
count {SELECT w AS a, x AS b, y FROM t1 WHERE 11=a AND b>2}
|
||||||
|
} {11 3 144 3}
|
||||||
|
do_test where-1.4.4 {
|
||||||
|
set sqlite_query_plan
|
||||||
|
} {t1 i1w}
|
||||||
do_test where-1.5 {
|
do_test where-1.5 {
|
||||||
count {SELECT x, y FROM t1 WHERE y<200 AND w=11 AND x>2}
|
count {SELECT x, y FROM t1 WHERE y<200 AND w=11 AND x>2}
|
||||||
} {3 144 3}
|
} {3 144 3}
|
||||||
|
Reference in New Issue
Block a user