Re: Adding a nullable DOMAIN column w/ CHECK

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: Marko Tiikkaja <marko(at)joh(dot)to>, PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>, Joe Van Dyk <joe(at)tanga(dot)com>
Subject: Re: Adding a nullable DOMAIN column w/ CHECK
Date: 2014-09-07 19:31:41
Message-ID: 9447.1410118301@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Noah Misch <noah(at)leadboat(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Petr Jelinek 2014-09-07 19:47:53 Re: Built-in binning functions
Previous Message Noah Misch 2014-09-07 19:23:34 Re: Adding a nullable DOMAIN column w/ CHECK