When flattening a SELECT query, do not discard collation sequences explicitly attached to expressions in the parent query. Fix for #3997. (CVS 6949)

FossilOrigin-Name: b2784cf5d8b520fb714efdb2d2746b2c88b56edf
This commit is contained in:
danielk1977 2009-07-28 13:30:30 +00:00
parent 3190f4b5f1
commit 0a458e5e2f
4 changed files with 86 additions and 9 deletions

View File

@ -1,5 +1,5 @@
C Fixed\sreversed\slabels\sin\sWHERETRACE()\sstatement.\s\sDebugging\scode\sonly.\s(CVS\s6948)
D 2009-07-28T08:43:09
C When\sflattening\sa\sSELECT\squery,\sdo\snot\sdiscard\scollation\ssequences\sexplicitly\sattached\sto\sexpressions\sin\sthe\sparent\squery.\sFix\sfor\s#3997.\s(CVS\s6949)
D 2009-07-28T13:30:31
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in df9359da7a726ccb67a45db905c5447d5c00c6ef
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -159,7 +159,7 @@ F src/printf.c 508a1c59433353552b6553cba175eaa7331f8fc1
F src/random.c 676b9d7ac820fe81e6fb2394ac8c10cff7f38628
F src/resolve.c 4a61d03e49b15440878096e6030863fc628828f0
F src/rowset.c c64dafba1f9fd876836c8db8682966b9d197eb1f
F src/select.c 71748b8e244112cf73df9446c4246c192276c30d
F src/select.c 90bc99bfcf8faae5ebb8d8948366c7c2a1b4cc00
F src/shell.c db2643650b9268df89a4bedca3f1c6d9e786f1bb
F src/sqlite.h.in 5672d9a6e19f80c1c7f1276dbe10e7d51c8fd97b
F src/sqlite3ext.h 1db7d63ab5de4b3e6b83dd03d1a4e64fef6d2a17
@ -658,6 +658,7 @@ F test/tkt3922.test 022ace32c049e3964f68492c12eb803e8e4856d8
F test/tkt3929.test 6a4c3baefb4e75127356b7d675b5df42c35c00d1
F test/tkt3935.test e15261fedb9e30a4305a311da614a5d8e693c767
F test/tkt3992.test c193b9643b1c25d020c503a986d5e4089e65c530
F test/tkt3997.test a335fa41ca3985660a139df7b734a26ef53284bd
F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7
F test/trace.test 19ffbc09885c3321d56358a5738feae8587fb377
F test/trans.test d887cb07630dc39879a322d958ad8b006137485c
@ -739,7 +740,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
P 224bc69a04f4fe6d1004125847761b7842c2bfe0
R 4ca3c5bfa0c281d0c8065c6aa9f9769d
U shane
Z dd29c0202db09ae4eaced40be14766c5
P 614a8d83158eb59e3fbe78d62461635bfcc13525
R 975e8b479e878820dd333965b8b9186b
U danielk1977
Z 57f9d4273370bcb522584f6e1fe3cab8

View File

@ -1 +1 @@
614a8d83158eb59e3fbe78d62461635bfcc13525
b2784cf5d8b520fb714efdb2d2746b2c88b56edf

View File

@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.524 2009/06/12 03:27:27 drh Exp $
** $Id: select.c,v 1.525 2009/07/28 13:30:31 danielk1977 Exp $
*/
#include "sqliteInt.h"
@ -2355,6 +2355,9 @@ static Expr *substExpr(
assert( pEList!=0 && pExpr->iColumn<pEList->nExpr );
assert( pExpr->pLeft==0 && pExpr->pRight==0 );
pNew = sqlite3ExprDup(db, pEList->a[pExpr->iColumn].pExpr, 0);
if( pExpr->pColl ){
pNew->pColl = pExpr->pColl;
}
sqlite3ExprDelete(db, pExpr);
pExpr = pNew;
}

73
test/tkt3997.test Normal file
View File

@ -0,0 +1,73 @@
# 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.
#
#***********************************************************************
#
# Tests to make sure #3997 is fixed.
#
# $Id: tkt3997.test,v 1.1 2009/07/28 13:30:31 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
proc reverse {lhs rhs} {
return [string compare $rhs $lhs]
}
proc usual {lhs rhs} {
return [string compare $lhs $rhs]
}
db collate reverse reverse
db collate usual usual
do_test tkt3997-1.1 {
execsql {
create table mytext(name BLOB);
INSERT INTO mytext VALUES('abc');
INSERT INTO mytext VALUES('acd');
INSERT INTO mytext VALUES('afe');
}
} {}
do_test tkt3997-1.2 {
execsql {
SELECT name
FROM mytext
ORDER BY name COLLATE reverse
}
} {afe acd abc}
do_test tkt3997-1.3 {
execsql {
SELECT name
FROM (SELECT name FROM mytext)
ORDER BY name COLLATE reverse
}
} {afe acd abc}
do_test tkt3997-2.1 {
execsql {
CREATE TABLE mytext2(name COLLATE reverse);
INSERT INTO mytext2 SELECT name FROM mytext;
}
} {}
do_test tkt3997-2.2 {
execsql {
SELECT name
FROM (SELECT name FROM mytext2)
ORDER BY name
}
} {afe acd abc}
do_test tkt3997-2.3 {
execsql {
SELECT name
FROM (SELECT name FROM mytext2)
ORDER BY name COLLATE usual
}
} {abc acd afe}
finish_test