db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r649007 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/services/io/ iapi/sql/execute/ impl/sql/compile/ impl/sql/execute/
Date Thu, 17 Apr 2008 08:47:45 GMT
Author: kahatlen
Date: Thu Apr 17 01:47:41 2008
New Revision: 649007

URL: http://svn.apache.org/viewvc?rev=649007&view=rev
Log:
DERBY-3616: TableFunctionTest fails under Ubuntu 7.10

Removed all encoding/decoding of the table function's return type and
instead stored it directly as a saved object in the compiled plan.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatIdUtil.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ResultSetFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericResultSetFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatIdUtil.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatIdUtil.java?rev=649007&r1=649006&r2=649007&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatIdUtil.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatIdUtil.java Thu
Apr 17 01:47:41 2008
@@ -48,10 +48,6 @@
  */
 public final class FormatIdUtil
 {
-	private	static	final	int		BYTE_MASK = 0xFF;
-	private	static	final	int		NIBBLE_MASK = 0xF;
-	private	static	final	int		NIBBLE_SHIFT = 4;
-	private	static	final	int		HEX_RADIX = 16;
 
 	private FormatIdUtil() {
 	}
@@ -82,60 +78,4 @@
 		return Integer.toString(fmtId);
 	}
 
-	/**
-	 * <p>
-	 * Encode a byte array as a string.
-	 * </p>
-	 */
-	public	static	String	toString( byte[] written, int count )
-	{
-		char[]	chars = new char[ count * 2 ];
-		int		charIdx = 0;
-
-		for ( int i = 0; i < count; i++ )
-		{
-			int		current = written[ i ] & BYTE_MASK;
-			int		lowNibble = current & NIBBLE_MASK;
-			int		highNibble = current >>> NIBBLE_SHIFT;
-
-			chars[ charIdx++ ] = encodeNibble( lowNibble );
-			chars[ charIdx++ ] = encodeNibble( highNibble );
-		}
-
-		return new String( chars );
-	}
-
-	/**
-	 * <p>
-	 * Decode a byte array which had been encoded as a string.
-	 * </p>
-	 */
-	public	static	byte[]	fromString( String objString )
-	{
-		char[]	chars = objString.toCharArray();
-		int		count = chars.length;
-		byte[]	bytes = new byte[ count / 2 ];
-		int		byteIdx = 0;
-
-		for ( int i = 0; i < count; i = i + 2 )
-		{
-			int lowNibble = decodeNibble( chars[ i ] );
-			int highNibble = decodeNibble( chars[ i + 1 ] );
-
-			bytes[ byteIdx++ ] = (byte) ( ( highNibble << NIBBLE_SHIFT ) | lowNibble );
-		}
-
-		return bytes;
-	}
-
-	private	static	char	encodeNibble( int nibble )
-	{
-		return Character.forDigit( nibble, HEX_RADIX );
-	}
-
-	private	static	int		decodeNibble( char c )
-	{
-		return Character.digit( c, HEX_RADIX );
-	}
-    
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ResultSetFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ResultSetFactory.java?rev=649007&r1=649006&r2=649007&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ResultSetFactory.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ResultSetFactory.java
Thu Apr 17 01:47:41 2008
@@ -643,7 +643,8 @@
 											optimizer
 		@param optimizerEstimatedCost		Estimated total cost by optimizer
 		@param isDerbyStyleTableFunction    True if this is a Derby-style table function
-		@param returnType The name of the return type (a multi-set) as a string
+		@param returnTypeNumber	Which saved object contains the return type
+								(a multi-set) serialized as a byte array
 		@return the row as a result set.
 		@exception StandardException thrown when unable to create the
 			result set
@@ -661,7 +662,7 @@
 									 double optimizerEstimatedRowCount,
 									 double optimizerEstimatedCost,
                                      boolean isDerbyStyleTableFunction,
-                                     String returnType
+                                     int returnTypeNumber
                                           )
 		 throws StandardException;
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java?rev=649007&r1=649006&r2=649007&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java Thu Apr
17 01:47:41 2008
@@ -21,9 +21,6 @@
 
 package	org.apache.derby.impl.sql.compile;
 
-import org.apache.derby.iapi.services.io.DynamicByteArrayOutputStream;
-import org.apache.derby.iapi.services.io.FormatIdOutputStream;
-import org.apache.derby.iapi.services.io.FormatIdUtil;
 import org.apache.derby.iapi.services.loader.ClassInspector;
 import org.apache.derby.iapi.services.loader.GeneratedMethod;
 
@@ -1327,15 +1324,12 @@
 		mb.push(isDerbyStyleTableFunction);
 
 		// Push the return type
+        int rtNum = -1;
         if ( isDerbyStyleTableFunction )
         {
-            String  returnType = freezeReturnType( methodCall.getRoutineInfo().getReturnType()
);
-            mb.push( returnType );
-        }
-        else
-        {
-			mb.pushNull( String.class.getName());
+            rtNum = acb.addItem(methodCall.getRoutineInfo().getReturnType());
         }
