summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/suite/innodb/r/innodb-index.result3
-rw-r--r--mysql-test/suite/innodb/r/undo_log.result142
-rw-r--r--mysql-test/suite/innodb/t/innodb-index.test3
-rw-r--r--mysql-test/suite/innodb/t/undo_log.test139
-rw-r--r--storage/innobase/trx/trx0rec.c24
-rw-r--r--storage/xtradb/trx/trx0rec.c24
6 files changed, 331 insertions, 4 deletions
diff --git a/mysql-test/suite/innodb/r/innodb-index.result b/mysql-test/suite/innodb/r/innodb-index.result
index 5b0fccbe615..5676b6d12cd 100644
--- a/mysql-test/suite/innodb/r/innodb-index.result
+++ b/mysql-test/suite/innodb/r/innodb-index.result
@@ -1046,8 +1046,9 @@ PRIMARY KEY (b(10), a), INDEX (c(767)), INDEX(b(767))
) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
INSERT INTO bug12547647 VALUES (5,repeat('khdfo5AlOq',1900),repeat('g',7751));
COMMIT;
+BEGIN;
UPDATE bug12547647 SET c = REPEAT('b',16928);
-ERROR HY000: Undo log record is too big.
+ROLLBACK;
DROP TABLE bug12547647;
set global innodb_file_per_table=0;
set global innodb_file_format=Antelope;
diff --git a/mysql-test/suite/innodb/r/undo_log.result b/mysql-test/suite/innodb/r/undo_log.result
new file mode 100644
index 00000000000..a40c6b5b3bf
--- /dev/null
+++ b/mysql-test/suite/innodb/r/undo_log.result
@@ -0,0 +1,142 @@
+CREATE TABLE test_tab (
+a_str_18 mediumtext,
+b_str_3 varchar(32) DEFAULT NULL,
+a_str_13 mediumtext,
+b_str_5 varchar(40) DEFAULT NULL,
+b_str_6 varchar(50) DEFAULT NULL,
+b_str_7 char(32) DEFAULT NULL,
+b_str_8 varchar(32) DEFAULT NULL,
+b_str_9 varchar(255) DEFAULT NULL,
+a_str_28 char(255) DEFAULT NULL,
+a_str_27 varchar(255) DEFAULT NULL,
+b_str_10 varchar(32) DEFAULT NULL,
+a_str_26 varchar(255) DEFAULT NULL,
+a_str_6 varchar(50) DEFAULT NULL,
+b_str_11 varchar(32) DEFAULT NULL,
+b_str_12 varchar(255) DEFAULT NULL,
+b_str_13 char(32) DEFAULT NULL,
+b_str_14 varchar(32) DEFAULT NULL,
+b_str_15 char(32) DEFAULT NULL,
+b_str_16 char(32) DEFAULT NULL,
+b_str_17 varchar(32) DEFAULT NULL,
+b_str_18 varchar(32) DEFAULT NULL,
+a_str_25 varchar(40) DEFAULT NULL,
+b_str_19 varchar(255) DEFAULT NULL,
+a_str_23 varchar(40) DEFAULT NULL,
+b_str_20 varchar(32) DEFAULT NULL,
+a_str_21 varchar(255) DEFAULT NULL,
+a_str_20 varchar(255) DEFAULT NULL,
+a_str_39 varchar(255) DEFAULT NULL,
+a_str_38 varchar(255) DEFAULT NULL,
+a_str_37 varchar(255) DEFAULT NULL,
+b_str_21 char(32) DEFAULT NULL,
+b_str_23 varchar(80) DEFAULT NULL,
+b_str_24 varchar(32) DEFAULT NULL,
+b_str_25 varchar(32) DEFAULT NULL,
+b_str_26 char(32) NOT NULL DEFAULT '',
+b_str_27 varchar(255) DEFAULT NULL,
+a_str_36 varchar(255) DEFAULT NULL,
+a_str_33 varchar(100) DEFAULT NULL,
+a_ref_10 char(32) DEFAULT NULL,
+b_str_28 char(32) DEFAULT NULL,
+b_str_29 char(32) DEFAULT NULL,
+a_ref_6 char(32) DEFAULT NULL,
+a_ref_12 varchar(32) DEFAULT NULL,
+a_ref_11 varchar(32) DEFAULT NULL,
+a_str_49 varchar(40) DEFAULT NULL,
+b_str_30 varchar(32) DEFAULT NULL,
+a_ref_3 varchar(32) DEFAULT NULL,
+a_str_48 varchar(40) DEFAULT NULL,
+a_ref_1 char(32) DEFAULT NULL,
+b_str_31 varchar(32) DEFAULT NULL,
+b_str_32 varchar(255) DEFAULT NULL,
+b_str_33 char(32) DEFAULT NULL,
+b_str_34 varchar(32) DEFAULT NULL,
+a_str_47 varchar(40) DEFAULT NULL,
+b_str_36 varchar(255) DEFAULT NULL,
+a_str_46 varchar(40) DEFAULT NULL,
+a_str_45 varchar(255) DEFAULT NULL,
+b_str_38 varchar(32) DEFAULT NULL,
+b_str_39 char(32) DEFAULT NULL,
+b_str_40 varchar(32) DEFAULT NULL,
+a_str_41 varchar(255) DEFAULT NULL,
+b_str_41 varchar(32) DEFAULT NULL,
+PRIMARY KEY (b_str_26),
+UNIQUE KEY a_str_47 (a_str_47),
+UNIQUE KEY a_str_49 (a_str_49),
+UNIQUE KEY a_str_33 (a_str_33),
+UNIQUE KEY a_str_46 (a_str_46),
+UNIQUE KEY a_str_48 (a_str_48),
+KEY b_str_18 (b_str_18),
+KEY a_str_26 (a_str_26),
+KEY b_str_27 (b_str_27,b_str_19),
+KEY b_str_41 (b_str_41),
+KEY b_str_15 (b_str_15),
+KEY a_str_20 (a_str_20),
+KEY b_str_17 (b_str_17),
+KEY b_str_40 (b_str_40),
+KEY b_str_24 (b_str_24),
+KEY b_str_10 (b_str_10),
+KEY b_str_16 (b_str_16),
+KEY b_str_29 (b_str_29),
+KEY a_str_41 (a_str_41),
+KEY b_str_7 (b_str_7),
+KEY a_str_45 (a_str_45),
+KEY a_str_28 (a_str_28),
+KEY a_str_37 (a_str_37),
+KEY b_str_6 (b_str_6),
+KEY a_ref_6 (a_ref_6),
+KEY b_str_34 (b_str_34),
+KEY b_str_38 (b_str_38),
+KEY a_ref_10 (a_ref_10),
+KEY b_str_21 (b_str_21),
+KEY b_str_23 (b_str_23,b_str_19),
+KEY b_str_33 (b_str_33),
+KEY a_ref_12 (a_ref_12),
+KEY a_str_18 (a_str_18(255)),
+KEY a_str_39 (a_str_39),
+KEY a_str_27 (a_str_27),
+KEY a_str_25 (a_str_25),
+KEY b_str_9 (b_str_9),
+KEY a_str_23 (a_str_23),
+KEY b_str_8 (b_str_8),
+KEY a_str_21 (a_str_21),
+KEY b_str_3 (b_str_3),
+KEY b_str_30 (b_str_30),
+KEY b_str_12 (b_str_12),
+KEY b_str_25 (b_str_25),
+KEY b_str_13 (b_str_13),
+KEY a_str_38 (a_str_38),
+KEY a_str_13 (a_str_13(255)),
+KEY a_str_36 (a_str_36),
+KEY b_str_28 (b_str_28),
+KEY b_str_19 (b_str_19),
+KEY b_str_11 (b_str_11),
+KEY a_ref_1 (a_ref_1),
+KEY b_str_20 (b_str_20),
+KEY b_str_14 (b_str_14),
+KEY a_ref_3 (a_ref_3),
+KEY b_str_39 (b_str_39),
+KEY b_str_32 (b_str_32),
+KEY a_str_6 (a_str_6),
+KEY b_str_5 (b_str_5),
+KEY b_str_31 (b_str_31),
+KEY a_ref_11 (a_ref_11)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
+BEGIN;
+INSERT INTO test_tab (b_str_26, a_str_13, a_str_18) VALUES
+('a', REPEAT('f',4031), REPEAT('g', 4031));
+UPDATE test_tab SET a_str_13=REPEAT('h',4032), a_str_18=REPEAT('i',4032);
+SELECT 'Reducing length to 4030';
+Reducing length to 4030
+Reducing length to 4030
+UPDATE test_tab SET a_str_13=REPEAT('j',4030), a_str_18=REPEAT('k',4030);
+UPDATE test_tab SET a_str_13=REPEAT('l',4031), a_str_18=REPEAT('m',4031);
+ROLLBACK;
+SELECT COUNT(*) FROM test_tab;
+COUNT(*)
+0
+CHECK TABLE test_tab;
+Table Op Msg_type Msg_text
+test.test_tab check status OK
+DROP TABLE test_tab;
diff --git a/mysql-test/suite/innodb/t/innodb-index.test b/mysql-test/suite/innodb/t/innodb-index.test
index cea9055b873..a9829b4f500 100644
--- a/mysql-test/suite/innodb/t/innodb-index.test
+++ b/mysql-test/suite/innodb/t/innodb-index.test
@@ -532,9 +532,10 @@ PRIMARY KEY (b(10), a), INDEX (c(767)), INDEX(b(767))
INSERT INTO bug12547647 VALUES (5,repeat('khdfo5AlOq',1900),repeat('g',7751));
COMMIT;
+BEGIN;
# The following used to cause infinite undo log allocation.
---error ER_UNDO_RECORD_TOO_BIG
UPDATE bug12547647 SET c = REPEAT('b',16928);
+ROLLBACK;
DROP TABLE bug12547647;
eval set global innodb_file_per_table=$per_table;
diff --git a/mysql-test/suite/innodb/t/undo_log.test b/mysql-test/suite/innodb/t/undo_log.test
new file mode 100644
index 00000000000..c1a98793d91
--- /dev/null
+++ b/mysql-test/suite/innodb/t/undo_log.test
@@ -0,0 +1,139 @@
+--source include/have_innodb.inc
+CREATE TABLE test_tab (
+a_str_18 mediumtext,
+b_str_3 varchar(32) DEFAULT NULL,
+a_str_13 mediumtext,
+b_str_5 varchar(40) DEFAULT NULL,
+b_str_6 varchar(50) DEFAULT NULL,
+b_str_7 char(32) DEFAULT NULL,
+b_str_8 varchar(32) DEFAULT NULL,
+b_str_9 varchar(255) DEFAULT NULL,
+a_str_28 char(255) DEFAULT NULL,
+a_str_27 varchar(255) DEFAULT NULL,
+b_str_10 varchar(32) DEFAULT NULL,
+a_str_26 varchar(255) DEFAULT NULL,
+a_str_6 varchar(50) DEFAULT NULL,
+b_str_11 varchar(32) DEFAULT NULL,
+b_str_12 varchar(255) DEFAULT NULL,
+b_str_13 char(32) DEFAULT NULL,
+b_str_14 varchar(32) DEFAULT NULL,
+b_str_15 char(32) DEFAULT NULL,
+b_str_16 char(32) DEFAULT NULL,
+b_str_17 varchar(32) DEFAULT NULL,
+b_str_18 varchar(32) DEFAULT NULL,
+a_str_25 varchar(40) DEFAULT NULL,
+b_str_19 varchar(255) DEFAULT NULL,
+a_str_23 varchar(40) DEFAULT NULL,
+b_str_20 varchar(32) DEFAULT NULL,
+a_str_21 varchar(255) DEFAULT NULL,
+a_str_20 varchar(255) DEFAULT NULL,
+a_str_39 varchar(255) DEFAULT NULL,
+a_str_38 varchar(255) DEFAULT NULL,
+a_str_37 varchar(255) DEFAULT NULL,
+b_str_21 char(32) DEFAULT NULL,
+b_str_23 varchar(80) DEFAULT NULL,
+b_str_24 varchar(32) DEFAULT NULL,
+b_str_25 varchar(32) DEFAULT NULL,
+b_str_26 char(32) NOT NULL DEFAULT '',
+b_str_27 varchar(255) DEFAULT NULL,
+a_str_36 varchar(255) DEFAULT NULL,
+a_str_33 varchar(100) DEFAULT NULL,
+a_ref_10 char(32) DEFAULT NULL,
+b_str_28 char(32) DEFAULT NULL,
+b_str_29 char(32) DEFAULT NULL,
+a_ref_6 char(32) DEFAULT NULL,
+a_ref_12 varchar(32) DEFAULT NULL,
+a_ref_11 varchar(32) DEFAULT NULL,
+a_str_49 varchar(40) DEFAULT NULL,
+b_str_30 varchar(32) DEFAULT NULL,
+a_ref_3 varchar(32) DEFAULT NULL,
+a_str_48 varchar(40) DEFAULT NULL,
+a_ref_1 char(32) DEFAULT NULL,
+b_str_31 varchar(32) DEFAULT NULL,
+b_str_32 varchar(255) DEFAULT NULL,
+b_str_33 char(32) DEFAULT NULL,
+b_str_34 varchar(32) DEFAULT NULL,
+a_str_47 varchar(40) DEFAULT NULL,
+b_str_36 varchar(255) DEFAULT NULL,
+a_str_46 varchar(40) DEFAULT NULL,
+a_str_45 varchar(255) DEFAULT NULL,
+b_str_38 varchar(32) DEFAULT NULL,
+b_str_39 char(32) DEFAULT NULL,
+b_str_40 varchar(32) DEFAULT NULL,
+a_str_41 varchar(255) DEFAULT NULL,
+b_str_41 varchar(32) DEFAULT NULL,
+PRIMARY KEY (b_str_26),
+UNIQUE KEY a_str_47 (a_str_47),
+UNIQUE KEY a_str_49 (a_str_49),
+UNIQUE KEY a_str_33 (a_str_33),
+UNIQUE KEY a_str_46 (a_str_46),
+UNIQUE KEY a_str_48 (a_str_48),
+KEY b_str_18 (b_str_18),
+KEY a_str_26 (a_str_26),
+KEY b_str_27 (b_str_27,b_str_19),
+KEY b_str_41 (b_str_41),
+KEY b_str_15 (b_str_15),
+KEY a_str_20 (a_str_20),
+KEY b_str_17 (b_str_17),
+KEY b_str_40 (b_str_40),
+KEY b_str_24 (b_str_24),
+KEY b_str_10 (b_str_10),
+KEY b_str_16 (b_str_16),
+KEY b_str_29 (b_str_29),
+KEY a_str_41 (a_str_41),
+KEY b_str_7 (b_str_7),
+KEY a_str_45 (a_str_45),
+KEY a_str_28 (a_str_28),
+KEY a_str_37 (a_str_37),
+KEY b_str_6 (b_str_6),
+KEY a_ref_6 (a_ref_6),
+KEY b_str_34 (b_str_34),
+KEY b_str_38 (b_str_38),
+KEY a_ref_10 (a_ref_10),
+KEY b_str_21 (b_str_21),
+KEY b_str_23 (b_str_23,b_str_19),
+KEY b_str_33 (b_str_33),
+KEY a_ref_12 (a_ref_12),
+KEY a_str_18 (a_str_18(255)),
+KEY a_str_39 (a_str_39),
+KEY a_str_27 (a_str_27),
+KEY a_str_25 (a_str_25),
+KEY b_str_9 (b_str_9),
+KEY a_str_23 (a_str_23),
+KEY b_str_8 (b_str_8),
+KEY a_str_21 (a_str_21),
+KEY b_str_3 (b_str_3),
+KEY b_str_30 (b_str_30),
+KEY b_str_12 (b_str_12),
+KEY b_str_25 (b_str_25),
+KEY b_str_13 (b_str_13),
+KEY a_str_38 (a_str_38),
+KEY a_str_13 (a_str_13(255)),
+KEY a_str_36 (a_str_36),
+KEY b_str_28 (b_str_28),
+KEY b_str_19 (b_str_19),
+KEY b_str_11 (b_str_11),
+KEY a_ref_1 (a_ref_1),
+KEY b_str_20 (b_str_20),
+KEY b_str_14 (b_str_14),
+KEY a_ref_3 (a_ref_3),
+KEY b_str_39 (b_str_39),
+KEY b_str_32 (b_str_32),
+KEY a_str_6 (a_str_6),
+KEY b_str_5 (b_str_5),
+KEY b_str_31 (b_str_31),
+KEY a_ref_11 (a_ref_11)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
+
+BEGIN;
+INSERT INTO test_tab (b_str_26, a_str_13, a_str_18) VALUES
+('a', REPEAT('f',4031), REPEAT('g', 4031));
+
+UPDATE test_tab SET a_str_13=REPEAT('h',4032), a_str_18=REPEAT('i',4032);
+SELECT 'Reducing length to 4030';
+UPDATE test_tab SET a_str_13=REPEAT('j',4030), a_str_18=REPEAT('k',4030);
+UPDATE test_tab SET a_str_13=REPEAT('l',4031), a_str_18=REPEAT('m',4031);
+ROLLBACK;
+SELECT COUNT(*) FROM test_tab;
+CHECK TABLE test_tab;
+DROP TABLE test_tab;
diff --git a/storage/innobase/trx/trx0rec.c b/storage/innobase/trx/trx0rec.c
index f80f58493aa..cc209bbc213 100644
--- a/storage/innobase/trx/trx0rec.c
+++ b/storage/innobase/trx/trx0rec.c
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -773,7 +774,25 @@ trx_undo_page_report_modify(
const dict_col_t* col
= dict_table_get_nth_col(table, col_no);
- if (col->ord_part) {
+ if (!col->ord_part) {
+ continue;
+ }
+
+ if (update) {
+ for (i = 0; i < update->n_fields; i++) {
+ const dict_field_t* f
+ = dict_index_get_nth_field(
+ index,
+ upd_get_nth_field(
+ update, i)
+ ->field_no);
+ if (f->col == col) {
+ goto already_logged;
+ }
+ }
+ }
+
+ if (TRUE) {
ulint pos;
/* Write field number to undo log */
@@ -823,6 +842,9 @@ trx_undo_page_report_modify(
ptr += flen;
}
}
+
+already_logged:
+ continue;
}
mach_write_to_2(old_ptr, ptr - old_ptr);
diff --git a/storage/xtradb/trx/trx0rec.c b/storage/xtradb/trx/trx0rec.c
index ef42152aeb7..fc38f81c594 100644
--- a/storage/xtradb/trx/trx0rec.c
+++ b/storage/xtradb/trx/trx0rec.c
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -786,7 +787,25 @@ trx_undo_page_report_modify(
const dict_col_t* col
= dict_table_get_nth_col(table, col_no);
- if (col->ord_part) {
+ if (!col->ord_part) {
+ continue;
+ }
+
+ if (update) {
+ for (i = 0; i < update->n_fields; i++) {
+ const dict_field_t* f
+ = dict_index_get_nth_field(
+ index,
+ upd_get_nth_field(
+ update, i)
+ ->field_no);
+ if (f->col == col) {
+ goto already_logged;
+ }
+ }
+ }
+
+ if (TRUE) {
ulint pos;
/* Write field number to undo log */
@@ -836,6 +855,9 @@ trx_undo_page_report_modify(
ptr += flen;
}
}
+
+already_logged:
+ continue;
}
mach_write_to_2(old_ptr, ptr - old_ptr);