Remove an incorrect assert() statement (ticket [beba9cae6345a]). Fix other
minor problems in the name resolution logic. FossilOrigin-Name: afe96a118c8a9627819ba5960aa83a607e734087
This commit is contained in:
parent
3e3f1a5b49
commit
c75e09c761
16
manifest
16
manifest
@ -1,5 +1,5 @@
|
||||
C Now\ssupports\sresult\ssets\sof\sthe\sform\s"TABLE.*"\swith\snested\sFROM\sclauses.
|
||||
D 2013-01-03T00:45:56.842
|
||||
C Remove\san\sincorrect\sassert()\sstatement\s(ticket\s[beba9cae6345a]).\s\sFix\sother\nminor\sproblems\sin\sthe\sname\sresolution\slogic.
|
||||
D 2013-01-03T16:54:20.331
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -172,9 +172,9 @@ F src/pragma.c 8907c559d3127729d3bcedb1fe5c59fc196d3a17
|
||||
F src/prepare.c 931ad0d852a0df48f79adcba6ce79ca5f475625c
|
||||
F src/printf.c 4a9f882f1c1787a8b494a2987765acf9d97ac21f
|
||||
F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
|
||||
F src/resolve.c e00f17ac321b48f022e0154e5c2fb90456b6d3a6
|
||||
F src/resolve.c 2b3ae4d8578384caf2f19b42c5ccc0512ead84c3
|
||||
F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
|
||||
F src/select.c 9a76144e137fbe26bad3c5ef06e0acd953de9f59
|
||||
F src/select.c 962a028bbb5d0bce997a0802ee806fe72403df4d
|
||||
F src/shell.c 11c9611580bb2ffce3a232f31f7f8cc310df0843
|
||||
F src/sqlite.h.in 39cc33bb08897c748fe3383c29ccf56585704177
|
||||
F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0
|
||||
@ -701,7 +701,7 @@ F test/select9.test c0ca3cd87a8ebb04de2cb1402c77df55d911a0ea
|
||||
F test/selectA.test 06d1032fa9009314c95394f2ca2e60d9f7ae8532
|
||||
F test/selectB.test 954e4e49cf1f896d61794e440669e03a27ceea25
|
||||
F test/selectC.test 871fb55d884d3de5943c4057ebd22c2459e71977
|
||||
F test/selectD.test 5e05091a755b12e0afd350137c49b25f7d9bc61b
|
||||
F test/selectD.test 03f7c1ea8d5ab3c637cbc30fcbbbac96b988c162
|
||||
F test/server1.test 46803bd3fe8b99b30dbc5ff38ffc756f5c13a118
|
||||
F test/shared.test 1da9dbad400cee0d93f252ccf76e1ae007a63746
|
||||
F test/shared2.test 03eb4a8d372e290107d34b6ce1809919a698e879
|
||||
@ -1031,7 +1031,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
|
||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
|
||||
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
|
||||
P ef01e30456670e6b1bc67fe41ec27e52c182efaf
|
||||
R 0fd360c4969bf18ffc741f29481411d6
|
||||
P 4cf5ed7ea198abc32f8118e79490e77f847f08c1
|
||||
R 7012a50322397b26dcf2d91c29b5b20b
|
||||
U drh
|
||||
Z a4217b32c27253cef4a6339df637b923
|
||||
Z 261d0c48c10993cca01d26b0f623d70a
|
||||
|
@ -1 +1 @@
|
||||
4cf5ed7ea198abc32f8118e79490e77f847f08c1
|
||||
afe96a118c8a9627819ba5960aa83a607e734087
|
@ -262,9 +262,6 @@ static int lookupName(
|
||||
pTab = pItem->pTab;
|
||||
assert( pTab!=0 && pTab->zName!=0 );
|
||||
assert( pTab->nCol>0 );
|
||||
if( zDb && pTab->pSchema!=pSchema ){
|
||||
continue;
|
||||
}
|
||||
if( pItem->pSelect && (pItem->pSelect->selFlags & SF_NestedFrom)!=0 ){
|
||||
ExprList *pEList = pItem->pSelect->pEList;
|
||||
int hit = 0;
|
||||
@ -278,6 +275,9 @@ static int lookupName(
|
||||
}
|
||||
if( hit || zTab==0 ) continue;
|
||||
}
|
||||
if( zDb && pTab->pSchema!=pSchema ){
|
||||
continue;
|
||||
}
|
||||
if( zTab ){
|
||||
const char *zTabName = pItem->zAlias ? pItem->zAlias : pTab->zName;
|
||||
assert( zTabName!=0 );
|
||||
|
13
src/select.c
13
src/select.c
@ -1336,8 +1336,6 @@ static int selectColumnsFromExprList(
|
||||
/* Get an appropriate name for the column
|
||||
*/
|
||||
p = sqlite3ExprSkipCollate(pEList->a[i].pExpr);
|
||||
assert( p->pRight==0 || ExprHasProperty(p->pRight, EP_IntValue)
|
||||
|| p->pRight->u.zToken==0 || p->pRight->u.zToken[0]!=0 );
|
||||
if( (zName = pEList->a[i].zName)!=0 ){
|
||||
/* If the column contains an "AS <name>" phrase, use <name> as the name */
|
||||
zName = sqlite3DbStrDup(db, zName);
|
||||
@ -3429,18 +3427,18 @@ static int selectExpander(Walker *pWalker, Select *p){
|
||||
Select *pSub = pFrom->pSelect;
|
||||
char *zTabName = pFrom->zAlias;
|
||||
const char *zSchemaName = 0;
|
||||
int iDb;
|
||||
if( zTabName==0 ){
|
||||
zTabName = pTab->zName;
|
||||
}
|
||||
if( db->mallocFailed ) break;
|
||||
if( pSub==0 || (pSub->selFlags & SF_NestedFrom)==0 ){
|
||||
int iDb;
|
||||
pSub = 0;
|
||||
if( zTName && sqlite3StrICmp(zTName, zTabName)!=0 ){
|
||||
continue;
|
||||
}
|
||||
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
|
||||
zSchemaName = iDb>=0 ? db->aDb[i].zName : "*";
|
||||
zSchemaName = iDb>=0 ? db->aDb[iDb].zName : "*";
|
||||
}
|
||||
for(j=0; j<pTab->nCol; j++){
|
||||
char *zName = pTab->aCol[j].zName;
|
||||
@ -3448,6 +3446,7 @@ static int selectExpander(Walker *pWalker, Select *p){
|
||||
char *zToFree; /* Malloced string that needs to be freed */
|
||||
Token sColname; /* Computed column name as a token */
|
||||
|
||||
assert( zName );
|
||||
if( zTName && pSub
|
||||
&& sqlite3MatchSpanName(pSub->pEList->a[j].zSpan, 0, zTName, 0)==0
|
||||
){
|
||||
@ -3485,6 +3484,10 @@ static int selectExpander(Walker *pWalker, Select *p){
|
||||
Expr *pLeft;
|
||||
pLeft = sqlite3Expr(db, TK_ID, zTabName);
|
||||
pExpr = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
|
||||
if( zSchemaName && iDb>0 ){
|
||||
pLeft = sqlite3Expr(db, TK_ID, zSchemaName);
|
||||
pExpr = sqlite3PExpr(pParse, TK_DOT, pLeft, pExpr, 0);
|
||||
}
|
||||
if( longNames ){
|
||||
zColname = sqlite3MPrintf(db, "%s.%s", zTabName, zName);
|
||||
zToFree = zColname;
|
||||
@ -3500,9 +3503,11 @@ static int selectExpander(Walker *pWalker, Select *p){
|
||||
struct ExprList_item *pX = &pNew->a[pNew->nExpr-1];
|
||||
if( pSub ){
|
||||
pX->zSpan = sqlite3DbStrDup(db, pSub->pEList->a[j].zSpan);
|
||||
testcase( pX->zSpan==0 );
|
||||
}else{
|
||||
pX->zSpan = sqlite3MPrintf(db, "%s.%s.%s",
|
||||
zSchemaName, zTabName, zColname);
|
||||
testcase( pX->zSpan==0 );
|
||||
}
|
||||
pX->bSpanIsTab = 1;
|
||||
}
|
||||
|
@ -25,10 +25,12 @@ for {set i 1} {$i<=2} {incr i} {
|
||||
}
|
||||
do_test selectD-$i.0 {
|
||||
db eval {
|
||||
ATTACH ':memory:' AS aux1;
|
||||
CREATE TABLE t1(a,b); INSERT INTO t1 VALUES(111,'x1');
|
||||
CREATE TABLE t2(a,b); INSERT INTO t2 VALUES(222,'x2');
|
||||
CREATE TEMP TABLE t3(a,b); INSERT INTO t3 VALUES(333,'x3');
|
||||
CREATE TABLE t4(a,b); INSERT INTO t4 VALUES(444,'x4');
|
||||
CREATE TABLE main.t4(a,b); INSERT INTO main.t4 VALUES(444,'x4');
|
||||
CREATE TABLE aux1.t4(a,b); INSERT INTO aux1.t4 VALUES(555,'x5');
|
||||
}
|
||||
} {}
|
||||
do_test selectD-$i.1 {
|
||||
@ -72,6 +74,38 @@ for {set i 1} {$i<=2} {incr i} {
|
||||
ON t2.a=t1.a+111;
|
||||
}
|
||||
} {333 x3 222 x2}
|
||||
do_test selectD-$i.2.4 {
|
||||
db eval {
|
||||
SELECT *
|
||||
FROM t1 JOIN (t2 JOIN (main.t4 JOIN aux1.t4 ON aux1.t4.a=main.t4.a+111)
|
||||
ON main.t4.a=t2.a+222)
|
||||
ON t2.a=t1.a+111;
|
||||
}
|
||||
} {111 x1 222 x2 444 x4 555 x5}
|
||||
do_test selectD-$i.2.5 {
|
||||
db eval {
|
||||
SELECT *
|
||||
FROM t1 JOIN (t2 JOIN (main.t4 AS x JOIN aux1.t4 ON aux1.t4.a=x.a+111)
|
||||
ON x.a=t2.a+222)
|
||||
ON t2.a=t1.a+111;
|
||||
}
|
||||
} {111 x1 222 x2 444 x4 555 x5}
|
||||
do_test selectD-$i.2.6 {
|
||||
catchsql {
|
||||
SELECT *
|
||||
FROM t1 JOIN (t2 JOIN (main.t4 JOIN aux.t4 ON aux.t4.a=main.t4.a+111)
|
||||
ON main.t4.a=t2.a+222)
|
||||
ON t2.a=t1.a+111;
|
||||
}
|
||||
} {1 {no such table: aux.t4}}
|
||||
do_test selectD-$i.2.7 {
|
||||
db eval {
|
||||
SELECT x.a, y.b
|
||||
FROM t1 JOIN (t2 JOIN (main.t4 x JOIN aux1.t4 y ON y.a=x.a+111)
|
||||
ON x.a=t2.a+222)
|
||||
ON t2.a=t1.a+111;
|
||||
}
|
||||
} {444 x5}
|
||||
do_test selectD-$i.3 {
|
||||
db eval {
|
||||
UPDATE t2 SET a=111;
|
||||
|
Loading…
x
Reference in New Issue
Block a user