Re: BUG #15352: postgresql FDW error "ERROR: ORDER BY position 0 is not in select list"

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: maxim(dot)boguk(at)gmail(dot)com, rhaas(at)postgresql(dot)org, Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>
Subject: Re: BUG #15352: postgresql FDW error "ERROR: ORDER BY position 0 is not in select list"
Date: 2018-08-25 17:12:58
Message-ID: 87a7paz8b1.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

>>>>> "Andrew" == Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> writes:

Andrew> So what's happening here is that there's an equivalence class
Andrew> containing members
Andrew> "greatest(pg_catalog.pg_stat_user_tables.idx_scan,
Andrew> public.pg_stat_user_tables.idx_scan)" and "0" (as an integer
Andrew> constant), and somehow a pathkey for this eclass is becoming
Andrew> attached to the query going to the remote for statistics
Andrew> purposes.

Andrew> It seems obviously wrong that a constant pathkey with no actual
Andrew> reference to the foreign table should be being pushed down, so
Andrew> so far I suspect that get_useful_pathkeys_for_relation isn't
Andrew> being selective enough about what is "useful". In this context
Andrew> I find it suspicious that find_em_expr_for_rel will return an
Andrew> expr with no vars as being "for" every rel, since it's just
Andrew> looking for a subset.

So this looks to me like an oversight in aa09cd242 (CCing rhaas and
Ashutosh accordingly), which changed find_em_expr_for_rel from using
bms_equal to bms_is_subset without considering the degenerate case of
members with no relids at all. I propose to simply add a !bms_is_empty
condition there; anyone have any better idea?

--
Andrew (irc:RhodiumToad)

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2018-08-25 21:09:38 BUG #15353: \det (list foreign tables) ignoring search_path
Previous Message Andrew Gierth 2018-08-25 08:50:13 Re: BUG #15352: postgresql FDW error "ERROR: ORDER BY position 0 is not in select list"