Re: Adding a nullable DOMAIN column w/ CHECK - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Adding a nullable DOMAIN column w/ CHECK
Date
Msg-id 9447.1410118301@sss.pgh.pa.us
Whole thread Raw
In response to Re: Adding a nullable DOMAIN column w/ CHECK  (Noah Misch <noah@leadboat.com>)
List pgsql-hackers
Noah Misch <noah@leadboat.com> writes:
> On Sun, Sep 07, 2014 at 01:06:04PM -0400, Tom Lane wrote:
>> This objection could be met by doing a precheck to verify that the table
>> contains at least one live row.  That's pretty ugly and personally I'm not
>> sure it's necessary, but I think there's room to argue that it is.

> Yes; I doubt one could justify failing on an empty table as though it had been
> a one-row table.  I see a couple ways we could avoid the I/O and complexity:

> 1) If contain_leaky_functions() approves every constraint expression, test the
>    constraints once, and we're done.  Otherwise, proceed as we do today.

> 2) Test the constraints in a subtransaction.  If the subtransaction commits,
>    we're done.  Otherwise, proceed as we do today.

I'm not sure either of those is better than doing a single heap_getnext(),
which really should be pretty cheap except under pathological conditions.
It's the messiness I'm worried about more than the cost.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: Re: Adding a nullable DOMAIN column w/ CHECK
Next
From: Petr Jelinek
Date:
Subject: Re: Built-in binning functions