Assertion failure in get_appendrel_parampathinfo - Mailing list pgsql-bugs

From Elvis Pranskevichus
Subject Assertion failure in get_appendrel_parampathinfo
Date
Msg-id 2326379.AOuSqtNClj@klinga.prans.org
Whole thread Raw
Responses Re: Assertion failure in get_appendrel_parampathinfo
List pgsql-bugs
Postgres 9.4beta2 and later crashes given the following query:


BEGIN;

CREATE TABLE k (
    id int
);
CREATE UNIQUE INDEX k_idx ON k (id);

INSERT INTO k VALUES(1);

CREATE TABLE link (
    source int,
    target int
);
CREATE UNIQUE INDEX l_idx ON link (source, target);


CREATE TABLE b (
    id int
);
CREATE UNIQUE INDEX b_idx ON b (id);


CREATE TABLE d () INHERITS (b);
CREATE UNIQUE INDEX d_idx ON d (id);


ANALYZE;


SELECT
    1
FROM
    k AS k1
WHERE
    EXISTS (
        (SELECT
                True
            FROM
                k AS k2

                INNER JOIN (
                    link

                    INNER JOIN

                    (SELECT id FROM b
                     UNION ALL SELECT id FROM d) AS v

                    ON (link.target =3D v.id)

                ) ON (k2.id =3D link.source=20
                      AND k1.id =3D link.source)
        )
    );


ROLLBACK;


Which generates the following query plan:

                                            QUERY PLAN                 =
                          =20
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=
=E2=94=80=E2=94=80
 Seq Scan on k k1  (cost=3D0.00..1.33 rows=3D1 width=3D0)
   Filter: (SubPlan 1)
   SubPlan 1
     ->  Nested Loop  (cost=3D0.15..44.43 rows=3D264 width=3D0)
           ->  Seq Scan on k k2  (cost=3D0.00..1.01 rows=3D1 width=3D4)=

                 Filter: (id =3D k1.id)
           ->  Nested Loop  (cost=3D0.15..40.77 rows=3D264 width=3D4)
                 ->  Append  (cost=3D0.00..40.18 rows=3D3 width=3D4)
                       ->  Seq Scan on b  (cost=3D0.00..0.00 rows=3D1 w=
idth=3D4)
                             Filter: (id =3D id)
                       ->  Index Only Scan using d_idx on d d_1  (cost=3D=
0.15..0.18 rows=3D1 width=3D4)
                             Index Cond: (id =3D id)
                       ->  Seq Scan on d  (cost=3D0.00..40.00 rows=3D1 =
width=3D4)
                             Filter: (id =3D id)
                 ->  Index Only Scan using l_idx on link  (cost=3D0.15.=
.0.19 rows=3D1 width=3D8)
                       Index Cond: ((source =3D k1.id) AND (target =3D =
b.id))
 Planning time: 0.411 ms
(17 rows)


Traceback:


#0  0x00007fc0e05cc2f7 in raise () from /lib64/libc.so.6
#1  0x00007fc0e05cd638 in abort () from /lib64/libc.so.6
#2  0x00000000008e9445 in ExceptionalCondition (conditionName=3D0xa75e1=
0 "!(!bms_overlap(appendrel->relids, required_outer))", errorType=3D0xa=
75b5a "FailedAssertion", fileName=3D0xa75b50 "relnode.c", lineNumber=3D=
983) at assert.c:54
#3  0x0000000000720dda in get_appendrel_parampathinfo (appendrel=3D0x13=
f6340, required_outer=3D0x1400c90) at relnode.c:983
#4  0x0000000000718b55 in create_append_path (rel=3D0x13f6340, subpaths=
=3D0x1403ff0, required_outer=3D0x1400c90) at pathnode.c:897
#5  0x00000000006d309a in set_append_rel_pathlist (root=3D0x13ef630, re=
l=3D0x13f6340, rti=3D3, rte=3D0x13ecbd8) at allpaths.c:855
#6  0x00000000006d23e1 in set_rel_pathlist (root=3D0x13ef630, rel=3D0x1=
3f6340, rti=3D3, rte=3D0x13ecbd8) at allpaths.c:320
#7  0x00000000006d21c2 in set_base_rel_pathlists (root=3D0x13ef630) at =
allpaths.c:222
#8  0x00000000006d202f in make_one_rel (root=3D0x13ef630, joinlist=3D0x=
13f5cf0) at allpaths.c:152
#9  0x00000000006f846f in query_planner (root=3D0x13ef630, tlist=3D0x0,=
 qp_callback=3D0x6fc460 <standard_qp_callback>, qp_extra=3D0x7fffe32c28=
