Skip to content

Commit b2d69cc

Browse files
committed
Merge branch 'mysql-5.7-cluster-7.5' into mysql-5.7-cluster-7.6
Change-Id: I2f6d8e5f35d82f52218d8f45255bb7237883a29c
2 parents dc7921b + 14df29b commit b2d69cc

File tree

7 files changed

+594
-64
lines changed

7 files changed

+594
-64
lines changed

mysql-test/suite/ndb/include/ndb_desc_print.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ let $ndb_desc_cmd= $NDB_DESC --no-defaults $ndb_desc_opts;
1616
replace_regex /Version: [0-9]*/Version: Any/
1717
/NDB\$BLOB_[0-9]*_/NDB$BLOB_XX_/
1818
/Length of frm data: [0-9]*/Length of frm data: XXX/
19+
/^[0-9]+\/[0-9]+/XX\/XX/
1920
/IndexTable [0-9]*/IndexTable XX/
2021
/^([0-9][0-9]*) [0-9 ]*/\1 .../
2122
/Table id: [0-9]*/Table id: XXX/;

mysql-test/suite/ndb/r/ndb_fk_build.result

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,52 @@ drop foreign key fk4,
6666
drop foreign key fk5,
6767
drop foreign key fk6;
6868
drop table parent, child;
69+
create table parent (
70+
b1 int as (b) stored not null,
71+
c1 int as (c) stored not null,
72+
a1 int as (a) stored not null,
73+
b2 int as (b) stored not null,
74+
c2 int as (c) stored not null,
75+
a2 int as (a) stored not null,
76+
a int default 0,
77+
b int default 0,
78+
c int default 0,
79+
primary key pk1 (a1,b1,c1) using hash,
80+
unique key uk2 (a2,b2,c2) using hash
81+
) engine=ndbcluster;
82+
create table child (
83+
a int default 0,
84+
b int default 0,
85+
c int default 0,
86+
d int default 0,
87+
e int default 0,
88+
f int default 0,
89+
b1 int as (b) stored not null,
90+
c1 int as (c) stored not null,
91+
a1 int as (a) stored not null,
92+
b2 int as (b) stored not null,
93+
c2 int as (c) stored not null,
94+
a2 int as (a) stored not null,
95+
b3 int as (b) stored not null,
96+
c3 int as (c) stored not null,
97+
a3 int as (a) stored not null,
98+
primary key pk1 (a1,b1,c1) using hash,
99+
unique key uk2 (a2,b2,c2) using hash,
100+
key ok3 (a3,b3,c3),
101+
key ok3def (c3,b3,a3,d,e,f)
102+
) engine=ndbcluster;
103+
insert into parent (a, b, c) values (11, 12, 13);
104+
insert into child (a, b, c) values (11, 12, 13);
105+
alter table child add
106+
constraint fk11 foreign key (c1,b1,a1) references parent (c1,b1,a1);
107+
alter table child add
108+
constraint fk21 foreign key (c2,b2,a2) references parent (c1,b1,a1);
109+
alter table child add
110+
constraint fk31 foreign key (c3,b3,a3) references parent (c1,b1,a1);
111+
alter table child add
112+
constraint fk12 foreign key (c1,b1,a1) references parent (c2,b2,a2);
113+
alter table child add
114+
constraint fk22 foreign key (c2,b2,a2) references parent (c2,b2,a2);
115+
alter table child add
116+
constraint fk32 foreign key (c3,b3,a3) references parent (c2,b2,a2);
117+
drop table child, parent;

mysql-test/suite/ndb/r/ndb_fk_restore.result

