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, maxim(dot)boguk(at)gmail(dot)com
Subject: Re: BUG #15352: postgresql FDW error "ERROR: ORDER BY position 0 is not in select list"
Date: 2018-08-25 08:50:13
Message-ID: 87efemzw0v.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

>>>>> "PG" == PG Bug reporting form <noreply(at)postgresql(dot)org> writes:

PG> ERROR: ORDER BY position 0 is not in select list
PG> CONTEXT: Remote SQL command: EXPLAIN SELECT relid, schemaname, relname,
PG> seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd,
PG> n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze,
PG> last_vacuum, last_autovacuum, last_analyze, last_autoanalyze, vacuum_count,
PG> autovacuum_count, analyze_count, autoanalyze_count FROM
PG> pg_catalog.pg_stat_user_tables ORDER BY 0 ASC NULLS LAST

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

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

--
Andrew (irc:RhodiumToad)

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrew Gierth 2018-08-25 17:12:58 Re: BUG #15352: postgresql FDW error "ERROR: ORDER BY position 0 is not in select list"
Previous Message PG Bug reporting form 2018-08-25 08:03:22 BUG #15352: postgresql FDW error "ERROR: ORDER BY position 0 is not in select list"