db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r534985 - in /db/derby/code/trunk/java: drda/org/apache/derby/impl/drda/DRDAConnThread.java drda/org/apache/derby/impl/drda/DRDAStatement.java testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMappingTest.java
Date Thu, 03 May 2007 20:39:19 GMT
Author: kmarsden
Date: Thu May  3 13:39:18 2007
New Revision: 534985

URL: http://svn.apache.org/viewvc?view=rev&rev=534985
Log:
DERBY-2381 ParameterMappingTest fails due to ArrayIndexOutOfBoundsException executing a procedure

Formerly, the server would rely on the input parameter type information received from the
client to determine the output parameter type. This patch changes the server to look at the
parameter metadata to determine the drda type to send.
It also enables the test ParameterMappingTest for client. 


Modified:
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMappingTest.java

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java?view=diff&rev=534985&r1=534984&r2=534985
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java Thu May 
3 13:39:18 2007
@@ -6299,9 +6299,8 @@
 												 (pmeta.isNullable(i) == JDBC30Translation.PARAMETER_NULLABLE));
 			int colType = (hasRs ? rsmeta.getColumnType(i) : pmeta.getParameterType(i));
 			int[] outlen = {-1};
-			int drdaType =
-				(hasRs ?FdocaConstants.mapJdbcTypeToDrdaType(colType,nullable,outlen): 
-				 stmt.getParamDRDAType(i));
+			int drdaType = FdocaConstants.mapJdbcTypeToDrdaType(colType,nullable,outlen);
+				
 
 			boolean isDecimal = ((drdaType | 1) == DRDAConstants.DRDA_TYPE_NDECIMAL);
 			int precision = 0, scale = 0;
@@ -6317,9 +6316,12 @@
 			else if (isDecimal)
 			{
 				if (stmt.isOutputParam(i))
-					((CallableStatement) stmt.ps).registerOutParameter(i,Types.DECIMAL);
-				precision = pmeta.getPrecision(i);
-				scale = pmeta.getScale(i);
+				{
+					precision = pmeta.getPrecision(i);
+					scale = pmeta.getScale(i);
+					((CallableStatement) stmt.ps).registerOutParameter(i,Types.DECIMAL,scale);
+				  
+				}
 
 			}
 
@@ -6715,12 +6717,17 @@
 				}
 				else
 				{
+                                    
 					drdaType =   stmt.getParamDRDAType(i) & 0xff;
 					precision = stmt.getParamPrecision(i);
 					scale = stmt.getParamScale(i);
-					ndrdaType = drdaType | 1;
 					
 					if (stmt.isOutputParam(i)) {
+						int[] outlen = new int[1];
+						drdaType = FdocaConstants.mapJdbcTypeToDrdaType(stmt.getOutputParamType(i),true,outlen);
+						precision = stmt.getOutputParamPrecision(i);
+						scale = stmt.getOutputParamScale(i);
+                                                
 						if (SanityManager.DEBUG)
 							trace("***getting Object "+i);
 						val = ((CallableStatement) stmt.ps).getObject(i);

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java?view=diff&rev=534985&r1=534984&r2=534985
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java Thu May  3
13:39:18 2007
@@ -88,6 +88,9 @@
 	protected String procName;			// callable statement's method name
 	private   int[] outputTypes;		// jdbc type for output parameter or NOT_OUTPUT_PARAM
 	                                    // if not an output parameter.
+	private int[] outputPrecision;
+	private int[] outputScale;
+        
 	protected static int NOT_OUTPUT_PARAM = -100000;
 	protected boolean outputExpected;	// expect output from a callable statement
 	private Statement stmt;				// SQL statement
@@ -1080,6 +1083,8 @@
 		rslsetflg = null;
 		procName = null;
 		outputTypes = null;
+		outputPrecision = null;
+		outputScale = null;
 		// Clear parameters and release excess storage
 		drdaParamState_.clear(true);
 	}
@@ -1444,6 +1449,8 @@
 			
 			int parameterMode = pmeta.getParameterMode(i + 1);
 			int parameterType = pmeta.getParameterType(i + 1);
+                        int parameterPrecision = pmeta.getPrecision(i + 1);
+                        int parameterScale = pmeta.getScale(i + 1);
 
 			switch (parameterMode) {
 				case JDBC30Translation.PARAMETER_MODE_IN:
@@ -1466,12 +1473,19 @@
 				if (outputTypes == null) //not initialized yet, since previously none output
 				{
 					outputTypes = new int[numElems];
-					for (int j = 0; j < numElems; j++)
+					outputPrecision = new int [numElems];
+					outputScale = new int [numElems];
+					for (int j = 0; j < numElems; j++) {
 						outputTypes[j] = NOT_OUTPUT_PARAM;  //default init value
+						outputPrecision[j] = NOT_OUTPUT_PARAM;
+						outputScale[j] = NOT_OUTPUT_PARAM;
+					}
 				}
 				// save the output type so we can register when we parse
 				// the SQLDTA
 				outputTypes[i] = parameterType;
+				outputPrecision[i] = parameterPrecision;
+				outputScale[i] = parameterScale;                
 			}
 			
 		}
