Re: Checking number of entries - Mailing list pgsql-general

From Philip Warner
Subject Re: Checking number of entries
Date
Msg-id 3.0.5.32.20000930235242.02b43b00@mail.rhyme.com.au
Whole thread Raw
In response to Re: Checking number of entries  (Philip Warner <pjw@rhyme.com.au>)
Responses Re: Checking number of entries  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-general
At 18:09 29/09/00 -0700, Stephan Szabo wrote:
>
>How do other systems (Oracle, etc...) handle the subselect and arbitrary
>function cases?
>

Dec RDB seems to go the distance. With the following incredibly silly
constraint:

alter table zzz add constraint
     check( (select sum(zzzz.f1*zzz1.f1_1) from zzzz,zzz1
                where zzzz.f2=zzz1.f1_1) + f1 > 0);

Any updates to the referenced tables cause it to run a query that *seems*
to be:

     select * from ZZZ where not ( <constraint-condition> )

This is my guess based on the optimizer output, but it seems reasonable.

An update to the main table causes the same query to be executed but only
for the updated row.

Adding the main table to the check query produces a similar result.


This may be a useful general model? Is there a problem with the approach?
It couls be further improved by using 'limit 1', but otherwise seems good...





----------------------------------------------------------------
Philip Warner                    |     __---_____
Albatross Consulting Pty. Ltd.   |----/       -  \
(A.B.N. 75 008 659 498)          |          /(@)   ______---_
Tel: (+61) 0500 83 82 81         |                 _________  \
Fax: (+61) 0500 83 82 82         |                 ___________ |
Http://www.rhyme.com.au          |                /           \|
                                 |    --________--
PGP key available upon request,  |  /
and from pgp5.ai.mit.edu:11371   |/

pgsql-general by date:

Previous
From: Mark Kirkwood
Date:
Subject: RE:Redhat 7 And Pgsql
Next
From: Stephan Szabo
Date:
Subject: Re: Checking number of entries