db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1502329 - in /db/derby/code/branches/10.8: ./ java/engine/org/apache/derby/impl/sql/compile/FromVTI.java java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
Date Thu, 11 Jul 2013 19:14:36 GMT
Author: mamta
Date: Thu Jul 11 19:14:35 2013
New Revision: 1502329

URL: http://svn.apache.org/r1502329
Log:

DERBY-6040(Incorrect row order returned for an ORDER BY on a join of two table functions)

Backporting to 10.8 from 10.9. Original fix contributed by Rick


Modified:
    db/derby/code/branches/10.8/   (props changed)
    db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java
    db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java

Propchange: db/derby/code/branches/10.8/
------------------------------------------------------------------------------
  Merged /db/derby/code/branches/10.9:r1501816

Modified: db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java?rev=1502329&r1=1502328&r2=1502329&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java
(original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java
Thu Jul 11 19:14:35 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.8/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java?rev=1502329&r1=1502328&r2=1502329&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
(original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
Thu Jul 11 19:14:35 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