+        mb.push(rtNum);
 
 		return 16;
 	}
@@ -1688,32 +1682,4 @@
             throw StandardException.unexpectedUserException( t );
         }
     }
-
-    /**
-     * Serialize a row multi set as a string.
-     */
-    private String  freezeReturnType( TypeDescriptor td )
-        throws StandardException
-    {
-        try {
-            DynamicByteArrayOutputStream    dbaos = new DynamicByteArrayOutputStream();
-            FormatIdOutputStream                fios = new FormatIdOutputStream( dbaos );
-
-            fios.writeObject( td );
-            dbaos.flush();
-
-            byte[]      rawResult = dbaos.getByteArray();
-            int         count = dbaos.getUsed();
-
-            String  retval = FormatIdUtil.toString( rawResult, count );
-
-            return retval;
-            
-        } catch (Throwable t)
-        {
-            throw StandardException.unexpectedUserException( t );
-        }
-    }
-
-   
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericResultSetFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericResultSetFactory.java?rev=649007&r1=649006&r2=649007&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericResultSetFactory.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericResultSetFactory.java
Thu Apr 17 01:47:41 2008
@@ -446,7 +446,7 @@
 									 double optimizerEstimatedRowCount,
 									 double optimizerEstimatedCost,
                                      boolean isDerbyStyleTableFunction,
-                                     String returnType
+                                     int returnTypeNumber
                                           )
 		throws StandardException
 	{
@@ -462,7 +462,7 @@
 							    optimizerEstimatedRowCount,
 								optimizerEstimatedCost,
 								isDerbyStyleTableFunction,
-                                returnType
+                                returnTypeNumber
                                 );
 	}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java?rev=649007&r1=649006&r2=649007&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java Thu
Apr 17 01:47:41 2008
@@ -48,8 +48,6 @@
 
 import org.apache.derby.iapi.error.StandardException;
 
-import org.apache.derby.iapi.services.io.FormatIdInputStream;
-import org.apache.derby.iapi.services.io.FormatIdUtil;
 import org.apache.derby.iapi.services.loader.GeneratedMethod;
 
 import org.apache.derby.iapi.types.RowLocation;
@@ -62,7 +60,6 @@
 import org.apache.derby.vti.IFastPath;
 import org.apache.derby.vti.VTIEnvironment;
 
-import java.io.ByteArrayInputStream;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -101,7 +98,7 @@
 
 	private boolean isDerbyStyleTableFunction;
 
-    private String  returnType;
+    private final TypeDescriptor returnType;
 
     private DataTypeDescriptor[]    returnColumnTypes;
 
@@ -126,7 +123,7 @@
 			     double optimizerEstimatedRowCount,
 				 double optimizerEstimatedCost,
 				 boolean isDerbyStyleTableFunction,
-                 String returnType
+                 int returnTypeNumber
                  ) 
 		throws StandardException
 	{
@@ -141,7 +138,10 @@
 		this.pushedQualifiers = pushedQualifiers;
 		this.scanIsolationLevel = scanIsolationLevel;
 		this.isDerbyStyleTableFunction = isDerbyStyleTableFunction;
-        this.returnType = returnType;
+
+        this.returnType = returnTypeNumber == -1 ? null :
+            (TypeDescriptor)
+            activation.getPreparedStatement().getSavedObject(returnTypeNumber);
 
 		if (erdNumber != -1)
 		{
@@ -668,8 +668,7 @@
     {
         if ( returnColumnTypes == null )
         {
-            TypeDescriptor      td = thawReturnType( returnType );
-            TypeDescriptor[]    columnTypes = td.getRowTypes();
+            TypeDescriptor[] columnTypes = returnType.getRowTypes();
             int                         count = columnTypes.length;
 
             returnColumnTypes = new DataTypeDescriptor[ count ];
@@ -682,28 +681,6 @@
         return returnColumnTypes;
     }
 
-    /**
-     * <p>
-     * Deserialize a type descriptor from a string.
-     * </p>
-     */
-    private TypeDescriptor  thawReturnType( String ice )
-        throws StandardException
-    {
-        try {
-            byte[]                                          bytes = FormatIdUtil.fromString(
ice );
-            ByteArrayInputStream                    bais = new ByteArrayInputStream( bytes
);
-            FormatIdInputStream                     fiis = new FormatIdInputStream( bais
);
-            TypeDescriptor                              td = (TypeDescriptor) fiis.readObject();
-
-            return td;
-            
-        } catch (Throwable t)
-        {
-            throw StandardException.unexpectedUserException( t );
-        }
-    }
-    
     /**
      * <p>
      * Cast the value coming out of the user-coded ResultSet. The



Mime
View raw message