db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r613169 - in /db/derby/code/trunk/java: drda/org/apache/derby/impl/drda/DRDAConnThread.java drda/org/apache/derby/impl/drda/DRDAStatement.java engine/org/apache/derby/iapi/jdbc/EngineResultSet.java
Date Fri, 18 Jan 2008 14:20:00 GMT
Author: dyre
Date: Fri Jan 18 06:19:59 2008
New Revision: 613169

URL: http://svn.apache.org/viewvc?rev=613169&view=rev
Log:
DERBY-3311: Client ResultSet.getHoldabilty will return incorrect value when the ResultSet
is obtained from a procedure call
Patch contributed by Daniel John Debrunner
Patch file: derby_3311_diff.txt 

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/engine/org/apache/derby/iapi/jdbc/EngineResultSet.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?rev=613169&r1=613168&r2=613169&view=diff
==============================================================================
--- 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 Fri Jan 18
06:19:59 2008
@@ -61,6 +61,7 @@
 import org.apache.derby.iapi.services.stream.HeaderPrintWriter;
 import org.apache.derby.iapi.tools.i18n.LocalizedResource;
 import org.apache.derby.iapi.jdbc.AuthenticationService;
+import org.apache.derby.iapi.jdbc.EngineResultSet;
 import org.apache.derby.impl.jdbc.EmbedSQLException;
 import org.apache.derby.impl.jdbc.Util;
 import org.apache.derby.jdbc.InternalDriver;
@@ -4127,7 +4128,7 @@
 		writer.createDssObject();
 		writer.startDdm(CodePoint.SQLCINRD);
 		if (sqlamLevel >= MGRLVL_7)
-			writeSQLDHROW (stmt);
+			writeSQLDHROW(((EngineResultSet) rs).getHoldability());
 
 		ResultSetMetaData rsmeta = rs.getMetaData();
 		int ncols = rsmeta.getColumnCount();
@@ -6250,7 +6251,7 @@
 		writeSQLCAGRP(e, getSqlCode(getExceptionSeverity(e)), 0, 0);
 
 		if (sqlamLevel >= MGRLVL_7)
-			writeSQLDHROW (stmt);
+			writeSQLDHROW(ps.getResultSetHoldability());
 
 		//SQLNUMROW
 		if (SanityManager.DEBUG) 
@@ -6460,9 +6461,15 @@
 
 
 
-	//pass PreparedStatement here so we can send correct holdability on the wire for jdk1.3
and higher
-	//For jdk1.3, we provide hold cursor support through reflection.
-	private void writeSQLDHROW (DRDAStatement stmt) throws DRDAProtocolException,SQLException
+
+    /**
+     * Holdability passed in as it can represent the holdability of
+     * the statement or a specific result set.
+     * @param holdability HOLD_CURSORS_OVER_COMMIT or CLOSE_CURSORS_AT_COMMIT
+     * @throws DRDAProtocolException
+     * @throws SQLException
+     */
+	private void writeSQLDHROW(int holdability) throws DRDAProtocolException,SQLException
 	{		
 		if (JVMInfo.JDK_ID < 2) //write null indicator for SQLDHROW because there is no holdability
support prior to jdk1.3
 		{
@@ -6473,7 +6480,7 @@
 		writer.writeByte(0);		// SQLDHROW INDICATOR
 
 		//SQLDHOLD
-		writer.writeShort(stmt.getResultSetHoldability());
+		writer.writeShort(holdability);
 		
 		//SQLDRETURN
 		writer.writeShort(0);

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?rev=613169&r1=613168&r2=613169&view=diff
==============================================================================
--- 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 Fri Jan 18
06:19:59 2008
@@ -43,6 +43,7 @@
 import org.apache.derby.iapi.jdbc.BrokeredPreparedStatement;
 import org.apache.derby.iapi.jdbc.EngineConnection;
 import org.apache.derby.iapi.jdbc.EnginePreparedStatement;
+import org.apache.derby.iapi.jdbc.EngineResultSet;
 import org.apache.derby.iapi.reference.JDBC30Translation;
 import org.apache.derby.iapi.sql.execute.ExecutionContext;
 import org.apache.derby.iapi.util.StringUtil;
@@ -408,38 +409,6 @@
 		currentDrdaRs.clearExtDtaObjects();
 	}
 
-	/**
-	 *
-	 *  get resultSetHoldability.
-	 * 
-	 * @return the resultSet holdability for the prepared statement
-	 *
-	 */
-	protected int getResultSetHoldability() throws SQLException
-	{
-		return getResultSetHoldability(getResultSet());
-	}
-	
-	/**
-	 *
-	 *  get resultSetHoldability.
-	 * 
-	 * @param rs ResultSet 
-	 * @return the resultSet holdability for the prepared statement
-	 *
-	 */
-	int getResultSetHoldability(ResultSet rs) throws SQLException
-	{
-		Statement rsstmt;
-
-		if (rs  != null)
-			rsstmt = rs.getStatement();
-		else
-			rsstmt = getPreparedStatement();
-        
-        return rsstmt.getResultSetHoldability();
-	}	
-
 	/*
 	 * Is lob object nullable
 	 * @param index - offset starting with 0
@@ -727,7 +696,7 @@
 			{
 				//For callable statement, get holdability of statement generating the result set
 				if(isCallable)
-					addResultSet(rs,getResultSetHoldability(rs));
+					addResultSet(rs, ((EngineResultSet) rs).getHoldability());
 				else
 					addResultSet(rs,withHoldCursor);
 				hasResultSet = true;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineResultSet.java?rev=613169&r1=613168&r2=613169&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineResultSet.java Fri Jan
18 06:19:59 2008
@@ -57,4 +57,12 @@
      */
     public int getLength(int columnIndex) throws SQLException;
     
+    /**
+     * Fetch the holdability of this ResultSet which may be different
+     * from the holdability of its Statement.
+     * @return HOLD_CURSORS_OVER_COMMIT or CLOSE_CURSORS_AT_COMMIT
+     * @throws SQLException Error.
+     */
+    public int getHoldability() throws SQLException;
+    
 }



Mime
View raw message