[libpostgresql-jdbc-java] 04/08: 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.
Emmanuel Bourg
ebourg-guest at moszumanska.debian.org
Mon Jan 9 10:19:26 UTC 2017
This is an automated email from the git hooks/post-receive script.
ebourg-guest pushed a commit to tag REL8_0_318
in repository libpostgresql-jdbc-java.
commit 32dd53cb798cad5c65991e27dd086d1957434116
Author: Kris Jurka <books at ejurka.com>
Date: Sun Aug 6 18:11:52 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 ce4b520..d3df8ba 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.12 2004/11/09 08:44:12 jurka Exp $
+* $PostgreSQL: pgjdbc/org/postgresql/core/BaseConnection.java,v 1.13 2005/01/11 08:25:43 jurka Exp $
*
*-------------------------------------------------------------------------
*/
@@ -35,6 +35,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 8b44e21..850181b 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.26.2.1 2005/02/15 08:55:50 jurka Exp $
+* $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Connection.java,v 1.26.2.2 2005/06/21 20:11:52 davec Exp $
*
*-------------------------------------------------------------------------
*/
@@ -184,11 +184,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 2892200..d9bf7a0 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.71.2.6 2005/11/05 09:25:03 jurka Exp $
+* $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java,v 1.71.2.7 2005/12/04 21:41:35 jurka Exp $
*
*-------------------------------------------------------------------------
*/
@@ -172,7 +172,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
More information about the pkg-java-commits
mailing list