summaryrefslogtreecommitdiff
path: root/sql/sql_sequence.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_sequence.cc')
-rw-r--r--sql/sql_sequence.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/sql/sql_sequence.cc b/sql/sql_sequence.cc
index 4e8624d6360..035fb1211e6 100644
--- a/sql/sql_sequence.cc
+++ b/sql/sql_sequence.cc
@@ -487,9 +487,12 @@ int SEQUENCE::read_initial_values(TABLE *table)
Doing mysql_lock_tables() may have started a read only transaction.
If that happend, it's better that we commit it now, as a lot of
code assumes that there is no active stmt transaction directly after
- open_tables()
+ open_tables().
+ But we also don't want to commit the stmt transaction while in a
+ substatement, see MDEV-15977.
*/
- if (!has_active_transaction && !thd->transaction.stmt.is_empty())
+ if (!has_active_transaction && !thd->transaction.stmt.is_empty() &&
+ !thd->in_sub_stmt)
trans_commit_stmt(thd);
}
write_unlock(table);