Skip to content

Commit

Permalink
MDEV-32833 InnoDB wrong error message
Browse files Browse the repository at this point in the history
trx_t::commit_in_memory(): Empty the detailed_error string, so that
FOREIGN KEY error messages from an earlier transaction will not be
wrongly reused in ha_innobase::get_error_message().

Reviewed by: Thirunarayanan Balathandayuthapani
  • Loading branch information
dr-m committed Nov 29, 2023
1 parent 1fec501 commit 47fc64c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions mysql-test/suite/innodb/r/foreign-keys.result
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,10 @@ INSERT INTO t2 VALUES('G', 3);
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`))
DROP TABLE t2, t1;
SET FOREIGN_KEY_CHECKS=DEFAULT;
CREATE TABLE t1(a SERIAL) ENGINE=InnoDB ROW_FORMAT=COMPRESSED PAGE_COMPRESSED=1;
ERROR HY000: Can't create table `test`.`t1` (errno: 140 "Wrong create options")
SHOW WARNINGS;
Level Code Message
Warning 140 InnoDB: PAGE_COMPRESSED table can't have ROW_TYPE=COMPRESSED
Error 1005 Can't create table `test`.`t1` (errno: 140 "Wrong create options")
Warning 1030 Got error 140 "Wrong create options" from storage engine InnoDB
2 changes: 1 addition & 1 deletion mysql-test/suite/innodb/r/innodb.result
Original file line number Diff line number Diff line change
Expand Up @@ -2481,7 +2481,7 @@ INSERT INTO t2 VALUES(1);
DELETE FROM t1 WHERE id = 1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
DROP TABLE t1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
SET FOREIGN_KEY_CHECKS=0;
DROP TABLE t1;
SET FOREIGN_KEY_CHECKS=1;
Expand Down
4 changes: 4 additions & 0 deletions mysql-test/suite/innodb/t/foreign-keys.test
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,7 @@ SET FOREIGN_KEY_CHECKS=1;
INSERT INTO t2 VALUES('G', 3);
DROP TABLE t2, t1;
SET FOREIGN_KEY_CHECKS=DEFAULT;

--error ER_CANT_CREATE_TABLE
CREATE TABLE t1(a SERIAL) ENGINE=InnoDB ROW_FORMAT=COMPRESSED PAGE_COMPRESSED=1;
SHOW WARNINGS;
1 change: 1 addition & 0 deletions storage/innobase/include/trx0trx.h
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,7 @@ struct trx_t {
{
ut_ad(state == TRX_STATE_NOT_STARTED);
ut_ad(!id);
ut_ad(!*detailed_error);
ut_ad(!has_logged());
ut_ad(!is_referenced());
ut_ad(!is_wsrep());
Expand Down
1 change: 1 addition & 0 deletions storage/innobase/trx/trx0trx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,7 @@ inline void trx_t::commit_in_memory(const mtr_t *mtr)

DBUG_LOG("trx", "Commit in memory: " << this);
state= TRX_STATE_NOT_STARTED;
*detailed_error= '\0';

assert_freed();
trx_init(this);
Expand Down

0 comments on commit 47fc64c

Please sign in to comment.