public inbox for [email protected]
help / color / mirror / Atom feedFrom: Alvaro Herrera <[email protected]>
To: jian he <[email protected]>
Cc: Ashutosh Bapat <[email protected]>
Cc: Rushabh Lathia <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: Support NOT VALID / VALIDATE constraint options for named NOT NULL constraints
Date: Fri, 21 Mar 2025 15:50:37 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <CACJufxGcH34SjCuee+7OJXjmYmWgceuOyo3U-fo30hpxP6vQ_g@mail.gmail.com>
On 2025-Mar-21, jian he wrote:
> * if partitioned table have valid not-null, then partition with
> invalid not-null can not attach to the partition tree.
Correct.
> if partitioned table have not valid not-null, we *can* attach a
> valid not-null to the partition tree.
Also correct.
> (inheritance hierarchy behaves the same).
Good -- it should! :-)
> this part does not require a lot of code changes.
> However, to make the pg_dump working with partitioned table we need to
> tweak AdjustNotNullInheritance a little bit.
Hmm, well, modifying a function to suite what we need it to do is part
of code patching :-)
> i changed this accordingly.
> ALTER TABLE .. ALTER COLUMN .. SET NOT NULL
> will validate not-null and set attnotnull, attinvalidnotnull accordingly.
Okay.
> i basically model NOT NULL NOT VALID == CHECK (x IS NOT NULL).
> i think your idea may need more refactoring?
> all the "if (attr->attnotnull" need change to "if (attr->attnotnull &&
> attr->attnotnullvalid)"
> or am i missing something?
In some places, yes we will need to change like that. However, many
places do not need to change like that. In particular, (most?) client
applications do not necessarily need that change, and to me, that's the
most important part, because we do not control external applications,
and --as I said upthread-- we do not have the luxury of breaking them.
> Anyway, I will just share my idea first, and will explore your idea later.
Thank you.
> in my attached patch, you will only create an not-null not valid
> pg_constraint entry
> If `if (constr->contype == CONSTR_NOTNULL && constr->skip_validation)`
> in ATAddCheckNNConstraint conditions are satisfied.
>
>
> imho, my approach is less bug-prone, almost no need to refactor current code.
I'll give this a look ... probably won't have time today ... however,
IMO the consideration of external applications (ORMs, LibreOffice, admin
GUIs, etc) not breaking is the most important thing to keep in mind.
You can go over the code found by codesearch.debian.net when searching
for `attnotnull` to see the sort of code that would be affected.
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
"¿Qué importan los años? Lo que realmente importa es comprobar que
a fin de cuentas la mejor edad de la vida es estar vivo" (Mafalda)
view thread (44+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: Support NOT VALID / VALIDATE constraint options for named NOT NULL constraints
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox