Skip to content

Commit 0b2b721

Browse files
committed
When executing a statement, we want to make sure any previous state
was cleaned up, so the code was calling close(). This additionally set a closed flag which would throw exceptions later saying that you can't call various methods because the Statement is closed. It's not actually closed, so split the internal cleanup routine to clear() and make close() something that only a user should call.
1 parent e5a089a commit 0b2b721

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/java/pljava/org/postgresql/pljava/jdbc/SPIStatement.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class SPIStatement implements Statement
3434
private ResultSet m_resultSet = null;
3535
private int m_updateCount = 0;
3636
private ArrayList m_batch = null;
37-
private boolean m_closed = false;
37+
private boolean m_closed = false;
3838

3939
public SPIStatement(SPIConnection conn)
4040
{
@@ -66,7 +66,7 @@ public void clearWarnings()
6666
{
6767
}
6868

69-
public void close()
69+
private void clear()
7070
throws SQLException
7171
{
7272
if(m_resultSet != null)
@@ -79,15 +79,22 @@ public void close()
7979
m_updateCount = -1;
8080
m_cursorName = null;
8181
m_batch = null;
82-
m_closed = true;
82+
}
83+
84+
public void close()
85+
throws SQLException
86+
{
87+
clear();
88+
m_closed = true;
8389
}
8490

8591
public boolean execute(String statement)
8692
throws SQLException
8793
{
88-
// Ensure that the statement is closed before we re-execute
94+
// Ensure that the last statement is cleaned up
95+
// before we re-execute
8996
//
90-
this.close();
97+
this.clear();
9198

9299
ExecutionPlan plan = ExecutionPlan.prepare(
93100
m_connection.nativeSQL(statement), null);
@@ -310,9 +317,9 @@ public int getUpdateCount()
310317
public SQLWarning getWarnings()
311318
throws SQLException
312319
{
313-
if (m_closed) {
314-
throw new SQLException("getWarnings: Statement is closed");
315-
}
320+
if (m_closed) {
321+
throw new SQLException("getWarnings: Statement is closed");
322+
}
316323

317324
return null;
318325
}
@@ -390,4 +397,4 @@ void resultSetClosed(ResultSet rs)
390397
if(rs == m_resultSet)
391398
m_resultSet = null;
392399
}
393-
}
400+
}

0 commit comments

Comments
 (0)