Re: Accidentally dropped constraints: bug? - Mailing list pgsql-hackers

From Mark Dilger
Subject Re: Accidentally dropped constraints: bug?
Date
Msg-id 0585B8C1-4E5E-4E02-BCC0-DE6737602623@enterprisedb.com
Whole thread Raw
In response to Accidentally dropped constraints: bug?  (Simon Riggs <simon.riggs@enterprisedb.com>)
List pgsql-hackers

> On Aug 5, 2021, at 12:35 AM, Simon Riggs <simon.riggs@enterprisedb.com> wrote:
>
> Noting that all constraints have been removed, not just the ones
> wholly dependent on dropped columns.

I don't find this all that surprising.  If CHECK (a > 5 AND b IS NOT NULL AND c > 10) is really meant as three
independentchecks, it should be written that way.  However, for any row where c is null, the entire expression will
eitherbe null or false, and the check will fail precisely when (a > 5 AND b IS NOT NULL) is false.  So if you imagine
thedropped column as a column of phantom null values, you'd expect the check to still reject rows where a <= 5 or b is
null.

Is it reasonable to imagine the dropped column as implicitly full of nulls?  That's how an added column works, but do
wethink about dropped columns that way? 

In any event, the documentation is pretty clear about this:

> DROP COLUMN [ IF EXISTS ]
> This form drops a column from a table. Indexes and table constraints involving the column will be automatically
droppedas well. 

—
Mark Dilger
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company






pgsql-hackers by date:

Previous
From: Mark Dilger
Date:
Subject: Re: Assert triggered during RE_compile_and_cache
Next
From: Andres Freund
Date:
Subject: Re: EXEC_BACKEND vs bgworkers without BGWORKER_SHMEM_ACCESS