On Sat, 4 Dec 2004, sarlav kumar wrote:
> Thanks for the information on replication tools!!
> Now, I have a question regarding locking tables and updating tables
> that have a relationship to the locked table.
> I opened up two pgsql windows logged in using same userid.
> Let's say I lock a table "customerdata" on one window.
> lock table customerdata;
> Then in the other window,I want to make an update to table "customer".
> update customer set status=0 where id=111;
> The relation ship between the two tables is as follows
> customerdata.uid is FK on customer.id. There are no triggers that will
> try to update customerdata table when the above update statement is
> My problem is the update does not continue unless the lock on
> customerdata is released. Is it because the lock statement does a lock
> on all related tables? Is it possible to lock only the particular table
> we want to lock and not the related tables?
The no action foreign key triggers grab a Row Share on the referencing
table which conflicts with the Exclusive lock that LOCK TABLE takes by
default. Depending on what you're trying to prevent, you may be able to
ask lock table for a lesser lock (see the list and descriptions here:
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings