@@ -409,11 +409,207 @@ ALTER TABLE t1 DISCARD TABLESPACE;
409409# Restore the descending key IBD and the v99 version of the CFG.
410410# Attempt to import the table.
411411ALTER TABLE t1 IMPORT TABLESPACE;
412- ERROR HY000: Failed to import test/t1 because the CFG file version (99) is not compatible with the current version (4 )
412+ ERROR HY000: Failed to import test/t1 because the CFG file version (99) is not compatible with the current version (5 )
413413SHOW WARNINGS;
414414Level Code Message
415- Error 3949 Failed to import test/t1 because the CFG file version (99) is not compatible with the current version (4 )
415+ Error 3949 Failed to import test/t1 because the CFG file version (99) is not compatible with the current version (5 )
416416Warning 1816 InnoDB: ALTER TABLE `test`.`t1` IMPORT TABLESPACE failed with error 48 : 'Unsupported'
417417Error 1112 Table 't1' uses an extension that doesn't exist in this MySQL version
418418# Cleanup
419419DROP TABLE t1;
420+ #
421+ # Bug#30191523 : FLUSH TABLE T FOR EXPORT OR ALTER TABLE T2 IMPORT
422+ # TABLESPACE BROKEN IN 8.0.17.
423+ #
424+ # ---------------------- Test 1 ----------------------------------
425+ # Source table has INSTANT columns but target table doesn't
426+ # ----------------------------------------------------------------
427+ # Create source table t1 and add a column INSTANTly
428+ CREATE TABLE t1(id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY);
429+ ALTER TABLE t1 ADD COLUMN v1 VARCHAR(255), ALGORITHM=INSTANT;
430+ ALTER TABLE t1 ADD COLUMN v2 VARCHAR(255), ALGORITHM=INSTANT;
431+ # Insert some data into t1
432+ SELECT * from t1 limit 10;
433+ id v1 v2
434+ 1 aaaaaaaaaaaaa bbbbbbbbbbbbbb
435+ 2 aaaaaaaaaaaaa bbbbbbbbbbbbbb
436+ 3 aaaaaaaaaaaaa bbbbbbbbbbbbbb
437+ 4 aaaaaaaaaaaaa bbbbbbbbbbbbbb
438+ 5 aaaaaaaaaaaaa bbbbbbbbbbbbbb
439+ 6 aaaaaaaaaaaaa bbbbbbbbbbbbbb
440+ 7 aaaaaaaaaaaaa bbbbbbbbbbbbbb
441+ 8 aaaaaaaaaaaaa bbbbbbbbbbbbbb
442+ 9 aaaaaaaaaaaaa bbbbbbbbbbbbbb
443+ 10 aaaaaaaaaaaaa bbbbbbbbbbbbbb
444+ SELECT COUNT(*) from t1;
445+ COUNT(*)
446+ 1000
447+ SELECT NAME, N_COLS, INSTANT_COLS FROM INFORMATION_SCHEMA.INNODB_TABLES WHERE NAME="test/t1";
448+ NAME N_COLS INSTANT_COLS
449+ test/t1 6 1
450+ SELECT NAME, POS, HAS_DEFAULT from information_Schema.innodb_columns WHERE NAME='v1' OR NAME='v2';
451+ NAME POS HAS_DEFAULT
452+ v1 1 1
453+ v2 2 1
454+ # Flush the table and store CFG/IBD files to temp
455+ FLUSH TABLE t1 FOR EXPORT;
456+ UNLOCK TABLES;
457+ # Create table t2 without INSTANTly added columns
458+ CREATE TABLE t2 LIKE t1;
459+ ALTER TABLE t2 DISCARD TABLESPACE;
460+ # Copy CFG/IBD file from temp
461+ # IMPORT should succeed. Target table metadata should have been updated.
462+ ALTER TABLE t2 IMPORT TABLESPACE;
463+ SELECT * from t2 limit 10;
464+ id v1 v2
465+ 1 aaaaaaaaaaaaa bbbbbbbbbbbbbb
466+ 2 aaaaaaaaaaaaa bbbbbbbbbbbbbb
467+ 3 aaaaaaaaaaaaa bbbbbbbbbbbbbb
468+ 4 aaaaaaaaaaaaa bbbbbbbbbbbbbb
469+ 5 aaaaaaaaaaaaa bbbbbbbbbbbbbb
470+ 6 aaaaaaaaaaaaa bbbbbbbbbbbbbb
471+ 7 aaaaaaaaaaaaa bbbbbbbbbbbbbb
472+ 8 aaaaaaaaaaaaa bbbbbbbbbbbbbb
473+ 9 aaaaaaaaaaaaa bbbbbbbbbbbbbb
474+ 10 aaaaaaaaaaaaa bbbbbbbbbbbbbb
475+ SELECT COUNT(*) from t2;
476+ COUNT(*)
477+ 1000
478+ SELECT NAME, N_COLS, INSTANT_COLS FROM INFORMATION_SCHEMA.INNODB_TABLES WHERE NAME="test/t1" OR NAME="test/t2";
479+ NAME N_COLS INSTANT_COLS
480+ test/t1 6 1
481+ test/t2 6 1
482+ SELECT NAME, POS, HAS_DEFAULT from information_Schema.innodb_columns WHERE NAME='v1' OR NAME='v2';
483+ NAME POS HAS_DEFAULT
484+ v1 1 1
485+ v2 2 1
486+ v1 1 1
487+ v2 2 1
488+ DROP TABLE t2;
489+ # Create table t2 with one column added INSTANTly
490+ CREATE TABLE t2(id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, v1 VARCHAR(255));
491+ ALTER TABLE t2 ADD COLUMN v2 VARCHAR(255);
492+ ALTER TABLE t2 DISCARD TABLESPACE;
493+ # Copy CFG/IBD file from temp
494+ # IMPORT should succeed. Target table metadata should have been updated.
495+ ALTER TABLE t2 IMPORT TABLESPACE;
496+ SELECT * from t2 limit 10;
497+ id v1 v2
498+ 1 aaaaaaaaaaaaa bbbbbbbbbbbbbb
499+ 2 aaaaaaaaaaaaa bbbbbbbbbbbbbb
500+ 3 aaaaaaaaaaaaa bbbbbbbbbbbbbb
501+ 4 aaaaaaaaaaaaa bbbbbbbbbbbbbb
502+ 5 aaaaaaaaaaaaa bbbbbbbbbbbbbb
503+ 6 aaaaaaaaaaaaa bbbbbbbbbbbbbb
504+ 7 aaaaaaaaaaaaa bbbbbbbbbbbbbb
505+ 8 aaaaaaaaaaaaa bbbbbbbbbbbbbb
506+ 9 aaaaaaaaaaaaa bbbbbbbbbbbbbb
507+ 10 aaaaaaaaaaaaa bbbbbbbbbbbbbb
508+ SELECT COUNT(*) from t2;
509+ COUNT(*)
510+ 1000
511+ SELECT NAME, N_COLS, INSTANT_COLS FROM INFORMATION_SCHEMA.INNODB_TABLES WHERE NAME="test/t1" OR NAME="test/t2";
512+ NAME N_COLS INSTANT_COLS
513+ test/t1 6 1
514+ test/t2 6 1
515+ SELECT NAME, POS, HAS_DEFAULT from information_Schema.innodb_columns WHERE NAME='v1' OR NAME='v2';
516+ NAME POS HAS_DEFAULT
517+ v1 1 1
518+ v2 2 1
519+ v1 1 1
520+ v2 2 1
521+ DROP TABLE t2;
522+ # Create table t2 with two column added INSTANTly
523+ CREATE TABLE t2(id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY);
524+ ALTER TABLE t2 ADD COLUMN v1 VARCHAR(255);
525+ ALTER TABLE t2 ADD COLUMN v2 VARCHAR(255);
526+ ALTER TABLE t2 DISCARD TABLESPACE;
527+ # Copy CFG/IBD file from temp
528+ # IMPORT should succeed.
529+ ALTER TABLE t2 IMPORT TABLESPACE;
530+ SELECT * from t2 limit 10;
531+ id v1 v2
532+ 1 aaaaaaaaaaaaa bbbbbbbbbbbbbb
533+ 2 aaaaaaaaaaaaa bbbbbbbbbbbbbb
534+ 3 aaaaaaaaaaaaa bbbbbbbbbbbbbb
535+ 4 aaaaaaaaaaaaa bbbbbbbbbbbbbb
536+ 5 aaaaaaaaaaaaa bbbbbbbbbbbbbb
537+ 6 aaaaaaaaaaaaa bbbbbbbbbbbbbb
538+ 7 aaaaaaaaaaaaa bbbbbbbbbbbbbb
539+ 8 aaaaaaaaaaaaa bbbbbbbbbbbbbb
540+ 9 aaaaaaaaaaaaa bbbbbbbbbbbbbb
541+ 10 aaaaaaaaaaaaa bbbbbbbbbbbbbb
542+ SELECT COUNT(*) from t2;
543+ COUNT(*)
544+ 1000
545+ SELECT NAME, N_COLS, INSTANT_COLS FROM INFORMATION_SCHEMA.INNODB_TABLES WHERE NAME="test/t1" OR NAME="test/t2";
546+ NAME N_COLS INSTANT_COLS
547+ test/t1 6 1
548+ test/t2 6 1
549+ SELECT NAME, POS, HAS_DEFAULT from information_Schema.innodb_columns WHERE NAME='v1' OR NAME='v2';
550+ NAME POS HAS_DEFAULT
551+ v1 1 1
552+ v2 2 1
553+ v1 1 1
554+ v2 2 1
555+ DROP TABLE t2;
556+ DROP TABLE t1;
557+ # ---------------------- Test 2 ----------------------------------
558+ # Source table doesn't have INSTANT columns but target table does
559+ # ----------------------------------------------------------------
560+ # Create source table t1 and add a column INSTANTly
561+ CREATE TABLE t1(id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, v1 VARCHAR(255), v2 VARCHAR(255));
562+ # Insert some data into t1
563+ SELECT * from t1 limit 10;
564+ id v1 v2
565+ 1 aaaaaaaaaaaaa bbbbbbbbbbbbbb
566+ 2 aaaaaaaaaaaaa bbbbbbbbbbbbbb
567+ 3 aaaaaaaaaaaaa bbbbbbbbbbbbbb
568+ 4 aaaaaaaaaaaaa bbbbbbbbbbbbbb
569+ 5 aaaaaaaaaaaaa bbbbbbbbbbbbbb
570+ 6 aaaaaaaaaaaaa bbbbbbbbbbbbbb
571+ 7 aaaaaaaaaaaaa bbbbbbbbbbbbbb
572+ 8 aaaaaaaaaaaaa bbbbbbbbbbbbbb
573+ 9 aaaaaaaaaaaaa bbbbbbbbbbbbbb
574+ 10 aaaaaaaaaaaaa bbbbbbbbbbbbbb
575+ SELECT COUNT(*) from t1;
576+ COUNT(*)
577+ 1000
578+ SELECT NAME, N_COLS, INSTANT_COLS FROM INFORMATION_SCHEMA.INNODB_TABLES WHERE NAME="test/t1";
579+ NAME N_COLS INSTANT_COLS
580+ test/t1 6 0
581+ SELECT NAME, POS, HAS_DEFAULT from information_Schema.innodb_columns WHERE NAME='v1' OR NAME='v2';
582+ NAME POS HAS_DEFAULT
583+ v1 1 0
584+ v2 2 0
585+ # Flush the table and store CFG/IBD files to temp
586+ FLUSH TABLE t1 FOR EXPORT;
587+ UNLOCK TABLES;
588+ # Create table t2 with no INSTANTly added columns
589+ CREATE TABLE t2(id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, v1 VARCHAR(255), v2 VARCHAR(255));
590+ ALTER TABLE t2 DISCARD TABLESPACE;
591+ # Copy CFG/IBD file from temp
592+ # IMPORT should succeed.
593+ ALTER TABLE t2 IMPORT TABLESPACE;
594+ DROP TABLE t2;
595+ # Create table t2 with 1 INSTANTly added columns
596+ CREATE TABLE t2(id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, v1 VARCHAR(255));
597+ ALTER TABLE t2 ADD COLUMN v2 VARCHAR(255), ALGORITHM=INSTANT;
598+ ALTER TABLE t2 DISCARD TABLESPACE;
599+ # Copy CFG/IBD file from temp
600+ # IMPORT should fail.
601+ ALTER TABLE t2 IMPORT TABLESPACE;
602+ ERROR HY000: Schema mismatch (The .cfg file indicates no INSTANT column in the source table whereas the metadata in data dictionary says there are instant columns in the target table)
603+ DROP TABLE t2;
604+ # Create table t2 with 2 INSTANTly added columns
605+ CREATE TABLE t2(id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY);
606+ ALTER TABLE t2 ADD COLUMN v1 VARCHAR(255), ALGORITHM=INSTANT;
607+ ALTER TABLE t2 ADD COLUMN v2 VARCHAR(255), ALGORITHM=INSTANT;
608+ ALTER TABLE t2 DISCARD TABLESPACE;
609+ # Copy CFG/IBD file from temp
610+ # IMPORT should fail.
611+ ALTER TABLE t2 IMPORT TABLESPACE;
612+ ERROR HY000: Schema mismatch (The .cfg file indicates no INSTANT column in the source table whereas the metadata in data dictionary says there are instant columns in the target table)
613+ DROP TABLE t2;
614+ # Cleanup
615+ DROP TABLE t1;
0 commit comments