Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
fix: synchronize Statement#result field access to make #close() more …
- Loading branch information
|
@@ -87,7 +87,11 @@ public boolean executeWithFlags(int flags) throws SQLException { |
|
|
PSQLState.NO_DATA); |
|
|
} |
|
|
|
|
|
ResultSet rs = result.getResultSet(); |
|
|
ResultSet rs; |
|
|
synchronized (this) { |
|
|
checkClosed(); |
|
|
rs = result.getResultSet(); |
|
|
} |
|
|
if (!rs.next()) { |
|
|
throw new PSQLException(GT.tr("A CallableStatement was executed with nothing returned."), |
|
|
PSQLState.NO_DATA); |
|
@@ -146,7 +150,9 @@ public boolean executeWithFlags(int flags) throws SQLException { |
|
|
|
|
|
} |
|
|
rs.close(); |
|
|
result = null; |
|
|
synchronized (this) { |
|
|
result = null; |
|
|
} |
|
|
return false; |
|
|
} |
|
|
|
|
|
|
@@ -118,12 +118,7 @@ |
|
|
throw new PSQLException(GT.tr("No results were returned by the query."), PSQLState.NO_DATA); |
|
|
} |
|
|
|
|
|
if (result.getNext() != null) { |
|
|
throw new PSQLException(GT.tr("Multiple ResultSets were returned by the query."), |
|
|
PSQLState.TOO_MANY_RESULTS); |
|
|
} |
|
|
|
|
|
return result.getResultSet(); |
|
|
return getSingleResultSet(); |
|
|
} |
|
|
|
|
|
public int executeUpdate(String p_sql) throws SQLException { |
|
@@ -135,17 +130,7 @@ public int executeUpdate(String p_sql) throws SQLException { |
|
|
public int executeUpdate() throws SQLException { |
|
|
executeWithFlags(QueryExecutor.QUERY_NO_RESULTS); |
|
|
|
|
|
ResultWrapper iter = result; |
|
|
while (iter != null) { |
|
|
if (iter.getResultSet() != null) { |
|
|
throw new PSQLException(GT.tr("A result was returned when none was expected."), |
|
|
PSQLState.TOO_MANY_RESULTS); |
|
|
|
|
|
} |
|
|
iter = iter.getNext(); |
|
|
} |
|
|
|
|
|
return getUpdateCount(); |
|
|
return getNoResultUpdateCount(); |
|
|
} |
|
|
|
|
|
public boolean execute(String p_sql) throws SQLException { |
|
@@ -168,7 +153,10 @@ public boolean executeWithFlags(int flags) throws SQLException { |
|
|
|
|
|
execute(preparedQuery, preparedParameters, flags); |
|
|
|
|
|
return (result != null && result.getResultSet() != null); |
|
|
synchronized (this) { |
|
|
checkClosed(); |
|
|
return (result != null && result.getResultSet() != null); |
|
|
} |
|
|
} finally { |
|
|
defaultTimeZone = null; |
|
|
} |
|
|
Oops, something went wrong.