db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1501816 - in /db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile: FromVTI.java ResultColumnList.java
Date Wed, 10 Jul 2013 16:03:29 GMT
Author: mamta
Date: Wed Jul 10 16:03:28 2013
New Revision: 1501816

URL: http://svn.apache.org/r1501816
Log:
DERBY-6040(Incorrect row order returned for an ORDER BY on a join of two table functions)

Hand backported(svn merge was running into conflicts) revision 1433031 from trunk to 10.9
without junit test since junit test is using feature not available in 10.9




Modified:
    db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java
    db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java

Modified: db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java?rev=1501816&r1=1501815&r2=1501816&view=diff
==============================================================================
--- db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java
(original)
+++ db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java
Wed Jul 10 16:03:28 2013
@@ -52,6 +52,8 @@ import org.apache.derby.iapi.sql.diction
 import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;
 import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
 import org.apache.derby.iapi.types.DataTypeDescriptor;
+import org.apache.derby.iapi.types.DataValueDescriptor;
+import org.apache.derby.catalog.DefaultInfo;
 
 import org.apache.derby.iapi.reference.ClassName;
 import org.apache.derby.iapi.reference.SQLState;
@@ -1925,10 +1927,27 @@ public class FromVTI extends FromTable i
         TypeDescriptor[] types = td.getRowTypes();
         for ( int i = 0; i < columnNames.length; i++ )
         {
-            resultColumns.addColumn( exposedName, columnNames[ i ],
-                    DataTypeDescriptor.getType(types[i]));
+            String          columnName = columnNames[ i ];
+            DataTypeDescriptor  dtd = DataTypeDescriptor.getType(types[i]);
+            ResultColumn    rc = resultColumns.addColumn
+                ( exposedName, columnName, dtd );
+
+            //
+            // Stuff a column descriptor into the ResultColumn. We do this so that
+            // getColumnPosition() will return the column position within the
+            // table function's shape. Later on, projection may remove columns
+            // from the ResultColumnList. We don't want getColumnPosition() to say
+            // that the column position is the index into the abbreviated ResultColumnList.
+            // See DERBY-6040.
+            //
+            ColumnDescriptor    coldesc = new ColumnDescriptor
+                (
+                 columnName, i+1, dtd,
+                 (DataValueDescriptor) null, (DefaultInfo) null, (UUID) null, (UUID) null,
+                 0L, 0L, 0L
+                 );
+            rc.setColumnDescriptor( null, coldesc );
         }
-
     }
 
     /**

Modified: db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java?rev=1501816&r1=1501815&r2=1501816&view=diff
==============================================================================
--- db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
(original)
+++ db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
Wed Jul 10 16:03:28 2013
@@ -3604,9 +3604,10 @@ public class ResultColumnList extends Qu
 
     /** 
      * Add a column to the list given a tablename, columnname, and datatype.
+     * Return the just-added column.
      *
      */
-    public void addColumn( TableName tableName, String columnName, DataTypeDescriptor dts
)
+    public ResultColumn addColumn( TableName tableName, String columnName, DataTypeDescriptor
dts )
         throws StandardException
     {
         ValueNode bcn = (ValueNode) getNodeFactory().getNode(
@@ -3622,6 +3623,8 @@ public class ResultColumnList extends Qu
                                                                   getContextManager());
         rc.setType(dts);
         addResultColumn(rc);
+
+        return rc;
     }
     
 	/**



Mime
View raw message