db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r554012 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile: CreateTableNode.java FromTable.java GroupByNode.java ResultColumn.java SetOperatorNode.java VirtualColumnNode.java
Date Fri, 06 Jul 2007 19:40:08 GMT
Author: djd
Date: Fri Jul  6 12:40:07 2007
New Revision: 554012

URL: http://svn.apache.org/viewvc?view=rev&rev=554012
Log:
DERBY-2775 (partial) Clarify some type handling for ResultColumn and its expression by making
callers explictly get the expression's type from the expression, rather than having
a method in ResultColumn that doesn't do what it indicates it did.
Make VirtualColumnNode's type just refect its source node.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromTable.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java?view=diff&rev=554012&r1=554011&r2=554012
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java
Fri Jul  6 12:40:07 2007
@@ -310,7 +310,7 @@
 							SQLState.LANG_TABLE_REQUIRES_COLUMN_NAMES);
 				}
 
-				DataTypeDescriptor dtd = rc.getExpressionType();
+				DataTypeDescriptor dtd = rc.getExpression().getTypeServices();
 				if ((dtd != null) && !dtd.isUserCreatableType())
 				{
 					throw StandardException.newException(

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromTable.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromTable.java?view=diff&rev=554012&r1=554011&r2=554012
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromTable.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromTable.java Fri Jul
 6 12:40:07 2007
@@ -824,7 +824,7 @@
                 if (refCols.isSet(i))
                 {
                     ResultColumn rc = (ResultColumn) resultColumns.elementAt(i);
-                    DataTypeDescriptor expressionType = rc.getExpressionType();
+                    DataTypeDescriptor expressionType = rc.getExpression().getTypeServices();
                     if( expressionType != null)
                         perRowUsage += expressionType.estimatedMemoryUsage();
                 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java?view=diff&rev=554012&r1=554011&r2=554012
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java Fri
Jul  6 12:40:07 2007
@@ -625,7 +625,7 @@
 					null,
 					getContextManager());
 			newColumnRef.setSource(newRC);
-			newColumnRef.setType(newRC.getExpressionType());
+			newColumnRef.setType(newRC.getExpression().getTypeServices());
 			newColumnRef.setNestingLevel(this.getLevel());
 			newColumnRef.setSourceLevel(this.getLevel());
 			tmpRC = (ResultColumn) getNodeFactory().getNode(
@@ -1087,7 +1087,7 @@
 											null,
 											getContextManager());
 		tmpColumnRef.setSource(targetRC);
-		tmpColumnRef.setType(targetRC.getExpressionType());
+		tmpColumnRef.setType(targetRC.getExpression().getTypeServices());
 		tmpColumnRef.setNestingLevel(this.getLevel());
 		tmpColumnRef.setSourceLevel(this.getLevel());
 		newRC = (ResultColumn) getNodeFactory().getNode(

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java?view=diff&rev=554012&r1=554011&r2=554012
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java Fri
Jul  6 12:40:07 2007
@@ -71,6 +71,10 @@
  * statements, the result column represents an column in a stored table.
  * So, a ResultColumn has to be bound differently depending on the type of
  * statement it appears in.
+ * 
+ * The type of the ResultColumn can differ from its underlying expression,
+ * for example in certain joins the ResultColumn can be nullable even if
+ * its underlying column is not.
  *
  */
 
@@ -294,13 +298,6 @@
 		return dataTypeServices;
 	}
 
-	public DataTypeDescriptor getExpressionType() throws StandardException
-	{
-		return (expression == null) ?
-			dataTypeServices :
-			expression.getTypeServices();
-	}
-
 	public int getColumnPosition()
 	{
 		if (columnDescriptor!=null)
@@ -864,12 +861,11 @@
 	public void checkStorableExpression()
 					throws StandardException
 	{
-		TypeId columnTypeId = getTypeId();
-		TypeId toStoreTypeId = getExpressionType().getTypeId();
+		TypeId toStoreTypeId = getExpression().getTypeId();
 
 		if (! getTypeCompiler().storable(toStoreTypeId, getClassFactory()))
 			throw StandardException.newException(SQLState.LANG_NOT_STORABLE, 
-				columnTypeId.getSQLTypeName(),
+                getTypeId().getSQLTypeName(),
 				toStoreTypeId.getSQLTypeName() );
 	}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java?view=diff&rev=554012&r1=554011&r2=554012
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java
Fri Jul  6 12:40:07 2007
@@ -688,7 +688,7 @@
 					(ResultColumn) rrsn.getResultColumns().elementAt(i);
 				if ( ! (rc.getExpression().requiresTypeFromContext()))
 				{
-					types[i] = rc.getExpressionType();
+					types[i] = rc.getExpression().getTypeServices();
 					numTypes++;
 				}
 			}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java?view=diff&rev=554012&r1=554011&r2=554012
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java
Fri Jul  6 12:40:07 2007
@@ -54,7 +54,7 @@
 	 */
 	int columnId;
 
-	boolean correlated = false;
+	private boolean correlated = false;
 
 
 	/**
@@ -275,15 +275,13 @@
 	 */
 	public DataTypeDescriptor getTypeServices() throws StandardException
 	{
-        DataTypeDescriptor dtd = super.getTypeServices();
-        if( dtd == null && sourceColumn != null)
-        {
-            dtd = sourceColumn.getTypeServices();
-            if( dtd != null)
-                setType( dtd);
-        }
-        return dtd;
-    } // end of getTypeServices
+        return sourceColumn.getTypeServices();
+    }
+    
+    public void setType(DataTypeDescriptor dtd) throws StandardException
+    {
+        sourceColumn.setType(dtd);
+    }
     
     protected boolean isEquivalent(ValueNode o) throws StandardException
     {



Mime
View raw message