summaryrefslogtreecommitdiff
path: root/sql/ha_sequence.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/ha_sequence.cc')
-rw-r--r--sql/ha_sequence.cc17
1 files changed, 15 insertions, 2 deletions
diff --git a/sql/ha_sequence.cc b/sql/ha_sequence.cc
index 596f8584041..2447242593c 100644
--- a/sql/ha_sequence.cc
+++ b/sql/ha_sequence.cc
@@ -30,6 +30,10 @@
#include "sql_base.h"
#include "log_event.h"
+#ifdef WITH_WSREP
+#include "wsrep_trans_observer.h" /* wsrep_start_transaction() */
+#endif
+
/*
Table flags we should inherit and disable from the original engine.
We add HA_STATS_RECORDS_IS_EXACT as ha_sequence::info() will ensure
@@ -204,6 +208,7 @@ int ha_sequence::write_row(const uchar *buf)
int error;
sequence_definition tmp_seq;
bool sequence_locked;
+ THD *thd= table->in_use;
DBUG_ENTER("ha_sequence::write_row");
DBUG_ASSERT(table->record[0] == buf);
@@ -245,8 +250,6 @@ int ha_sequence::write_row(const uchar *buf)
on master and slaves
- Check that the new row is an accurate SEQUENCE object
*/
-
- THD *thd= table->in_use;
if (table->s->tmp_table == NO_TMP_TABLE &&
thd->mdl_context.upgrade_shared_lock(table->mdl_ticket,
MDL_EXCLUSIVE,
@@ -265,6 +268,16 @@ int ha_sequence::write_row(const uchar *buf)
sequence->write_lock(table);
}
+#ifdef WITH_WSREP
+ /* We need to start Galera transaction for select NEXT VALUE FOR
+ sequence if it is not yet started. Note that ALTER is handled
+ as TOI. */
+ if (WSREP_ON && WSREP(thd) &&
+ !thd->wsrep_trx().active() &&
+ wsrep_thd_is_local(thd))
+ wsrep_start_transaction(thd, thd->wsrep_next_trx_id());
+#endif
+
if (likely(!(error= file->update_first_row(buf))))
{
Log_func *log_func= Write_rows_log_event::binlog_row_logging_function;