Re: postgres_fdw: wrong results with self join + enable_nestloop off

Etsuro Fujita <etsuro.fujita@gmail.com>

From: Etsuro Fujita <etsuro.fujita@gmail.com>
To: Nishant Sharma <nishant.sharma@enterprisedb.com>
Cc: Suraj Kharage <suraj.kharage@enterprisedb.com>, Richard Guo <guofenglinux@gmail.com>, pgsql-hackers@postgresql.org
Date: 2023-06-05T13:19:31Z
Lists: pgsql-hackers

Attachments

Hi,

On Fri, Jun 2, 2023 at 9:31 PM Nishant Sharma
<nishant.sharma@enterprisedb.com> wrote:
> I also agree that Richard's patch is better. As it fixes the issue at the backend and does not treat pseudoconstant as local condition.
>
> I have tested Richard's patch and observe that it is resolving the problem. Patch looks good to me as well.

If the patch is intended for HEAD only, I also think it goes in the
right direction.  But if it is intended for back branches as well, I
do not think so, because it would cause ABI breakage due to changes
made to the ForeignPath struct and the create_foreign_join_path() API.
(For the former, I think we could avoid doing so by adding the new
member at the end of the struct, not in the middle, though.)

To avoid this issue, I am wondering if we should modify
add_paths_to_joinrel() in back branches so that it just disallows the
FDW to consider pushing down joins when the restrictlist has
pseudoconstant clauses.  Attached is a patch for that.

My apologies for not reviewing your patch and the long long delay.

Best regards,
Etsuro Fujita

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Re-allow FDWs and custom scan providers to replace joins with pseudoconstant quals.

  2. Disallow replacing joins with scans in problematic cases.

  3. doc: PQinitOpenSSL and PQinitSSL are obsolete in OpenSSL 1.1.0+