From d742bb78f82cd8b5436056dd30eefeaea5ac85e0 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 2 Mar 2009 01:22:40 +0000 Subject: [PATCH] Fix a bug in the GROUP BY alias name resolution. The bug was by check-in (6305). Discovered by regression test on 64-bit linux. Test cases added so that the problems is detected on 32-bit systems. (CVS 6332) FossilOrigin-Name: fa0008502ec4f891bfed4a11f01650d274f95c44 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/resolve.c | 3 ++- test/selectC.test | 32 ++++++++++++++++++++++++++++---- 4 files changed, 38 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 129d5834a6..9df03fac7a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Suppress\ssome\scompiler\swarnings\s(where\spossible).\s\sTicket\s#3696.\s(CVS\s6331) -D 2009-03-01T22:29:20 +C Fix\sa\sbug\sin\sthe\sGROUP\sBY\salias\sname\sresolution.\sThe\sbug\swas\sby\ncheck-in\s(6305).\s\sDiscovered\sby\sregression\stest\son\s64-bit\slinux.\nTest\scases\sadded\sso\sthat\sthe\sproblems\sis\sdetected\son\s32-bit\ssystems.\s(CVS\s6332) +D 2009-03-02T01:22:40 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in d64baddbf55cdf33ff030e14da837324711a4ef7 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -152,7 +152,7 @@ F src/pragma.c 22ed04836aab8ce134c53be1ca896f3ad20fabdb F src/prepare.c 1ede93a00f1835a10b3d3aad968e8f8ecd2c98dd F src/printf.c 9866a9a9c4a90f6d4147407f373df3fd5d5f9b6f F src/random.c 676b9d7ac820fe81e6fb2394ac8c10cff7f38628 -F src/resolve.c dea005135845acbbfae1f2968c0deb6b2e3d580c +F src/resolve.c ac4f914b32f9d76fd7ad29c4686105216e8d7995 F src/rowset.c ba9375f37053d422dd76965a9c370a13b6e1aac4 F src/select.c 4d0b77fd76ff80f09a798ee98953e344c9de8fbb F src/shell.c 0cada72035b819ed2bede27e254efcfbb88167f7 @@ -522,7 +522,7 @@ F test/select8.test 391de11bdd52339c30580dabbbbe97e3e9a3c79d F test/select9.test b4007b15396cb7ba2615cab31e1973b572e43210 F test/selectA.test 06d1032fa9009314c95394f2ca2e60d9f7ae8532 F test/selectB.test 31e81ac9af7d224850e0706350f070ecb92fcbc7 -F test/selectC.test 44f4e1b2c86e40f8135294a826ec4142766e21c3 +F test/selectC.test ae49d258c875bc1712898f1632062bc5c01a7470 F test/server1.test f5b790d4c0498179151ca8a7715a65a7802c859c F test/shared.test 2f6c65de8123c130b92e4e18a516f669eaa02fea F test/shared2.test 0ee9de8964d70e451936a48c41cb161d9134ccf4 @@ -703,7 +703,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P ec3b18acaecabae6eb04eda006870e602faacb8c -R 54956e5fad91f855ede30eccd038cab5 +P a2373e5409e4e59903f315a4446db8cb6ba000cc +R 63b49fa689a852f21c1ea5f0d83afe2b U drh -Z 82111cc0e3cd0c60f383783eb123460b +Z 0b75cd981aa0c228ad7eaacfbe7139e5 diff --git a/manifest.uuid b/manifest.uuid index 8151471f9e..e122f7f200 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a2373e5409e4e59903f315a4446db8cb6ba000cc \ No newline at end of file +fa0008502ec4f891bfed4a11f01650d274f95c44 \ No newline at end of file diff --git a/src/resolve.c b/src/resolve.c index 749e473d45..81180df9e5 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -14,7 +14,7 @@ ** resolve all identifiers by associating them with a particular ** table and column. ** -** $Id: resolve.c,v 1.18 2009/02/24 10:14:40 danielk1977 Exp $ +** $Id: resolve.c,v 1.19 2009/03/02 01:22:40 drh Exp $ */ #include "sqliteInt.h" #include @@ -65,6 +65,7 @@ static void resolveAlias( db = pParse->db; pDup = sqlite3ExprDup(db, pOrig, 0); if( pDup==0 ) return; + sqlite3TokenCopy(db, &pDup->token, &pOrig->token); if( pDup->op!=TK_COLUMN && zType[0]!='G' ){ pDup = sqlite3PExpr(pParse, TK_AS, pDup, 0, 0); if( pDup==0 ) return; diff --git a/test/selectC.test b/test/selectC.test index d35ca569e0..e92b83bbd4 100644 --- a/test/selectC.test +++ b/test/selectC.test @@ -10,7 +10,7 @@ #*********************************************************************** # This file implements regression tests for SQLite library. # -# $Id: selectC.test,v 1.3 2008/09/17 00:13:12 drh Exp $ +# $Id: selectC.test,v 1.4 2009/03/02 01:22:40 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -102,14 +102,23 @@ do_test selectC-1.11 { GROUP BY x, y } } {1 aaabbb} -do_test selectC-1.12 { +proc longname_toupper x {return [string toupper $x]} +db function uppercaseconversionfunctionwithaverylongname longname_toupper +do_test selectC-1.12.1 { execsql { SELECT DISTINCT upper(b) AS x FROM t1 ORDER BY x } } {AAA CCC} -do_test selectC-1.13 { +do_test selectC-1.12.2 { + execsql { + SELECT DISTINCT uppercaseconversionfunctionwithaverylongname(b) AS x + FROM t1 + ORDER BY x + } +} {AAA CCC} +do_test selectC-1.13.1 { execsql { SELECT upper(b) AS x FROM t1 @@ -117,12 +126,27 @@ do_test selectC-1.13 { ORDER BY x } } {AAA CCC} -do_test selectC-1.14 { +do_test selectC-1.13.2 { + execsql { + SELECT uppercaseconversionfunctionwithaverylongname(b) AS x + FROM t1 + GROUP BY x + ORDER BY x + } +} {AAA CCC} +do_test selectC-1.14.1 { execsql { SELECT upper(b) AS x FROM t1 ORDER BY x DESC } } {CCC AAA AAA} +do_test selectC-1.14.2 { + execsql { + SELECT uppercaseconversionfunctionwithaverylongname(b) AS x + FROM t1 + ORDER BY x DESC + } +} {CCC AAA AAA} finish_test