Re: Accidentally dropped constraints: bug?

From: Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>
To: Simon Riggs <simon(dot)riggs(at)enterprisedb(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Accidentally dropped constraints: bug?
Date: 2021-08-05 22:30:20
Message-ID: 0585B8C1-4E5E-4E02-BCC0-DE6737602623@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Aug 5, 2021, at 12:35 AM, Simon Riggs <simon(dot)riggs(at)enterprisedb(dot)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 independent checks, it should be written that way. However, for any row where c is null, the entire expression will either be null or false, and the check will fail precisely when (a > 5 AND b IS NOT NULL) is false. So if you imagine the dropped 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 we think 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 dropped as well.


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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2021-08-05 23:09:02 Re: EXEC_BACKEND vs bgworkers without BGWORKER_SHMEM_ACCESS
Previous Message Mark Dilger 2021-08-05 22:22:57 Re: Assert triggered during RE_compile_and_cache