Issue Details (XML | Word | Printable)

Key: DERBY-2351
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Bryan Pendleton
Reporter: Yip Ng
Votes: 1
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

ORDER BY with expression with distinct in the select list returns incorrect result

Created: 17/Feb/07 12:36 AM   Updated: 30/Jun/09 04:12 PM
Return to search
Component/s: SQL
Affects Version/s: 10.2.1.6, 10.2.2.0, 10.3.1.4
Fix Version/s: 10.3.3.0, 10.4.1.3, 10.5.1.1

Time Tracking:
Not Specified

File Attachments:
  Size
File Licensed for inclusion in ASF works d2351_aliasing.diff 2008-03-04 04:34 AM Bryan Pendleton 9 kB
File Licensed for inclusion in ASF works d2351_aliasing.diff 2008-03-02 10:42 PM Bryan Pendleton 7 kB
File Licensed for inclusion in ASF works d2351_aliasing_checkQualifiedName.diff 2008-03-06 04:29 AM Bryan Pendleton 11 kB
File Licensed for inclusion in ASF works derby_2351.diff 2007-06-17 03:30 AM Bryan Pendleton 9 kB
File Licensed for inclusion in ASF works derby_2351_v2.diff 2007-06-17 07:42 PM Bryan Pendleton 10 kB
File Licensed for inclusion in ASF works modifySynonymResults.diff 2008-03-08 08:45 PM Bryan Pendleton 12 kB
HTML File Licensed for inclusion in ASF works releaseNote.html 2008-04-01 01:29 PM Rick Hillegas 6 kB
HTML File Licensed for inclusion in ASF works releaseNote.html 2008-03-20 02:42 PM Bryan Pendleton 6 kB
HTML File Licensed for inclusion in ASF works releaseNote.html 2008-03-20 05:20 AM Bryan Pendleton 4 kB
File Licensed for inclusion in ASF works reproTests.diff 2007-06-10 09:45 PM Bryan Pendleton 5 kB
Environment: Any
Issue Links:
Reference

Issue & fix info: Release Note Needed
Resolution Date: 16/Mar/08 03:51 AM


 Description  « Hide
When distinct is in the select list and the query has order by with expression, the resultset produced contains an additional column.

ij> create table t1 (c1 int, c2 varchar(10))
0 rows inserted/updated/deleted
ij> insert into t1 values (1,'a'),(2,'b'),(3,'c');
3 rows inserted/updated/deleted
select distinct c1, c2 from t1 order by c1;
C1 |C2
----------------------
1 |a
2 |b
3 |c

3 rows selected
ij> select distinct c1, c2 from t1 order by c1+1;
C1 |C2 |3 <=====returns 3 columns, incorrect result returned
----------------------------------
1 |a |2
2 |b |3
3 |c |4

3 rows selected


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Yip Ng made changes - 17/Feb/07 12:41 AM
Field Original Value New Value
Description When distinct is in the select list and the query has order by with expression, the resultset produced contains an additional column.

ij> create table t1 (c1 int, c2 varchar(10))
0 rows inserted/updated/deleted
ij> insert into t1 values (1,'a'),(2,'b'),(3,'c');
3 rows inserted/updated/deleted
select distinct c1, c2 from t1 order by c1;
C1 |C2
----------------------
1 |a
2 |b
3 |c

3 rows selected
ij> select distinct c1, c2 from t1 order by c1+1;
C1 |C2 |3 <=====returns 3 columns, incorrect result returned, should have thrown an error
----------------------------------
1 |a |2
2 |b |3
3 |c |4

3 rows selected
When distinct is in the select list and the query has order by with expression, the resultset produced contains an additional column.

ij> create table t1 (c1 int, c2 varchar(10))
0 rows inserted/updated/deleted
ij> insert into t1 values (1,'a'),(2,'b'),(3,'c');
3 rows inserted/updated/deleted
select distinct c1, c2 from t1 order by c1;
C1 |C2
----------------------
1 |a
2 |b
3 |c

