mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-14 00:22:38 +03:00
Remove an ALWAYS macro around an expression that is sometimes false.
FossilOrigin-Name: f2a9ee722c568e73f2a08fb6a2886719850f2923
This commit is contained in:
26
src/select.c
26
src/select.c
@@ -884,7 +884,7 @@ static const char *columnType(
|
||||
int iCol = pExpr->iColumn; /* Index of column in pTab */
|
||||
testcase( pExpr->op==TK_AGG_COLUMN );
|
||||
testcase( pExpr->op==TK_COLUMN );
|
||||
while( ALWAYS(pNC) && !pTab ){
|
||||
while( pNC && !pTab ){
|
||||
SrcList *pTabList = pNC->pSrcList;
|
||||
for(j=0;j<pTabList->nSrc && pTabList->a[j].iCursor!=pExpr->iTable;j++);
|
||||
if( j<pTabList->nSrc ){
|
||||
@@ -895,18 +895,28 @@ static const char *columnType(
|
||||
}
|
||||
}
|
||||
|
||||
if( NEVER(pTab==0) ){
|
||||
if( pTab==0 ){
|
||||
/* At one time, code such as "SELECT new.x" within a trigger would
|
||||
** cause this condition to run. Since then, we have restructured how
|
||||
** trigger code is generated and so this condition is no longer
|
||||
** possible. But it seems prudent to keep the test in place in
|
||||
** case something else changes.
|
||||
*/
|
||||
zType = "TEXT";
|
||||
** possible. However, it can still be true for statements like
|
||||
** the following:
|
||||
**
|
||||
** CREATE TABLE t1(col INTEGER);
|
||||
** SELECT (SELECT t1.col) FROM FROM t1;
|
||||
**
|
||||
** when columnType() is called on the expression "t1.col" in the
|
||||
** sub-select. In this case, set the column type to NULL, even
|
||||
** though it should really be "INTEGER".
|
||||
**
|
||||
** This is not a problem, as the column type of "t1.col" is never
|
||||
** used. When columnType() is called on the expression
|
||||
** "(SELECT t1.col)", the correct type is returned (see the TK_SELECT
|
||||
** branch below. */
|
||||
break;
|
||||
}
|
||||
|
||||
assert( pTab );
|
||||
assert( pTab && pExpr->pTab==pTab );
|
||||
if( pS ){
|
||||
/* The "table" is actually a sub-select or a view in the FROM clause
|
||||
** of the SELECT statement. Return the declaration type and origin
|
||||
@@ -920,7 +930,7 @@ static const char *columnType(
|
||||
NameContext sNC;
|
||||
Expr *p = pS->pEList->a[iCol].pExpr;
|
||||
sNC.pSrcList = pS->pSrc;
|
||||
sNC.pNext = 0;
|
||||
sNC.pNext = pNC;
|
||||
sNC.pParse = pNC->pParse;
|
||||
zType = columnType(&sNC, p, &zOriginDb, &zOriginTab, &zOriginCol);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user