-- TRAP: FailedAssertion("!(mergeTargetRelation > 0)", File: "planner.c", Line: 1496)

-- master at 7923118c16
-- revert ad7dbee368a
-- apply merge_v16a.patch

CREATE TABLE hash_i4_heap (
    seqno integer,
    random integer
);
CREATE TABLE idxpart (
    a integer
)
PARTITION BY RANGE (a);
CREATE TABLE idxpart1 PARTITION OF idxpart
FOR VALUES FROM (0) TO (100);
CREATE TABLE idxpart2 PARTITION OF idxpart
FOR VALUES FROM (100) TO (1000)
PARTITION BY RANGE (a);
CREATE TABLE idxpart21 PARTITION OF idxpart2
FOR VALUES FROM (100) TO (200);
CREATE TABLE idxpart22 PARTITION OF idxpart2
FOR VALUES FROM (200) TO (300);
CREATE INDEX hash_i4_index ON hash_i4_heap USING hash (random);
CREATE INDEX idxpart1_a_idx ON idxpart1 USING btree (a);
CREATE INDEX idxpart22_a_idx ON idxpart22 USING btree (a);
CREATE INDEX idxpart2_a_idx ON ONLY idxpart2 USING btree (a);
CREATE INDEX idxpart_a_idx ON ONLY idxpart USING btree (a);
ALTER INDEX public.idxpart_a_idx ATTACH PARTITION public.idxpart1_a_idx;
ALTER INDEX public.idxpart2_a_idx ATTACH PARTITION public.idxpart22_a_idx;
ALTER INDEX public.idxpart_a_idx ATTACH PARTITION public.idxpart2_a_idx;
begin;MERGE INTO public.idxpart as target_0
USING public.hash_i4_heap as ref_0
ON target_0.a = ref_0.seqno 
WHEN MATCHED 
  AND true
   THEN DELETE
;rollback;
