Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Handle quotes on the table name in TABLE.* terms in SELECT statements. Ticket #680. (CVS 1833) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
826b6797a9f08c69b9378cb403d746e9 |
User & Date: | drh 2004-07-20 01:45:20.000 |
Context
2004-07-20
| ||
12:45 | Add the '%ifdef' capability to lemon. Other minor changes. (CVS 1836) (check-in: 522ff721cc user: drh tags: trunk) | |
01:45 | Handle quotes on the table name in TABLE.* terms in SELECT statements. Ticket #680. (CVS 1833) (check-in: 826b6797a9 user: drh tags: trunk) | |
01:14 | Report an error when attempting to open a directory as a database. Ticket #687. (CVS 1832) (check-in: 4d77037be3 user: drh tags: trunk) | |
Changes
Changes to src/select.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** ** $Id: select.c,v 1.201 2004/07/20 01:45:20 drh Exp $ */ #include "sqliteInt.h" /* ** Allocate a new Select structure and return a pointer to that ** structure. |
︙ | ︙ | |||
984 985 986 987 988 989 990 | pNew->a[pNew->nExpr-1].zName = a[k].zName; a[k].pExpr = 0; a[k].zName = 0; }else{ /* This expression is a "*" or a "TABLE.*" and needs to be ** expanded. */ int tableSeen = 0; /* Set to 1 when TABLE matches */ | | | | | < | | 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 | pNew->a[pNew->nExpr-1].zName = a[k].zName; a[k].pExpr = 0; a[k].zName = 0; }else{ /* This expression is a "*" or a "TABLE.*" and needs to be ** expanded. */ int tableSeen = 0; /* Set to 1 when TABLE matches */ char *zTName; /* text of name of TABLE */ if( pE->op==TK_DOT && pE->pLeft ){ zTName = sqlite3NameFromToken(&pE->pLeft->token); }else{ zTName = 0; } for(i=0; i<pTabList->nSrc; i++){ Table *pTab = pTabList->a[i].pTab; char *zTabName = pTabList->a[i].zAlias; if( zTabName==0 || zTabName[0]==0 ){ zTabName = pTab->zName; } if( zTName && (zTabName==0 || zTabName[0]==0 || sqlite3StrICmp(zTName, zTabName)!=0) ){ continue; } tableSeen = 1; for(j=0; j<pTab->nCol; j++){ Expr *pExpr, *pLeft, *pRight; char *zName = pTab->aCol[j].zName; |
︙ | ︙ | |||
1043 1044 1045 1046 1047 1048 1049 | pExpr = pRight; pExpr->span = pExpr->token; } pNew = sqlite3ExprListAppend(pNew, pExpr, 0); } } if( !tableSeen ){ | | | > | 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 | pExpr = pRight; pExpr->span = pExpr->token; } pNew = sqlite3ExprListAppend(pNew, pExpr, 0); } } if( !tableSeen ){ if( zTName ){ sqlite3ErrorMsg(pParse, "no such table: %s", zTName); }else{ sqlite3ErrorMsg(pParse, "no tables specified"); } rc = 1; } sqliteFree(zTName); } } sqlite3ExprListDelete(pEList); p->pEList = pNew; } return rc; } |
︙ | ︙ |
Changes to test/select1.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the SELECT statement. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the SELECT statement. # # $Id: select1.test,v 1.35 2004/07/20 01:45:21 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Try to select on a non-existant table. # do_test select1-1.1 { |
︙ | ︙ | |||
617 618 619 620 621 622 623 | } } {t3.a 1 t3.b 2 t4.a 3 t4.b 4} do_test select1-11.3 { execsql2 { SELECT * FROM t3 AS x, t4 AS y; } } {x.a 1 x.b 2 y.a 3 y.b 4} | | > > > > > | 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 | } } {t3.a 1 t3.b 2 t4.a 3 t4.b 4} do_test select1-11.3 { execsql2 { SELECT * FROM t3 AS x, t4 AS y; } } {x.a 1 x.b 2 y.a 3 y.b 4} do_test select1-11.4.1 { execsql { SELECT t3.*, t4.b FROM t3, t4; } } {1 2 4} do_test select1-11.4.2 { execsql { SELECT "t3".*, t4.b FROM t3, t4; } } {1 2 4} do_test select1-11.5 { execsql2 { SELECT t3.*, t4.b FROM t3, t4; } } {t3.a 1 t3.b 2 t4.b 4} do_test select1-11.6 { |
︙ | ︙ |