1use test;
2More complex example
3create table idx_tbl (entry_key bigint unsigned not null auto_increment,
4k1 varchar(100),
5k2 varchar(100),
6data int,
7primary key (k1, k2),
8unique(entry_key)) engine=ndb;
9create table type1_1 (entry_key bigint unsigned not null primary key,
10data int) engine=ndb;
11create table type1_2 (entry_key bigint unsigned not null primary key,
12data int) engine=ndb;
13create table type2_1 (entry_key bigint unsigned not null,
14mv_idx bigint unsigned not null auto_increment,
15data int,
16primary key (entry_key, mv_idx)) engine=ndb;
17create table type2_2 (entry_key bigint unsigned not null,
18mv_idx bigint unsigned not null auto_increment,
19data text,
20primary key (entry_key, mv_idx)) engine=ndb;
21Populate a number of entities, each with
22a couple of type_1 rows and 2 sets of type_2 rows
23insert into idx_tbl (k1,k2,data) values ('Edinburgh', 'UK', 1);
24select last_insert_id() into @ek;
25insert into type1_1 values (@ek, 11);
26insert into type1_2 values (@ek, 12);
27insert into type2_1 (entry_key, data) values (@ek, 110);
28insert into type2_1 (entry_key, data) values (@ek, 111);
29insert into type2_1 (entry_key, data) values (@ek, 112);
30insert into type2_1 (entry_key, data) values (@ek, 113);
31insert into type2_2 (entry_key, data) values (@ek, repeat("0121", 10000));
32insert into type2_2 (entry_key, data) values (@ek, repeat("0122", 10000));
33insert into idx_tbl (k1,k2,data) values ('Bristol', 'UK', 2);
34select last_insert_id() into @ek;
35insert into type1_1 values (@ek, 21);
36insert into type1_2 values (@ek, 22);
37insert into type2_1 (entry_key, data) values (@ek, 210);
38insert into type2_1 (entry_key, data) values (@ek, 211);
39insert into type2_1 (entry_key, data) values (@ek, 212);
40insert into type2_1 (entry_key, data) values (@ek, 213);
41insert into type2_2 (entry_key, data) values (@ek, repeat("0221", 10000));
42insert into type2_2 (entry_key, data) values (@ek, repeat("0222", 10000));
43insert into idx_tbl (k1,k2,data) values ('Glasgow', 'UK', 3);
44select last_insert_id() into @ek;
45insert into type1_1 values (@ek, 31);
46insert into type1_2 values (@ek, 32);
47insert into type2_1 (entry_key, data) values (@ek, 310);
48insert into type2_1 (entry_key, data) values (@ek, 311);
49insert into type2_1 (entry_key, data) values (@ek, 312);
50insert into type2_1 (entry_key, data) values (@ek, 313);
51insert into type2_2 (entry_key, data) values (@ek, repeat("0321", 10000));
52insert into type2_2 (entry_key, data) values (@ek, repeat("0322", 10000));
53insert into idx_tbl (k1,k2,data) values ('London', 'UK', 4);
54select last_insert_id() into @ek;
55insert into type1_1 values (@ek, 41);
56insert into type1_2 values (@ek, 42);
57insert into type2_1 (entry_key, data) values (@ek, 410);
58insert into type2_1 (entry_key, data) values (@ek, 411);
59insert into type2_1 (entry_key, data) values (@ek, 412);
60insert into type2_1 (entry_key, data) values (@ek, 413);
61insert into type2_2 (entry_key, data) values (@ek, repeat("0421", 10000));
62insert into type2_2 (entry_key, data) values (@ek, repeat("0422", 10000));
63insert into idx_tbl (k1,k2,data) values ('Paris', 'France', 5);
64select last_insert_id() into @ek;
65insert into type1_1 values (@ek, 51);
66insert into type1_2 values (@ek, 52);
67insert into type2_1 (entry_key, data) values (@ek, 510);
68insert into type2_1 (entry_key, data) values (@ek, 511);
69insert into type2_1 (entry_key, data) values (@ek, 512);
70insert into type2_1 (entry_key, data) values (@ek, 513);
71insert into type2_2 (entry_key, data) values (@ek, repeat("0521", 10000));
72insert into type2_2 (entry_key, data) values (@ek, repeat("0522", 10000));
73insert into idx_tbl (k1,k2,data) values ('Heidelberg', 'Germany', 6);
74select last_insert_id() into @ek;
75insert into type1_1 values (@ek, 61);
76insert into type1_2 values (@ek, 62);
77insert into type2_1 (entry_key, data) values (@ek, 610);
78insert into type2_1 (entry_key, data) values (@ek, 611);
79insert into type2_1 (entry_key, data) values (@ek, 612);
80insert into type2_1 (entry_key, data) values (@ek, 613);
81insert into type2_2 (entry_key, data) values (@ek, repeat("0621", 10000));
82insert into type2_2 (entry_key, data) values (@ek, repeat("0622", 10000));
83insert into idx_tbl (k1,k2,data) values ('Riga', 'Latvia', 7);
84select last_insert_id() into @ek;
85insert into type1_1 values (@ek, 71);
86insert into type1_2 values (@ek, 72);
87insert into type2_1 (entry_key, data) values (@ek, 710);
88insert into type2_1 (entry_key, data) values (@ek, 711);
89insert into type2_1 (entry_key, data) values (@ek, 712);
90insert into type2_1 (entry_key, data) values (@ek, 713);
91insert into type2_2 (entry_key, data) values (@ek, repeat("0721", 10000));
92insert into type2_2 (entry_key, data) values (@ek, repeat("0722", 10000));
93insert into idx_tbl (k1,k2,data) values ('Orlando', 'USA', 8);
94select last_insert_id() into @ek;
95insert into type1_1 values (@ek, 81);
96insert into type1_2 values (@ek, 82);
97insert into type2_1 (entry_key, data) values (@ek, 810);
98insert into type2_1 (entry_key, data) values (@ek, 811);
99insert into type2_1 (entry_key, data) values (@ek, 812);
100insert into type2_1 (entry_key, data) values (@ek, 813);
101insert into type2_2 (entry_key, data) values (@ek, repeat("0821", 10000));
102insert into type2_2 (entry_key, data) values (@ek, repeat("0822", 10000));
103select * from idx_tbl order by entry_key;
104entry_key	k1	k2	data
1051	Edinburgh	UK	1
1062	Bristol	UK	2
1073	Glasgow	UK	3
1084	London	UK	4
1095	Paris	France	5
1106	Heidelberg	Germany	6
1117	Riga	Latvia	7
1128	Orlando	USA	8
113select * from type1_1 order by entry_key;
114entry_key	data
1151	11
1162	21
1173	31
1184	41
1195	51
1206	61
1217	71
1228	81
123select * from type1_2 order by entry_key;
124entry_key	data
1251	12
1262	22
1273	32
1284	42
1295	52
1306	62
1317	72
1328	82
133select * from type2_1 order by entry_key, mv_idx;
134entry_key	mv_idx	data
1351	1	110
1361	2	111
1371	3	112
1381	4	113
1392	5	210
1402	6	211
1412	7	212
1422	8	213
1433	9	310
1443	10	311
1453	11	312
1463	12	313
1474	13	410
1484	14	411
1494	15	412
1504	16	413
1515	17	510
1525	18	511
1535	19	512
1545	20	513
1556	21	610
1566	22	611
1576	23	612
1586	24	613
1597	25	710
1607	26	711
1617	27	712
1627	28	713
1638	29	810
1648	30	811
1658	31	812
1668	32	813
167select entry_key, mv_idx, right(data, 4) from type2_2 order by entry_key, mv_idx;
168entry_key	mv_idx	right(data, 4)
1691	1	0121
1701	2	0122
1712	3	0221
1722	4	0222
1733	5	0321
1743	6	0322
1754	7	0421
1764	8	0422
1775	9	0521
1785	10	0522
1796	11	0621
1806	12	0622
1817	13	0721
1827	14	0722
1838	15	0821
1848	16	0822
185First set of content
186--------------------
187select idx_tbl.entry_key,
188idx_tbl.k1,
189idx_tbl.k2,
190idx_tbl.data,
191type1_1.data,
192type1_2.data,
193type2_1.mv_idx,
194type2_1.data,
195type2_2.mv_idx,
196right(type2_2.data, 4),
197length(type2_2.data)
198from
199idx_tbl join type1_1 join type1_2 join type2_1 join type2_2
200on
201idx_tbl.entry_key = type1_1.entry_key
202and
203idx_tbl.entry_key = type1_2.entry_key
204and
205idx_tbl.entry_key = type2_1.entry_key
206and
207idx_tbl.entry_key = type2_2.entry_key
208order by idx_tbl.entry_key, type2_1.data, right(type2_2.data, 4);
209entry_key	k1	k2	data	data	data	mv_idx	data	mv_idx	right(type2_2.data, 4)	length(type2_2.data)
2101	Edinburgh	UK	1	11	12	1	110	1	0121	40000
2111	Edinburgh	UK	1	11	12	1	110	2	0122	40000
2121	Edinburgh	UK	1	11	12	2	111	1	0121	40000
2131	Edinburgh	UK	1	11	12	2	111	2	0122	40000
2141	Edinburgh	UK	1	11	12	3	112	1	0121	40000
2151	Edinburgh	UK	1	11	12	3	112	2	0122	40000
2161	Edinburgh	UK	1	11	12	4	113	1	0121	40000
2171	Edinburgh	UK	1	11	12	4	113	2	0122	40000
2182	Bristol	UK	2	21	22	5	210	3	0221	40000
2192	Bristol	UK	2	21	22	5	210	4	0222	40000
2202	Bristol	UK	2	21	22	6	211	3	0221	40000
2212	Bristol	UK	2	21	22	6	211	4	0222	40000
2222	Bristol	UK	2	21	22	7	212	3	0221	40000
2232	Bristol	UK	2	21	22	7	212	4	0222	40000
2242	Bristol	UK	2	21	22	8	213	3	0221	40000
2252	Bristol	UK	2	21	22	8	213	4	0222	40000
2263	Glasgow	UK	3	31	32	9	310	5	0321	40000
2273	Glasgow	UK	3	31	32	9	310	6	0322	40000
2283	Glasgow	UK	3	31	32	10	311	5	0321	40000
2293	Glasgow	UK	3	31	32	10	311	6	0322	40000
2303	Glasgow	UK	3	31	32	11	312	5	0321	40000
2313	Glasgow	UK	3	31	32	11	312	6	0322	40000
2323	Glasgow	UK	3	31	32	12	313	5	0321	40000
2333	Glasgow	UK	3	31	32	12	313	6	0322	40000
2344	London	UK	4	41	42	13	410	7	0421	40000
2354	London	UK	4	41	42	13	410	8	0422	40000
2364	London	UK	4	41	42	14	411	7	0421	40000
2374	London	UK	4	41	42	14	411	8	0422	40000
2384	London	UK	4	41	42	15	412	7	0421	40000
2394	London	UK	4	41	42	15	412	8	0422	40000
2404	London	UK	4	41	42	16	413	7	0421	40000
2414	London	UK	4	41	42	16	413	8	0422	40000
2425	Paris	France	5	51	52	17	510	9	0521	40000
2435	Paris	France	5	51	52	17	510	10	0522	40000
2445	Paris	France	5	51	52	18	511	9	0521	40000
2455	Paris	France	5	51	52	18	511	10	0522	40000
2465	Paris	France	5	51	52	19	512	9	0521	40000
2475	Paris	France	5	51	52	19	512	10	0522	40000
2485	Paris	France	5	51	52	20	513	9	0521	40000
2495	Paris	France	5	51	52	20	513	10	0522	40000
2506	Heidelberg	Germany	6	61	62	21	610	11	0621	40000
2516	Heidelberg	Germany	6	61	62	21	610	12	0622	40000
2526	Heidelberg	Germany	6	61	62	22	611	11	0621	40000
2536	Heidelberg	Germany	6	61	62	22	611	12	0622	40000
2546	Heidelberg	Germany	6	61	62	23	612	11	0621	40000
2556	Heidelberg	Germany	6	61	62	23	612	12	0622	40000
2566	Heidelberg	Germany	6	61	62	24	613	11	0621	40000
2576	Heidelberg	Germany	6	61	62	24	613	12	0622	40000
2587	Riga	Latvia	7	71	72	25	710	13	0721	40000
2597	Riga	Latvia	7	71	72	25	710	14	0722	40000
2607	Riga	Latvia	7	71	72	26	711	13	0721	40000
2617	Riga	Latvia	7	71	72	26	711	14	0722	40000
2627	Riga	Latvia	7	71	72	27	712	13	0721	40000
2637	Riga	Latvia	7	71	72	27	712	14	0722	40000
2647	Riga	Latvia	7	71	72	28	713	13	0721	40000
2657	Riga	Latvia	7	71	72	28	713	14	0722	40000
2668	Orlando	USA	8	81	82	29	810	15	0821	40000
2678	Orlando	USA	8	81	82	29	810	16	0822	40000
2688	Orlando	USA	8	81	82	30	811	15	0821	40000
2698	Orlando	USA	8	81	82	30	811	16	0822	40000
2708	Orlando	USA	8	81	82	31	812	15	0821	40000
2718	Orlando	USA	8	81	82	31	812	16	0822	40000
2728	Orlando	USA	8	81	82	32	813	15	0821	40000
2738	Orlando	USA	8	81	82	32	813	16	0822	40000
274Show auto-inc values
275select count(1), max(entry_key) from test.idx_tbl;
276count(1)	max(entry_key)
2778	8
278show create table idx_tbl;
279Table	Create Table
280idx_tbl	CREATE TABLE `idx_tbl` (
281  `entry_key` bigint unsigned NOT NULL AUTO_INCREMENT,
282  `k1` varchar(100) NOT NULL,
283  `k2` varchar(100) NOT NULL,
284  `data` int DEFAULT NULL,
285  PRIMARY KEY (`k1`,`k2`),
286  UNIQUE KEY `entry_key` (`entry_key`)
287) ENGINE=ndbcluster AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
288select count(1), max(mv_idx) from test.type2_1;
289count(1)	max(mv_idx)
29032	32
291show create table type2_1;
292Table	Create Table
293type2_1	CREATE TABLE `type2_1` (
294  `entry_key` bigint unsigned NOT NULL,
295  `mv_idx` bigint unsigned NOT NULL AUTO_INCREMENT,
296  `data` int DEFAULT NULL,
297  PRIMARY KEY (`entry_key`,`mv_idx`)
298) ENGINE=ndbcluster AUTO_INCREMENT=33 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
299select count(1), max(mv_idx) from test.type2_2;
300count(1)	max(mv_idx)
30116	16
302show create table type2_2;
303Table	Create Table
304type2_2	CREATE TABLE `type2_2` (
305  `entry_key` bigint unsigned NOT NULL,
306  `mv_idx` bigint unsigned NOT NULL AUTO_INCREMENT,
307  `data` text,
308  PRIMARY KEY (`entry_key`,`mv_idx`)
309) ENGINE=ndbcluster AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
310No mv_idx duplicates in type_2 tables
311select mv_idx, count(1) as ct
312from type2_1 group by mv_idx
313having ct > 1;
314mv_idx	ct
315select mv_idx, count(1) as ct
316from type2_2 group by mv_idx
317having ct > 1;
318mv_idx	ct
319Run backup
320Create a different set of entities, with the same auto-inc
321keys for entry_key and mv_idx
322update idx_tbl set k1="Stockholm", k2="Sweden" where entry_key = 1;
323update idx_tbl set k1="Trondheim", k2="Norway" where entry_key = 2;
324update idx_tbl set k1="Portland", k2="USA" where entry_key=3;
325update idx_tbl set k1="Bangalore", k2="India" where entry_key=4;
326update idx_tbl set k1="Helsinki", k2="Finland" where entry_key=5;
327update idx_tbl set k1="Lisbon", k2="Portugal" where entry_key=6;
328update idx_tbl set k1="Norrwaste", k2="Sweden" where entry_key=7;
329update idx_tbl set k1="ROW", k2="Earth" where entry_key=8;
330Modify data to be distinct
331update idx_tbl set data = data+10;
332update type1_1 set data = data+100;
333update type1_2 set data = data+100;
334update type2_1 set data = data+1000;
335update type2_2 set data = repeat(right(data, 4)+1000, 10000);
336Second set of content
337---------------------
338select idx_tbl.entry_key,
339idx_tbl.k1,
340idx_tbl.k2,
341idx_tbl.data,
342type1_1.data,
343type1_2.data,
344type2_1.mv_idx,
345type2_1.data,
346type2_2.mv_idx,
347right(type2_2.data,4),
348length(type2_2.data)
349from
350idx_tbl join type1_1 join type1_2 join type2_1 join type2_2
351on
352idx_tbl.entry_key = type1_1.entry_key
353and
354idx_tbl.entry_key = type1_2.entry_key
355and
356idx_tbl.entry_key = type2_1.entry_key
357and
358idx_tbl.entry_key = type2_2.entry_key
359order by idx_tbl.entry_key, type2_1.data, right(type2_2.data,4);
360entry_key	k1	k2	data	data	data	mv_idx	data	mv_idx	right(type2_2.data,4)	length(type2_2.data)
3611	Stockholm	Sweden	11	111	112	1	1110	1	1121	40000
3621	Stockholm	Sweden	11	111	112	1	1110	2	1122	40000
3631	Stockholm	Sweden	11	111	112	2	1111	1	1121	40000
3641	Stockholm	Sweden	11	111	112	2	1111	2	1122	40000
3651	Stockholm	Sweden	11	111	112	3	1112	1	1121	40000
3661	Stockholm	Sweden	11	111	112	3	1112	2	1122	40000
3671	Stockholm	Sweden	11	111	112	4	1113	1	1121	40000
3681	Stockholm	Sweden	11	111	112	4	1113	2	1122	40000
3692	Trondheim	Norway	12	121	122	5	1210	3	1221	40000
3702	Trondheim	Norway	12	121	122	5	1210	4	1222	40000
3712	Trondheim	Norway	12	121	122	6	1211	3	1221	40000
3722	Trondheim	Norway	12	121	122	6	1211	4	1222	40000
3732	Trondheim	Norway	12	121	122	7	1212	3	1221	40000
3742	Trondheim	Norway	12	121	122	7	1212	4	1222	40000
3752	Trondheim	Norway	12	121	122	8	1213	3	1221	40000
3762	Trondheim	Norway	12	121	122	8	1213	4	1222	40000
3773	Portland	USA	13	131	132	9	1310	5	1321	40000
3783	Portland	USA	13	131	132	9	1310	6	1322	40000
3793	Portland	USA	13	131	132	10	1311	5	1321	40000
3803	Portland	USA	13	131	132	10	1311	6	1322	40000
3813	Portland	USA	13	131	132	11	1312	5	1321	40000
3823	Portland	USA	13	131	132	11	1312	6	1322	40000
3833	Portland	USA	13	131	132	12	1313	5	1321	40000
3843	Portland	USA	13	131	132	12	1313	6	1322	40000
3854	Bangalore	India	14	141	142	13	1410	7	1421	40000
3864	Bangalore	India	14	141	142	13	1410	8	1422	40000
3874	Bangalore	India	14	141	142	14	1411	7	1421	40000
3884	Bangalore	India	14	141	142	14	1411	8	1422	40000
3894	Bangalore	India	14	141	142	15	1412	7	1421	40000
3904	Bangalore	India	14	141	142	15	1412	8	1422	40000
3914	Bangalore	India	14	141	142	16	1413	7	1421	40000
3924	Bangalore	India	14	141	142	16	1413	8	1422	40000
3935	Helsinki	Finland	15	151	152	17	1510	9	1521	40000
3945	Helsinki	Finland	15	151	152	17	1510	10	1522	40000
3955	Helsinki	Finland	15	151	152	18	1511	9	1521	40000
3965	Helsinki	Finland	15	151	152	18	1511	10	1522	40000
3975	Helsinki	Finland	15	151	152	19	1512	9	1521	40000
3985	Helsinki	Finland	15	151	152	19	1512	10	1522	40000
3995	Helsinki	Finland	15	151	152	20	1513	9	1521	40000
4005	Helsinki	Finland	15	151	152	20	1513	10	1522	40000
4016	Lisbon	Portugal	16	161	162	21	1610	11	1621	40000
4026	Lisbon	Portugal	16	161	162	21	1610	12	1622	40000
4036	Lisbon	Portugal	16	161	162	22	1611	11	1621	40000
4046	Lisbon	Portugal	16	161	162	22	1611	12	1622	40000
4056	Lisbon	Portugal	16	161	162	23	1612	11	1621	40000
4066	Lisbon	Portugal	16	161	162	23	1612	12	1622	40000
4076	Lisbon	Portugal	16	161	162	24	1613	11	1621	40000
4086	Lisbon	Portugal	16	161	162	24	1613	12	1622	40000
4097	Norrwaste	Sweden	17	171	172	25	1710	13	1721	40000
4107	Norrwaste	Sweden	17	171	172	25	1710	14	1722	40000
4117	Norrwaste	Sweden	17	171	172	26	1711	13	1721	40000
4127	Norrwaste	Sweden	17	171	172	26	1711	14	1722	40000
4137	Norrwaste	Sweden	17	171	172	27	1712	13	1721	40000
4147	Norrwaste	Sweden	17	171	172	27	1712	14	1722	40000
4157	Norrwaste	Sweden	17	171	172	28	1713	13	1721	40000
4167	Norrwaste	Sweden	17	171	172	28	1713	14	1722	40000
4178	ROW	Earth	18	181	182	29	1810	15	1821	40000
4188	ROW	Earth	18	181	182	29	1810	16	1822	40000
4198	ROW	Earth	18	181	182	30	1811	15	1821	40000
4208	ROW	Earth	18	181	182	30	1811	16	1822	40000
4218	ROW	Earth	18	181	182	31	1812	15	1821	40000
4228	ROW	Earth	18	181	182	31	1812	16	1822	40000
4238	ROW	Earth	18	181	182	32	1813	15	1821	40000
4248	ROW	Earth	18	181	182	32	1813	16	1822	40000
425Show auto-inc values
426select count(1), max(entry_key) from test.idx_tbl;
427count(1)	max(entry_key)
4288	8
429show create table idx_tbl;
430Table	Create Table
431idx_tbl	CREATE TABLE `idx_tbl` (
432  `entry_key` bigint unsigned NOT NULL AUTO_INCREMENT,
433  `k1` varchar(100) NOT NULL,
434  `k2` varchar(100) NOT NULL,
435  `data` int DEFAULT NULL,
436  PRIMARY KEY (`k1`,`k2`),
437  UNIQUE KEY `entry_key` (`entry_key`)
438) ENGINE=ndbcluster AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
439select count(1), max(mv_idx) from test.type2_1;
440count(1)	max(mv_idx)
44132	32
442show create table type2_1;
443Table	Create Table
444type2_1	CREATE TABLE `type2_1` (
445  `entry_key` bigint unsigned NOT NULL,
446  `mv_idx` bigint unsigned NOT NULL AUTO_INCREMENT,
447  `data` int DEFAULT NULL,
448  PRIMARY KEY (`entry_key`,`mv_idx`)
449) ENGINE=ndbcluster AUTO_INCREMENT=33 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
450select count(1), max(mv_idx) from test.type2_2;
451count(1)	max(mv_idx)
45216	16
453show create table type2_2;
454Table	Create Table
455type2_2	CREATE TABLE `type2_2` (
456  `entry_key` bigint unsigned NOT NULL,
457  `mv_idx` bigint unsigned NOT NULL AUTO_INCREMENT,
458  `data` text,
459  PRIMARY KEY (`entry_key`,`mv_idx`)
460) ENGINE=ndbcluster AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
461No mv_idx duplicates in type_2 tables
462select mv_idx, count(1) as ct
463from type2_1 group by mv_idx
464having ct > 1;
465mv_idx	ct
466select mv_idx, count(1) as ct
467from type2_2 group by mv_idx
468having ct > 1;
469mv_idx	ct
470Run backup
471drop table idx_tbl, type1_1, type1_2, type2_1, type2_2;
472Run normal restore for first set of content
473Waiting for metadata sync
474Metadata synchronised
475Remap args : -x test.idx_tbl.entry_key:offset:9 -x test.type1_1.entry_key:offset:9 -x test.type1_2.entry_key:offset:9 -x test.type2_1.entry_key:offset:9 -x test.type2_1.mv_idx:offset:33 -x test.type2_2.entry_key:offset:9 -x test.type2_2.mv_idx:offset:17
476Run offset restore for second set of content
477Combined dataset
478-----------------
479select idx_tbl.entry_key,
480idx_tbl.k1,
481idx_tbl.k2,
482idx_tbl.data,
483type1_1.data,
484type1_2.data,
485type2_1.mv_idx,
486type2_1.data,
487type2_2.mv_idx,
488right(type2_2.data,4),
489length(type2_2.data)
490from
491idx_tbl join type1_1 join type1_2 join type2_1 join type2_2
492on
493idx_tbl.entry_key = type1_1.entry_key
494and
495idx_tbl.entry_key = type1_2.entry_key
496and
497idx_tbl.entry_key = type2_1.entry_key
498and
499idx_tbl.entry_key = type2_2.entry_key
500order by idx_tbl.entry_key, type2_1.data, right(type2_2.data,4);
501entry_key	k1	k2	data	data	data	mv_idx	data	mv_idx	right(type2_2.data,4)	length(type2_2.data)
5021	Edinburgh	UK	1	11	12	1	110	1	0121	40000
5031	Edinburgh	UK	1	11	12	1	110	2	0122	40000
5041	Edinburgh	UK	1	11	12	2	111	1	0121	40000
5051	Edinburgh	UK	1	11	12	2	111	2	0122	40000
5061	Edinburgh	UK	1	11	12	3	112	1	0121	40000
5071	Edinburgh	UK	1	11	12	3	112	2	0122	40000
5081	Edinburgh	UK	1	11	12	4	113	1	0121	40000
5091	Edinburgh	UK	1	11	12	4	113	2	0122	40000
5102	Bristol	UK	2	21	22	5	210	3	0221	40000
5112	Bristol	UK	2	21	22	5	210	4	0222	40000
5122	Bristol	UK	2	21	22	6	211	3	0221	40000
5132	Bristol	UK	2	21	22	6	211	4	0222	40000
5142	Bristol	UK	2	21	22	7	212	3	0221	40000
5152	Bristol	UK	2	21	22	7	212	4	0222	40000
5162	Bristol	UK	2	21	22	8	213	3	0221	40000
5172	Bristol	UK	2	21	22	8	213	4	0222	40000
5183	Glasgow	UK	3	31	32	9	310	5	0321	40000
5193	Glasgow	UK	3	31	32	9	310	6	0322	40000
5203	Glasgow	UK	3	31	32	10	311	5	0321	40000
5213	Glasgow	UK	3	31	32	10	311	6	0322	40000
5223	Glasgow	UK	3	31	32	11	312	5	0321	40000
5233	Glasgow	UK	3	31	32	11	312	6	0322	40000
5243	Glasgow	UK	3	31	32	12	313	5	0321	40000
5253	Glasgow	UK	3	31	32	12	313	6	0322	40000
5264	London	UK	4	41	42	13	410	7	0421	40000
5274	London	UK	4	41	42	13	410	8	0422	40000
5284	London	UK	4	41	42	14	411	7	0421	40000
5294	London	UK	4	41	42	14	411	8	0422	40000
5304	London	UK	4	41	42	15	412	7	0421	40000
5314	London	UK	4	41	42	15	412	8	0422	40000
5324	London	UK	4	41	42	16	413	7	0421	40000
5334	London	UK	4	41	42	16	413	8	0422	40000
5345	Paris	France	5	51	52	17	510	9	0521	40000
5355	Paris	France	5	51	52	17	510	10	0522	40000
5365	Paris	France	5	51	52	18	511	9	0521	40000
5375	Paris	France	5	51	52	18	511	10	0522	40000
5385	Paris	France	5	51	52	19	512	9	0521	40000
5395	Paris	France	5	51	52	19	512	10	0522	40000
5405	Paris	France	5	51	52	20	513	9	0521	40000
5415	Paris	France	5	51	52	20	513	10	0522	40000
5426	Heidelberg	Germany	6	61	62	21	610	11	0621	40000
5436	Heidelberg	Germany	6	61	62	21	610	12	0622	40000
5446	Heidelberg	Germany	6	61	62	22	611	11	0621	40000
5456	Heidelberg	Germany	6	61	62	22	611	12	0622	40000
5466	Heidelberg	Germany	6	61	62	23	612	11	0621	40000
5476	Heidelberg	Germany	6	61	62	23	612	12	0622	40000
5486	Heidelberg	Germany	6	61	62	24	613	11	0621	40000
5496	Heidelberg	Germany	6	61	62	24	613	12	0622	40000
5507	Riga	Latvia	7	71	72	25	710	13	0721	40000
5517	Riga	Latvia	7	71	72	25	710	14	0722	40000
5527	Riga	Latvia	7	71	72	26	711	13	0721	40000
5537	Riga	Latvia	7	71	72	26	711	14	0722	40000
5547	Riga	Latvia	7	71	72	27	712	13	0721	40000
5557	Riga	Latvia	7	71	72	27	712	14	0722	40000
5567	Riga	Latvia	7	71	72	28	713	13	0721	40000
5577	Riga	Latvia	7	71	72	28	713	14	0722	40000
5588	Orlando	USA	8	81	82	29	810	15	0821	40000
5598	Orlando	USA	8	81	82	29	810	16	0822	40000
5608	Orlando	USA	8	81	82	30	811	15	0821	40000
5618	Orlando	USA	8	81	82	30	811	16	0822	40000
5628	Orlando	USA	8	81	82	31	812	15	0821	40000
5638	Orlando	USA	8	81	82	31	812	16	0822	40000
5648	Orlando	USA	8	81	82	32	813	15	0821	40000
5658	Orlando	USA	8	81	82	32	813	16	0822	40000
56610	Stockholm	Sweden	11	111	112	34	1110	18	1121	40000
56710	Stockholm	Sweden	11	111	112	34	1110	19	1122	40000
56810	Stockholm	Sweden	11	111	112	35	1111	18	1121	40000
56910	Stockholm	Sweden	11	111	112	35	1111	19	1122	40000
57010	Stockholm	Sweden	11	111	112	36	1112	18	1121	40000
57110	Stockholm	Sweden	11	111	112	36	1112	19	1122	40000
57210	Stockholm	Sweden	11	111	112	37	1113	18	1121	40000
57310	Stockholm	Sweden	11	111	112	37	1113	19	1122	40000
57411	Trondheim	Norway	12	121	122	38	1210	20	1221	40000
57511	Trondheim	Norway	12	121	122	38	1210	21	1222	40000
57611	Trondheim	Norway	12	121	122	39	1211	20	1221	40000
57711	Trondheim	Norway	12	121	122	39	1211	21	1222	40000
57811	Trondheim	Norway	12	121	122	40	1212	20	1221	40000
57911	Trondheim	Norway	12	121	122	40	1212	21	1222	40000
58011	Trondheim	Norway	12	121	122	41	1213	20	1221	40000
58111	Trondheim	Norway	12	121	122	41	1213	21	1222	40000
58212	Portland	USA	13	131	132	42	1310	22	1321	40000
58312	Portland	USA	13	131	132	42	1310	23	1322	40000
58412	Portland	USA	13	131	132	43	1311	22	1321	40000
58512	Portland	USA	13	131	132	43	1311	23	1322	40000
58612	Portland	USA	13	131	132	44	1312	22	1321	40000
58712	Portland	USA	13	131	132	44	1312	23	1322	40000
58812	Portland	USA	13	131	132	45	1313	22	1321	40000
58912	Portland	USA	13	131	132	45	1313	23	1322	40000
59013	Bangalore	India	14	141	142	46	1410	24	1421	40000
59113	Bangalore	India	14	141	142	46	1410	25	1422	40000
59213	Bangalore	India	14	141	142	47	1411	24	1421	40000
59313	Bangalore	India	14	141	142	47	1411	25	1422	40000
59413	Bangalore	India	14	141	142	48	1412	24	1421	40000
59513	Bangalore	India	14	141	142	48	1412	25	1422	40000
59613	Bangalore	India	14	141	142	49	1413	24	1421	40000
59713	Bangalore	India	14	141	142	49	1413	25	1422	40000
59814	Helsinki	Finland	15	151	152	50	1510	26	1521	40000
59914	Helsinki	Finland	15	151	152	50	1510	27	1522	40000
60014	Helsinki	Finland	15	151	152	51	1511	26	1521	40000
60114	Helsinki	Finland	15	151	152	51	1511	27	1522	40000
60214	Helsinki	Finland	15	151	152	52	1512	26	1521	40000
60314	Helsinki	Finland	15	151	152	52	1512	27	1522	40000
60414	Helsinki	Finland	15	151	152	53	1513	26	1521	40000
60514	Helsinki	Finland	15	151	152	53	1513	27	1522	40000
60615	Lisbon	Portugal	16	161	162	54	1610	28	1621	40000
60715	Lisbon	Portugal	16	161	162	54	1610	29	1622	40000
60815	Lisbon	Portugal	16	161	162	55	1611	28	1621	40000
60915	Lisbon	Portugal	16	161	162	55	1611	29	1622	40000
61015	Lisbon	Portugal	16	161	162	56	1612	28	1621	40000
61115	Lisbon	Portugal	16	161	162	56	1612	29	1622	40000
61215	Lisbon	Portugal	16	161	162	57	1613	28	1621	40000
61315	Lisbon	Portugal	16	161	162	57	1613	29	1622	40000
61416	Norrwaste	Sweden	17	171	172	58	1710	30	1721	40000
61516	Norrwaste	Sweden	17	171	172	58	1710	31	1722	40000
61616	Norrwaste	Sweden	17	171	172	59	1711	30	1721	40000
61716	Norrwaste	Sweden	17	171	172	59	1711	31	1722	40000
61816	Norrwaste	Sweden	17	171	172	60	1712	30	1721	40000
61916	Norrwaste	Sweden	17	171	172	60	1712	31	1722	40000
62016	Norrwaste	Sweden	17	171	172	61	1713	30	1721	40000
62116	Norrwaste	Sweden	17	171	172	61	1713	31	1722	40000
62217	ROW	Earth	18	181	182	62	1810	32	1821	40000
62317	ROW	Earth	18	181	182	62	1810	33	1822	40000
62417	ROW	Earth	18	181	182	63	1811	32	1821	40000
62517	ROW	Earth	18	181	182	63	1811	33	1822	40000
62617	ROW	Earth	18	181	182	64	1812	32	1821	40000
62717	ROW	Earth	18	181	182	64	1812	33	1822	40000
62817	ROW	Earth	18	181	182	65	1813	32	1821	40000
62917	ROW	Earth	18	181	182	65	1813	33	1822	40000
630Show auto-inc values
631select count(1), max(entry_key) from test.idx_tbl;
632count(1)	max(entry_key)
63316	17
634show create table idx_tbl;
635Table	Create Table
636idx_tbl	CREATE TABLE `idx_tbl` (
637  `entry_key` bigint unsigned NOT NULL AUTO_INCREMENT,
638  `k1` varchar(100) NOT NULL,
639  `k2` varchar(100) NOT NULL,
640  `data` int DEFAULT NULL,
641  PRIMARY KEY (`k1`,`k2`),
642  UNIQUE KEY `entry_key` (`entry_key`)
643) ENGINE=ndbcluster AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
644select count(1), max(mv_idx) from test.type2_1;
645count(1)	max(mv_idx)
64664	65
647show create table type2_1;
648Table	Create Table
649type2_1	CREATE TABLE `type2_1` (
650  `entry_key` bigint unsigned NOT NULL,
651  `mv_idx` bigint unsigned NOT NULL AUTO_INCREMENT,
652  `data` int DEFAULT NULL,
653  PRIMARY KEY (`entry_key`,`mv_idx`)
654) ENGINE=ndbcluster AUTO_INCREMENT=66 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
655select count(1), max(mv_idx) from test.type2_2;
656count(1)	max(mv_idx)
65732	33
658show create table type2_2;
659Table	Create Table
660type2_2	CREATE TABLE `type2_2` (
661  `entry_key` bigint unsigned NOT NULL,
662  `mv_idx` bigint unsigned NOT NULL AUTO_INCREMENT,
663  `data` text,
664  PRIMARY KEY (`entry_key`,`mv_idx`)
665) ENGINE=ndbcluster AUTO_INCREMENT=34 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
666No mv_idx duplicates in type_2 tables
667select mv_idx, count(1) as ct
668from type2_1 group by mv_idx
669having ct > 1;
670mv_idx	ct
671select mv_idx, count(1) as ct
672from type2_2 group by mv_idx
673having ct > 1;
674mv_idx	ct
675Verify the insert of further entity succeeds
676insert into idx_tbl (k1,k2,data) values ('Sancerre', 'France', 9);
677select last_insert_id() into @ek;
678insert into type1_1 values (@ek, 91);
679insert into type1_2 values (@ek, 92);
680insert into type2_1 (entry_key, data) values (@ek, 910);
681insert into type2_1 (entry_key, data) values (@ek, 911);
682insert into type2_1 (entry_key, data) values (@ek, 912);
683insert into type2_1 (entry_key, data) values (@ek, 913);
684insert into type2_2 (entry_key, data) values (@ek, repeat("0921", 10000));
685insert into type2_2 (entry_key, data) values (@ek, repeat("0922", 10000));
686Modified content
687----------------
688select idx_tbl.entry_key,
689idx_tbl.k1,
690idx_tbl.k2,
691idx_tbl.data,
692type1_1.data,
693type1_2.data,
694type2_1.mv_idx,
695type2_1.data,
696type2_2.mv_idx,
697right(type2_2.data,4),
698length(type2_2.data)
699from
700idx_tbl join type1_1 join type1_2 join type2_1 join type2_2
701on
702idx_tbl.entry_key = type1_1.entry_key
703and
704idx_tbl.entry_key = type1_2.entry_key
705and
706idx_tbl.entry_key = type2_1.entry_key
707and
708idx_tbl.entry_key = type2_2.entry_key
709order by idx_tbl.entry_key, type2_1.data, right(type2_2.data,4);
710entry_key	k1	k2	data	data	data	mv_idx	data	mv_idx	right(type2_2.data,4)	length(type2_2.data)
7111	Edinburgh	UK	1	11	12	1	110	1	0121	40000
7121	Edinburgh	UK	1	11	12	1	110	2	0122	40000
7131	Edinburgh	UK	1	11	12	2	111	1	0121	40000
7141	Edinburgh	UK	1	11	12	2	111	2	0122	40000
7151	Edinburgh	UK	1	11	12	3	112	1	0121	40000
7161	Edinburgh	UK	1	11	12	3	112	2	0122	40000
7171	Edinburgh	UK	1	11	12	4	113	1	0121	40000
7181	Edinburgh	UK	1	11	12	4	113	2	0122	40000
7192	Bristol	UK	2	21	22	5	210	3	0221	40000
7202	Bristol	UK	2	21	22	5	210	4	0222	40000
7212	Bristol	UK	2	21	22	6	211	3	0221	40000
7222	Bristol	UK	2	21	22	6	211	4	0222	40000
7232	Bristol	UK	2	21	22	7	212	3	0221	40000
7242	Bristol	UK	2	21	22	7	212	4	0222	40000
7252	Bristol	UK	2	21	22	8	213	3	0221	40000
7262	Bristol	UK	2	21	22	8	213	4	0222	40000
7273	Glasgow	UK	3	31	32	9	310	5	0321	40000
7283	Glasgow	UK	3	31	32	9	310	6	0322	40000
7293	Glasgow	UK	3	31	32	10	311	5	0321	40000
7303	Glasgow	UK	3	31	32	10	311	6	0322	40000
7313	Glasgow	UK	3	31	32	11	312	5	0321	40000
7323	Glasgow	UK	3	31	32	11	312	6	0322	40000
7333	Glasgow	UK	3	31	32	12	313	5	0321	40000
7343	Glasgow	UK	3	31	32	12	313	6	0322	40000
7354	London	UK	4	41	42	13	410	7	0421	40000
7364	London	UK	4	41	42	13	410	8	0422	40000
7374	London	UK	4	41	42	14	411	7	0421	40000
7384	London	UK	4	41	42	14	411	8	0422	40000
7394	London	UK	4	41	42	15	412	7	0421	40000
7404	London	UK	4	41	42	15	412	8	0422	40000
7414	London	UK	4	41	42	16	413	7	0421	40000
7424	London	UK	4	41	42	16	413	8	0422	40000
7435	Paris	France	5	51	52	17	510	9	0521	40000
7445	Paris	France	5	51	52	17	510	10	0522	40000
7455	Paris	France	5	51	52	18	511	9	0521	40000
7465	Paris	France	5	51	52	18	511	10	0522	40000
7475	Paris	France	5	51	52	19	512	9	0521	40000
7485	Paris	France	5	51	52	19	512	10	0522	40000
7495	Paris	France	5	51	52	20	513	9	0521	40000
7505	Paris	France	5	51	52	20	513	10	0522	40000
7516	Heidelberg	Germany	6	61	62	21	610	11	0621	40000
7526	Heidelberg	Germany	6	61	62	21	610	12	0622	40000
7536	Heidelberg	Germany	6	61	62	22	611	11	0621	40000
7546	Heidelberg	Germany	6	61	62	22	611	12	0622	40000
7556	Heidelberg	Germany	6	61	62	23	612	11	0621	40000
7566	Heidelberg	Germany	6	61	62	23	612	12	0622	40000
7576	Heidelberg	Germany	6	61	62	24	613	11	0621	40000
7586	Heidelberg	Germany	6	61	62	24	613	12	0622	40000
7597	Riga	Latvia	7	71	72	25	710	13	0721	40000
7607	Riga	Latvia	7	71	72	25	710	14	0722	40000
7617	Riga	Latvia	7	71	72	26	711	13	0721	40000
7627	Riga	Latvia	7	71	72	26	711	14	0722	40000
7637	Riga	Latvia	7	71	72	27	712	13	0721	40000
7647	Riga	Latvia	7	71	72	27	712	14	0722	40000
7657	Riga	Latvia	7	71	72	28	713	13	0721	40000
7667	Riga	Latvia	7	71	72	28	713	14	0722	40000
7678	Orlando	USA	8	81	82	29	810	15	0821	40000
7688	Orlando	USA	8	81	82	29	810	16	0822	40000
7698	Orlando	USA	8	81	82	30	811	15	0821	40000
7708	Orlando	USA	8	81	82	30	811	16	0822	40000
7718	Orlando	USA	8	81	82	31	812	15	0821	40000
7728	Orlando	USA	8	81	82	31	812	16	0822	40000
7738	Orlando	USA	8	81	82	32	813	15	0821	40000
7748	Orlando	USA	8	81	82	32	813	16	0822	40000
77510	Stockholm	Sweden	11	111	112	34	1110	18	1121	40000
77610	Stockholm	Sweden	11	111	112	34	1110	19	1122	40000
77710	Stockholm	Sweden	11	111	112	35	1111	18	1121	40000
77810	Stockholm	Sweden	11	111	112	35	1111	19	1122	40000
77910	Stockholm	Sweden	11	111	112	36	1112	18	1121	40000
78010	Stockholm	Sweden	11	111	112	36	1112	19	1122	40000
78110	Stockholm	Sweden	11	111	112	37	1113	18	1121	40000
78210	Stockholm	Sweden	11	111	112	37	1113	19	1122	40000
78311	Trondheim	Norway	12	121	122	38	1210	20	1221	40000
78411	Trondheim	Norway	12	121	122	38	1210	21	1222	40000
78511	Trondheim	Norway	12	121	122	39	1211	20	1221	40000
78611	Trondheim	Norway	12	121	122	39	1211	21	1222	40000
78711	Trondheim	Norway	12	121	122	40	1212	20	1221	40000
78811	Trondheim	Norway	12	121	122	40	1212	21	1222	40000
78911	Trondheim	Norway	12	121	122	41	1213	20	1221	40000
79011	Trondheim	Norway	12	121	122	41	1213	21	1222	40000
79112	Portland	USA	13	131	132	42	1310	22	1321	40000
79212	Portland	USA	13	131	132	42	1310	23	1322	40000
79312	Portland	USA	13	131	132	43	1311	22	1321	40000
79412	Portland	USA	13	131	132	43	1311	23	1322	40000
79512	Portland	USA	13	131	132	44	1312	22	1321	40000
79612	Portland	USA	13	131	132	44	1312	23	1322	40000
79712	Portland	USA	13	131	132	45	1313	22	1321	40000
79812	Portland	USA	13	131	132	45	1313	23	1322	40000
79913	Bangalore	India	14	141	142	46	1410	24	1421	40000
80013	Bangalore	India	14	141	142	46	1410	25	1422	40000
80113	Bangalore	India	14	141	142	47	1411	24	1421	40000
80213	Bangalore	India	14	141	142	47	1411	25	1422	40000
80313	Bangalore	India	14	141	142	48	1412	24	1421	40000
80413	Bangalore	India	14	141	142	48	1412	25	1422	40000
80513	Bangalore	India	14	141	142	49	1413	24	1421	40000
80613	Bangalore	India	14	141	142	49	1413	25	1422	40000
80714	Helsinki	Finland	15	151	152	50	1510	26	1521	40000
80814	Helsinki	Finland	15	151	152	50	1510	27	1522	40000
80914	Helsinki	Finland	15	151	152	51	1511	26	1521	40000
81014	Helsinki	Finland	15	151	152	51	1511	27	1522	40000
81114	Helsinki	Finland	15	151	152	52	1512	26	1521	40000
81214	Helsinki	Finland	15	151	152	52	1512	27	1522	40000
81314	Helsinki	Finland	15	151	152	53	1513	26	1521	40000
81414	Helsinki	Finland	15	151	152	53	1513	27	1522	40000
81515	Lisbon	Portugal	16	161	162	54	1610	28	1621	40000
81615	Lisbon	Portugal	16	161	162	54	1610	29	1622	40000
81715	Lisbon	Portugal	16	161	162	55	1611	28	1621	40000
81815	Lisbon	Portugal	16	161	162	55	1611	29	1622	40000
81915	Lisbon	Portugal	16	161	162	56	1612	28	1621	40000
82015	Lisbon	Portugal	16	161	162	56	1612	29	1622	40000
82115	Lisbon	Portugal	16	161	162	57	1613	28	1621	40000
82215	Lisbon	Portugal	16	161	162	57	1613	29	1622	40000
82316	Norrwaste	Sweden	17	171	172	58	1710	30	1721	40000
82416	Norrwaste	Sweden	17	171	172	58	1710	31	1722	40000
82516	Norrwaste	Sweden	17	171	172	59	1711	30	1721	40000
82616	Norrwaste	Sweden	17	171	172	59	1711	31	1722	40000
82716	Norrwaste	Sweden	17	171	172	60	1712	30	1721	40000
82816	Norrwaste	Sweden	17	171	172	60	1712	31	1722	40000
82916	Norrwaste	Sweden	17	171	172	61	1713	30	1721	40000
83016	Norrwaste	Sweden	17	171	172	61	1713	31	1722	40000
83117	ROW	Earth	18	181	182	62	1810	32	1821	40000
83217	ROW	Earth	18	181	182	62	1810	33	1822	40000
83317	ROW	Earth	18	181	182	63	1811	32	1821	40000
83417	ROW	Earth	18	181	182	63	1811	33	1822	40000
83517	ROW	Earth	18	181	182	64	1812	32	1821	40000
83617	ROW	Earth	18	181	182	64	1812	33	1822	40000
83717	ROW	Earth	18	181	182	65	1813	32	1821	40000
83817	ROW	Earth	18	181	182	65	1813	33	1822	40000
83918	Sancerre	France	9	91	92	66	910	34	0921	40000
84018	Sancerre	France	9	91	92	66	910	35	0922	40000
84118	Sancerre	France	9	91	92	67	911	34	0921	40000
84218	Sancerre	France	9	91	92	67	911	35	0922	40000
84318	Sancerre	France	9	91	92	68	912	34	0921	40000
84418	Sancerre	France	9	91	92	68	912	35	0922	40000
84518	Sancerre	France	9	91	92	69	913	34	0921	40000
84618	Sancerre	France	9	91	92	69	913	35	0922	40000
847Show auto-inc values
848select count(1), max(entry_key) from test.idx_tbl;
849count(1)	max(entry_key)
85017	18
851show create table idx_tbl;
852Table	Create Table
853idx_tbl	CREATE TABLE `idx_tbl` (
854  `entry_key` bigint unsigned NOT NULL AUTO_INCREMENT,
855  `k1` varchar(100) NOT NULL,
856  `k2` varchar(100) NOT NULL,
857  `data` int DEFAULT NULL,
858  PRIMARY KEY (`k1`,`k2`),
859  UNIQUE KEY `entry_key` (`entry_key`)
860) ENGINE=ndbcluster AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
861select count(1), max(mv_idx) from test.type2_1;
862count(1)	max(mv_idx)
86368	69
864show create table type2_1;
865Table	Create Table
866type2_1	CREATE TABLE `type2_1` (
867  `entry_key` bigint unsigned NOT NULL,
868  `mv_idx` bigint unsigned NOT NULL AUTO_INCREMENT,
869  `data` int DEFAULT NULL,
870  PRIMARY KEY (`entry_key`,`mv_idx`)
871) ENGINE=ndbcluster AUTO_INCREMENT=70 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
872select count(1), max(mv_idx) from test.type2_2;
873count(1)	max(mv_idx)
87434	35
875show create table type2_2;
876Table	Create Table
877type2_2	CREATE TABLE `type2_2` (
878  `entry_key` bigint unsigned NOT NULL,
879  `mv_idx` bigint unsigned NOT NULL AUTO_INCREMENT,
880  `data` text,
881  PRIMARY KEY (`entry_key`,`mv_idx`)
882) ENGINE=ndbcluster AUTO_INCREMENT=36 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
883No mv_idx duplicates in type_2 tables
884select mv_idx, count(1) as ct
885from type2_1 group by mv_idx
886having ct > 1;
887mv_idx	ct
888select mv_idx, count(1) as ct
889from type2_2 group by mv_idx
890having ct > 1;
891mv_idx	ct
892drop table idx_tbl, type1_1, type1_2, type2_1, type2_2;
893