aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <>2022-05-02 19:59:03 +0000
committerdrh <>2022-05-02 19:59:03 +0000
commit72d620bdb1a4e3e7c8d405a56ec382a89202dcec (patch)
tree19fdfa059f5a43657fb7350fa8f480cc2845d63c /src
parent85f93850f7589e27fca2f41789525e9ccca2fb65 (diff)
downloadsqlite-72d620bdb1a4e3e7c8d405a56ec382a89202dcec.tar.gz
sqlite-72d620bdb1a4e3e7c8d405a56ec382a89202dcec.zip
Name resolution and "*" wildcard expansion for parenthesized FROM clauses
seems to work the same as PG. The code is chaos, however, and needs some cleanup. FossilOrigin-Name: 6f9c0b07aadc5189c65c3ee4e6938aac10fc0d98f1cb06980f5e5d7b0308f237
Diffstat (limited to 'src')
-rw-r--r--src/expr.c1
-rw-r--r--src/select.c15
-rw-r--r--src/sqliteInt.h1
-rw-r--r--src/treeview.c1
4 files changed, 17 insertions, 1 deletions
diff --git a/src/expr.c b/src/expr.c
index 77b5e0ad6..a93c6a1bc 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -1635,6 +1635,7 @@ ExprList *sqlite3ExprListDup(sqlite3 *db, const ExprList *p, int flags){
pItem->bUsed = pOldItem->bUsed;
pItem->bUsingTerm = pOldItem->bUsingTerm;
pItem->bSorterRef = pOldItem->bSorterRef;
+ pItem->bNoExpand = pOldItem->bNoExpand;
pItem->u = pOldItem->u;
}
return pNew;
diff --git a/src/select.c b/src/select.c
index ed0fc6e4c..187d89888 100644
--- a/src/select.c
+++ b/src/select.c
@@ -2231,6 +2231,9 @@ int sqlite3ColumnsFromExprList(
}
pCol->zCnName = zName;
pCol->hName = sqlite3StrIHash(zName);
+ if( pX->bNoExpand ){
+ pCol->colFlags |= COLFLAG_NOEXPAND;
+ }
sqlite3ColumnPropertiesFromName(0, pCol);
if( zName && sqlite3HashInsert(&ht, zName, pX)==pX ){
sqlite3OomFault(db);
@@ -5822,6 +5825,7 @@ static int selectExpander(Walker *pWalker, Select *p){
char *zTabName; /* AS name for this data source */
const char *zSchemaName = 0; /* Schema name for this data source */
int iDb; /* Schema index for this data src */
+ IdList *pUsing; /* USING clause for this join */
if( (zTabName = pFrom->zAlias)==0 ){
zTabName = pTab->zName;
@@ -5846,7 +5850,7 @@ static int selectExpander(Walker *pWalker, Select *p){
&& (selFlags & SF_NestedFrom)!=0
){
int ii;
- IdList *pUsing = pFrom[1].u3.pUsing;
+ pUsing = pFrom[1].u3.pUsing;
for(ii=0; ii<pUsing->nId; ii++){
const char *zUName = pUsing->a[ii].zName;
pRight = sqlite3Expr(db, TK_ID, zUName);
@@ -5859,6 +5863,8 @@ static int selectExpander(Walker *pWalker, Select *p){
pX->bUsingTerm = 1;
}
}
+ }else{
+ pUsing = 0;
}
for(j=0; j<pTab->nCol; j++){
char *zName = pTab->aCol[j].zCnName;
@@ -5938,6 +5944,13 @@ static int selectExpander(Walker *pWalker, Select *p){
testcase( pX->zEName==0 );
}
pX->eEName = ENAME_TAB;
+ if( (pFrom->fg.isUsing
+ && sqlite3IdListIndex(pFrom->u3.pUsing, zName)>=0)
+ || (pUsing && sqlite3IdListIndex(pUsing, zName)>=0)
+ || (pTab->aCol[j].colFlags & COLFLAG_NOEXPAND)!=0
+ ){
+ pX->bNoExpand = 1;
+ }
}else if( longNames ){
pX->zEName = sqlite3MPrintf(db, "%s.%s", zTabName, zName);
pX->eEName = ENAME_NAME;
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index 0715cae3c..f4c48c112 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -3008,6 +3008,7 @@ struct ExprList {
unsigned bNulls :1; /* True if explicit "NULLS FIRST/LAST" */
unsigned bUsed :1; /* This column used in a SF_NestedFrom subquery */
unsigned bUsingTerm:1; /* Term from the USING clause of a NestedFrom */
+ unsigned bNoExpand: 1;
union {
struct { /* Used by any ExprList other than Parse.pConsExpr */
u16 iOrderByCol; /* For ORDER BY, column number in result set */
diff --git a/src/treeview.c b/src/treeview.c
index b498692ba..b9d65e1ac 100644
--- a/src/treeview.c
+++ b/src/treeview.c
@@ -882,6 +882,7 @@ void sqlite3TreeViewBareExprList(
fprintf(stdout, "TABLE-ALIAS-NAME(\"%s\") ", zName);
if( pList->a[i].bUsed ) fprintf(stdout, "(used) ");
if( pList->a[i].bUsingTerm ) fprintf(stdout, "(USING-term) ");
+ if( pList->a[i].bNoExpand ) fprintf(stdout, "(NoExpand) ");
break;
case ENAME_SPAN:
fprintf(stdout, "SPAN(\"%s\") ", zName);