db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r546478 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile: AggregateDefinition.java AggregateNode.java CountAggregateDefinition.java MaxMinAggregateDefinition.java SumAvgAggregateDefinition.java
Date Tue, 12 Jun 2007 13:30:41 GMT
Author: djd
Date: Tue Jun 12 06:30:39 2007
New Revision: 546478

URL: http://svn.apache.org/viewvc?view=rev&rev=546478
Log:
DERBY-2775 (partial) Change AggregateDefinition to use a DataTypeDescritor as the
declared type instead of a TypeDescriptor. Code using the api assumed the object
was a DTD anyway.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateDefinition.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CountAggregateDefinition.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MaxMinAggregateDefinition.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SumAvgAggregateDefinition.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateDefinition.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateDefinition.java?view=diff&rev=546478&r1=546477&r2=546478
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateDefinition.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateDefinition.java
Tue Jun 12 06:30:39 2007
@@ -21,10 +21,10 @@
 
 package	org.apache.derby.impl.sql.compile;
 
-import java.lang.StringBuffer;
-import org.apache.derby.catalog.TypeDescriptor;
 import java.sql.SQLException;
 
+import org.apache.derby.iapi.types.DataTypeDescriptor;
+
 /**
  * An AggregateDefinition defines an aggregate.
  * 
@@ -80,9 +80,7 @@
 	 *
 	 * @see org.apache.derby.catalog.TypeDescriptor
 	 *
-	 * @exception SQLException Thrown on error.
 	 */
-	public	TypeDescriptor getAggregator(TypeDescriptor inputType,
-							StringBuffer aggregatorClassName)
-							throws SQLException;
+	public	DataTypeDescriptor getAggregator(DataTypeDescriptor inputType,
+							StringBuffer aggregatorClassName);
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java?view=diff&rev=546478&r1=546477&r2=546478
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java Tue
Jun 12 06:30:39 2007
@@ -276,14 +276,7 @@
 					Vector				aggregateVector)
 			throws StandardException
 	{
-		TypeId	outType;
-		TypeId	inputType = null;
-		Class				inputClass = null;
-		String				inputTypeName = null;
-		Class				inputInterfaceClass = null;
-		String				inputInterfaceName = null;
 		DataTypeDescriptor 	dts = null;
-		TypeDescriptor 		resultType = null;
 		ClassFactory		cf;
 
 		cf = getClassFactory();
@@ -298,6 +291,7 @@
 				fromList, subqueryList,
 				aggregateVector);
 
