Commit:
https://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=
eea522ebfcf791a623e865deaa1aa6fb59e3c50b
fixed some cases in aborted transaction so that SQL commands except
COMMIT/ROLLBACK are not forwarded to backend. But it missed ROLLBACK
TO command. As a result even if ROLLBACK TO command is issued, the
command was not forwarded to backend and the transaction keeps on in
aborted state.
Back patched through 4.3 which the commit was brought in.
Also add a test case for ROLLBACK TO to test 078.
Discussion:
https://www.pgpool.net/pipermail/pgpool-general-jp/2022-November/001715.html
extern bool is_commit_query(Node *node);
extern bool is_rollback_query(Node *node);
extern bool is_commit_or_rollback_query(Node *node);
+extern bool is_rollback_to_query(Node *node);
extern bool is_strict_query(Node *node); /* returns non 0 if this is strict
* query */
extern int need_insert_lock(POOL_CONNECTION_POOL * backend, char *query, Node *node);
bool
is_commit_or_rollback_query(Node *node)
{
- return is_commit_query(node) || is_rollback_query(node);
+ return is_commit_query(node) || is_rollback_query(node) || is_rollback_to_query(node);
}
/*
return stmt->kind == TRANS_STMT_ROLLBACK;
}
+/*
+ * Returns true if SQL is transaction rollback to command
+ */
+bool
+is_rollback_to_query(Node *node)
+{
+ TransactionStmt *stmt;
+
+ if (node == NULL || !IsA(node, TransactionStmt))
+ return false;
+
+ stmt = (TransactionStmt *) node;
+ return stmt->kind == TRANS_STMT_ROLLBACK_TO;
+}
+
/*
* send error message to frontend
*/
/*
* Check if the transaction is in abort status. If so, we do nothing
* and just return an error message to frontend, execpt for
- * transaction commit or abort command.
+ * transaction COMMIT or ROLLBACK (TO) command.
*/
if (check_transaction_state_and_abort(contents, node, frontend, backend) == false)
{
1
(1 row)
+BEGIN;
+BEGIN
+SAVEPOINT s1;
+SAVEPOINT
+aaa;
+ERROR: syntax error at or near "aaa"
+LINE 1: aaa;
+ ^
+ROLLBACK TO s1;
+ROLLBACK
+SELECT 1;
+ ?column?
+----------
+ 1
+(1 row)
+
+END;
+COMMIT
SELECT 1;
END;
SELECT 1;
+BEGIN;
+SAVEPOINT s1;
+aaa;
+ROLLBACK TO s1;
+SELECT 1;
+END;
EOF
if cmp ../expected.txt results.txt >/dev/null