Re: Checking number of entries

From: Philip Warner <pjw(at)rhyme(dot)com(dot)au>
To: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: Re: Checking number of entries
Date: 2000-10-01 00:45:29
Message-ID: 3.0.5.32.20001001104529.02899660@mail.rhyme.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

At 11:25 30/09/00 -0700, Stephan Szabo wrote:
>
>On Sat, 30 Sep 2000, Philip Warner wrote:
>
>>
>> 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> )
>>
>
>Well, I'm not sure how easy/hard it is to get all referenced tables right
>now, since you'd have to decend into subqueries. But, yeah, that seems
>like it would probably work since you probably couldn't currently put
>anything in the check constraint that would work there but not in a
>subquery context (although i could be wrong about that).

Yes; we'd need to generate a plan for the constraint, and find all the
tables it references. Is that a hard thing to do?

>Can you do arbitrary user functions in Dec RDB that access tables and put
>those in constraints? I'm not sure what to do about the fact that we can't
>actually get the referenced tables inside functions for some cases.

RDB has two kinds of functions: external & SQL. External functions can't
make data changes, or even easily read the database, and SQL functions are
just pieces of (complex multi-line) SQL, that can be parsed like anything
else. As a result, when you call a function in a constraint, it plans the
function, and gets the list of tables.

Also, RDB does allow non-deterministic constraints, but if someone is silly
enough to use one, then so be it...

----------------------------------------------------------------
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 |/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Fernando Lobo 2000-10-01 15:05:02 universities using postgresql
Previous Message Tom Lane 2000-09-30 18:57:04 Re: reldesc does not exit