Re: using index to speedup add not null constraints to a table

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: using index to speedup add not null constraints to a table
Date: 2025-04-28 08:40:53
Message-ID: 202504280840.vmqn6igfmeuh@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2025-Apr-28, jian he wrote:

> for tests, just found out i can imitate
> src/test/modules/test_misc/t/001_constraint_validation.pl,
>
> So I created a file:
> src/test/modules/test_misc/t/008_indexscan_validate_notnull.pl
> for TAP tests.

Seems reasonable, didn't look at it in detail. I think you don't have
any tests where you try to set multiple columns as NOT NULL in a single
ALTER TABLE command; I think this is worth having. Something like

CREATE TABLE foo (col1 int, col2 int, col3 int);
... create indexes on col1 and col2 ...
alter table foo set col1 not null,
set col3 not null,
add constraint bla not null b;
and stuff like that.

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"If you have nothing to say, maybe you need just the right tool to help you
not say it." (New York Times, about Microsoft PowerPoint)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhijie Hou (Fujitsu) 2025-04-28 08:56:52 RE: Fix slot synchronization with two_phase decoding enabled
Previous Message Nitin Motiani 2025-04-28 08:22:53 Re: Adding pg_dump flag for parallel export to pipes