Skip site navigation (1) Skip section navigation (2)

[sqlsmith] Planner crash on foreign table join

From: Andreas Seltenreich <seltenreich(at)gmx(dot)de>
To: pgsql-hackers(at)postgresql(dot)org
Subject: [sqlsmith] Planner crash on foreign table join
Date: 2017-04-08 06:45:46
Message-ID: 87inmf5rdx.fsf@credativ.de (view raw, whole thread or download thread mbox)
Thread:
Lists: pgsql-hackers
Hi,

testing master at f0e44021df with a loopback postgres_fdw installed, I
see lots of crashes on queries joining foreign tables with various
expressions.  Below is a reduced recipe for the regression database and
a backtrace.

regards,
Andreas

--8<---------------cut here---------------start------------->8---
create extension postgres_fdw;
create server myself foreign data wrapper postgres_fdw;
create schema fdw_postgres;
create user fdw login;
grant all on schema public to fdw;
grant all on all tables in schema public to fdw;
create user mapping for public server myself options (user 'fdw');
import foreign schema public from server myself into fdw_postgres;

explain select from
  fdw_postgres.hslot
    left join fdw_postgres.num_exp_div
    on ((exists (values (1))) and (values (1)) is null);
--8<---------------cut here---------------end--------------->8---

Program terminated with signal SIGSEGV, Segmentation fault.
#0  bms_get_singleton_member (a=0x10, member=member(at)entry=0x7fffb577cafc) at bitmapset.c:577
#1  0x000056425107b531 in find_relation_from_clauses (clauses=0x564251a68570, root=0x564251a273d8) at clausesel.c:445
#2  clauselist_selectivity (root=root(at)entry=0x564251a273d8, clauses=0x564251a68570, varRelid=varRelid(at)entry=0, jointype=JOIN_LEFT, sjinfo=0x564251a661c0) at clausesel.c:128
#3  0x00007f61d3d9f22f in postgresGetForeignJoinPaths (root=<optimized out>, joinrel=0x564251a66ba8, outerrel=<optimized out>, innerrel=<optimized out>, jointype=<optimized out>, extra=0x7fffb577cc50) at postgres_fdw.c:4466
#4  0x000056425108a238 in add_paths_to_joinrel (root=root(at)entry=0x564251a273d8, joinrel=joinrel(at)entry=0x564251a66ba8, outerrel=outerrel(at)entry=0x564251a65378, innerrel=innerrel(at)entry=0x564251a65f30, jointype=jointype(at)entry=JOIN_LEFT, sjinfo=sjinfo(at)entry=0x564251a661c0, restrictlist=0x564251a681c8) at joinpath.c:278
#5  0x000056425108bff2 in populate_joinrel_with_paths (restrictlist=<optimized out>, sjinfo=0x564251a661c0, joinrel=0x564251a66ba8, rel2=0x564251a65f30, rel1=0x564251a65378, root=0x564251a273d8) at joinrels.c:795
#6  make_join_rel (root=root(at)entry=0x564251a273d8, rel1=rel1(at)entry=0x564251a65378, rel2=rel2(at)entry=0x564251a65f30) at joinrels.c:731
#7  0x000056425108c7ef in make_rels_by_clause_joins (other_rels=<optimized out>, old_rel=<optimized out>, root=<optimized out>) at joinrels.c:277
#8  join_search_one_level (root=root(at)entry=0x564251a273d8, level=level(at)entry=2) at joinrels.c:99
#9  0x0000564251079bdb in standard_join_search (root=0x564251a273d8, levels_needed=2, initial_rels=<optimized out>) at allpaths.c:2385
#10 0x000056425107ac7b in make_one_rel (root=root(at)entry=0x564251a273d8, joinlist=joinlist(at)entry=0x564251a65998) at allpaths.c:184
#11 0x0000564251099ef4 in query_planner (root=root(at)entry=0x564251a273d8, tlist=tlist(at)entry=0x0, qp_callback=qp_callback(at)entry=0x56425109aeb0 <standard_qp_callback>, qp_extra=qp_extra(at)entry=0x7fffb577cff0) at planmain.c:253
#12 0x000056425109dbc2 in grouping_planner (root=root(at)entry=0x564251a273d8, inheritance_update=inheritance_update(at)entry=0 '\000', tuple_fraction=<optimized out>, tuple_fraction(at)entry=0) at planner.c:1684
#13 0x00005642510a0133 in subquery_planner (glob=glob(at)entry=0x564251a2a6d0, parse=parse(at)entry=0x5642519aac60, parent_root=parent_root(at)entry=0x0, hasRecursion=hasRecursion(at)entry=0 '\000', tuple_fraction=tuple_fraction(at)entry=0) at planner.c:833
#14 0x00005642510a0f71 in standard_planner (parse=0x5642519aac60, cursorOptions=256, boundParams=0x0) at planner.c:333
#15 0x00005642511458cd in pg_plan_query (querytree=querytree(at)entry=0x5642519aac60, cursorOptions=256, boundParams=boundParams(at)entry=0x0) at postgres.c:802
#16 0x0000564250fa9a40 in ExplainOneQuery (query=0x5642519aac60, cursorOptions=<optimized out>, into=0x0, es=0x564251a513a0, queryString=0x564251a09590 "explain select from\n  fdw_postgres.hslot\n    left join fdw_postgres.num_exp_div\n    on ((exists (values (1))) and (values (1)) is null);", params=0x0, queryEnv=0x0) at explain.c:367
#17 0x0000564250faa005 in ExplainQuery (pstate=pstate(at)entry=0x564251a511f0, stmt=stmt(at)entry=0x564251a0aa58, queryString=queryString(at)entry=0x564251a09590 "explain select from\n  fdw_postgres.hslot\n    left join fdw_postgres.num_exp_div\n    on ((exists (values (1))) and (values (1)) is null);", params=params(at)entry=0x0, queryEnv=queryEnv(at)entry=0x0, dest=dest(at)entry=0x564251a51308) at explain.c:256
#18 0x000056425114b9cb in standard_ProcessUtility (pstmt=0x564251a0b2e0, queryString=0x564251a09590 "explain select from\n  fdw_postgres.hslot\n    left join fdw_postgres.num_exp_div\n    on ((exists (values (1))) and (values (1)) is null);", context=PROCESS_UTILITY_TOPLEVEL, params=0x0, queryEnv=0x0, dest=0x564251a51308, completionTag=0x7fffb577d390 "") at utility.c:680
#19 0x00005642511487b4 in PortalRunUtility (portal=0x564251a07580, pstmt=0x564251a0b2e0, isTopLevel=<optimized out>, setHoldSnapshot=<optimized out>, dest=<optimized out>, completionTag=0x7fffb577d390 "") at pquery.c:1179
#20 0x0000564251149633 in FillPortalStore (portal=portal(at)entry=0x564251a07580, isTopLevel=isTopLevel(at)entry=1 '\001') at pquery.c:1039
#21 0x000056425114a21d in PortalRun (portal=portal(at)entry=0x564251a07580, count=count(at)entry=9223372036854775807, isTopLevel=isTopLevel(at)entry=1 '\001', run_once=run_once(at)entry=1 '\001', dest=dest(at)entry=0x564251a0b378, altdest=altdest(at)entry=0x564251a0b378, completionTag=0x7fffb577d5b0 "") at pquery.c:769
#22 0x0000564251145d8a in exec_simple_query (query_string=0x564251a09590 "explain select from\n  fdw_postgres.hslot\n    left join fdw_postgres.num_exp_div\n    on ((exists (values (1))) and (values (1)) is null);") at postgres.c:1105
#23 0x0000564251147ab1 in PostgresMain (argc=<optimized out>, argv=argv(at)entry=0x5642519b2e00, dbname=<optimized out>, username=<optimized out>) at postgres.c:4075
#24 0x0000564250e5c4cc in BackendRun (port=0x5642519a7d70) at postmaster.c:4317
#25 BackendStartup (port=0x5642519a7d70) at postmaster.c:3989
#26 ServerLoop () at postmaster.c:1729
#27 0x00005642510d07c3 in PostmasterMain (argc=3, argv=0x5642519844d0) at postmaster.c:1337
#28 0x0000564250e5db2d in main (argc=3, argv=0x5642519844d0) at main.c:228



Responses

pgsql-hackers by date

Next:From: Pavel StehuleDate: 2017-04-08 07:42:44
Subject: Re: PoC plpgsql - possibility to force custom or generic plan
Previous:From: Masahiko SawadaDate: 2017-04-08 04:32:56
Subject: Re: Remaining 2017-03 CF entries

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group