On 2024-Oct-02, Alvaro Herrera wrote:

> On 2024-Oct-02, jian he wrote:
> 
> > On Tue, Oct 1, 2024 at 11:20 PM Alvaro Herrera <alvhe...@alvh.no-ip.org> 
> > wrote:

> > after v7, still not bullet-proof. as before, pg_dump/restore will fail
> > for the following:
> > 
> > drop table if exists t2, t2_0
> > create table t2 (a int, b int, c int, constraint foo primary key(a),
> > constraint foo1 not null a no inherit);
> > create table t2_0 (a int constraint foo1 not null no inherit, b int, c
> > int, constraint foo12 primary key(a));
> 
> Rats.  Fixing :-)

Hmm, I thought this was going to be a five-minute job: I figured I could
add a check in DefineIndex() that reads all columns and ensure they're
no-inherit.  First complication: when creating a partition, we do
DefineIndex to create the indexes that the parent table has, before we
do AddRelationNotNullConstraints(), so the not-null constraint lookup
fails.  Easy enough to fix: just move the AddRelationNotNullConstraints
call a few lines up.  However, things are still not OK because ALTER
TABLE ALTER COLUMN TYPE does want to recreate the PK before the
not-nulls (per ATPostAlterTypeParse), because AT_PASS_OLD_INDEX comes
before AT_PASS_OLD_CONSTR ...  and obviously we cannot change that.

Another possibility is to add something like AT_PASS_OLD_NOTNULL but
that sounds far too ad-hoc.

Maybe I need the restriction to appear somewhere else rather than on
DefineIndex.

Still looking ...

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/
"Los dioses no protegen a los insensatos.  Éstos reciben protección de
otros insensatos mejor dotados" (Luis Wu, Mundo Anillo)


Reply via email to