You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ba...@apache.org on 2005/07/23 02:40:45 UTC

svn commit: r224427 - in /incubator/derby/code/trunk/java: engine/org/apache/derby/impl/sql/execute/SortResultSet.java testing/org/apache/derbyTesting/functionTests/master/distinct.out testing/org/apache/derbyTesting/functionTests/tests/lang/distinct.sql

Author: bandaram
Date: Fri Jul 22 17:40:38 2005
New Revision: 224427

URL: http://svn.apache.org/viewcvs?rev=224427&view=rev
Log:
DERBY-466: Reset nextCalled in SortResultSet.openCore() to handle the case of eliminating duplicates without a sorter for a distinct operator.

Submitted by Manish Khettry (manish_khettry@yahoo.com)

Modified:
    incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/SortResultSet.java
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/distinct.out
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/distinct.sql

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/SortResultSet.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/SortResultSet.java?rev=224427&r1=224426&r2=224427&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/SortResultSet.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/SortResultSet.java Fri Jul 22 17:40:38 2005
@@ -230,6 +230,7 @@
      */
 	public void	openCore() throws StandardException 
 	{
+		nextCalled = false;
 		beginTime = getCurrentTimeMillis();
 		// REVISIT: through the direct DB API, this needs to be an
 		// error, not an ASSERT; users can open twice. Only through JDBC

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/distinct.out
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/distinct.out?rev=224427&r1=224426&r2=224427&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/distinct.out (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/distinct.out Fri Jul 22 17:40:38 2005
@@ -2477,6 +2477,31 @@
 -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 name1                                                                                                                           |sum2                                                                                                                            
 ij> rollback;
+ij> create table td (x int);
+0 rows inserted/updated/deleted
+ij> insert into td values (1);
+1 row inserted/updated/deleted
+ij> insert into td values (1);
+1 row inserted/updated/deleted
+ij> insert into td values (2);
+1 row inserted/updated/deleted
+ij> -- distinct in subquery where the store does not perform the sort.
+select * from td, (select distinct 1 from td) as sub(x);
+X          |X          
+-----------------------
+1          |1          
+1          |1          
+2          |1          
+ij> -- get the storage system to do the sort.
+select * from td, (select distinct x from td) as sub(x);
+X          |X          
+-----------------------
+1          |2          
+1          |1          
+1          |2          
+1          |1          
+2          |2          
+2          |1          
 ij> -- reset autocomiit
 autocommit on;
 ij> 

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/distinct.sql
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/distinct.sql?rev=224427&r1=224426&r2=224427&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/distinct.sql (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/distinct.sql Fri Jul 22 17:40:38 2005
@@ -329,5 +329,16 @@
 execute c1 using 'values(''lusername1'', ''lusername2'', ''lname1'')';
 rollback;
 
+create table td (x int);
+insert into td values (1);
+insert into td values (1);
+insert into td values (2);
+
+-- distinct in subquery where the store does not perform the sort.
+select * from td, (select distinct 1 from td) as sub(x);
+
+-- get the storage system to do the sort.
+select * from td, (select distinct x from td) as sub(x);
+
 -- reset autocomiit
 autocommit on;