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@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@entry=0x564251a273d8, 
clauses=0x564251a68570, varRelid=varRelid@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@entry=0x564251a273d8, 
joinrel=joinrel@entry=0x564251a66ba8, outerrel=outerrel@entry=0x564251a65378, 
innerrel=innerrel@entry=0x564251a65f30, jointype=jointype@entry=JOIN_LEFT, 
sjinfo=sjinfo@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@entry=0x564251a273d8, 
rel1=rel1@entry=0x564251a65378, rel2=rel2@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@entry=0x564251a273d8, level=level@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@entry=0x564251a273d8, 
joinlist=joinlist@entry=0x564251a65998) at allpaths.c:184
#11 0x0000564251099ef4 in query_planner (root=root@entry=0x564251a273d8, 
tlist=tlist@entry=0x0, qp_callback=qp_callback@entry=0x56425109aeb0 
<standard_qp_callback>, qp_extra=qp_extra@entry=0x7fffb577cff0) at 
planmain.c:253
#12 0x000056425109dbc2 in grouping_planner (root=root@entry=0x564251a273d8, 
inheritance_update=inheritance_update@entry=0 '\000', tuple_fraction=<optimized 
out>, tuple_fraction@entry=0) at planner.c:1684
#13 0x00005642510a0133 in subquery_planner (glob=glob@entry=0x564251a2a6d0, 
parse=parse@entry=0x5642519aac60, parent_root=parent_root@entry=0x0, 
hasRecursion=hasRecursion@entry=0 '\000', 
tuple_fraction=tuple_fraction@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@entry=0x5642519aac60, cursorOptions=256, 
boundParams=boundParams@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@entry=0x564251a511f0, 
stmt=stmt@entry=0x564251a0aa58, queryString=queryString@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@entry=0x0, queryEnv=queryEnv@entry=0x0, 
dest=dest@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@entry=0x564251a07580, 
isTopLevel=isTopLevel@entry=1 '\001') at pquery.c:1039
#21 0x000056425114a21d in PortalRun (portal=portal@entry=0x564251a07580, 
count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=1 '\001', 
run_once=run_once@entry=1 '\001', dest=dest@entry=0x564251a0b378, 
altdest=altdest@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@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



-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to