Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Remove an ALWAYS macro around an expression that is sometimes false. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
f2a9ee722c568e73f2a08fb6a2886719 |
User & Date: | dan 2009-09-10 10:15:59.000 |
Context
2009-09-10
| ||
16:14 | Fix a problem with the sqlite3VdbeMayAbort() assert failing following an OOM. (check-in: b302786350 user: dan tags: trunk) | |
10:15 | Remove an ALWAYS macro around an expression that is sometimes false. (check-in: f2a9ee722c user: dan tags: trunk) | |
02:54 | Reduce default SQLITE_MAX_TRIGGER_DEPTH when SQLITE_SMALL_STACK is defined. (check-in: 913fb70ea8 user: shane tags: trunk) | |
Changes
Changes to src/select.c.
︙ | ︙ | |||
880 881 882 883 884 885 886 | ** database table or a subquery. */ Table *pTab = 0; /* Table structure column is extracted from */ Select *pS = 0; /* Select the column is extracted from */ int iCol = pExpr->iColumn; /* Index of column in pTab */ testcase( pExpr->op==TK_AGG_COLUMN ); testcase( pExpr->op==TK_COLUMN ); | | | | | | > > > > > > > > | > > | | | 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 | ** database table or a subquery. */ Table *pTab = 0; /* Table structure column is extracted from */ Select *pS = 0; /* Select the column is extracted from */ int iCol = pExpr->iColumn; /* Index of column in pTab */ testcase( pExpr->op==TK_AGG_COLUMN ); testcase( pExpr->op==TK_COLUMN ); while( pNC && !pTab ){ SrcList *pTabList = pNC->pSrcList; for(j=0;j<pTabList->nSrc && pTabList->a[j].iCursor!=pExpr->iTable;j++); if( j<pTabList->nSrc ){ pTab = pTabList->a[j].pTab; pS = pTabList->a[j].pSelect; }else{ pNC = pNC->pNext; } } 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. 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 && 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 ** data for the result-set column of the sub-select. */ if( ALWAYS(iCol>=0 && iCol<pS->pEList->nExpr) ){ /* If iCol is less than zero, then the expression requests the ** rowid of the sub-select or view. This expression is legal (see ** test case misc2.2.2) - it always evaluates to NULL. */ NameContext sNC; Expr *p = pS->pEList->a[iCol].pExpr; sNC.pSrcList = pS->pSrc; sNC.pNext = pNC; sNC.pParse = pNC->pParse; zType = columnType(&sNC, p, &zOriginDb, &zOriginTab, &zOriginCol); } }else if( ALWAYS(pTab->pSchema) ){ /* A real table */ assert( !pS ); if( iCol<0 ) iCol = pTab->iPKey; |
︙ | ︙ |
Changes to test/capi3c.test.
︙ | ︙ | |||
1316 1317 1318 1319 1320 1321 1322 1323 1324 | } {one} do_test capi3c-23.6 { sqlite3_column_text16 $STMT 2 sqlite3_column_text $STMT 3 } {one} sqlite3_finalize $STMT } finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 | } {one} do_test capi3c-23.6 { sqlite3_column_text16 $STMT 2 sqlite3_column_text $STMT 3 } {one} sqlite3_finalize $STMT } # Test decltype on some SELECT statements that contain sub-selects. # proc decltype {zSql} { set ret [list] set STMT [sqlite3_prepare_v2 db $zSql -1 TAIL] for {set i 0} {$i < [sqlite3_column_count $STMT]} {incr i} { lappend ret [sqlite3_column_decltype $STMT $i] } sqlite3_finalize $STMT return $ret } do_test capi3c-24.1 { execsql { CREATE TABLE t5(a INTEGER, b STRING, c DATETIME) } decltype {SELECT * FROM t5} } {INTEGER STRING DATETIME} do_test capi3c-24.2 { decltype {SELECT (SELECT c) FROM t5} } {DATETIME} do_test capi3c-24.3 { decltype {SELECT (SELECT * FROM (SELECT c)) FROM t5} } {DATETIME} do_test capi3c-24.4 { decltype {SELECT * FROM (SELECT * FROM t5 ORDER BY c LIMIT 1) ORDER BY b} } {INTEGER STRING DATETIME} do_test capi3c-24.5 { decltype { SELECT (SELECT x FROM (SELECT c AS x)) FROM (SELECT * FROM t5 ORDER BY c LIMIT 1) ORDER BY b } } {DATETIME} do_test capi3c-24.3 { decltype {SELECT (SELECT x FROM (SELECT t5.a AS x)) FROM t5} } {INTEGER} finish_test |