|
| 1 | +SET @row_format = @@GLOBAL.innodb_default_row_format; |
| 2 | +#################################### |
| 3 | +# Check if table rebuilding alter isn't affect if table is created |
| 4 | +# with explicit row_format |
| 5 | +CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ROW_FORMAT=COMPACT ENGINE=INNODB; |
| 6 | +INSERT INTO t1 VALUES (1, 'abc'); |
| 7 | +SHOW TABLE STATUS LIKE 't1'; |
| 8 | +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 |
| 9 | +t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=COMPACT |
| 10 | +SET GLOBAL innodb_default_row_format=DYNAMIC; |
| 11 | +ALTER TABLE t1 DROP PRIMARY KEY, ADD COLUMN c INT PRIMARY KEY; |
| 12 | +# Here we expect COMPACT because it was explicitly specified at CREATE |
| 13 | +SHOW TABLE STATUS LIKE 't1'; |
| 14 | +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 |
| 15 | +t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=COMPACT |
| 16 | +DROP TABLE t1; |
| 17 | +#################################### |
| 18 | +# Check if table rebuilding alter is affected when there is no |
| 19 | +# row_format specified at CREATE TABLE. |
| 20 | +SET GLOBAL innodb_default_row_format = COMPACT; |
| 21 | +CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=INNODB; |
| 22 | +INSERT INTO t1 VALUES (1, 'abc'); |
| 23 | +SHOW TABLE STATUS LIKE 't1'; |
| 24 | +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 |
| 25 | +t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL |
| 26 | +SET GLOBAL innodb_default_row_format = DYNAMIC; |
| 27 | +ALTER TABLE t1 DROP PRIMARY KEY, ADD COLUMN c INT PRIMARY KEY; |
| 28 | +# Here we expect DYNAMIC because there is no explicit ROW_FORMAT and the |
| 29 | +# default_row_format is changed to DYNAMIC just before ALTER |
| 30 | +SHOW TABLE STATUS LIKE 't1'; |
| 31 | +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 |
| 32 | +t1 InnoDB # Dynamic # # # # # # NULL # NULL NULL latin1_swedish_ci NULL |
| 33 | +DROP TABLE t1; |
| 34 | +#################################### |
| 35 | +# Check the row_format effect on ALTER, ALGORITHM=COPY |
| 36 | +SET GLOBAL innodb_default_row_format = REDUNDANT; |
| 37 | +CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=INNODB; |
| 38 | +INSERT INTO t1 VALUES (1, REPEAT('abc',1000)); |
| 39 | +SHOW TABLE STATUS LIKE 't1'; |
| 40 | +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 |
| 41 | +t1 InnoDB # Redundant # # # # # # NULL # NULL NULL latin1_swedish_ci NULL |
| 42 | +SET GLOBAL innoDB_default_row_format = COMPACT; |
| 43 | +ALTER TABLE t1 ADD COLUMN c2 BLOB, ALGORITHM=COPY; |
| 44 | +# Because of ALGORITHM=COPY, there is TABLE REBUILD and the table isn't |
| 45 | +# created with explicit row_format, so we expect ROW_FORMAT=COMPACT |
| 46 | +SHOW TABLE STATUS LIKE 't1'; |
| 47 | +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 |
| 48 | +t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL |
| 49 | +DROP TABLE t1; |
| 50 | + |
| 51 | +################################### |
| 52 | +# Check the row_format effect on ALTER, ALGORITH=COPY on |
| 53 | +# create table with explicit row_format |
| 54 | +CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ROW_FORMAT=REDUNDANT ENGINE=INNODB; |
| 55 | +INSERT INTO t1 VALUES (1, REPEAT('abc',1000)); |
| 56 | +SHOW TABLE STATUS LIKE 't1'; |
| 57 | +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 |
| 58 | +t1 InnoDB # Redundant # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=REDUNDANT |
| 59 | +SET GLOBAL innoDB_default_row_format = COMPACT; |
| 60 | +ALTER TABLE t1 ADD COLUMN c2 BLOB, ALGORITHM=COPY; |
| 61 | +# Because of ALGORITHM=COPY, there is TABLE REBUILD and the table is |
| 62 | +# created with explicit row_format, so we expect original |
| 63 | +# ROW_FORMAT=REDUNDANT |
| 64 | +SHOW TABLE STATUS LIKE 't1'; |
| 65 | +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 |
| 66 | +t1 InnoDB # Redundant # # # # # # NULL # NULL NULL latin1_swedish_ci NULL row_format=REDUNDANT |
| 67 | +DROP TABLE t1; |
| 68 | + |
| 69 | +################################## |
| 70 | +# Check row_format on ALTER ALGORITHM=INPLACE |
| 71 | +SET GLOBAL innodb_default_row_format=COMPACT; |
| 72 | +CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT, KEY k1(b(10))) ENGINE=INNODB; |
| 73 | +INSERT INTO t1 VALUES (1, REPEAT('abc',1000)); |
| 74 | +SHOW TABLE STATUS LIKE 't1'; |
| 75 | +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 |
| 76 | +t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL |
| 77 | +SET GLOBAL innodb_default_row_format=DYNAMIC; |
| 78 | +ALTER TABLE t1 DROP INDEX k1; |
| 79 | +# Because it is in-place operation, there is no rebuild, so the |
| 80 | +# original format has to be retained. |
| 81 | +SHOW TABLE STATUS LIKE 't1'; |
| 82 | +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 |
| 83 | +t1 InnoDB # Compact # # # # # # NULL # NULL NULL latin1_swedish_ci NULL |
| 84 | +DROP TABLE t1; |
| 85 | +SET GLOBAL innodb_default_row_format = @row_format; |
0 commit comments