3 rows selected
ij> select distinct c1, c2 from t1 order by c1+1;
C1 |C2 |3 <=====returns 3 columns, incorrect result returned
----------------------------------
1 |a |2
2 |b |3
3 |c |4

3 rows selected
Bryan Pendleton made changes - 29/May/07 01:29 AM
Assignee Bryan Pendleton [ bryanpendleton ]
Bryan Pendleton made changes - 10/Jun/07 09:45 PM
Attachment reproTests.diff [ 12359377 ]
Bryan Pendleton made changes - 15/Jun/07 04:44 AM
Link This issue is related to DERBY-2805 [ DERBY-2805 ]
Bryan Pendleton made changes - 17/Jun/07 03:30 AM
Attachment derby_2351.diff [ 12359951 ]
Bryan Pendleton made changes - 17/Jun/07 07:42 PM
Attachment derby_2351_v2.diff [ 12359958 ]
Bryan Pendleton made changes - 12/Aug/07 10:25 PM
Resolution Fixed [ 1 ]
Fix Version/s 10.4.0.0 [ 12312540 ]
Status Open [ 1 ] Resolved [ 5 ]
Bryan Pendleton made changes - 13/Aug/07 02:39 PM
Fix Version/s 10.3.2.0 [ 12312670 ]
Affects Version/s 10.3.1.4 [ 12312590 ]
Affects Version/s 10.2.1.6 [ 11187 ]
Bryan Pendleton made changes - 14/Aug/07 02:19 PM
Fix Version/s 10.3.1.5 [ 12312671 ]
Bryan Pendleton made changes - 19/Feb/08 12:30 AM
Status Resolved [ 5 ] Reopened [ 4 ]
Resolution Fixed [ 1 ]
Dyre Tjeldvoll made changes - 29/Feb/08 09:12 PM
Fix Version/s 10.3.2.1 [ 12312876 ]
Fix Version/s 10.3.2.2 [ 12312885 ]
Bryan Pendleton made changes - 02/Mar/08 10:42 PM
Attachment d2351_aliasing.diff [ 12376944 ]
Bryan Pendleton made changes - 04/Mar/08 04:34 AM
Attachment d2351_aliasing.diff [ 12377030 ]
Bryan Pendleton made changes - 04/Mar/08 05:47 PM
Derby Info [Existing Application Impact]
Bryan Pendleton made changes - 06/Mar/08 04:29 AM
Attachment d2351_aliasing_checkQualifiedName.diff [ 12377226 ]
Dyre Tjeldvoll made changes - 06/Mar/08 03:14 PM
Link This issue relates to DERBY-3373 [ DERBY-3373 ]
Bryan Pendleton made changes - 07/Mar/08 04:39 PM
Link This issue relates to DERBY-2085 [ DERBY-2085 ]
Bryan Pendleton made changes - 08/Mar/08 08:45 PM
Attachment modifySynonymResults.diff [ 12377457 ]
Bryan Pendleton made changes - 16/Mar/08 03:51 AM
Resolution Fixed [ 1 ]
Fix Version/s 10.4.1.0 [ 12313072 ]
Fix Version/s 10.5.0.0 [ 12313010 ]
Status Reopened [ 4 ] Resolved [ 5 ]
Bryan Pendleton made changes - 20/Mar/08 05:20 AM
Attachment releaseNote.html [ 12378296 ]
Bryan Pendleton made changes - 20/Mar/08 02:42 PM
Attachment releaseNote.html [ 12378317 ]
Rick Hillegas made changes - 01/Apr/08 01:29 PM
Attachment releaseNote.html [ 12379028 ]
Dyre Tjeldvoll made changes - 02/Apr/08 08:29 AM
Derby Info [Existing Application Impact] [Existing Application Impact, Release Note Needed]
Myrna van Lunteren made changes - 04/May/09 06:22 PM
Fix Version/s 10.5.0.0 [ 12313010 ]
Fix Version/s 10.5.1.1 [ 12313771 ]
Dag H. Wanvik made changes - 30/Jun/09 04:12 PM
Issue & fix info [Release Note Needed, Existing Application Impact] [Release Note Needed]