CREATE DATABASE mariadb_mrr_bug;

USE mariadb_mrr_bug;

CREATE TABLE `t2` (
	`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
	`s1` BIGINT(20) NOT NULL,
	`c9` BIGINT(20) NULL DEFAULT NULL,
	PRIMARY KEY (`id`),
	INDEX `A` (`s1`),
	INDEX `origId` (`c9`)
)
COLLATE='utf8_unicode_ci'
ENGINE=InnoDB
;

CREATE TABLE `t1` (
	`id` BIGINT(20) NOT NULL,
	`c13` BIGINT(20) NULL DEFAULT NULL,
	PRIMARY KEY (`id`),
	INDEX `c13` (`c13`),
	CONSTRAINT `B` FOREIGN KEY (`id`) REFERENCES `t2` (`id`) ON UPDATE NO ACTION ON DELETE NO ACTION
)
COLLATE='utf8_unicode_ci'
ENGINE=InnoDB
;

INSERT INTO `t2` (`id`, `s1`, `c9`) VALUES (351, 83, 351), (352, 83, 352), (353, 83, 353), (354, 83, 354), (355, 64, 355), (356, 64, 356), (357, 68, 357), (358, 68, 358), (359, 68, 359), (360, 68, 360), (361, 77, 361), (362, 77, 362), (363, 77, 363), (364, 77, 364), (365, 77, 365), (366, 77, 366), (367, 77, 367), (368, 91, 368), (369, 91, 369), (370, 91, 370), (371, 91, 371), (372, 96, 372), (373, 96, 373), (374, 96, 374), (375, 96, 375), (376, 96, 376), (377, 96, 377), (378, 96, 378), (379, 96, 379), (380, 96, 380), (381, 96, 381), (382, 97, 382), (383, 97, 383), (384, 97, 384), (385, 97, 385), (386, 97, 386), (387, 97, 387), (388, 97, 388), (389, 97, 389), (390, 97, 390), (391, 98, 391), (392, 98, 392), (393, 98, 393), (394, 98, 394), (395, 98, 395), (396, 98, 396), (397, 98, 397), (398, 98, 398), (399, 98, 399), (400, 98, 400), (401, 99, 401), (504, 109, 504), (505, 1, 505), (506, 1, 506), (507, 1, 507), (508, 1, 508), (509, 1, 509), (510, 97, 510), (511, 10, 511), (512, 10, 512), (513, 100, 513), (514, 100, 514), (515, 114, 515), (516, 114, 516), (517, 116, 517), (518, 113, 518), (519, 83, 519), (520, 101, 520), (521, 101, 521), (522, 114, 522), (523, 124, 523), (524, 127, 524), (525, 116, 525), (526, 126, 526), (527, 115, 527), (528, 7, 528), (2444, 84, 2444), (2445, 84, 2445), (2446, 84, 2446), (2447, 84, 2447), (2448, 64, 2448), (2449, 64, 2449), (2450, 88, 2450), (2451, 87, 2451), (2452, 87, 2452), (2453, 89, 2453), (2454, 89, 2454), (2455, 90, 2455), (2456, 90, 2456), (2457, 90, 2457), (2458, 91, 2458), (2459, 91, 2459), (2460, 93, 2460), (2461, 93, 2461), (2462, 93, 2462), (2463, 93, 2463), (2464, 94, 2464), (2465, 94, 2465), (2466, 96, 2466), (2467, 96, 2467), (2468, 96, 2468), (2469, 96, 2469), (2470, 96, 2470), (2471, 97, 2471), (2472, 97, 2472), (2473, 97, 2473), (2474, 97, 2474), (2475, 97, 2475), (2476, 98, 2476), (2477, 98, 2477), (2478, 98, 2478), (2479, 98, 2479), (2480, 98, 2480), (2481, 99, 2481), (2482, 99, 2482), (2483, 99, 2483), (2484, 99, 2484), (2485, 99, 2485), (2486, 100, 2486), (2487, 100, 2487), (2488, 100, 2488), (2489, 100, 2489), (2490, 100, 2490), (3142, 38, 3142), (3143, 58, 3143), (3144, 64, 3144), (3145, 64, 3145), (3146, 64, 3146), (3147, 64, 3147), (3148, 64, 3148), (3149, 64, 3149), (3150, 65, 3150), (3151, 65, 3151), (3152, 68, 3152), (3153, 68, 3153), (3154, 68, 3154), (3155, 68, 3155), (3156, 93, 3156), (3157, 93, 3157), (3158, 93, 3158), (3159, 93, 3159), (3160, 94, 3160), (3161, 94, 3161), (3162, 96, 3162), (3163, 96, 3163), (3164, 96, 3164), (3165, 96, 3165), (3166, 96, 3166), (3167, 97, 3167), (3168, 97, 3168), (3169, 97, 3169), (3170, 97, 3170), (3171, 97, 3171), (3172, 98, 3172), (3173, 98, 3173), (3174, 98, 3174), (3175, 98, 3175), (3176, 98, 3176), (3177, 99, 3177), (3178, 99, 3178), (3179, 99, 3179), (3180, 99, 3180), (3181, 99, 3181), (3182, 100, 3182), (3183, 100, 3183), (3184, 100, 3184), (3185, 100, 3185), (3186, 100, 3186), (3187, 101, 3187), (3188, 101, 3188), (3189, 101, 3189), (3190, 101, 3190), (3191, 101, 3191), (3192, 102, 3192), (3193, 102, 3193), (3356, 96, 3356), (3357, 97, 3357), (3358, 97, 3358), (3359, 97, 3359), (3360, 97, 3360), (3361, 97, 3361), (3362, 98, 3362), (3363, 98, 3363), (3364, 98, 3364), (3365, 98, 3365), (3366, 98, 3366), (3367, 99, 3367), (3368, 99, 3368), (3369, 99, 3369), (3370, 99, 3370), (3371, 99, 3371), (3372, 100, 3372), (3373, 100, 3373), (3374, 100, 3374), (3375, 100, 3375), (3376, 100, 3376), (3377, 101, 3377), (3378, 101, 3378), (3379, 101, 3379), (3380, 101, 3380), (3381, 101, 3381), (3382, 102, 3382), (3383, 102, 3383), (3384, 102, 3384), (3385, 102, 3385), (3386, 102, 3386), (3387, 103, 3387), (3388, 84, 3388), (3389, 105, 3389), (3390, 105, 3390), (3391, 105, 3391), (3392, 105, 3392), (3393, 105, 3393), (3394, 105, 3394), (3395, 133, 3395), (3396, 1, 3396), (3397, 20, 3397), (3398, 153, 3398), (3399, 153, 3399), (3400, 154, 3400), (3401, 154, 3401), (3402, 155, 3402), (3403, 155, 3403), (3404, 155, 3404), (3405, 155, 3405), (3406, 156, 3406), (5569, 23, 5569), (5570, 23, 5570), (5571, 25, 5571), (5572, 26, 5572), (5573, 26, 5573), (5574, 28, 5574), (5575, 30, 5575), (5576, 43, 5576), (5577, 64, 5577), (5578, 67, 5578), (5579, 67, 5579), (5580, 67, 5580), (5581, 67, 5581), (5582, 67, 5582), (5583, 68, 5583), (5584, 68, 5584), (5585, 67, 5585), (5586, 91, 5586), (5587, 96, 5587), (5588, 96, 5588), (5589, 96, 5589), (5590, 97, 5590), (5591, 97, 5591), (5592, 98, 5592), (5593, 98, 5593), (5594, 98, 5594), (5595, 98, 5595), (5596, 99, 5596), (5597, 99, 5597), (5598, 99, 5598), (5599, 100, 5599), (5600, 100, 5600), (5601, 101, 5601), (5602, 101, 5602), (5603, 102, 5603), (5604, 102, 5604), (5605, 102, 5605), (5606, 103, 5606), (5607, 133, 5607), (5608, 116, 5608), (5609, 116, 5609), (5610, 116, 5610), (5611, 117, 5611), (5612, 119, 5612), (5613, 120, 5613), (5614, 122, 5614), (5615, 122, 5615), (5616, 123, 5616), (5617, 123, 5617), (5618, 123, 5618), (5768, 96, 5768), (5769, 96, 5769), (5770, 97, 5770), (5771, 97, 5771), (5772, 97, 5772), (5773, 98, 5773), (5774, 99, 5774), (5775, 99, 5775), (5776, 100, 5776), (5777, 100, 5777), (5778, 100, 5778);
 
INSERT INTO `t1` (`id`, `c13`) VALUES (351, NULL), (352, NULL), (353, NULL), (354, NULL), (355, NULL), (356, NULL), (357, NULL), (358, NULL), (359, NULL), (360, NULL), (361, NULL), (362, NULL), (363, NULL), (364, NULL), (365, NULL), (366, NULL), (367, NULL), (368, NULL), (369, NULL), (370, NULL), (371, NULL), (372, NULL), (373, NULL), (374, NULL), (375, NULL), (376, NULL), (377, NULL), (378, NULL), (379, NULL), (380, NULL), (381, NULL), (382, NULL), (383, NULL), (384, NULL), (385, NULL), (386, NULL), (387, NULL), (388, NULL), (389, NULL), (390, NULL), (391, NULL), (392, NULL), (393, NULL), (394, NULL), (395, NULL), (396, NULL), (397, NULL), (398, NULL), (399, NULL);