Lines changed: 273 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,3 +594,276 @@ drop table db3.t5, db3.t4;
594594
# cleanup
595595
drop table db3.t6, db3.t7, db3.t8, db3.t9;
596596
drop database db3;
597+
#
598+
# Bug#36345882 Fix column ordering in Dbdict::buildFK_prepare
599+
#
600+
use test;
601+
create table t1 (
602+
b1 int as (b) stored not null,
603+
c1 int as (c) stored not null,
604+
a1 int as (a) stored not null,
605+
b2 int as (b) stored not null,
606+
c2 int as (c) stored not null,
607+
a2 int as (a) stored not null,
608+
a int default 0,
609+
b int default 0,
610+
c int default 0,
611+
primary key pk1 (a1,b1,c1) using hash,
612+
unique key uk2 (a2,b2,c2) using hash
613+
) engine=ndbcluster;
614+
create table t2 (
615+
a int default 0,
616+
b int default 0,
617+
c int default 0,
618+
d int default 0,
619+
e int default 0,
620+
f int default 0,
621+
b1 int as (b) stored not null,
622+
c1 int as (c) stored not null,
623+
a1 int as (a) stored not null,
624+
b2 int as (b) stored not null,
625+
c2 int as (c) stored not null,
626+
a2 int as (a) stored not null,
627+
b3 int as (b) stored not null,
628+
c3 int as (c) stored not null,
629+
a3 int as (a) stored not null,
630+
primary key pk1 (a1,b1,c1) using hash,
631+
unique key uk2 (a2,b2,c2) using hash,
632+
key ok3 (a3,b3,c3),
633+
key ok3def (c3,b3,a3,d,e,f),
634+
constraint fk11 foreign key (c1,b1,a1) references t1 (c1,b1,a1),
635+
constraint fk21 foreign key (c2,b2,a2) references t1 (c1,b1,a1),
636+
constraint fk31 foreign key (c3,b3,a3) references t1 (c1,b1,a1),
637+
constraint fk12 foreign key (c1,b1,a1) references t1 (c2,b2,a2),
638+
constraint fk22 foreign key (c2,b2,a2) references t1 (c2,b2,a2),
639+
constraint fk32 foreign key (c3,b3,a3) references t1 (c2,b2,a2)
640+
) engine=ndbcluster;
641+
alter table t2 drop index ok3;
642+
alter table t2 drop index fk12;
643+
alter table t2 drop index fk22;
644+
-- t1 --
645+
Version: Any
646+
Fragment type: HashMapPartition
647+
K Value: 6
648+
Min load factor: 78
649+
Max load factor: 80
650+
Temporary table: no
651+
Number of attributes: 9
652+
Number of primary keys: 3
653+
Length of frm data: XXX
654+
Max Rows: 0
655+
Row Checksum: 1
656+
Row GCI: 1
657+
SingleUserMode: 0
658+
ForceVarPart: 1
659+
PartitionCount: 8
660+
FragmentCount: 8
661+
PartitionBalance: FOR_RP_BY_LDM
662+
ExtraRowGciBits: 0
663+
ExtraRowAuthorBits: 0
664+
TableStatus: Retrieved
665+
Table options:
666+
HashMap: DEFAULT-HASHMAP-3840-8
667+
-- Attributes --
668+
b1 Int PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY
669+
c1 Int PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY
670+
a1 Int PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY
671+
b2 Int NOT NULL AT=FIXED ST=MEMORY
672+
c2 Int NOT NULL AT=FIXED ST=MEMORY
673+
a2 Int NOT NULL AT=FIXED ST=MEMORY
674+
a Int NULL AT=FIXED ST=MEMORY DEFAULT 0
675+
b Int NULL AT=FIXED ST=MEMORY DEFAULT 0
676+
c Int NULL AT=FIXED ST=MEMORY DEFAULT 0
677+
-- Indexes --
678+
PRIMARY KEY(b1, c1, a1) - UniqueHashIndex
679+
uk2$unique(b2, c2, a2) - UniqueHashIndex
680+
-- t2 --
681+
Version: Any
682+
Fragment type: HashMapPartition
683+
K Value: 6
684+
Min load factor: 78
685+
Max load factor: 80
686+
Temporary table: no
687+
Number of attributes: 15
688+
Number of primary keys: 3
689+
Length of frm data: XXX
690+
Max Rows: 0
691+
Row Checksum: 1
692+
Row GCI: 1
693+
SingleUserMode: 0
694+
ForceVarPart: 1
695+
PartitionCount: 8
696+
FragmentCount: 8
697+
PartitionBalance: FOR_RP_BY_LDM
698+
ExtraRowGciBits: 0
699+
ExtraRowAuthorBits: 0
700+
TableStatus: Retrieved
701+
Table options:
702+
HashMap: DEFAULT-HASHMAP-3840-8
703+
-- Attributes --
704+
a Int NULL AT=FIXED ST=MEMORY DEFAULT 0
705+
b Int NULL AT=FIXED ST=MEMORY DEFAULT 0
706+
c Int NULL AT=FIXED ST=MEMORY DEFAULT 0
707+
d Int NULL AT=FIXED ST=MEMORY DEFAULT 0
708+
e Int NULL AT=FIXED ST=MEMORY DEFAULT 0
709+
f Int NULL AT=FIXED ST=MEMORY DEFAULT 0
710+
b1 Int PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY
711+
c1 Int PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY
712+
a1 Int PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY
713+
b2 Int NOT NULL AT=FIXED ST=MEMORY
714+
c2 Int NOT NULL AT=FIXED ST=MEMORY
715+
a2 Int NOT NULL AT=FIXED ST=MEMORY
716+
b3 Int NOT NULL AT=FIXED ST=MEMORY
717+
c3 Int NOT NULL AT=FIXED ST=MEMORY
718+
a3 Int NOT NULL AT=FIXED ST=MEMORY
719+
-- Indexes --
720+
PRIMARY KEY(b1, c1, a1) - UniqueHashIndex
721+
uk2$unique(b2, c2, a2) - UniqueHashIndex
722+
ok3def(c3, b3, a3, d, e, f) - OrderedIndex
723+
-- ForeignKeys --
724+
XX/XX/fk11 PRIMARY KEY (c1, b1, a1) REFERENCES test.t1/PRIMARY KEY () on update noaction on delete noaction
725+
XX/XX/fk21 uk2$unique (c2, b2, a2) REFERENCES test.t1/PRIMARY KEY () on update noaction on delete noaction
726+
XX/XX/fk31 ok3def (c3, b3, a3) REFERENCES test.t1/PRIMARY KEY () on update noaction on delete noaction
727+
XX/XX/fk12 PRIMARY KEY (c1, b1, a1) REFERENCES test.t1/uk2$unique () on update noaction on delete noaction
728+
XX/XX/fk22 uk2$unique (c2, b2, a2) REFERENCES test.t1/uk2$unique () on update noaction on delete noaction
729+
XX/XX/fk32 ok3def (c3, b3, a3) REFERENCES test.t1/uk2$unique () on update noaction on delete noaction
730+
731+
NDBT_ProgramExit: 0 - OK
732+
733+
insert into t1 (a, b, c) values (11, 12, 13);
734+
insert into t2 (a, b, c) values (11, 12, 13);
735+
insert into t2 (a,b,c) values (101, 102, 103);
736+
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (Unknown error code)
737+
# show meta
738+
show create table t2;
739+
Table Create Table
740+
t2 CREATE TABLE `t2` (
741+
`a` int(11) DEFAULT '0',
742+
`b` int(11) DEFAULT '0',
743+
`c` int(11) DEFAULT '0',
744+
`d` int(11) DEFAULT '0',
745+
`e` int(11) DEFAULT '0',
746+
`f` int(11) DEFAULT '0',
747+
`b1` int(11) GENERATED ALWAYS AS (`b`) STORED NOT NULL,
748+
`c1` int(11) GENERATED ALWAYS AS (`c`) STORED NOT NULL,
749+
`a1` int(11) GENERATED ALWAYS AS (`a`) STORED NOT NULL,
750+
`b2` int(11) GENERATED ALWAYS AS (`b`) STORED NOT NULL,
751+
`c2` int(11) GENERATED ALWAYS AS (`c`) STORED NOT NULL,
752+
`a2` int(11) GENERATED ALWAYS AS (`a`) STORED NOT NULL,
753+
`b3` int(11) GENERATED ALWAYS AS (`b`) STORED NOT NULL,
754+
`c3` int(11) GENERATED ALWAYS AS (`c`) STORED NOT NULL,
755+
`a3` int(11) GENERATED ALWAYS AS (`a`) STORED NOT NULL,
756+
PRIMARY KEY (`a1`,`b1`,`c1`) USING HASH,
757+
UNIQUE KEY `uk2` (`a2`,`b2`,`c2`) USING HASH,
758+
KEY `ok3def` (`c3`,`b3`,`a3`,`d`,`e`,`f`),
759+
CONSTRAINT `fk11` FOREIGN KEY (`c1`,`b1`,`a1`) REFERENCES `t1` (`c1`,`b1`,`a1`) ON DELETE NO ACTION ON UPDATE NO ACTION,
760+
CONSTRAINT `fk12` FOREIGN KEY (`c1`,`b1`,`a1`) REFERENCES `t1` (`c2`,`b2`,`a2`) ON DELETE NO ACTION ON UPDATE NO ACTION,
761+
CONSTRAINT `fk21` FOREIGN KEY (`c2`,`b2`,`a2`) REFERENCES `t1` (`c1`,`b1`,`a1`) ON DELETE NO ACTION ON UPDATE NO ACTION,
762+
CONSTRAINT `fk22` FOREIGN KEY (`c2`,`b2`,`a2`) REFERENCES `t1` (`c2`,`b2`,`a2`) ON DELETE NO ACTION ON UPDATE NO ACTION,
763+
CONSTRAINT `fk31` FOREIGN KEY (`c3`,`b3`,`a3`) REFERENCES `t1` (`c1`,`b1`,`a1`) ON DELETE NO ACTION ON UPDATE NO ACTION,
764+
CONSTRAINT `fk32` FOREIGN KEY (`c3`,`b3`,`a3`) REFERENCES `t1` (`c2`,`b2`,`a2`) ON DELETE NO ACTION ON UPDATE NO ACTION
765+
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
766+
767+
ndb_show_tables completed.....
768+
769+
select type,name from ndb_show_tables_results
770+
where type in ('''ForeignKey''','''FKParentTrigger''','''FKChildTrigger''');
771+
type name
772+
'FKChildTrigger' 'NDB$FK_XX_CHILD_XX'
773+
'FKChildTrigger' 'NDB$FK_XX_CHILD_XX'
774+
'FKChildTrigger' 'NDB$FK_XX_CHILD_XX'
775+
'FKChildTrigger' 'NDB$FK_XX_CHILD_XX'
776+
'FKChildTrigger' 'NDB$FK_XX_CHILD_XX'
777+
'FKChildTrigger' 'NDB$FK_XX_CHILD_XX'
778+
'FKParentTrigger' 'NDB$FK_XX_PARENT_XX'
779+
'FKParentTrigger' 'NDB$FK_XX_PARENT_XX'
780+
'FKParentTrigger' 'NDB$FK_XX_PARENT_XX'
781+
'FKParentTrigger' 'NDB$FK_XX_PARENT_XX'
782+
'FKParentTrigger' 'NDB$FK_XX_PARENT_XX'
783+
'FKParentTrigger' 'NDB$FK_XX_PARENT_XX'
784+
'ForeignKey' 'XX/XX/fk11'
785+
'ForeignKey' 'XX/XX/fk12'
786+
'ForeignKey' 'XX/XX/fk21'
787+
'ForeignKey' 'XX/XX/fk22'
788+
'ForeignKey' 'XX/XX/fk31'
789+
'ForeignKey' 'XX/XX/fk32'
790+
# show counts
791+
select count(*) from t1;
792+
count(*)
793+
1
794+
select count(*) from t2;
795+
count(*)
796+
1
797+
# run backup
798+
# drop tables
799+
drop table t2, t1;
800+
# restore meta (disable indexes)
801+
# restore data (disable indexes)
802+
# rebuild indexes
803+
# show meta
804+
show create table t2;
805+
Table Create Table
806+
t2 CREATE TABLE `t2` (
807+
`a` int(11) DEFAULT '0',
808+
`b` int(11) DEFAULT '0',
809+
`c` int(11) DEFAULT '0',
810+
`d` int(11) DEFAULT '0',
811+
`e` int(11) DEFAULT '0',
812+
`f` int(11) DEFAULT '0',
813+
`b1` int(11) GENERATED ALWAYS AS (`b`) STORED NOT NULL,
814+
`c1` int(11) GENERATED ALWAYS AS (`c`) STORED NOT NULL,
815+
`a1` int(11) GENERATED ALWAYS AS (`a`) STORED NOT NULL,
816+
`b2` int(11) GENERATED ALWAYS AS (`b`) STORED NOT NULL,
817+
`c2` int(11) GENERATED ALWAYS AS (`c`) STORED NOT NULL,
818+
`a2` int(11) GENERATED ALWAYS AS (`a`) STORED NOT NULL,
819+
`b3` int(11) GENERATED ALWAYS AS (`b`) STORED NOT NULL,
820+
`c3` int(11) GENERATED ALWAYS AS (`c`) STORED NOT NULL,
821+
`a3` int(11) GENERATED ALWAYS AS (`a`) STORED NOT NULL,
822+
PRIMARY KEY (`a1`,`b1`,`c1`) USING HASH,
823+
UNIQUE KEY `uk2` (`a2`,`b2`,`c2`) USING HASH,
824+
KEY `ok3def` (`c3`,`b3`,`a3`,`d`,`e`,`f`),
825+
CONSTRAINT `fk11` FOREIGN KEY (`c1`,`b1`,`a1`) REFERENCES `t1` (`c1`,`b1`,`a1`) ON DELETE NO ACTION ON UPDATE NO ACTION,
826+
CONSTRAINT `fk12` FOREIGN KEY (`c1`,`b1`,`a1`) REFERENCES `t1` (`c2`,`b2`,`a2`) ON DELETE NO ACTION ON UPDATE NO ACTION,
827+
CONSTRAINT `fk21` FOREIGN KEY (`c2`,`b2`,`a2`) REFERENCES `t1` (`c1`,`b1`,`a1`) ON DELETE NO ACTION ON UPDATE NO ACTION,
828+
CONSTRAINT `fk22` FOREIGN KEY (`c2`,`b2`,`a2`) REFERENCES `t1` (`c2`,`b2`,`a2`) ON DELETE NO ACTION ON UPDATE NO ACTION,
829+
CONSTRAINT `fk31` FOREIGN KEY (`c3`,`b3`,`a3`) REFERENCES `t1` (`c1`,`b1`,`a1`) ON DELETE NO ACTION ON UPDATE NO ACTION,
830+
CONSTRAINT `fk32` FOREIGN KEY (`c3`,`b3`,`a3`) REFERENCES `t1` (`c2`,`b2`,`a2`) ON DELETE NO ACTION ON UPDATE NO ACTION
831+
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
832+
833+
ndb_show_tables completed.....
834+
835+
select type,name from ndb_show_tables_results
836+
where type in ('''ForeignKey''','''FKParentTrigger''','''FKChildTrigger''');
837+
type name
838+
'FKChildTrigger' 'NDB$FK_XX_CHILD_XX'
839+
'FKChildTrigger' 'NDB$FK_XX_CHILD_XX'
840+
'FKChildTrigger' 'NDB$FK_XX_CHILD_XX'
841+
'FKChildTrigger' 'NDB$FK_XX_CHILD_XX'
842+
'FKChildTrigger' 'NDB$FK_XX_CHILD_XX'
843+
'FKChildTrigger' 'NDB$FK_XX_CHILD_XX'
844+
'FKParentTrigger' 'NDB$FK_XX_PARENT_XX'
845+
'FKParentTrigger' 'NDB$FK_XX_PARENT_XX'
846+
'FKParentTrigger' 'NDB$FK_XX_PARENT_XX'
847+
'FKParentTrigger' 'NDB$FK_XX_PARENT_XX'
848+
'FKParentTrigger' 'NDB$FK_XX_PARENT_XX'
849+
'FKParentTrigger' 'NDB$FK_XX_PARENT_XX'
850+
'ForeignKey' 'XX/XX/fk11'
851+
'ForeignKey' 'XX/XX/fk12'
852+
'ForeignKey' 'XX/XX/fk21'
853+
'ForeignKey' 'XX/XX/fk22'
854+
'ForeignKey' 'XX/XX/fk31'
855+
'ForeignKey' 'XX/XX/fk32'
856+
# show counts
857+
select count(*) from t1;
858+
count(*)
859+
1
860+
select count(*) from t2;
861+
count(*)
862+
1
863+
select * from t1;
864+
b1 c1 a1 b2 c2 a2 a b c
865+
12 13 11 12 13 11 11 12 13
866+
select * from t2;
867+
a b c d e f b1 c1 a1 b2 c2 a2 b3 c3 a3
868+
11 12 13 0 0 0 12 13 11 12 13 11 12 13 11
869+
drop table t2,t1;

mysql-test/suite/ndb/t/ndb_fk_build.test

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,61 @@ drop foreign key fk5,
7272
drop foreign key fk6;
7373

7474
drop table parent, child;
75+
76+
# Check multi column foreign keys
77+
78+
eval create table parent (
79+
b1 int as (b) stored not null,
80+
c1 int as (c) stored not null,
81+
a1 int as (a) stored not null,
82+
b2 int as (b) stored not null,
83+
c2 int as (c) stored not null,
84+
a2 int as (a) stored not null,
85+
a int default 0,
86+
b int default 0,
87+
c int default 0,
88+
primary key pk1 (a1,b1,c1) using hash,
89+
unique key uk2 (a2,b2,c2) using hash
90+
) engine=ndbcluster;
91+
92+
eval create table child (
93+
a int default 0,
94+
b int default 0,
95+
c int default 0,
96+
d int default 0,
97+
e int default 0,
98+
f int default 0,
99+
b1 int as (b) stored not null,
100+
c1 int as (c) stored not null,
101+
a1 int as (a) stored not null,
102+
b2 int as (b) stored not null,
103+
c2 int as (c) stored not null,
104+
a2 int as (a) stored not null,
105+
b3 int as (b) stored not null,
106+
c3 int as (c) stored not null,
107+
a3 int as (a) stored not null,
108+
primary key pk1 (a1,b1,c1) using hash,
109+
unique key uk2 (a2,b2,c2) using hash,
110+
key ok3 (a3,b3,c3),
111+
key ok3def (c3,b3,a3,d,e,f)
112+
) engine=ndbcluster;
113+
114+
# Add parent row, use different values for the different columns.
115+
insert into parent (a, b, c) values (11, 12, 13);
116+
# Add valid child row.
117+
insert into child (a, b, c) values (11, 12, 13);
118+
119+
alter table child add
120+
constraint fk11 foreign key (c1,b1,a1) references parent (c1,b1,a1);
121+
alter table child add
122+
constraint fk21 foreign key (c2,b2,a2) references parent (c1,b1,a1);
123+
alter table child add
124+
constraint fk31 foreign key (c3,b3,a3) references parent (c1,b1,a1);
125+
alter table child add
126+
constraint fk12 foreign key (c1,b1,a1) references parent (c2,b2,a2);
127+
alter table child add
128+
constraint fk22 foreign key (c2,b2,a2) references parent (c2,b2,a2);
129+
alter table child add
130+
constraint fk32 foreign key (c3,b3,a3) references parent (c2,b2,a2);
131+
132+
drop table child, parent;

0 commit comments

Comments
 (0)