Skip to content
Snippets Groups Projects
Commit 13acfe47 authored by Vladimir Davydov's avatar Vladimir Davydov
Browse files

txn: add helper to detect transaction boundaries

Add txn_is_first_statement() function, which returns true if this is the
first statement of the transaction. The function is supposed to be used
from on_replace trigger to detect transaction boundaries.

Needed for #2129
parent 21eed04c
No related branches found
No related tags found
No related merge requests found
......@@ -398,8 +398,7 @@ txn_abort(struct txn *txn)
int
txn_check_singlestatement(struct txn *txn, const char *where)
{
if (!txn->is_autocommit ||
stailq_last(&txn->stmts) != stailq_first(&txn->stmts)) {
if (!txn->is_autocommit || !txn_is_first_statement(txn)) {
diag_set(ClientError, ER_UNSUPPORTED,
where, "multi-statement transactions");
return -1;
......
......@@ -280,6 +280,17 @@ txn_rollback_stmt();
int
txn_check_singlestatement(struct txn *txn, const char *where);
/**
* Returns true if the transaction has a single statement.
* Supposed to be used from a space on_replace trigger to
* detect transaction boundaries.
*/
static inline bool
txn_is_first_statement(struct txn *txn)
{
return stailq_last(&txn->stmts) == stailq_first(&txn->stmts);
}
/** The current statement of the transaction. */
static inline struct txn_stmt *
txn_current_stmt(struct txn *txn)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment