Skip to content

Commit fd6dfb3

Browse files
committed
Merge branch 'github/10.1' into 10.2
2 parents 6680b04 + 3138557 commit fd6dfb3

File tree

4 files changed

+41
-8
lines changed

4 files changed

+41
-8
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
rename table mysql.table_stats to mysql.table_stats_save;
2+
flush tables;
3+
set use_stat_tables= PREFERABLY;
4+
create table t1 (a int) engine=InnoDB;
5+
start transaction;
6+
insert t1 values (1);
7+
insert t1 values (2);
8+
commit;
9+
select * from t1;
10+
a
11+
1
12+
2
13+
drop table t1;
14+
rename table mysql.table_stats_save to mysql.table_stats;
15+
flush tables;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
source include/have_innodb.inc;
2+
3+
#
4+
# MDEV-20354 All but last insert ignored in InnoDB tables when table locked
5+
#
6+
rename table mysql.table_stats to mysql.table_stats_save;
7+
flush tables;
8+
set use_stat_tables= PREFERABLY;
9+
create table t1 (a int) engine=InnoDB;
10+
start transaction;
11+
insert t1 values (1);
12+
insert t1 values (2);
13+
commit;
14+
select * from t1;
15+
drop table t1;
16+
rename table mysql.table_stats_save to mysql.table_stats;
17+
flush tables;

sql/sql_class.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,12 +1579,16 @@ class Open_tables_backup: public Open_tables_state
15791579
/**
15801580
@class Sub_statement_state
15811581
@brief Used to save context when executing a function or trigger
1582+
1583+
operations on stat tables aren't technically a sub-statement, but they are
1584+
similar in a sense that they cannot change the transaction status.
15821585
*/
15831586

15841587
/* Defines used for Sub_statement_state::in_sub_stmt */
15851588

15861589
#define SUB_STMT_TRIGGER 1
15871590
#define SUB_STMT_FUNCTION 2
1591+
#define SUB_STMT_STAT_TABLES 4
15881592

15891593

15901594
class Sub_statement_state

sql/sql_statistics.cc

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -258,23 +258,23 @@ index_stat_def= {INDEX_STAT_N_FIELDS, index_stat_fields, 4, index_stat_pk_col};
258258
Open all statistical tables and lock them
259259
*/
260260

261-
static
262-
inline int open_stat_tables(THD *thd, TABLE_LIST *tables,
263-
Open_tables_backup *backup,
264-
bool for_write)
261+
static int open_stat_tables(THD *thd, TABLE_LIST *tables,
262+
Open_tables_backup *backup, bool for_write)
265263
{
266264
int rc;
267265

268266
Dummy_error_handler deh; // suppress errors
269267
thd->push_internal_handler(&deh);
270268
init_table_list_for_stat_tables(tables, for_write);
271269
init_mdl_requests(tables);
270+
thd->in_sub_stmt|= SUB_STMT_STAT_TABLES;
272271
rc= open_system_tables_for_read(thd, tables, backup);
272+
thd->in_sub_stmt&= ~SUB_STMT_STAT_TABLES;
273273
thd->pop_internal_handler();
274274

275275

276276
/* If the number of tables changes, we should revise the check below. */
277-
DBUG_ASSERT(STATISTICS_TABLES == 3);
277+
compile_time_assert(STATISTICS_TABLES == 3);
278278

279279
if (!rc &&
280280
(stat_table_intact.check(tables[TABLE_STAT].table, &table_stat_def) ||
@@ -3276,10 +3276,7 @@ int read_statistics_for_tables(THD *thd, TABLE_LIST *tables)
32763276
DBUG_RETURN(0);
32773277

32783278
if (open_stat_tables(thd, stat_tables, &open_tables_backup, FALSE))
3279-
{
3280-
thd->clear_error();
32813279
DBUG_RETURN(1);
3282-
}
32833280

32843281
for (TABLE_LIST *tl= tables; tl; tl= tl->next_global)
32853282
{

0 commit comments

Comments
 (0)