Skip to content

Commit

Permalink
SHOW TABLE STATUS now shows if an Aria table is transactional or not
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
montywi committed May 29, 2020
1 parent 39dc461 commit df4ab26
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 20 deletions.
20 changes: 10 additions & 10 deletions mysql-test/suite/maria/maria.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions mysql-test/suite/maria/max_length.result
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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;
11 changes: 9 additions & 2 deletions sql/handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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
Expand Down
21 changes: 18 additions & 3 deletions sql/sql_show.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 5 additions & 1 deletion storage/maria/ha_maria.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 */

Expand Down

0 comments on commit df4ab26

Please sign in to comment.