Please sign in to comment.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: reset server-prepared statements on deallocate/discard, ability…
… to autorollback on sqlexception from executing a query Bug report: http://stackoverflow.com/questions/34180932/error-cached-plan-must-not-change-result-type-when-mixing-ddl-with-select-via 1) If "DEALLOCATE" or "DISCARD" command status is observed, the driver would invalidate cached statements, and subsequent executions would go through parse, describe, etc. This feature is enabled by deafault. 2) If fails with "cached plan must not change result type", then re-parse might solve the problem. However, if there a pending transaction, then the error would kill the transaction. For that purpose, the driver sets a savepoint before each statement. Automatic savepoint is configured via autosave property that can take the following values: * conservative (default) -- rollback to savepoint only in case of "prepared statement does not exist" and "cached plan must not change result type". Then the driver would re-execute the statement ant it would pass through * never -- never set automatic safepoint. Note: in this mode statements might still fail with "cached plan must not change result type" in autoCommit=FALSE mode * always -- always rollback to "before statement execution" state in case of failure. This mode prevents "current transaction aborted" errors. It is similar to psql's ON_ERROR_ROLLBACK. The overhead of additional savepoint is like 3us (see #477). fixes #451 closes #423 fixes #617 closes #477
- Loading branch information
Showing with 546 additions and 30 deletions.
- +17 −0 pgjdbc/src/main/java/org/postgresql/PGConnection.java
- +13 −0 pgjdbc/src/main/java/org/postgresql/PGProperty.java
- +7 −0 pgjdbc/src/main/java/org/postgresql/core/QueryExecutor.java
- +49 −0 pgjdbc/src/main/java/org/postgresql/core/QueryExecutorBase.java
- +1 −0 pgjdbc/src/main/java/org/postgresql/core/SqlCommand.java
- +86 −8 pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java
- +7 −2 pgjdbc/src/main/java/org/postgresql/core/v3/SimpleQuery.java
- +17 −0 pgjdbc/src/main/java/org/postgresql/ds/common/BaseDataSource.java
- +21 −0 pgjdbc/src/main/java/org/postgresql/jdbc/AutoSave.java
- +36 −19 pgjdbc/src/main/java/org/postgresql/jdbc/PgConnection.java
- +17 −1 pgjdbc/src/main/java/org/postgresql/jdbc/PgStatement.java
- +4 −0 pgjdbc/src/main/java/org/postgresql/util/PSQLState.java
- +258 −0 pgjdbc/src/test/java/org/postgresql/test/jdbc2/AutoRollbackTestSuite.java
- +2 −0 pgjdbc/src/test/java/org/postgresql/test/jdbc2/PreparedStatementTest.java
- +11 −0 ubenchmark/src/main/java/org/postgresql/benchmark/statement/ParseStatement.java
Oops, something went wrong.