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

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
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-05-14 09:16:14
Message-ID: CACJufxHNpusqZOhckVZxGAE2zOOWU0YTJvs3nob38XL=8zArpw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Apr 28, 2025 at 4:40 PM Álvaro Herrera <alvherre(at)kurilemu(dot)de> wrote:
>
> 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.
>

newly added tests covered that.
now the test coverage is quite good, IMHO.

also rebased to address test failure.

Attachment Content-Type Size
v6-0001-using-indexscan-to-speedup-add-not-null-constrain.patch application/x-patch 29.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2025-05-14 09:33:33 Re: Small fixes needed by high-availability tools
Previous Message Dilip Kumar 2025-05-14 09:15:53 Re: Backward movement of confirmed_flush resulting in data duplication.