a0) at planmain.c:236
#10 0x00000000006fa484 in grouping_planner (root=3D0x13ef630, tuple_fra=
ction=3D1) at planner.c:1288
#11 0x00000000006f91d1 in subquery_planner (glob=3D0x1380d00, parse=3D0=
x13ec4d8, parent_root=3D0x13825b8, hasRecursion=3D0 '\000', tuple_fract=
ion=3D1, subroot=3D0x7fffe32c2aa8) at planner.c:573
#12 0x000000000070288f in make_subplan (root=3D0x13825b8, orig_subquery=
=3D0x137dcd8, subLinkType=3DEXISTS_SUBLINK, subLinkId=3D0, testexpr=3D0=
x0, isTopQual=3D1 '\001') at subselect.c:490
#13 0x0000000000704b77 in process_sublinks_mutator (node=3D0x13ec480, c=
ontext=3D0x7fffe32c2ba0) at subselect.c:1862
#14 0x0000000000704ada in SS_process_sublinks (root=3D0x13825b8, expr=3D=
0x13ec480, isQual=3D1 '\001') at subselect.c:1835
#15 0x00000000006f941c in preprocess_expression (root=3D0x13825b8, expr=
=3D0x13ec480, kind=3D0) at planner.c:693
#16 0x00000000006f94fc in preprocess_qual_conditions (root=3D0x13825b8,=
 jtnode=3D0x1382850) at planner.c:738
#17 0x00000000006f8dae in subquery_planner (glob=3D0x1380d00, parse=3D0=
x137d8a0, parent_root=3D0x0, hasRecursion=3D0 '\000', tuple_fraction=3D=
0, subroot=3D0x7fffe32c2d48) at planner.c:443
#18 0x00000000006f86f8 in standard_planner (parse=3D0x137d8a0, cursorOp=
tions=3D0, boundParams=3D0x0) at planner.c:210
#19 0x00000000006f855c in planner (parse=3D0x137d8a0, cursorOptions=3D0=
, boundParams=3D0x0) at planner.c:139
#20 0x00000000007b04c7 in pg_plan_query (querytree=3D0x137d8a0, cursorO=
ptions=3D0, boundParams=3D0x0) at postgres.c:750
#21 0x00000000007b057a in pg_plan_queries (querytrees=3D0x1382580, curs=
orOptions=3D0, boundParams=3D0x0) at postgres.c:809
#22 0x00000000007b0885 in exec_simple_query (query_string=3D0x1309788 "=
BEGIN;\n\nCREATE TABLE k (\n    id int\n);\nCREATE UNIQUE INDEX k_idx O=
N k (id);\n\nINSERT INTO k VALUES(1);\n\nCREATE TABLE link (\n    sourc=
e int,\n    target int\n);\nCREATE UNIQUE INDEX l_idx ON link (source, =
"...) at postgres.c:974
#23 0x00000000007b4de6 in PostgresMain (argc=3D10, argv=3D0x12b5040, db=
name=3D0x12d2350 "template1", username=3D0x12bcc60 "elvis") at postgres=
.c:4010
#24 0x000000000069757e in main (argc=3D10, argv=3D0x12b5040) at main.c:=
215





                                    Elvis

pgsql-bugs by date:

Previous
From: Michael Paquier
Date:
Subject: Re: BUG #11335: an invalid prepare statement causes crash at log_statement = 'mod' or 'ddl'.
Next
From: hmozaffari@hubhead.com
Date:
Subject: BUG #11442: Long binding time for queries on tables with partitions