summaryrefslogtreecommitdiff
path: root/sql/sql_statistics.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2019-10-30 19:31:26 +0100
committerSergei Golubchik <serg@mariadb.org>2019-10-30 23:14:44 +0100
commit5392b4a32c9da296f7b2e6a5b83e3bff6c24871e (patch)
tree2f37d97bbf9ebe895fe409b12dff3d99ea2d2724 /sql/sql_statistics.cc
parentc8ba98206f1b08bf02c6a6f993b8e1b6842cb665 (diff)
downloadmariadb-git-5392b4a32c9da296f7b2e6a5b83e3bff6c24871e.tar.gz
MDEV-20354 All but last insert ignored in InnoDB tables when table locked
mysql_insert() first opens all affected tables (which implicitly starts a transaction in InnoDB), then stat tables. A failure to open a stat table caused open_tables() to abort the current stmt transaction (trans_rollback_stmt()). So, from the server point of view the following ha_write_row()-s happened outside of a transactions, and the server didn't bother to commit them. The server has a mechanism to prevent a transaction being unexpectedly committed or rolled back in the middle of a statement - if an operation takes place _in a sub-statement_ it cannot change the transaction state. Operations on stat tables are exactly that - they are not allowed to change a transaction state. Put them in a sub-statement to make sure they don't.
Diffstat (limited to 'sql/sql_statistics.cc')
-rw-r--r--sql/sql_statistics.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index 4a1ed9cde4e..f002a5a5eab 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -268,7 +268,9 @@ inline int open_stat_tables(THD *thd, TABLE_LIST *tables,
thd->push_internal_handler(&deh);
init_table_list_for_stat_tables(tables, for_write);
init_mdl_requests(tables);
+ thd->in_sub_stmt|= SUB_STMT_STAT_TABLES;
rc= open_system_tables_for_read(thd, tables, backup);
+ thd->in_sub_stmt&= ~SUB_STMT_STAT_TABLES;
thd->pop_internal_handler();