Re: BUG #19698: IMPORT FOREIGN SCHEMA treats a NOT VALID NOT NULL constraint as validated

From: Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com>
To: imchifan(at)163(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19698: IMPORT FOREIGN SCHEMA treats a NOT VALID NOT NULL constraint as validated
Date: 2026-10-07 04:52:51
Message-ID: CAPmGK15wJxr-TZ9gvptw+rCw12RoESt_HVFZhLFc1_P4k50dkQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Sep 18, 2026 at 5:25 PM PG Bug reporting form
<noreply(at)postgresql(dot)org> wrote:
> Description
> -----------
> When IMPORT FOREIGN SCHEMA imports a remote table having a NOT NULL
> constraint declared NOT VALID, postgres_fdw creates trusted local NOT NULL
> metadata. The remote table can still contain NULL values because its
> constraint has not been validated. With constraint_exclusion enabled,
> PostgreSQL relies on the imported metadata and incorrectly excludes a query
> that would find such a row. Queries through the imported foreign table can
> therefore silently omit existing rows.

For the reported case, I think we should set the import_not_null
option for IMPORT FOREIGN SCHEMA to false. That option is enabled by
default, but should be disabled if it isn't ensured that the remote
table never has NULL.

Best regards,
Etsuro Fujita

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Etsuro Fujita 2026-10-07 05:00:41 Re: BUG #19698: IMPORT FOREIGN SCHEMA treats a NOT VALID NOT NULL constraint as validated
Previous Message shihao zhong 2026-10-07 00:53:52 Re: BUG #19732: first_value/last_value/nth_value return NULL with EXCLUDE TIES when the current row is outside its f