db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r643644 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile: InsertNode.java NormalizeResultSetNode.java ResultColumnList.java UnionNode.java UpdateNode.java
Date Tue, 01 Apr 2008 23:31:07 GMT
Author: kmarsden
Date: Tue Apr  1 16:31:04 2008
New Revision: 643644

URL: http://svn.apache.org/viewvc?rev=643644&view=rev
Log:
DERBY-3494 Move the setup of NormalizeResultSetNode into the NormalizeResultSetNode

Removes ResultSetColumList.copyLengthsAndTypesToSource() and incorporate into the NormalizeResultSetNode
init method.


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NormalizeResultSetNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnionNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java?rev=643644&r1=643643&r2=643644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java Tue
Apr  1 16:31:04 2008
@@ -425,10 +425,9 @@
             
 			resultSet = 
 			(NormalizeResultSetNode) getNodeFactory().getNode(
-			C_NodeTypes.NORMALIZE_RESULT_SET_NODE,
-			resultSet, null, Boolean.FALSE,
+			C_NodeTypes.NORMALIZE_RESULT_SET_NODE, resultSet,
+			resultColumnList, null, Boolean.FALSE,
 			getContextManager());
-			resultColumnList.copyTypesAndLengthsToSource(resultSet.getResultColumns());
 		}
 
 		if (targetTableDescriptor != null)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NormalizeResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NormalizeResultSetNode.java?rev=643644&r1=643643&r2=643644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NormalizeResultSetNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NormalizeResultSetNode.java
Tue Apr  1 16:31:04 2008
@@ -87,6 +87,9 @@
 	 * (insert into t1 (smallintcol) values 1 union all values 2;
 	 *
 	 * @param childResult	The child ResultSetNode
+     * @param targetResultColumnList The target resultColumnList from 
+     *                          the InsertNode or UpdateNode. These will
+     *                          be the types used for the NormalizeResultSetNode.
 	 * @param tableProperties	Properties list associated with the table
 	 * @param forUpdate 	tells us if the normalize operation is being
 	 * performed on behalf of an update statement. 
@@ -95,6 +98,7 @@
 
 	public void init(
 							Object childResult,
+                            Object targetResultColumnList,
 							Object tableProperties,
 							Object forUpdate) throws StandardException
 	{
@@ -103,7 +107,8 @@
 
 		ResultSetNode rsn  = (ResultSetNode) childResult;
 		ResultColumnList rcl = rsn.getResultColumns();
-
+		ResultColumnList targetRCL = (ResultColumnList) targetResultColumnList;
+        
 		/* We get a shallow copy of the ResultColumnList and its 
 		 * ResultColumns.  (Copy maintains ResultColumn.expression for now.)
 		 * 
@@ -132,6 +137,14 @@
 		    }
         
         
+		if (targetResultColumnList != null) {
+		    int size = Math.min(targetRCL.size(), resultColumns.size());
+		    for (int index = 0; index < size; index++) {
+			ResultColumn sourceRC = (ResultColumn) resultColumns.elementAt(index);
+			ResultColumn resultColumn = (ResultColumn) targetRCL.elementAt(index);
+			sourceRC.setType(resultColumn.getTypeServices());
+		    }
+		}
 	}
 
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java?rev=643644&r1=643643&r2=643644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
Tue Apr  1 16:31:04 2008
@@ -1643,36 +1643,8 @@
 		}
 	}
 
-	/**
-	 * Copy the types and lengths for this RCL (the target)
-	 * to another RCL (the source).  
-	 * This is useful when adding a NormalizeResultSetNode.
-	 * It is called on the NormalizeResultSetNode to copy 
-	 * the types from the insert or update ResultColumnList (sourceRCL).
-	 * The type of the underlying expression should not be changed 
-	 * (DERBY-3310)
-	 * because that same expression is pointed to by the child result set's
-	 * result column list.  Only NormalizeResultSetNode should have a 
-	 * type that is different than its expresssion. See Army's write up
-	 * attached to DERBY-3310 for a detailed analysis of the role of 
-	 * copyTypesAndLengthsToSource.
-	 *
-	 * @param sourceRCL	The source RCL
-	 */
-	public void copyTypesAndLengthsToSource(ResultColumnList sourceRCL) throws StandardException
-	{
-		/* Source and target can have different lengths. */
-		int size = Math.min(size(), sourceRCL.size());
-		for (int index = 0; index < size; index++)
-		{
-			ResultColumn sourceRC = (ResultColumn) sourceRCL.elementAt(index);
-			ResultColumn resultColumn = (ResultColumn) elementAt(index);
-			sourceRC.setType(resultColumn.getTypeServices());
-		}
-	}
-		
-
-	/*
+    
+    /**
 	** Check whether the column lengths and types of the result columns
 	** match the expressions under those columns.  This is useful for
 	** INSERT and UPDATE statements.  For SELECT statements this method

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnionNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnionNode.java?rev=643644&r1=643643&r2=643644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnionNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnionNode.java Tue Apr
 1 16:31:04 2008
@@ -413,7 +413,7 @@
 			    treeTop = 
 				(NormalizeResultSetNode) getNodeFactory().getNode(
 				C_NodeTypes.NORMALIZE_RESULT_SET_NODE,
-				treeTop, null, Boolean.FALSE,
+				treeTop, null, null, Boolean.FALSE,
 				getContextManager());	
 			}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java?rev=643644&r1=643643&r2=643644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java Tue
Apr  1 16:31:04 2008
@@ -549,10 +549,10 @@
 		if (! resultColumnList.columnTypesAndLengthsMatch())
  		{
 			resultSet = (NormalizeResultSetNode) getNodeFactory().getNode(
-			    C_NodeTypes.NORMALIZE_RESULT_SET_NODE,
-			    resultSet, null, Boolean.TRUE,
+			    C_NodeTypes.NORMALIZE_RESULT_SET_NODE, 
+			    resultSet, resultColumnList, null, Boolean.TRUE,
 			    getContextManager());
-			resultColumnList.copyTypesAndLengthsToSource(resultSet.getResultColumns());
+			
 								
  			if (hasCheckConstraints(dataDictionary, targetTableDescriptor))
  			{



Mime
View raw message