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

From Andrew Gierth
Subject Re: BUG #15352: postgresql FDW error "ERROR: ORDER BY position 0 is not in select list"
Date
Msg-id 87efemzw0v.fsf@news-spur.riddles.org.uk
Whole thread Raw
In response to BUG #15352: postgresql FDW error "ERROR: ORDER BY position 0 is notin select list"  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #15352: postgresql FDW error "ERROR: ORDER BY position 0 is not in select list"  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
List pgsql-bugs
>>>>> "PG" == PG Bug reporting form <noreply@postgresql.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)


pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #15352: postgresql FDW error "ERROR: ORDER BY position 0 is notin select list"
Next
From: Andrew Gierth
Date:
Subject: Re: BUG #15352: postgresql FDW error "ERROR: ORDER BY position 0 is not in select list"