Re: Checking of constraints via subqueries?

Поиск
Список
Период
Сортировка
От Wolfgang Drotschmann
Тема Re: Checking of constraints via subqueries?
Дата
Msg-id 4215B614.8010208@fgan.de
обсуждение исходный текст
Ответ на Checking of constraints via subqueries?  (Wolfgang Drotschmann <drotschm@fgan.de>)
Список pgsql-general
Michael Fuhr wrote:
> On Thu, Feb 17, 2005 at 07:31:42PM +0100, Martijn van Oosterhout wrote:
>
>>On Thu, Feb 17, 2005 at 11:03:58AM -0700, Michael Fuhr wrote:
>>
>>>In experiments I've defined a domain's CHECK expression to call a
>>>function that makes queries.  It worked in simple tests; I don't
>>>know if it'll work in the general case.
>>
>>The problem is basically that modifying a table elsewhere could have
>>the effect of invalidating the entries in the table being checked.
>
>
> Yeah, that's the kind of thing that concerned me.  I meant to ask
> the OP the usual question:
>
> What problem are you trying to solve?

No problem actually.

Realising a constraint via a CHECK (<subquery>) is a decision made by the
developer.  So the developer has to make sure that this fits in the whole
picture and works the intended way.
I'm thinking about the feature, and not about whether the use of this feature
is dangerous or not.
My starting point was the thought of using this for checking in CREATE DOMAIN.
I see that the ubiquitous triggers could help (in an indirect way, being
called with every INSERT or UPDATE of a row with that domain, but is this
generic?).  The other (subquery) option looks quite more elegant (and
generic).  And that may be the reason why it is mentioned in the docs: it
seems to be an elegant and natural way the check a domain.

Best regards,
    Wolfgang


В списке pgsql-general по дате отправления:

Предыдущее
От: Scott Marlowe
Дата:
Сообщение: Re: Lost rows/data corruption?
Следующее
От: Benjamin
Дата:
Сообщение: db replication and errors