Re: cataloguing NOT NULL constraints - Mailing list pgsql-hackers

From Andres Freund
Subject Re: cataloguing NOT NULL constraints
Date
Msg-id 20230701011208.3dw746gs3q4x6kcz@awork3.anarazel.de
Whole thread Raw
In response to Re: cataloguing NOT NULL constraints  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Responses Re: cataloguing NOT NULL constraints
List pgsql-hackers
Hi,

On 2023-06-30 13:44:03 +0200, Alvaro Herrera wrote:
> OK, so here's a new attempt to get this working correctly.

Thanks for continuing to work on this!


> The main novelty in this version of the patch, is that we now emit
> "throwaway" NOT NULL constraints when a column is part of the primary
> key.  Then, after the PK is created, we run a DROP for that constraint.
> That lets us create the PK without having to scan the table during
> pg_upgrade.

Have you considered extending the DDL statement for this purpose? We have
  ALTER TABLE ... ADD CONSTRAINT ... PRIMARY KEY USING INDEX ...;
we could just do something similar for the NOT NULL constraint?  Which would
then delete the separate constraint NOT NULL constraint.

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Joe Conway
Date:
Subject: RFC: pg_stat_logmsg
Next
From: Amit Kapila
Date:
Subject: Re: Synchronizing slots from primary to standby