+        // operand being null means a count(*)
 		if (operand != null)
 		{
 			/*
@@ -359,22 +353,10 @@
 
 		/*
 		** Ask the aggregate definition whether it can handle
-	 	** the input datatype.  If an exception is thrown,
-		** barf.
+	 	** the input datatype.
 	 	*/
-		try
-		{
-			aggregatorClassName = new StringBuffer();
-			resultType = uad.getAggregator(dts, aggregatorClassName);
-		} catch (Exception e)
-		{
-			//RESOLVE: would be a good idea to add some additional text to
-			// this error, like during getResultDataType on aggregate x
-			// maybe enhance this error everywhere (seems like execution
-			// should also add some text, at the very least saying during
-			// execution.  see Compiltion/Generator/UserExpressionBuilder.java
-			throw StandardException.unexpectedUserException(e);
-		}
+        aggregatorClassName = new StringBuffer();
+        DataTypeDescriptor resultType = uad.getAggregator(dts, aggregatorClassName);
 
 		if (resultType == null)
 		{
@@ -385,35 +367,7 @@
 
 		checkAggregatorClassName(aggregatorClassName.toString());
 
-		/*
-		** Try for a built in type matching the
-		** type name.  
-		*/
-		TypeId compTypeId = TypeId.getBuiltInTypeId(resultType.getTypeName());
-		/*
-		** If not built in, it is probably a java type.
-		** Get the sql type descriptor for that.  
-		*/
-		if (compTypeId == null)
-		{
-			compTypeId = TypeId.getSQLTypeForJavaType(resultType.getTypeName());
-		}
-
-		/*
-		** Now set the type.  Get a new descriptor
-		** in case the user returned the same descriptor
-		** as was passed in.
-		*/
-		setType(new DataTypeDescriptor(
-							compTypeId,
-							resultType.getPrecision(),
-							resultType.getScale(),
-							resultType.isNullable(),
-							resultType.getMaximumWidth(),
-							resultType.getCollationType(),
-							resultType.getCollationDerivation()
-						)
-				);
+		setType(resultType);
 
 		return this;
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CountAggregateDefinition.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CountAggregateDefinition.java?view=diff&rev=546478&r1=546477&r2=546478
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CountAggregateDefinition.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CountAggregateDefinition.java
Tue Jun 12 06:30:39 2007
@@ -54,7 +54,7 @@
 	 * @return the output Class (null if cannot operate on
 	 *	value expression of this type.
 	 */
-	public final TypeDescriptor	getAggregator(TypeDescriptor inputType,
+	public final DataTypeDescriptor	getAggregator(DataTypeDescriptor inputType,
 				StringBuffer aggregatorClass) 
 	{
 		aggregatorClass.append( ClassName.CountAggregator);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MaxMinAggregateDefinition.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MaxMinAggregateDefinition.java?view=diff&rev=546478&r1=546477&r2=546478
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MaxMinAggregateDefinition.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MaxMinAggregateDefinition.java
Tue Jun 12 06:30:39 2007
@@ -64,7 +64,7 @@
 	 * @return the output Class (null if cannot operate on
 	 *	value expression of this type.
 	 */
-	public final TypeDescriptor	getAggregator(TypeDescriptor inputType, 
+	public final DataTypeDescriptor	getAggregator(DataTypeDescriptor inputType, 
 				StringBuffer aggregatorClass) 
 	{
 		LanguageConnectionContext lcc = (LanguageConnectionContext)
@@ -73,7 +73,7 @@
 			/*
 			** MIN and MAX may return null
 			*/
-		DataTypeDescriptor dts = new DataTypeDescriptor((DataTypeDescriptor) inputType, true);
+		DataTypeDescriptor dts = inputType.getNullabilityType(true);
 		TypeId compType = dts.getTypeId();
 
 		/*

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SumAvgAggregateDefinition.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SumAvgAggregateDefinition.java?view=diff&rev=546478&r1=546477&r2=546478
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SumAvgAggregateDefinition.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SumAvgAggregateDefinition.java
Tue Jun 12 06:30:39 2007
@@ -68,16 +68,12 @@
 	 * @return the output Class (null if cannot operate on
 	 *	value expression of this type.
 	 */
-	public final TypeDescriptor	getAggregator(TypeDescriptor inputType, 
+	public final DataTypeDescriptor	getAggregator(DataTypeDescriptor inputType, 
 				StringBuffer aggregatorClass) 
 	{
 		try
 		{
-			LanguageConnectionContext lcc = (LanguageConnectionContext)
-				ContextService.getContext(LanguageConnectionContext.CONTEXT_ID);
-
-			DataTypeDescriptor dts = new DataTypeDescriptor( (DataTypeDescriptor)inputType, inputType.isNullable());
-			TypeId compType = dts.getTypeId();
+			TypeId compType = inputType.getTypeId();
 		
 			CompilerContext cc = (CompilerContext)
 				ContextService.getContext(CompilerContext.CONTEXT_ID);
@@ -94,12 +90,11 @@
 				aggregatorClass.append(getAggregatorClassName());
 
 				DataTypeDescriptor outDts = tc.resolveArithmeticOperation( 
-															dts, dts, getOperator());
+                        inputType, inputType, getOperator());
 				/*
 				** SUM and AVG may return null
 				*/
-				outDts.setNullability(true);
-				return outDts;
+				return outDts.getNullabilityType(true);
 			}
 		}
 		catch (StandardException e)



Mime
View raw message