summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2020-05-28 22:40:27 +0300
committerMonty <monty@mariadb.org>2020-05-29 22:47:37 +0300
commitdf4ab26a6bbbebd4b253b4179c225feb33d6d40f (patch)
treea1bcb88b91321070de4cf7aad2be40d6b16b66f8
parent39dc46166297504f05ade40ae03f27adc0345b2f (diff)
downloadmariadb-git-df4ab26a6bbbebd4b253b4179c225feb33d6d40f.tar.gz
SHOW TABLE STATUS now shows if an Aria table is transactional or not
This change also affects information_schema.tables The create table option "transactional=0 | 1" is now always shown for storage engines that supports both transactional/crash safe tables and non transactional tables. Before this patch the transactional=... option was only shown if the user specified transactional=... in the CREATE TABLE or ALTER TABLE statement. The reason for the change was to be able to make it easy to know if an Aria table is transactional or not.
-rw-r--r--mysql-test/suite/maria/maria.result20
-rw-r--r--mysql-test/suite/maria/max_length.result8
-rw-r--r--sql/handler.h11
-rw-r--r--sql/sql_show.cc21
-rw-r--r--storage/maria/ha_maria.cc6
5 files changed, 46 insertions, 20 deletions
diff --git a/mysql-test/suite/maria/maria.result b/mysql-test/suite/maria/maria.result
index eaa4fa568a5..9f4835a63a2 100644
--- a/mysql-test/suite/maria/maria.result
+++ b/mysql-test/suite/maria/maria.result
@@ -935,7 +935,7 @@ _id
DELETE FROM t1 WHERE _id < 8;
SELECT table_name, engine, version, row_format, Table_rows, Data_free, create_options, table_comment FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test' and TABLE_NAME='t1';
table_name engine version row_format Table_rows Data_free create_options table_comment
-t1 Aria 10 Dynamic 2 140 row_format=DYNAMIC
+t1 Aria 10 Dynamic 2 140 row_format=DYNAMIC transactional=0
CHECK TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 check status OK
@@ -947,7 +947,7 @@ Table Op Msg_type Msg_text
test.t1 check status OK
SELECT table_name, engine, version, row_format, Table_rows, Data_free, create_options, table_comment FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test' and TABLE_NAME='t1';
table_name engine version row_format Table_rows Data_free create_options table_comment
-t1 Aria 10 Dynamic 2 0 row_format=DYNAMIC
+t1 Aria 10 Dynamic 2 0 row_format=DYNAMIC transactional=0
SELECT _id FROM t1;
_id
8
@@ -994,7 +994,7 @@ _id
DELETE FROM t1 WHERE _id < 8;
SELECT table_name, engine, version, row_format, Table_rows, Data_free, create_options, table_comment FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test' and TABLE_NAME='t1';
table_name engine version row_format Table_rows Data_free create_options table_comment
-t1 Aria 10 Dynamic 2 140 row_format=DYNAMIC
+t1 Aria 10 Dynamic 2 140 row_format=DYNAMIC transactional=0
CHECK TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 check status OK
@@ -1006,7 +1006,7 @@ Table Op Msg_type Msg_text
test.t1 check status OK
SELECT table_name, engine, version, row_format, Table_rows, Data_free, create_options, table_comment FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test' and TABLE_NAME='t1';
table_name engine version row_format Table_rows Data_free create_options table_comment
-t1 Aria 10 Dynamic 2 140 row_format=DYNAMIC
+t1 Aria 10 Dynamic 2 140 row_format=DYNAMIC transactional=0
SELECT _id FROM t1;
_id
8
@@ -1773,27 +1773,27 @@ DROP TABLE t1;
CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2));
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
-t1 Aria 10 Page 0 # # # 8192 # # # # # # # # N
+t1 Aria 10 Page 0 # # # 8192 # # # # # # # transactional=1 # N
INSERT INTO t1 VALUES (1,1);
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
-t1 Aria 10 Page 1 # # # 24576 # # # # # # # # N
+t1 Aria 10 Page 1 # # # 24576 # # # # # # # transactional=1 # N
ALTER TABLE t1 DISABLE KEYS;
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
-t1 Aria 10 Page 1 # # # 24576 # # # # # # # # N
+t1 Aria 10 Page 1 # # # 24576 # # # # # # # transactional=1 # N
ALTER TABLE t1 ENABLE KEYS;
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
-t1 Aria 10 Page 1 # # # 24576 # # # # # # # # N
+t1 Aria 10 Page 1 # # # 24576 # # # # # # # transactional=1 # N
ALTER TABLE t1 DISABLE KEYS;
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
-t1 Aria 10 Page 1 # # # 24576 # # # # # # # # N
+t1 Aria 10 Page 1 # # # 24576 # # # # # # # transactional=1 # N
ALTER TABLE t1 ENABLE KEYS;
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
-t1 Aria 10 Page 1 # # # 24576 # # # # # # # # N
+t1 Aria 10 Page 1 # # # 24576 # # # # # # # transactional=1 # N
# Enable keys with parallel repair
SET @@aria_repair_threads=2;
ALTER TABLE t1 DISABLE KEYS;
diff --git a/mysql-test/suite/maria/max_length.result b/mysql-test/suite/maria/max_length.result
index b4ca61392cc..1508ac25cb3 100644
--- a/mysql-test/suite/maria/max_length.result
+++ b/mysql-test/suite/maria/max_length.result
@@ -24,8 +24,8 @@ t2 CREATE TABLE `t2` (
lock tables t1 write,t2 write;
show table status like "t_";
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
-t1 Aria 10 Page 0 0 8192 268320768 8192 0 1 # # # latin1_swedish_ci NULL max_rows=2 row_format=PAGE 536862720 N
-t2 Aria 10 Page 0 0 8192 17592186011648 8192 0 1 # # # latin1_swedish_ci NULL max_rows=20000000 row_format=PAGE 137438945280 N
+t1 Aria 10 Page 0 0 8192 268320768 8192 0 1 # # # latin1_swedish_ci NULL max_rows=2 row_format=PAGE transactional=1 536862720 N
+t2 Aria 10 Page 0 0 8192 17592186011648 8192 0 1 # # # latin1_swedish_ci NULL max_rows=20000000 row_format=PAGE transactional=1 137438945280 N
insert into t1 values(null, repeat("ab",100),repeat("def",1000));
insert into t1 values(null, repeat("de",200),repeat("ghi",2000));
insert into t1 values(null, repeat("fe",300),repeat("ghi",3000));
@@ -177,9 +177,9 @@ test.t1 check warning Datafile is almost full, 268320768 of 268320768 used
test.t1 check status OK
show table status like "t1";
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
-t1 Aria 10 Page 6189940 43 268320768 268320768 8192 0 NULL # # # latin1_swedish_ci NULL max_rows=10 row_format=PAGE 137438945280 N
+t1 Aria 10 Page 6189940 43 268320768 268320768 8192 0 NULL # # # latin1_swedish_ci NULL max_rows=10 row_format=PAGE transactional=1 137438945280 N
create index seq on t1(c1);
show table status like "t1";
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
-t1 Aria 10 Page 6189940 43 268320768 268320768 49750016 0 NULL # # # latin1_swedish_ci NULL max_rows=10 page_checksum=1 row_format=PAGE 536862720 N
+t1 Aria 10 Page 6189940 43 268320768 268320768 49750016 0 NULL # # # latin1_swedish_ci NULL max_rows=10 page_checksum=1 row_format=PAGE transactional=1 536862720 N
drop table t1;
diff --git a/sql/handler.h b/sql/handler.h
index 6a283b2dac3..6eaaf0f3256 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -340,8 +340,9 @@ enum chf_create_flags {
#define HA_CAN_ONLINE_BACKUPS (1ULL << 56)
/* Support native hash index */
-#define HA_CAN_HASH_KEYS (1ULL << 58)
-#define HA_LAST_TABLE_FLAG HA_CAN_HASH_KEYS
+#define HA_CAN_HASH_KEYS (1ULL << 57)
+#define HA_CRASH_SAFE (1ULL << 58)
+#define HA_LAST_TABLE_FLAG HA_CRASH_SAFE
/* bits in index_flags(index_number) for what you can do with index */
#define HA_READ_NEXT 1 /* TODO really use this flag */
@@ -1773,6 +1774,12 @@ handlerton *ha_default_tmp_handlerton(THD *thd);
*/
#define HTON_NO_ROLLBACK (1 << 16)
+/*
+ This storage engine can support both transactional and non transactional
+ tables
+*/
+#define HTON_TRANSACTIONAL_AND_NON_TRANSACTIONAL (1 << 17)
+
class Ha_trx_info;
struct THD_TRANS
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index db5b4d1c5fd..62c93f6b61c 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -5504,10 +5504,25 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
str.qs_append(STRING_WITH_LEN(" partitioned"));
#endif
- if (share->transactional != HA_CHOICE_UNDEF)
- {
+ /*
+ Write transactional=0|1 for tables where the user has specified the
+ option or for tables that supports both transactional and non
+ transactional tables
+ */
+ if (share->transactional != HA_CHOICE_UNDEF ||
+ (share->db_type() &&
+ share->db_type()->flags & HTON_TRANSACTIONAL_AND_NON_TRANSACTIONAL &&
+ file))
+ {
+ uint choice= share->transactional;
+ if (choice == HA_CHOICE_UNDEF)
+ choice= ((file->ha_table_flags() &
+ (HA_NO_TRANSACTIONS | HA_CRASH_SAFE)) ==
+ HA_NO_TRANSACTIONS ?
+ HA_CHOICE_NO : HA_CHOICE_YES);
+
str.qs_append(STRING_WITH_LEN(" transactional="));
- str.qs_append(ha_choice_values[(uint) share->transactional]);
+ str.qs_append(ha_choice_values[choice]);
}
append_create_options(thd, &str, share->option_list, false, 0);
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc
index 9e7fad34ab8..d2cbdc78c58 100644
--- a/storage/maria/ha_maria.cc
+++ b/storage/maria/ha_maria.cc
@@ -1187,6 +1187,9 @@ int ha_maria::open(const char *name, int mode, uint test_if_locked)
*/
int_table_flags|= HA_CAN_INSERT_DELAYED | HA_NO_TRANSACTIONS;
}
+ else
+ int_table_flags|= HA_CRASH_SAFE;
+
if (file->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD))
int_table_flags |= HA_HAS_NEW_CHECKSUM;
@@ -3728,7 +3731,8 @@ static int ha_maria_init(void *p)
/* TODO: decide if we support Maria being used for log tables */
maria_hton->flags= (HTON_CAN_RECREATE | HTON_SUPPORT_LOG_TABLES |
- HTON_NO_ROLLBACK);
+ HTON_NO_ROLLBACK |
+ HTON_TRANSACTIONAL_AND_NON_TRANSACTIONAL);
bzero(maria_log_pagecache, sizeof(*maria_log_pagecache));
maria_tmpdir= &mysql_tmpdir_list; /* For REDO */