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: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, rhaas(at)postgresql(dot)org
Subject: Re: BUG #15352: postgresql FDW error "ERROR: ORDER BY position 0 is not in select list"
Date: 2018-08-30 08:44:34
Message-ID: 87efegxn6b.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

[removing the OP from CC list]

>>>>> "Ashutosh" == Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)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)

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2018-08-30 08:48:20 Re: BUG #15359: event_trigger via pg_event_trigger_ddl_commands() not returning "CREATE SEQUENCE" command
Previous Message Ashutosh Bapat 2018-08-30 05:37:28 Re: BUG #15352: postgresql FDW error "ERROR: ORDER BY position 0 is not in select list"