Re: BUG #19698: IMPORT FOREIGN SCHEMA treats a NOT VALID NOT NULL constraint as validated - Mailing list pgsql-bugs

From Etsuro Fujita
Subject Re: BUG #19698: IMPORT FOREIGN SCHEMA treats a NOT VALID NOT NULL constraint as validated
Date
Msg-id CAPmGK15wJxr-TZ9gvptw+rCw12RoESt_HVFZhLFc1_P4k50dkQ@mail.gmail.com
Whole thread
In response to BUG #19698: IMPORT FOREIGN SCHEMA treats a NOT VALID NOT NULL constraint as validated  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
On Fri, Sep 18, 2026 at 5:25 PM PG Bug reporting form
<noreply@postgresql.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



pgsql-bugs by date:

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