This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to tag REL8_1_408
in repository libpostgresql-jdbc-java.

commit a24b7a400a7dda014504f2a8fa388b30b93fb7be
Author: Kris Jurka <[email protected]>
Date:   Sun Aug 6 18:11:43 2006 +0000

    When creating a ResultSet from a refcursor, respect the creating
    ResultSet's scollability setting.  The way the ResultSet is created
    means that it will always be scrollable anyway, so there's no
    downside.  We cannot support updatable refcursor ResultSets until
    we get updatable cursors.
---
 org/postgresql/core/BaseConnection.java           |  4 +++-
 org/postgresql/jdbc2/AbstractJdbc2Connection.java | 10 +++++++---
 org/postgresql/jdbc2/AbstractJdbc2ResultSet.java  |  7 +++++--
 org/postgresql/test/jdbc2/RefCursorTest.java      | 18 ++++++++++++++++--
 4 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/org/postgresql/core/BaseConnection.java 
b/org/postgresql/core/BaseConnection.java
index 2a48d5c..7c3a543 100644
--- a/org/postgresql/core/BaseConnection.java
+++ b/org/postgresql/core/BaseConnection.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2003-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/core/BaseConnection.java,v 1.14 
2005/04/10 21:54:16 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/core/BaseConnection.java,v 1.15 
2005/08/01 06:54:14 oliver Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -36,6 +36,8 @@ public interface BaseConnection extends PGConnection, 
Connection
      */
     public ResultSet execSQLQuery(String s) throws SQLException;
 
+    public ResultSet execSQLQuery(String s, int resultSetType, int 
resultSetConcurrency) throws SQLException;
+
     /**
      * Execute a SQL query that does not return results.
      * Never causes a new transaction to be started regardless of the 
autocommit setting.
diff --git a/org/postgresql/jdbc2/AbstractJdbc2Connection.java 
b/org/postgresql/jdbc2/AbstractJdbc2Connection.java
index 1a436b9..07a9a8a 100644
--- a/org/postgresql/jdbc2/AbstractJdbc2Connection.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2Connection.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Connection.java,v 
1.31 2005/07/04 18:50:29 davec Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Connection.java,v 
1.32 2005/08/01 06:54:14 oliver Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -190,11 +190,15 @@ public abstract class AbstractJdbc2Connection implements 
BaseConnection
 
     }
 
+    public ResultSet execSQLQuery(String s) throws SQLException {
+        return execSQLQuery(s, ResultSet.TYPE_FORWARD_ONLY, 
ResultSet.CONCUR_READ_ONLY);
+    }
+
     /**
      * Simple query execution.
      */
-    public ResultSet execSQLQuery(String s) throws SQLException {
-        BaseStatement stat = (BaseStatement) createStatement();
+    public ResultSet execSQLQuery(String s, int resultSetType, int 
resultSetConcurrency) throws SQLException {
+        BaseStatement stat = (BaseStatement) createStatement(resultSetType, 
resultSetConcurrency);
         boolean hasResultSet = stat.executeWithFlags(s, 
QueryExecutor.QUERY_SUPPRESS_BEGIN);
 
         while (!hasResultSet && stat.getUpdateCount() != -1)
diff --git a/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java 
b/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
index d0a9b0a..48ebec8 100644
--- a/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2003-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java,v 
1.80 2005/11/05 09:24:15 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java,v 
1.80.2.1 2005/12/04 21:41:21 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -173,7 +173,10 @@ public abstract class AbstractJdbc2ResultSet implements 
BaseResultSet, org.postg
                 // new xact anyway since holdable cursor state isn't affected
                 // by xact boundaries. If our caller didn't commit at all, or
                 // autocommit was on, then we wouldn't issue a BEGIN anyway.
-                ResultSet rs = connection.execSQLQuery(fetchSql);
+                //
+                // We take the scrollability from the statement, but until
+                // we have updatable cursors it must be readonly.
+                ResultSet rs = connection.execSQLQuery(fetchSql, 
resultsettype, ResultSet.CONCUR_READ_ONLY);
                 ((AbstractJdbc2ResultSet)rs).setRefCursor(cursorName);
                 return rs;
             }
diff --git a/org/postgresql/test/jdbc2/RefCursorTest.java 
b/org/postgresql/test/jdbc2/RefCursorTest.java
index 37f0186..d9da595 100644
--- a/org/postgresql/test/jdbc2/RefCursorTest.java
+++ b/org/postgresql/test/jdbc2/RefCursorTest.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/RefCursorTest.java,v 1.5 
2005/01/11 08:25:48 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/RefCursorTest.java,v 1.6 
2005/01/30 11:04:55 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -34,7 +34,7 @@ public class RefCursorTest extends TestCase
         con = TestUtil.openDB();
         Statement stmt = con.createStatement();
 
-        TestUtil.createTable(con, "testrs", "id integer");
+        TestUtil.createTable(con, "testrs", "id integer primary key");
 
         stmt.executeUpdate("INSERT INTO testrs VALUES (1)");
         stmt.executeUpdate("INSERT INTO testrs VALUES (2)");
@@ -128,4 +128,18 @@ public class RefCursorTest extends TestCase
         call.close();
     }
 
+    public void testResultType() throws SQLException
+    {
+        CallableStatement call = con.prepareCall("{ ? = call 
testspg__getRefcursor () }", ResultSet.TYPE_SCROLL_INSENSITIVE, 
ResultSet.CONCUR_READ_ONLY);
+        call.registerOutParameter(1, Types.OTHER);
+        call.execute();
+        ResultSet rs = (ResultSet) call.getObject(1);
+
+        assertEquals(rs.getType(), ResultSet.TYPE_SCROLL_INSENSITIVE);
+        assertEquals(rs.getConcurrency(), ResultSet.CONCUR_READ_ONLY);
+
+        assertTrue(rs.last());
+        assertEquals(6, rs.getRow());
+    }
+
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-java/libpostgresql-jdbc-java.git

_______________________________________________
pkg-java-commits mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-commits

Reply via email to