SQLite
Check-in [7b96115e81]
Not logged in
Overview
SHA1 Hash:7b96115e81deab0aa0472839cf787ba3f2fc64a7
Date: 2012-12-08 03:34:04
User: drh
Comment:Veryquick passes all tests now.
Tags And Properties
Changes
hide diffs unified diffs patch

Changes to src/expr.c

27 ** 27 ** 28 ** CREATE TABLE t1(a); 28 ** CREATE TABLE t1(a); 29 ** SELECT * FROM t1 WHERE a; 29 ** SELECT * FROM t1 WHERE a; 30 ** SELECT a AS b FROM t1 WHERE b; 30 ** SELECT a AS b FROM t1 WHERE b; 31 ** SELECT * FROM t1 WHERE (select a from t1); 31 ** SELECT * FROM t1 WHERE (select a from t1); 32 */ 32 */ 33 char sqlite3ExprAffinity(Expr *pExpr){ 33 char sqlite3ExprAffinity(Expr *pExpr){ > 34 int op; > 35 pExpr = sqlite3ExprSkipCollate(pExpr); 34 int op = pExpr->op; | 36 op = pExpr->op; 35 if( op==TK_SELECT ){ 37 if( op==TK_SELECT ){ 36 assert( pExpr->flags&EP_xIsSelect ); 38 assert( pExpr->flags&EP_xIsSelect ); 37 return sqlite3ExprAffinity(pExpr->x.pSelect->pEList->a[0].pExpr); 39 return sqlite3ExprAffinity(pExpr->x.pSelect->pEList->a[0].pExpr); 38 } 40 } 39 #ifndef SQLITE_OMIT_CAST 41 #ifndef SQLITE_OMIT_CAST 40 if( op==TK_CAST ){ 42 if( op==TK_CAST ){ 41 assert( !ExprHasProperty(pExpr, EP_IntValue) ); 43 assert( !ExprHasProperty(pExpr, EP_IntValue) );

Changes to src/fkey.c

507 507 508 pLeft = sqlite3Expr(db, TK_REGISTER, 0); 508 pLeft = sqlite3Expr(db, TK_REGISTER, 0); 509 if( pLeft ){ 509 if( pLeft ){ 510 /* Set the collation sequence and affinity of the LHS of each TK_EQ 510 /* Set the collation sequence and affinity of the LHS of each TK_EQ 511 ** expression to the parent key column defaults. */ 511 ** expression to the parent key column defaults. */ 512 if( pIdx ){ 512 if( pIdx ){ 513 Column *pCol; 513 Column *pCol; > 514 const char *zColl; 514 iCol = pIdx->aiColumn[i]; 515 iCol = pIdx->aiColumn[i]; 515 pCol = &pTab->aCol[iCol]; 516 pCol = &pTab->aCol[iCol]; 516 if( pTab->iPKey==iCol ) iCol = -1; 517 if( pTab->iPKey==iCol ) iCol = -1; 517 pLeft->iTable = regData+iCol+1; 518 pLeft->iTable = regData+iCol+1; 518 pLeft->affinity = pCol->affinity; 519 pLeft->affinity = pCol->affinity; > 520 zColl = pCol->zColl; > 521 if( zColl==0 ) zColl = db->pDfltColl->zName; 519 pLeft = sqlite3ExprAddCollateString(pParse, pLeft, pCol->zColl); | 522 pLeft = sqlite3ExprAddCollateString(pParse, pLeft, zColl); 520 }else{ 523 }else{ 521 pLeft->iTable = regData; 524 pLeft->iTable = regData; 522 pLeft->affinity = SQLITE_AFF_INTEGER; 525 pLeft->affinity = SQLITE_AFF_INTEGER; 523 } 526 } 524 } 527 } 525 iCol = aiCol ? aiCol[i] : pFKey->aCol[0].iFrom; 528 iCol = aiCol ? aiCol[i] : pFKey->aCol[0].iFrom; 526 assert( iCol>=0 ); 529 assert( iCol>=0 );

Changes to src/select.c

1331 } 1331 } 1332 *pnCol = nCol; 1332 *pnCol = nCol; 1333 *paCol = aCol; 1333 *paCol = aCol; 1334 1334 1335 for(i=0, pCol=aCol; i<nCol; i++, pCol++){ 1335 for(i=0, pCol=aCol; i<nCol; i++, pCol++){ 1336 /* Get an appropriate name for the column 1336 /* Get an appropriate name for the column 1337 */ 1337 */ 1338 p = pEList->a[i].pExpr; | 1338 p = sqlite3ExprSkipCollate(pEList->a[i].pExpr); 1339 assert( p->pRight==0 || ExprHasProperty(p->pRight, EP_IntValue) 1339 assert( p->pRight==0 || ExprHasProperty(p->pRight, EP_IntValue) 1340 || p->pRight->u.zToken==0 || p->pRight->u.zToken[0]!=0 ); 1340 || p->pRight->u.zToken==0 || p->pRight->u.zToken[0]!=0 ); 1341 if( (zName = pEList->a[i].zName)!=0 ){ 1341 if( (zName = pEList->a[i].zName)!=0 ){ 1342 /* If the column contains an "AS <name>" phrase, use <name> as the name */ 1342 /* If the column contains an "AS <name>" phrase, use <name> as the name */ 1343 zName = sqlite3DbStrDup(db, zName); 1343 zName = sqlite3DbStrDup(db, zName); 1344 }else{ 1344 }else{ 1345 Expr *pColExpr = p; /* The expression that is the result column name */ 1345 Expr *pColExpr = p; /* The expression that is the result column name */

Changes to src/where.c

1471 Index *pIdx, /* Index to match column of */ 1471 Index *pIdx, /* Index to match column of */ 1472 int iCol /* Column of index to match */ 1472 int iCol /* Column of index to match */ 1473 ){ 1473 ){ 1474 int i; 1474 int i; 1475 const char *zColl = pIdx->azColl[iCol]; 1475 const char *zColl = pIdx->azColl[iCol]; 1476 1476 1477 for(i=0; i<pList->nExpr; i++){ 1477 for(i=0; i<pList->nExpr; i++){ 1478 Expr *p = pList->a[i].pExpr; | 1478 Expr *p = sqlite3ExprSkipCollate(pList->a[i].pExpr); 1479 if( p->op==TK_COLUMN 1479 if( p->op==TK_COLUMN 1480 && p->iColumn==pIdx->aiColumn[iCol] 1480 && p->iColumn==pIdx->aiColumn[iCol] 1481 && p->iTable==iBase 1481 && p->iTable==iBase 1482 ){ 1482 ){ 1483 CollSeq *pColl = sqlite3ExprCollSeq(pParse, p); | 1483 CollSeq *pColl = sqlite3ExprCollSeq(pParse, pList->a[i].pExpr); 1484 if( ALWAYS(pColl) && 0==sqlite3StrICmp(pColl->zName, zColl) ){ 1484 if( ALWAYS(pColl) && 0==sqlite3StrICmp(pColl->zName, zColl) ){ 1485 return i; 1485 return i; 1486 } 1486 } 1487 } 1487 } 1488 } 1488 } 1489 1489 1490 return -1; 1490 return -1; ................................................................................................................................................................................ 1523 ** can be ignored. If it does not, and the column does not belong to the 1523 ** can be ignored. If it does not, and the column does not belong to the 1524 ** same table as index pIdx, return early. Finally, if there is no 1524 ** same table as index pIdx, return early. Finally, if there is no 1525 ** matching "col=X" expression and the column is on the same table as pIdx, 1525 ** matching "col=X" expression and the column is on the same table as pIdx, 1526 ** set the corresponding bit in variable mask. 1526 ** set the corresponding bit in variable mask. 1527 */ 1527 */ 1528 for(i=0; i<pDistinct->nExpr; i++){ 1528 for(i=0; i<pDistinct->nExpr; i++){ 1529 WhereTerm *pTerm; 1529 WhereTerm *pTerm; 1530 Expr *p = pDistinct->a[i].pExpr; | 1530 Expr *p = sqlite3ExprSkipCollate(pDistinct->a[i].pExpr); 1531 if( p->op!=TK_COLUMN ) return 0; 1531 if( p->op!=TK_COLUMN ) return 0; 1532 pTerm = findTerm(pWC, p->iTable, p->iColumn, ~(Bitmask)0, WO_EQ, 0); 1532 pTerm = findTerm(pWC, p->iTable, p->iColumn, ~(Bitmask)0, WO_EQ, 0); 1533 if( pTerm ){ 1533 if( pTerm ){ 1534 Expr *pX = pTerm->pExpr; 1534 Expr *pX = pTerm->pExpr; 1535 CollSeq *p1 = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight); 1535 CollSeq *p1 = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight); 1536 CollSeq *p2 = sqlite3ExprCollSeq(pParse, p); 1536 CollSeq *p2 = sqlite3ExprCollSeq(pParse, p); 1537 if( p1==p2 ) continue; 1537 if( p1==p2 ) continue; ................................................................................................................................................................................ 1575 pTab = pTabList->a[0].pTab; 1575 pTab = pTabList->a[0].pTab; 1576 1576 1577 /* If any of the expressions is an IPK column on table iBase, then return 1577 /* If any of the expressions is an IPK column on table iBase, then return 1578 ** true. Note: The (p->iTable==iBase) part of this test may be false if the 1578 ** true. Note: The (p->iTable==iBase) part of this test may be false if the 1579 ** current SELECT is a correlated sub-query. 1579 ** current SELECT is a correlated sub-query. 1580 */ 1580 */ 1581 for(i=0; i<pDistinct->nExpr; i++){ 1581 for(i=0; i<pDistinct->nExpr; i++){ 1582 Expr *p = pDistinct->a[i].pExpr; | 1582 Expr *p = sqlite3ExprSkipCollate(pDistinct->a[i].pExpr); 1583 if( p->op==TK_COLUMN && p->iTable==iBase && p->iColumn<0 ) return 1; 1583 if( p->op==TK_COLUMN && p->iTable==iBase && p->iColumn<0 ) return 1; 1584 } 1584 } 1585 1585 1586 /* Loop through all indices on the table, checking each to see if it makes 1586 /* Loop through all indices on the table, checking each to see if it makes 1587 ** the DISTINCT qualifier redundant. It does so if: 1587 ** the DISTINCT qualifier redundant. It does so if: 1588 ** 1588 ** 1589 ** 1. The index is itself UNIQUE, and 1589 ** 1. The index is itself UNIQUE, and

Changes to test/distinct.test

164 2 "b, a FROM t1" {} {B A b a} 164 2 "b, a FROM t1" {} {B A b a} 165 3 "a, b, c FROM t1" {hash} {a b c A B C} 165 3 "a, b, c FROM t1" {hash} {a b c A B C} 166 4 "a, b, c FROM t1 ORDER BY a, b, c" {btree} {A B C a b c} 166 4 "a, b, c FROM t1 ORDER BY a, b, c" {btree} {A B C a b c} 167 5 "b FROM t1 WHERE a = 'a'" {} {b} 167 5 "b FROM t1 WHERE a = 'a'" {} {b} 168 6 "b FROM t1" {hash} {b B} 168 6 "b FROM t1" {hash} {b B} 169 7 "a FROM t1" {} {A a} 169 7 "a FROM t1" {} {A a} 170 8 "b COLLATE nocase FROM t1" {} {b} 170 8 "b COLLATE nocase FROM t1" {} {b} 171 9 "b COLLATE nocase FROM t1 ORDER BY b COLLATE nocase" {} {B} | 171 9 "b COLLATE nocase FROM t1 ORDER BY b COLLATE nocase" {} {b} 172 } { 172 } { 173 do_execsql_test 2.$tn.1 "SELECT DISTINCT $sql" $res 173 do_execsql_test 2.$tn.1 "SELECT DISTINCT $sql" $res 174 do_temptables_test 2.$tn.2 "SELECT DISTINCT $sql" $temptables 174 do_temptables_test 2.$tn.2 "SELECT DISTINCT $sql" $temptables 175 } 175 } 176 176 177 do_execsql_test 2.A { 177 do_execsql_test 2.A { 178 SELECT (SELECT DISTINCT o.a FROM t1 AS i) FROM t1 AS o ORDER BY rowid; 178 SELECT (SELECT DISTINCT o.a FROM t1 AS i) FROM t1 AS o ORDER BY rowid;

Changes to test/interrupt.test

162 for {set i 1} {$i<$max_count-5} {incr i 1} { 162 for {set i 1} {$i<$max_count-5} {incr i 1} { 163 do_test interrupt-4.$i.1 { 163 do_test interrupt-4.$i.1 { 164 set ::sqlite_interrupt_count $::i 164 set ::sqlite_interrupt_count $::i 165 catchsql $sql 165 catchsql $sql 166 } {1 interrupted} 166 } {1 interrupted} 167 } 167 } 168 168 > 169 if {0} { # This doesn't work anymore since the collation factor is > 170 # no longer called during schema parsing. 169 # Interrupt during parsing 171 # Interrupt during parsing 170 # 172 # 171 do_test interrupt-5.1 { 173 do_test interrupt-5.1 { 172 proc fake_interrupt {args} { 174 proc fake_interrupt {args} { 173 db collate fake_collation no-op 175 db collate fake_collation no-op 174 sqlite3_interrupt db 176 sqlite3_interrupt db 175 return SQLITE_OK 177 return SQLITE_OK 176 } 178 } 177 db collation_needed fake_interrupt 179 db collation_needed fake_interrupt 178 catchsql { 180 catchsql { 179 CREATE INDEX fake ON fake1(a COLLATE fake_collation, b, c DESC); 181 CREATE INDEX fake ON fake1(a COLLATE fake_collation, b, c DESC); 180 } 182 } 181 } {1 interrupt} 183 } {1 interrupt} 182 | 184 } 183 finish_test 185 finish_test