diff --git a/mysql-test/main/create.result b/mysql-test/main/create.result index 49e60dd9bcc..cec7452affd 100644 --- a/mysql-test/main/create.result +++ b/mysql-test/main/create.result @@ -1221,7 +1221,7 @@ drop table if exists t1,t2,t3; # Fix modified for MariaDB: we support this syntax create table t1 (a int) transactional=0; Warnings: -Warning 1478 Table storage engine 'MyISAM' does not support the create option 'TRANSACTIONAL=0' +Warning 1911 Unknown option 'transactional' create table t2 (a int) page_checksum=1; create table t3 (a int) row_format=page; drop table t1,t2,t3; @@ -2019,7 +2019,7 @@ drop table t1; # MDEV-18428 Memory: If transactional=0 is specified in CREATE TABLE, it is not possible to ALTER TABLE # create table t1 (c int(10) unsigned) engine=memory transactional=0; -ERROR HY000: Table storage engine 'MEMORY' does not support the create option 'TRANSACTIONAL=0' +ERROR HY000: Unknown option 'transactional' # # End of 10.2 tests # diff --git a/mysql-test/main/create.test b/mysql-test/main/create.test index db8638ebe54..e9470edefab 100644 --- a/mysql-test/main/create.test +++ b/mysql-test/main/create.test @@ -1879,7 +1879,7 @@ drop table t1; --echo # --echo # MDEV-18428 Memory: If transactional=0 is specified in CREATE TABLE, it is not possible to ALTER TABLE --echo # ---error ER_ILLEGAL_HA_CREATE_OPTION +--error ER_UNKNOWN_OPTION create table t1 (c int(10) unsigned) engine=memory transactional=0; --echo # diff --git a/mysql-test/main/myisam.result b/mysql-test/main/myisam.result index e1e1a18dac2..9f907e6df1e 100644 --- a/mysql-test/main/myisam.result +++ b/mysql-test/main/myisam.result @@ -2415,13 +2415,13 @@ DROP TABLE t1; set statement sql_mode='' for create table t1 (n int not null, c char(1)) transactional=1; Warnings: -Warning 1478 Table storage engine 'MyISAM' does not support the create option 'TRANSACTIONAL=1' +Warning 1911 Unknown option 'transactional' show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `n` int(11) NOT NULL, `c` char(1) DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci TRANSACTIONAL=1 +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci /* TRANSACTIONAL=1 */ drop table t1; CREATE TABLE t1 (line LINESTRING NOT NULL) engine=myisam; INSERT INTO t1 VALUES (GeomFromText("LINESTRING(0 0)")); diff --git a/mysql-test/main/table_options.result b/mysql-test/main/table_options.result index 60f25c96a0d..917c4716610 100644 --- a/mysql-test/main/table_options.result +++ b/mysql-test/main/table_options.result @@ -1,4 +1,3 @@ -drop table if exists t1; SET @OLD_SQL_MODE=@@SQL_MODE; SET SQL_MODE='IGNORE_BAD_TABLE_OPTIONS'; create table t1 (a int fkey=vvv, key akey (a) dff=vvv) tkey1='1v1'; @@ -180,3 +179,103 @@ SET SQL_MODE=''; create table t1 (a int fkey=vvv, key akey (a) dff=vvv) tkey1=1v1; ERROR HY000: Unknown option 'fkey' SET @@SQL_MODE=@OLD_SQL_MODE; +# +# End of 5.5 tests +# +# +# MDEV-31822 ALTER TABLE ENGINE=x started failing instead of producing warning on unsupported TRANSACTIONAL=1 +# +create table t0 (a int) transactional=0 engine=aria; +create table t1 (a int) transactional=1 engine=aria; +create table t2 (a int) transactional=default engine=aria; +show create table t0; +Table Create Table +t0 CREATE TABLE `t0` ( + `a` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 TRANSACTIONAL=0 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 TRANSACTIONAL=1 +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +alter table t0 engine=myisam; +alter table t1 engine=myisam; +alter table t2 engine=myisam; +show create table t0; +Table Create Table +t0 CREATE TABLE `t0` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 /* TRANSACTIONAL=0 */ +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 /* TRANSACTIONAL=1 */ +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 +alter table t0 engine=myisam transactional=0; +ERROR HY000: Unknown option 'transactional' +alter table t1 engine=myisam transactional=1; +ERROR HY000: Unknown option 'transactional' +alter table t2 engine=myisam transactional=default; +ERROR HY000: Unknown option 'transactional' +set sql_mode=IGNORE_BAD_TABLE_OPTIONS; +alter table t0 engine=myisam transactional=0; +Warnings: +Warning 1911 Unknown option 'transactional' +alter table t1 engine=myisam transactional=1; +Warnings: +Warning 1911 Unknown option 'transactional' +alter table t2 engine=myisam transactional=default; +Warnings: +Warning 1911 Unknown option 'transactional' +show create table t0; +Table Create Table +t0 CREATE TABLE `t0` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci TRANSACTIONAL=0 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci TRANSACTIONAL=1 +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +drop table t0,t1,t2; +create table t1 (a int) foo=bar; +Warnings: +Warning 1911 Unknown option 'foo' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci `foo`=bar +set sql_mode=default; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci /* `foo`=bar */ +alter table t1 engine=aria bar=foo; +ERROR HY000: Unknown option 'bar' +alter table t1 engine=aria; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 /* `foo`=bar */ +drop table t1; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/table_options.test b/mysql-test/main/table_options.test index 533e6829c00..0605ce9ee0d 100644 --- a/mysql-test/main/table_options.test +++ b/mysql-test/main/table_options.test @@ -1,7 +1,3 @@ ---disable_warnings -drop table if exists t1; ---enable_warnings - SET @OLD_SQL_MODE=@@SQL_MODE; SET SQL_MODE='IGNORE_BAD_TABLE_OPTIONS'; @@ -66,3 +62,52 @@ SET SQL_MODE=''; create table t1 (a int fkey=vvv, key akey (a) dff=vvv) tkey1=1v1; SET @@SQL_MODE=@OLD_SQL_MODE; + +--echo # +--echo # End of 5.5 tests +--echo # + +--echo # +--echo # MDEV-31822 ALTER TABLE ENGINE=x started failing instead of producing warning on unsupported TRANSACTIONAL=1 +--echo # +create table t0 (a int) transactional=0 engine=aria; +create table t1 (a int) transactional=1 engine=aria; +create table t2 (a int) transactional=default engine=aria; +show create table t0; +show create table t1; +show create table t2; +alter table t0 engine=myisam; +alter table t1 engine=myisam; +alter table t2 engine=myisam; +show create table t0; +show create table t1; +show create table t2; +--error ER_UNKNOWN_OPTION +alter table t0 engine=myisam transactional=0; +--error ER_UNKNOWN_OPTION +alter table t1 engine=myisam transactional=1; +--error ER_UNKNOWN_OPTION +alter table t2 engine=myisam transactional=default; +set sql_mode=IGNORE_BAD_TABLE_OPTIONS; +alter table t0 engine=myisam transactional=0; +alter table t1 engine=myisam transactional=1; +alter table t2 engine=myisam transactional=default; +show create table t0; +show create table t1; +show create table t2; +drop table t0,t1,t2; + +# same behavior for other unknown options: +create table t1 (a int) foo=bar; +show create table t1; +set sql_mode=default; +show create table t1; +--error ER_UNKNOWN_OPTION +alter table t1 engine=aria bar=foo; +alter table t1 engine=aria; +show create table t1; +drop table t1; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/suite/maria/maria3.result b/mysql-test/suite/maria/maria3.result index a2fb1c8cb1d..c5b49a9d259 100644 --- a/mysql-test/suite/maria/maria3.result +++ b/mysql-test/suite/maria/maria3.result @@ -521,8 +521,6 @@ t1 CREATE TABLE `t1` ( drop table t1; create table t1 (n int not null, c char(1)) engine=aria transactional=1; alter table t1 engine=myisam; -Warnings: -Warning 1478 Table storage engine 'MyISAM' does not support the create option 'TRANSACTIONAL=1' alter table t1 engine=aria; show create table t1; Table Create Table @@ -533,7 +531,7 @@ t1 CREATE TABLE `t1` ( drop table t1; create table t1 (n int not null, c char(1)) engine=myisam transactional=1; Warnings: -Warning 1478 Table storage engine 'MyISAM' does not support the create option 'TRANSACTIONAL=1' +Warning 1911 Unknown option 'transactional' alter table t1 engine=aria; show create table t1; Table Create Table diff --git a/mysql-test/suite/plugins/r/audit_null_debug.result b/mysql-test/suite/plugins/r/audit_null_debug.result index 69a1fa5a866..c916b27f95e 100644 --- a/mysql-test/suite/plugins/r/audit_null_debug.result +++ b/mysql-test/suite/plugins/r/audit_null_debug.result @@ -1,9 +1,4 @@ -set @old_sql_mode= @@sql_mode; -set @@sql_mode= ''; alter table mysql.plugin engine=myisam; -Warnings: -Warning 1478 Table storage engine 'MyISAM' does not support the create option 'TRANSACTIONAL=1' -set @@sql_mode= @old_sql_mode; set @old_dbug=@@debug_dbug; call mtr.add_suppression("Index for table.*mysql.plugin.MYI"); call mtr.add_suppression("Index for table 'plugin' is corrupt; try to repair it"); diff --git a/mysql-test/suite/plugins/t/audit_null_debug.test b/mysql-test/suite/plugins/t/audit_null_debug.test index ed1a59be033..52c50f13b74 100644 --- a/mysql-test/suite/plugins/t/audit_null_debug.test +++ b/mysql-test/suite/plugins/t/audit_null_debug.test @@ -5,10 +5,7 @@ if (!$ADT_NULL_SO) { skip No NULL_AUDIT plugin; } -set @old_sql_mode= @@sql_mode; -set @@sql_mode= ''; alter table mysql.plugin engine=myisam; -set @@sql_mode= @old_sql_mode; set @old_dbug=@@debug_dbug; call mtr.add_suppression("Index for table.*mysql.plugin.MYI"); diff --git a/sql/handler.h b/sql/handler.h index e28cb871fbd..67245850d62 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -3548,7 +3548,7 @@ public: - How things are tracked in trx and in add_changed_table(). - If we can combine several statements under one commit in the binary log. */ - bool has_transactions() + bool has_transactions() const { return ((ha_table_flags() & (HA_NO_TRANSACTIONS | HA_PERSISTENT_TABLE)) == 0); @@ -3559,24 +3559,33 @@ public: we don't have to write failed statements to the log as they can be rolled back. */ - bool has_transactions_and_rollback() + bool has_transactions_and_rollback() const { return has_transactions() && has_rollback(); } /* True if the underlaying table support transactions and rollback */ - bool has_transaction_manager() + bool has_transaction_manager() const { return ((ha_table_flags() & HA_NO_TRANSACTIONS) == 0 && has_rollback()); } + /* + True if the underlaying table support TRANSACTIONAL table option + */ + bool has_transactional_option() const + { + extern handlerton *maria_hton; + return partition_ht() == maria_hton || has_transaction_manager(); + } + /* True if table has rollback. Used to check if an update on the table can be killed fast. */ - bool has_rollback() + bool has_rollback() const { return ((ht->flags & HTON_NO_ROLLBACK) == 0); } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 1f1e7d67a2a..a194068d2b0 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1956,8 +1956,13 @@ static void add_table_options(THD *thd, TABLE *table, } if (share->transactional != HA_CHOICE_UNDEF) { + bool do_comment= !table->file->has_transactional_option() && check_options; + if (do_comment) + packet->append(STRING_WITH_LEN(" /*")); packet->append(STRING_WITH_LEN(" TRANSACTIONAL=")); packet->append(ha_choice_values[(uint) share->transactional], 1); + if (do_comment) + packet->append(STRING_WITH_LEN(" */")); } if (share->table_type == TABLE_TYPE_SEQUENCE) packet->append(STRING_WITH_LEN(" SEQUENCE=1")); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index f1eec6b22a6..8366e571f26 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4577,15 +4577,10 @@ without_overlaps_err: } /* Give warnings for not supported table options */ - extern handlerton *maria_hton; - if (file->partition_ht() != maria_hton && create_info->transactional && - !file->has_transaction_manager()) - push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, - ER_ILLEGAL_HA_CREATE_OPTION, - ER_THD(thd, ER_ILLEGAL_HA_CREATE_OPTION), - file->engine_name()->str, - create_info->transactional == HA_CHOICE_YES - ? "TRANSACTIONAL=1" : "TRANSACTIONAL=0"); + if (create_info->used_fields & HA_CREATE_USED_TRANSACTIONAL && + !file->has_transactional_option()) + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_OPTION, + ER_THD(thd, ER_UNKNOWN_OPTION), "transactional"); if (parse_option_list(thd, file->partition_ht(), &create_info->option_struct, &create_info->option_list,