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 87efegxn6b.fsf@news-spur.riddles.org.uk
Whole thread Raw
In response to Re: BUG #15352: postgresql FDW error "ERROR: ORDER BY position 0 isnot in select list"  (Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>)
Responses Re: BUG #15352: postgresql FDW error "ERROR: ORDER BY position 0 isnot in select list"  (Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>)
List pgsql-bugs
[removing the OP from CC list]

>>>>> "Ashutosh" == Ashutosh Bapat <ashutosh.bapat@enterprisedb.com> writes:

 >> Well, it's certainly pointless.
 >> 
 >> But the failure in this case is specifically about pushing down an
 >> _integer_ constant, because the deparse code for pushing down an
 >> ORDER BY does not understand that integer literals in ORDER BY
 >> clauses are a special case.

 Ashutosh> Deparser needs to be fixed then, irrespective of whether or
 Ashutosh> not we fix the costant pathkey problem.

Since we have no business sending sort expressions to the remote that do
not include remote vars, this seems superfluous. Any such expression is
either mutable (and hence not pushable anyway) or known locally to be
constant (in which case we never legitimately see it in a pathkey).
(Maybe Asserting it or throwing an error might be appropriate.)

 >> I'm pretty sure that constant (hence redundant) clauses have been
 >> removed from pathkeys before postgres_fdw will see them. The problem
 >> only occurs because postgres_fdw tries inventing _new_ pathkeys for
 >> possible orderings from eclasses (in order to try for mergejoin
 >> opportunities) in addition to using the requested pathkeys, and it's
 >> clearly pointless to do that with constants.

 Ashutosh> Yes, I forgot about that. But even in that case, we should
 Ashutosh> consider the case when the constant pathkey is just one in
 Ashutosh> the bunch and we are trying to push the whole bunch.

How do you think that could happen, given that redundant pathkeys are
already removed?

-- 
Andrew (irc:RhodiumToad)


pgsql-bugs by date:

Previous
From: Ashutosh Bapat
Date:
Subject: Re: BUG #15352: postgresql FDW error "ERROR: ORDER BY position 0 isnot in select list"
Next
From: Alvaro Herrera
Date:
Subject: Re: BUG #15359: event_trigger via pg_event_trigger_ddl_commands()not returning "CREATE SEQUENCE" command