You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2011/05/26 14:25:35 UTC

svn commit: r1127886 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/types/SQLBinary.java iapi/types/SQLChar.java iapi/types/SQLLongvarchar.java impl/sql/compile/BinaryOperatorNode.java impl/sql/compile/ConcatenationOperatorNode.java

Author: kahatlen
Date: Thu May 26 12:25:35 2011
New Revision: 1127886

URL: http://svn.apache.org/viewvc?rev=1127886&view=rev
Log:
DERBY-5246: Simplify bytecode generation for concatenation operator

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLLongvarchar.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java?rev=1127886&r1=1127885&r2=1127886&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java Thu May 26 12:25:35 2011
@@ -983,6 +983,11 @@ abstract class SQLBinary
 				BitDataValue result)
 		throws StandardException
 	{
+        if (result == null)
+        {
+            result = (BitDataValue) getNewNull();
+        }
+
 		if (left.isNull() || right.isNull())
 		{
 			result.setToNull();

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java?rev=1127886&r1=1127885&r2=1127886&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java Thu May 26 12:25:35 2011
@@ -2099,6 +2099,11 @@ readingLoop:
                 StringDataValue result)
         throws StandardException
     {
+        if (result == null)
+        {
+            result = (StringDataValue) getNewNull();
+        }
+
         if (leftOperand.isNull() || leftOperand.getString() == null ||
             rightOperand.isNull() || rightOperand.getString() == null)
         {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLLongvarchar.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLLongvarchar.java?rev=1127886&r1=1127885&r2=1127886&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLLongvarchar.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLLongvarchar.java Thu May 26 12:25:35 2011
@@ -145,7 +145,7 @@ public class SQLLongvarchar
 				StringDataValue result)
 		throws StandardException
 	{
-		super.concatenate(leftOperand, rightOperand, result);
+		result = super.concatenate(leftOperand, rightOperand, result);
 
 		//bug 5600 - according to db2 concatenation documentation, for compatibility with previous versions, there is no automatic
 		//escalation of results involving LONG data types to LOB data types. For eg, concatenation of a CHAR(200) value and a

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java?rev=1127886&r1=1127885&r2=1127886&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java Thu May 26 12:25:35 2011
@@ -600,9 +600,6 @@ public class BinaryOperatorNode extends 
 			** Call the method for this operator.
 			*/
 			mb.getField(resultField); // third arg
-			//following method is special code for concatenation where if field is null, we want it to be initialized to NULL SQLxxx type object
-			//before generating code "field = method(p1, p2, field);"
-			initializeResultField(acb, mb, resultField);
 
             // Adjust number of arguments for the result field
             numArgs++;
@@ -651,13 +648,6 @@ public class BinaryOperatorNode extends 
 		}
 	}
 
-	//following method is no-op here but in concatenation node, this method is used to check if resultField is null,
-	//and if yes, then we want it to be initialized to NULL SQLxxx type object
-	protected void initializeResultField(ExpressionClassBuilder acb, MethodBuilder mb, LocalField resultField)
-	throws StandardException
-	{
-	}
-
 	/**
 	 * Set the leftOperand to the specified ValueNode
 	 *

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java?rev=1127886&r1=1127885&r2=1127886&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java Thu May 26 12:25:35 2011
@@ -33,10 +33,6 @@ import org.apache.derby.iapi.sql.compile
 import org.apache.derby.iapi.types.StringDataValue;
 import org.apache.derby.iapi.types.DataTypeDescriptor;
 
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-import org.apache.derby.iapi.services.compiler.LocalField;
-import org.apache.derby.impl.sql.compile.ExpressionClassBuilder;
-
 import org.apache.derby.iapi.reference.Limits;
 import org.apache.derby.iapi.reference.SQLState;
 import org.apache.derby.iapi.reference.ClassName;
@@ -538,24 +534,6 @@ public class ConcatenationOperatorNode e
 		return returnDTD;
 	}
 
-	/*
-	 * for conatenation operator, we generate code as follows field = method(p1,
-	 * p2, field); what we are ensuring here is if field is null then initialize
-	 * it to NULL SQLxxx type. Because of the following, at execution time,
-	 * SQLxxx concatenate method do not have to worry about field coming in as
-	 * null
-	 */
-	protected void initializeResultField(ExpressionClassBuilder acb,
-			MethodBuilder mb, LocalField resultField) throws StandardException {
-		mb.conditionalIfNull();//get the field on the stack and if it is null
-		acb.generateNull(mb, getTypeCompiler(), getTypeServices()
-				.getCollationType());// yes, it is, hence create a NULL SQLxxx
-									 // type object and put that on stack
-		mb.startElseCode(); //no, it is not null
-		mb.getField(resultField); //so put it back on the stack
-		mb.completeConditional(); //complete if else block
-	}
-
 	private static int clobBlobHandling(DataTypeDescriptor clobBlobType,
 			DataTypeDescriptor otherType) throws StandardException {
 		int resultLength;