@@ -1599,6 +1613,30 @@
 		return NOT_OUTPUT_PARAM;
 	}
 
+        /** 
+         * get scale for output parameter. 
+         *
+         * @param paramNum - parameter number starting with 1
+         * @return scale or NOT_OUTPUT_PARAM if this is not an output parameter
+         */
+        int getOutputParamScale(int paramNum){
+            if (outputScale != null)
+                return (outputScale[paramNum -1]);
+            return NOT_OUTPUT_PARAM;
+        }
+
+        /** 
+         * get precision  for output parameter. 
+         *
+         * @param paramNum - parameter number starting with 1
+         * @return precision or NOT_OUTPUT_PARAM if this is not an output parameter
+         */
+        int getOutputParamPrecision(int paramNum){
+            if (outputPrecision != null)
+                return (outputPrecision[paramNum -1]);
+            return NOT_OUTPUT_PARAM;
+        }
+        
 	private boolean isDynamicPkgid(String pkgid)
 	{
 		char size = pkgid.charAt(3);

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMappingTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMappingTest.java?view=diff&rev=534985&r1=534984&r2=534985
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMappingTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMappingTest.java
Thu May  3 13:39:18 2007
@@ -484,7 +484,8 @@
 
                         } catch (SQLException sqle) {
                             boolean expectedConversionError = ("22018".equals(sqle.getSQLState())||

-                                                               "22007".equals(sqle.getSQLState()));
+                                                               "22007".equals(sqle.getSQLState())
||
+                                                               "22005".equals(sqle.getSQLState()));
                             assertTrue("FAIL: Unexpected exception" + sqle.getSQLState()
+ ":" + sqle.getMessage(),
                                     expectedConversionError);
                         }
@@ -771,7 +772,11 @@
                         assertEquals("17:14:24",s);
                         break;
                     case java.sql.Types.TIMESTAMP:
-                        assertEquals("2004-02-14 17:14:24.097625551",s);
+                    	// DERBY-2602 Client TIMESTAMP is truncated
+                        if (usingEmbedded())
+                            assertEquals("2004-02-14 17:14:24.097625551",s);
+                        else
+                            assertEquals("2004-02-14 17:14:24.097625",s);
                         break;
                     case java.sql.Types.CLOB:
                         assertEquals("67",s);
@@ -3495,10 +3500,17 @@
             assertNotNull(val);
             break;
         case java.sql.Types.TIMESTAMP:
+        	//DERBY-2602 Client TIMESTAMP is truncated
             if (param == 2)
-                assertEquals("2004-03-12 21:14:24.938222433", val.toString());
-            else if (param == 3)
-                assertEquals("2004-04-12 04:25:26.462983731", val.toString());
+                if (usingEmbedded())
+                    assertEquals("2004-03-12 21:14:24.938222433", val.toString());
+                else
+                    assertEquals("2004-03-12 21:14:24.938222", val.toString());
+            else if (param == 3)
+                if (usingEmbedded())
+                    assertEquals("2004-04-12 04:25:26.462983731", val.toString());
+                else
+                    assertEquals("2004-04-12 04:25:26.462983", val.toString());
             break;
         }
     }
@@ -3590,12 +3602,10 @@
     }
     
     public static Test suite() {
-        // Can't run for client for now, getting strange protocol error on tearDown
-        // DERBY-2381
-        //return TestConfiguration.defaultSuite(ParameterMappingTest.class);
+        
         // Don't run for JSR169 until DERBY-2403 is resolved.
         if (JDBC.vmSupportsJDBC2())
-            return TestConfiguration.embeddedSuite(ParameterMappingTest.class);
+            return TestConfiguration.defaultSuite(ParameterMappingTest.class);
         else
             return  new TestSuite("ParameterMapping");
     }



Mime
View raw message