Commit df4ab26a authored by Monty's avatar Monty

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.
parent 39dc4616
...@@ -935,7 +935,7 @@ _id ...@@ -935,7 +935,7 @@ _id
DELETE FROM t1 WHERE _id < 8; 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'; 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 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; CHECK TABLE t1 EXTENDED;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 check status OK test.t1 check status OK
...@@ -947,7 +947,7 @@ Table Op Msg_type Msg_text ...@@ -947,7 +947,7 @@ Table Op Msg_type Msg_text
test.t1 check status OK 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'; 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 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; SELECT _id FROM t1;
_id _id
8 8
...@@ -994,7 +994,7 @@ _id ...@@ -994,7 +994,7 @@ _id
DELETE FROM t1 WHERE _id < 8; 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'; 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 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; CHECK TABLE t1 EXTENDED;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 check status OK test.t1 check status OK
...@@ -1006,7 +1006,7 @@ Table Op Msg_type Msg_text ...@@ -1006,7 +1006,7 @@ Table Op Msg_type Msg_text
test.t1 check status OK 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'; 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 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; SELECT _id FROM t1;
_id _id
8 8
...@@ -1773,27 +1773,27 @@ DROP TABLE t1; ...@@ -1773,27 +1773,27 @@ DROP TABLE t1;
CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2)); CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2));
SHOW TABLE STATUS LIKE 't1'; 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 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); INSERT INTO t1 VALUES (1,1);
SHOW TABLE STATUS LIKE 't1'; 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 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; ALTER TABLE t1 DISABLE KEYS;
SHOW TABLE STATUS LIKE 't1'; 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 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; ALTER TABLE t1 ENABLE KEYS;
SHOW TABLE STATUS LIKE 't1'; 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 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; ALTER TABLE t1 DISABLE KEYS;
SHOW TABLE STATUS LIKE 't1'; 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 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; ALTER TABLE t1 ENABLE KEYS;
SHOW TABLE STATUS LIKE 't1'; 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 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 # Enable keys with parallel repair
SET @@aria_repair_threads=2; SET @@aria_repair_threads=2;
ALTER TABLE t1 DISABLE KEYS; ALTER TABLE t1 DISABLE KEYS;
......
...@@ -24,8 +24,8 @@ t2 CREATE TABLE `t2` ( ...@@ -24,8 +24,8 @@ t2 CREATE TABLE `t2` (
lock tables t1 write,t2 write; lock tables t1 write,t2 write;
show table status like "t_"; 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 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 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 137438945280 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("ab",100),repeat("def",1000));
insert into t1 values(null, repeat("de",200),repeat("ghi",2000)); insert into t1 values(null, repeat("de",200),repeat("ghi",2000));
insert into t1 values(null, repeat("fe",300),repeat("ghi",3000)); 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 ...@@ -177,9 +177,9 @@ test.t1 check warning Datafile is almost full, 268320768 of 268320768 used
test.t1 check status OK test.t1 check status OK
show table status like "t1"; 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 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); create index seq on t1(c1);
show table status like "t1"; 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 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; drop table t1;
...@@ -340,8 +340,9 @@ enum chf_create_flags { ...@@ -340,8 +340,9 @@ enum chf_create_flags {
#define HA_CAN_ONLINE_BACKUPS (1ULL << 56) #define HA_CAN_ONLINE_BACKUPS (1ULL << 56)
/* Support native hash index */ /* Support native hash index */
#define HA_CAN_HASH_KEYS (1ULL << 58) #define HA_CAN_HASH_KEYS (1ULL << 57)
#define HA_LAST_TABLE_FLAG HA_CAN_HASH_KEYS #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 */ /* bits in index_flags(index_number) for what you can do with index */
#define HA_READ_NEXT 1 /* TODO really use this flag */ #define HA_READ_NEXT 1 /* TODO really use this flag */
...@@ -1773,6 +1774,12 @@ handlerton *ha_default_tmp_handlerton(THD *thd); ...@@ -1773,6 +1774,12 @@ handlerton *ha_default_tmp_handlerton(THD *thd);
*/ */
#define HTON_NO_ROLLBACK (1 << 16) #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; class Ha_trx_info;
struct THD_TRANS struct THD_TRANS
......
...@@ -5504,10 +5504,25 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, ...@@ -5504,10 +5504,25 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
str.qs_append(STRING_WITH_LEN(" partitioned")); str.qs_append(STRING_WITH_LEN(" partitioned"));
#endif #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(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); append_create_options(thd, &str, share->option_list, false, 0);
......
...@@ -1187,6 +1187,9 @@ int ha_maria::open(const char *name, int mode, uint test_if_locked) ...@@ -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; 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)) if (file->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD))
int_table_flags |= HA_HAS_NEW_CHECKSUM; int_table_flags |= HA_HAS_NEW_CHECKSUM;
...@@ -3728,7 +3731,8 @@ static int ha_maria_init(void *p) ...@@ -3728,7 +3731,8 @@ static int ha_maria_init(void *p)
/* TODO: decide if we support Maria being used for log tables */ /* TODO: decide if we support Maria being used for log tables */
maria_hton->flags= (HTON_CAN_RECREATE | HTON_SUPPORT_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)); bzero(maria_log_pagecache, sizeof(*maria_log_pagecache));
maria_tmpdir= &mysql_tmpdir_list; /* For REDO */ maria_tmpdir= &mysql_tmpdir_list; /* For REDO */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment