[libpostgresql-jdbc-java] 17/93: fixed bug PreparedStatement.getMetaData failed if result set was closed reported by Emmanuel Guiton

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Mon Jan 9 10:18:47 UTC 2017


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

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

commit 3c57c9ca171adbb664f3a94d4394086114004684
Author: Dave Cramer <davecramer at gmail.com>
Date:   Fri Dec 20 07:23:42 2013 -0500

    fixed bug PreparedStatement.getMetaData failed if result set was closed
    reported by Emmanuel Guiton
---
 org/postgresql/jdbc2/AbstractJdbc2Statement.java     |  5 +++--
 org/postgresql/test/jdbc2/ResultSetMetaDataTest.java | 19 +++++++++++++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/org/postgresql/jdbc2/AbstractJdbc2Statement.java b/org/postgresql/jdbc2/AbstractJdbc2Statement.java
index f458b00..13630b2 100644
--- a/org/postgresql/jdbc2/AbstractJdbc2Statement.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2Statement.java
@@ -2979,8 +2979,9 @@ public abstract class AbstractJdbc2Statement implements BaseStatement
         checkClosed();
         ResultSet rs = getResultSet();
 
-        if (rs == null) {
-            // OK, we haven't executed it yet, we've got to go to the backend
+        if (rs == null || rs.isClosed() ) {
+            // OK, we haven't executed it yet, or it was closed
+            // we've got to go to the backend
             // for more info.  We send the full query, but just don't
             // execute it.
 
diff --git a/org/postgresql/test/jdbc2/ResultSetMetaDataTest.java b/org/postgresql/test/jdbc2/ResultSetMetaDataTest.java
index dda0843..c3cf03e 100644
--- a/org/postgresql/test/jdbc2/ResultSetMetaDataTest.java
+++ b/org/postgresql/test/jdbc2/ResultSetMetaDataTest.java
@@ -222,5 +222,24 @@ public class ResultSetMetaDataTest extends TestCase
         assertEquals(Types.STRUCT, rsmd.getColumnType(1));
         assertEquals("rsmd1", rsmd.getColumnTypeName(1));
     }
+    
+    public void testUnexecutedStatement() throws Exception 
+    {
+        PreparedStatement pstmt = conn.prepareStatement("SELECT col FROM compositetest");
+        // we have not executed the statement but we can still get the metadata
+        ResultSetMetaData rsmd = pstmt.getMetaData();
+        assertEquals(Types.STRUCT, rsmd.getColumnType(1));
+        assertEquals("rsmd1", rsmd.getColumnTypeName(1));
+    }
+    public void testClosedResultSet() throws Exception 
+    {
+        PreparedStatement pstmt = conn.prepareStatement("SELECT col FROM compositetest");
+        ResultSet rs = pstmt.executeQuery();
+        rs.close();
+        // close the statement and make sure we can still get the metadata
+        ResultSetMetaData rsmd = pstmt.getMetaData();
+        assertEquals(Types.STRUCT, rsmd.getColumnType(1));
+        assertEquals("rsmd1", rsmd.getColumnTypeName(1));
+    }
 
 }

-- 
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