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

From Hiroshi Inoue
Subject Re: Checking number of entries
Date
Msg-id 39E2740C.C7E1DE33@tpf.co.jp
Whole thread Raw
In response to Checking number of entries  (oberpwd@anubis.network.com (Wade D. Oberpriller))
List pgsql-general

Stephan Szabo wrote:

>
> >The implementation would be quite different from
> >that of (current) column constraints.
> >I've been suspicious if it could be implemented
> >properly and effectively.
> >For example,are there any discussions about
> >locking needed to guarantee the consistency ?
> Not yet, and I'm not sure the backend even provides
> the necessary hooks right now (I haven't looked).
> For example, what rows get locked when you are
> checking a count(*) constraint (apart from grabbing
> a lock on all the tables involved).

Though it's not preferable, we should grab an exclusive
lock on all the tables for this case.


>  How do you
> prevent someone from inserting a new row that matches
> a criteria until your check is finished (locking
> non-existant rows).

AFAIK,we have no standard way to lock non-existent rows
now. I don't know such cases other than unique constraints.
I'm not sure that the technique is applicable to all cases.
The current simplest and practical way is to grab an exclusive
lock on the target tables. However it's not preferable of cource.

Regards.

Hiroshi Inoue


pgsql-general by date:

Previous
From: Alex Pilosov
Date:
Subject: Re: Oracle to POSTGRESQL
Next
From: bmccoy@chapelperilous.net
Date:
Subject: Re: distinct