| 1 |
--source include/have_debug_sync.inc |
| 2 |
|
| 3 |
--echo # |
| 4 |
--echo # Bug#33319149: TABLE ID is not updated in dd::Column se_private_date |
| 5 |
--echo # for discarded table |
| 6 |
--echo # |
| 7 |
|
| 8 |
--echo # Test for non-partitioned table |
| 9 |
|
| 10 |
# Verify that the table_id is updated in the column metadata |
| 11 |
# after discarding a tablespace of a non-partitioned table |
| 12 |
CREATE TABLE t1 (c1 INT, c2 INT as (c1 + 1) VIRTUAL); |
| 13 |
SELECT TABLE_ID INTO @old_tableid FROM INFORMATION_SCHEMA.INNODB_TABLES WHERE NAME |
| 14 |
LIKE '%t1%'; |
| 15 |
let $old_tid = `SELECT TABLE_ID FROM INFORMATION_SCHEMA.INNODB_TABLES WHERE NAME LIKE '%t1%'`; |
| 16 |
|
| 17 |
# Verify that the column metadata reflects the old table_id |
| 18 |
SET SESSION debug= '+d,skip_dd_table_access_check'; |
| 19 |
SET @query = CONCAT("SELECT COUNT(*) FROM mysql.columns WHERE SE_PRIVATE_DATA like \"%table_id=", @old_tableid, "%\""); |
| 20 |
PREPARE stmt FROM @query; |
| 21 |
EXECUTE stmt; |
| 22 |
DEALLOCATE PREPARE stmt; |
| 23 |
|
| 24 |
# Discard the tablespace |
| 25 |
ALTER TABLE t1 DISCARD TABLESPACE; |
| 26 |
|
| 27 |
SELECT TABLE_ID INTO @new_tableid FROM INFORMATION_SCHEMA.INNODB_TABLES WHERE NAME |
| 28 |
LIKE '%t1%'; |
| 29 |
let $new_tid = `SELECT TABLE_ID FROM INFORMATION_SCHEMA.INNODB_TABLES WHERE NAME LIKE '%t1%'`; |
| 30 |
|
| 31 |
# Verify that the table_id has been updated |
| 32 |
if ($old_tid == $new_tid) |
| 33 |
{ |
| 34 |
--echo 'ERROR: table_id not updated'; |
| 35 |
} |
| 36 |
|
| 37 |
# Verify that the column metadata reflects the new table_id |
| 38 |
SET @query = CONCAT("SELECT COUNT(*) FROM mysql.columns WHERE SE_PRIVATE_DATA like \"%table_id=", @new_tableid, "%\""); |
| 39 |
PREPARE stmt FROM @query; |
| 40 |
EXECUTE stmt; |
| 41 |
DEALLOCATE PREPARE stmt; |
| 42 |
|
| 43 |
DROP TABLE t1; |
| 44 |
|
| 45 |
--echo # Test for partitioned table |
| 46 |
|
| 47 |
# Verify that the table_id is updated in the column metadata |
| 48 |
# after discarding a tablespace of a partitioned table |
| 49 |
CREATE TABLE tpart (c1 INT, c2 INT as (c1 + 1) VIRTUAL) |
| 50 |
PARTITION BY RANGE (c1) ( |
| 51 |
PARTITION p1 VALUES LESS THAN (10), |
| 52 |
PARTITION p2 VALUES LESS THAN (100)); |
| 53 |
|
| 54 |
SELECT TABLE_ID INTO @old_tableid FROM INFORMATION_SCHEMA.INNODB_TABLES WHERE NAME |
| 55 |
LIKE '%tpart%' LIMIT 1; |
| 56 |
|
| 57 |
let $old_tid = `SELECT TABLE_ID FROM INFORMATION_SCHEMA.INNODB_TABLES WHERE NAME LIKE '%tpart%' LIMIT 1`; |
| 58 |
|
| 59 |
# Verify that the column metadata reflects the old table_id |
| 60 |
SET @query = CONCAT("SELECT COUNT(*) FROM mysql.columns WHERE SE_PRIVATE_DATA like \"%table_id=", @old_tableid, "%\""); |
| 61 |
PREPARE stmt FROM @query; |
| 62 |
EXECUTE stmt; |
| 63 |
DEALLOCATE PREPARE stmt; |
| 64 |
|
| 65 |
# Discard the tablespace |
| 66 |
ALTER TABLE tpart DISCARD TABLESPACE; |
| 67 |
|
| 68 |
SELECT TABLE_ID INTO @new_tableid FROM INFORMATION_SCHEMA.INNODB_TABLES WHERE NAME |
| 69 |
LIKE '%tpart%' LIMIT 1; |
| 70 |
|
| 71 |
let $new_tid = `SELECT TABLE_ID FROM INFORMATION_SCHEMA.INNODB_TABLES WHERE NAME LIKE '%tpart%' LIMIT 1`; |
| 72 |
|
| 73 |
# Verify that the table_id has been updated |
| 74 |
if ($old_tid == $new_tid) |
| 75 |
{ |
| 76 |
--echo 'ERROR: table_id not updated'; |
| 77 |
} |
| 78 |
|
| 79 |
# Verify that the column metadata reflects the new table_id |
| 80 |
SET @query = CONCAT("SELECT COUNT(*) FROM mysql.columns WHERE SE_PRIVATE_DATA like \"%table_id=", @new_tableid, "%\""); |
| 81 |
PREPARE stmt FROM @query; |
| 82 |
EXECUTE stmt; |
| 83 |
DEALLOCATE PREPARE stmt; |
| 84 |
SET SESSION debug= '-d,skip_dd_table_access_check'; |
| 85 |
|
| 86 |
DROP TABLE tpart; |