Skip to content

Commit df08731

Browse files
committed
Merge 10.9 into 10.10
2 parents 3dd3378 + 1147e32 commit df08731

File tree

8 files changed

+71
-11
lines changed

8 files changed

+71
-11
lines changed

mysql-test/suite/innodb/r/insert_into_empty.result

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,21 @@ WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
214214
TABLE_ROWS AVG_ROW_LENGTH>0
215215
3 1
216216
DROP TABLE t1;
217+
#
218+
# MDEV-29975 InnoDB fails to release savepoint during bulk insert
219+
#
220+
CREATE TABLE t (c INT KEY) ENGINE=InnoDB;
221+
begin;
222+
INSERT INTO t VALUES (0,0);
223+
ERROR 21S01: Column count doesn't match value count at row 1
224+
SAVEPOINT a;
225+
INSERT INTO t VALUES (0),(0);
226+
ERROR HY000: Got error 1 "Operation not permitted" during COMMIT
227+
SAVEPOINT a;
228+
commit;
229+
SELECT * FROM t;
230+
c
231+
DROP TABLE t;
217232
# End of 10.6 tests
218233
#
219234
# MDEV-26947 UNIQUE column checks fail in InnoDB resulting

mysql-test/suite/innodb/r/undo_truncate.result

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
SET GLOBAL innodb_undo_log_truncate = 0;
22
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
3+
=== information_schema.innodb_sys_tablespaces and innodb_sys_datafiles ===
4+
Space_Name Page_Size Zip_Size Path
5+
innodb_undo001 DEFAULT DEFAULT MYSQLD_DATADIR//undo001
6+
innodb_undo002 DEFAULT DEFAULT MYSQLD_DATADIR//undo002
7+
innodb_temporary DEFAULT DEFAULT MYSQLD_DATADIR/ibtmp1
38
create table t1(keyc int primary key, c char(100)) engine = innodb;
49
create table t2(keyc int primary key, c char(100)) engine = innodb;
510
connect con1,localhost,root,,;

mysql-test/suite/innodb/t/insert_into_empty.test

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,20 @@ SELECT TABLE_ROWS, AVG_ROW_LENGTH>0 FROM INFORMATION_SCHEMA.TABLES
235235
WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
236236
DROP TABLE t1;
237237

238+
--echo #
239+
--echo # MDEV-29975 InnoDB fails to release savepoint during bulk insert
240+
--echo #
241+
CREATE TABLE t (c INT KEY) ENGINE=InnoDB;
242+
begin;
243+
--error ER_WRONG_VALUE_COUNT_ON_ROW
244+
INSERT INTO t VALUES (0,0);
245+
SAVEPOINT a;
246+
--error ER_ERROR_DURING_COMMIT
247+
INSERT INTO t VALUES (0),(0);
248+
SAVEPOINT a;
249+
commit;
250+
SELECT * FROM t;
251+
DROP TABLE t;
238252
--echo # End of 10.6 tests
239253

240254
--echo #
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
--innodb-buffer-pool-size=24M
22
--innodb-immediate-scrub-data-uncompressed=ON
3+
--loose-innodb-sys-tablespaces

mysql-test/suite/innodb/t/undo_truncate.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ call mtr.add_suppression("InnoDB: Trying to delete tablespace.*pending operation
1515
SET GLOBAL innodb_undo_log_truncate = 0;
1616
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
1717

18+
LET $MYSQLD_DATADIR = `select @@datadir`;
19+
LET $INNODB_PAGE_SIZE = `select @@innodb_page_size`;
20+
--source suite/innodb/include/show_i_s_tablespaces.inc
1821
#-----------------------------------------------------------------------------
1922
#
2023
# Perform DML action using multiple clients and multiple undo tablespace.

storage/innobase/handler/ha_innodb.cc

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4455,6 +4455,25 @@ innobase_commit_ordered(
44554455
DBUG_VOID_RETURN;
44564456
}
44574457

4458+
/** Mark the end of a statement.
4459+
@param trx transaction
4460+
@return whether an error occurred */
4461+
static bool end_of_statement(trx_t *trx)
4462+
{
4463+
trx_mark_sql_stat_end(trx);
4464+
if (UNIV_LIKELY(trx->error_state == DB_SUCCESS))
4465+
return false;
4466+
4467+
trx_savept_t savept;
4468+
savept.least_undo_no= 0;
4469+
trx->rollback(&savept);
4470+
/* MariaDB will roll back the entire transaction. */
4471+
trx->bulk_insert= false;
4472+
trx->last_sql_stat_start.least_undo_no= 0;
4473+
trx->savepoints_discard();
4474+
return true;
4475+
}
4476+
44584477
/*****************************************************************//**
44594478
Commits a transaction in an InnoDB database or marks an SQL statement
44604479
ended.
@@ -4531,10 +4550,7 @@ innobase_commit(
45314550
/* Store the current undo_no of the transaction so that we
45324551
know where to roll back if we have to roll back the next
45334552
SQL statement */
4534-
4535-
trx_mark_sql_stat_end(trx);
4536-
if (UNIV_UNLIKELY(trx->error_state != DB_SUCCESS)) {
4537-
trx_rollback_for_mysql(trx);
4553+
if (UNIV_UNLIKELY(end_of_statement(trx))) {
45384554
DBUG_RETURN(1);
45394555
}
45404556
}
@@ -16954,10 +16970,7 @@ innobase_xa_prepare(
1695416970
/* Store the current undo_no of the transaction so that we
1695516971
know where to roll back if we have to roll back the next
1695616972
SQL statement */
16957-
16958-
trx_mark_sql_stat_end(trx);
16959-
if (UNIV_UNLIKELY(trx->error_state != DB_SUCCESS)) {
16960-
trx_rollback_for_mysql(trx);
16973+
if (UNIV_UNLIKELY(end_of_statement(trx))) {
1696116974
return 1;
1696216975
}
1696316976
}

storage/innobase/handler/i_s.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6142,8 +6142,13 @@ static int i_s_sys_tablespaces_fill(THD *thd, const fil_space_t &s, TABLE *t)
61426142
OK(f->store(name.data(), name.size(), system_charset_info));
61436143
f->set_notnull();
61446144
}
6145-
else
6146-
f->set_notnull();
6145+
else if (srv_is_undo_tablespace(s.id))
6146+
{
6147+
char name[15];
6148+
snprintf(name, sizeof name, "innodb_undo%03u",
6149+
(s.id - srv_undo_space_id_start + 1));
6150+
OK(f->store(name, strlen(name), system_charset_info));
6151+
} else f->set_notnull();
61476152
}
61486153

61496154
fields[SYS_TABLESPACES_NAME]->set_null();

storage/innobase/trx/trx0roll.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,13 @@ trx_release_savepoint_for_mysql(
557557

558558
if (savep != NULL) {
559559
trx_roll_savepoint_free(trx, savep);
560+
return DB_SUCCESS;
561+
} else if (trx->last_sql_stat_start.least_undo_no == 0) {
562+
/* Bulk insert could have discarded savepoints */
563+
return DB_SUCCESS;
560564
}
561565

562-
return(savep != NULL ? DB_SUCCESS : DB_NO_SAVEPOINT);
566+
return DB_NO_SAVEPOINT;
563567
}
564568

565569
/*******************************************************************//**

0 commit comments

Comments
 (0)