Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Make sure "rowid" columns in views are named correctly. Ticket #3308. (CVS 5580) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
8593218c7c8016fbdbcc223db951751e |
User & Date: | drh 2008-08-21 14:54:29.000 |
Context
2008-08-21
| ||
15:13 | Increase the version number in preparation for the next release. (CVS 5581) (check-in: d68dad73d0 user: drh tags: trunk) | |
14:54 | Make sure "rowid" columns in views are named correctly. Ticket #3308. (CVS 5580) (check-in: 8593218c7c user: drh tags: trunk) | |
14:24 | Add test cases to verify that ticket #3314 has been fixed. (CVS 5579) (check-in: b46267ff07 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.468 2008/08/21 14:54:29 drh Exp $ */ #include "sqliteInt.h" /* ** Delete all the content of a Select structure but do not deallocate ** the select structure itself. |
︙ | ︙ | |||
1163 1164 1165 1166 1167 1168 1169 1170 | p = pEList->a[i].pExpr; assert( p->pRight==0 || p->pRight->token.z==0 || p->pRight->token.z[0]!=0 ); if( (zName = pEList->a[i].zName)!=0 ){ /* If the column contains an "AS <name>" phrase, use <name> as the name */ zName = sqlite3DbStrDup(db, zName); }else{ Expr *pCol = p; while( pCol->op==TK_DOT ) pCol = pCol->pRight; | > | | | > | 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 | p = pEList->a[i].pExpr; assert( p->pRight==0 || p->pRight->token.z==0 || p->pRight->token.z[0]!=0 ); if( (zName = pEList->a[i].zName)!=0 ){ /* If the column contains an "AS <name>" phrase, use <name> as the name */ zName = sqlite3DbStrDup(db, zName); }else{ Expr *pCol = p; Table *pTab; while( pCol->op==TK_DOT ) pCol = pCol->pRight; if( pCol->op==TK_COLUMN && (pTab = pCol->pTab)!=0 ){ /* For columns use the column name name */ int iCol = pCol->iColumn; if( iCol<0 ) iCol = pTab->iPKey; zName = sqlite3MPrintf(db, "%s", iCol>=0 ? pTab->aCol[iCol].zName : "rowid"); }else{ /* Use the original text of the column expression as its name */ zName = sqlite3MPrintf(db, "%T", &pCol->span); } } if( db->mallocFailed ){ sqlite3DbFree(db, zName); |
︙ | ︙ |
Changes to test/view.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2002 February 26 # # 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 VIEW statements. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2002 February 26 # # 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 VIEW statements. # # $Id: view.test,v 1.38 2008/08/21 14:54:29 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Omit this entire file if the library is not configured with views enabled. ifcapable !view { finish_test return |
︙ | ︙ | |||
534 535 536 537 538 539 540 | CREATE VIEW vv4 AS SELECT * FROM vv3; CREATE VIEW vv5 AS SELECT * FROM vv4; SELECT * FROM vv5; } } {1 2 3 4 5 6} | > > | > > > > > > > > > > > > > > > > > > > > > > > > > | 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 | CREATE VIEW vv4 AS SELECT * FROM vv3; CREATE VIEW vv5 AS SELECT * FROM vv4; SELECT * FROM vv5; } } {1 2 3 4 5 6} # Ticket #3308 # Make sure "rowid" columns in a view are named correctly. # do_test view-19.1 { execsql { CREATE VIEW v3308a AS SELECT rowid, * FROM t1; } execsql2 { SELECT * FROM v3308a } } {rowid 1 a 1 b 2 c 3 rowid 2 a 4 b 5 c 6} do_test view-19.2 { execsql { CREATE VIEW v3308b AS SELECT t1.rowid, t1.a, t1.b+t1.c FROM t1; } execsql2 { SELECT * FROM v3308b } } {rowid 1 a 1 t1.b+t1.c 5 rowid 2 a 4 t1.b+t1.c 11} do_test view-19.3 { execsql { CREATE VIEW v3308c AS SELECT t1.oid, A, t1.b+t1.c AS x FROM t1; } execsql2 { SELECT * FROM v3308c } } {rowid 1 a 1 x 5 rowid 2 a 4 x 11} finish_test |