From 0de2613e7aa22391760cb90a9c7338a9c085ecea Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 14 Oct 2024 15:12:02 +0300 Subject: [PATCH] Fixed that SHOW CREATE TABLE for sequences shows used table options --- mysql-test/suite/sql_sequence/create.result | 31 +++++++++++++++++++++ mysql-test/suite/sql_sequence/create.test | 20 +++++++++++++ sql/ha_sequence.h | 2 ++ sql/handler.h | 6 ++++ sql/sql_show.cc | 2 +- 5 files changed, 60 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/sql_sequence/create.result b/mysql-test/suite/sql_sequence/create.result index 61a0dfa7557..dff4dfaf3ec 100644 --- a/mysql-test/suite/sql_sequence/create.result +++ b/mysql-test/suite/sql_sequence/create.result @@ -724,3 +724,34 @@ ERROR HY000: Sequence 'test.s' table structure is invalid (Wrong number of colum # # End of 10.4 test # +# +# Ensure that SHOW CREATE TABLE shows used table options +# +SET @@innodb_compression_default=ON; +CREATE TABLE seq ( +`next_not_cached_value` bigint(21) NOT NULL, +`minimum_value` bigint(21) NOT NULL, +`maximum_value` bigint(21) NOT NULL, +`start_value` bigint(21) NOT NULL, +`increment` bigint(21) NOT NULL, +`cache_size` bigint(21) unsigned NOT NULL, +`cycle_option` tinyint(1) unsigned NOT NULL, +`cycle_count` bigint(21) NOT NULL +) engine=innodb,sequence=1; +show create sequence seq; +Table Create Table +seq CREATE SEQUENCE `seq` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB `PAGE_COMPRESSED`='ON' +show create table seq; +Table Create Table +seq CREATE TABLE `seq` ( + `next_not_cached_value` bigint(21) NOT NULL, + `minimum_value` bigint(21) NOT NULL, + `maximum_value` bigint(21) NOT NULL, + `start_value` bigint(21) NOT NULL, + `increment` bigint(21) NOT NULL, + `cache_size` bigint(21) unsigned NOT NULL, + `cycle_option` tinyint(1) unsigned NOT NULL, + `cycle_count` bigint(21) NOT NULL +) ENGINE=InnoDB SEQUENCE=1 `PAGE_COMPRESSED`='ON' +drop sequence seq; +SET @@innodb_compression_default=DEFAULT; diff --git a/mysql-test/suite/sql_sequence/create.test b/mysql-test/suite/sql_sequence/create.test index 4cece26de8e..625f3083487 100644 --- a/mysql-test/suite/sql_sequence/create.test +++ b/mysql-test/suite/sql_sequence/create.test @@ -565,3 +565,23 @@ create table s sequence=1 as select 1; --echo # --echo # End of 10.4 test --echo # + +--echo # +--echo # Ensure that SHOW CREATE TABLE shows used table options +--echo # + +SET @@innodb_compression_default=ON; +CREATE TABLE seq ( + `next_not_cached_value` bigint(21) NOT NULL, + `minimum_value` bigint(21) NOT NULL, + `maximum_value` bigint(21) NOT NULL, + `start_value` bigint(21) NOT NULL, + `increment` bigint(21) NOT NULL, + `cache_size` bigint(21) unsigned NOT NULL, + `cycle_option` tinyint(1) unsigned NOT NULL, + `cycle_count` bigint(21) NOT NULL +) engine=innodb,sequence=1; +show create sequence seq; +show create table seq; +drop sequence seq; +SET @@innodb_compression_default=DEFAULT; diff --git a/sql/ha_sequence.h b/sql/ha_sequence.h index c1810ac2351..24fcc6baa31 100644 --- a/sql/ha_sequence.h +++ b/sql/ha_sequence.h @@ -65,6 +65,8 @@ public: ha_sequence(handlerton *hton, TABLE_SHARE *share); ~ha_sequence(); + virtual handlerton *storage_ht() const override + { return file->ht; } /* virtual function that are re-implemented for sequence */ int open(const char *name, int mode, uint test_if_locked) override; diff --git a/sql/handler.h b/sql/handler.h index d204d9f1f9d..3d9db017a5b 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -4987,6 +4987,12 @@ public: /* XXX to be removed, see ha_partition::partition_ht() */ virtual handlerton *partition_ht() const { return ht; } + /* + Used with 'wrapper' engines, like SEQUENCE, to access to the + underlaying engine used for storage. + */ + virtual handlerton *storage_ht() const + { return ht; } inline int ha_write_tmp_row(uchar *buf); inline int ha_delete_tmp_row(uchar *buf); inline int ha_update_tmp_row(const uchar * old_data, uchar * new_data); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 9057ff8712f..e8b4bc5e447 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1838,7 +1838,7 @@ static void add_table_options(THD *thd, TABLE *table, hton= table->part_info->default_engine_type; else #endif - hton= table->file->ht; + hton= table->file->storage_ht(); bzero((char*) &create_info, sizeof(create_info)); /* Allow update_create_info to update row type, page checksums and options */