From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Amir Zicherman <amir(dot)zicherman(at)gmail(dot)com> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: LOCK TABLE and FUNCTIONS |
Date: | 2004-08-16 14:24:01 |
Message-ID: | 13103.1092666241@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Amir Zicherman <amir(dot)zicherman(at)gmail(dot)com> writes:
> I tried using the lock inside the function body and that didn't lock.
> ...
> LOCK TABLE "mytable" IN ROW EXCLUSIVE MODE;
Sure it did. But ROW EXCLUSIVE is a very weak lock (the same as what
INSERT would take for itself) and it's not going to lock out other
INSERTs.
If you want to be the only writer of the table then you need EXCLUSIVE
lock, or possibly ACCESS EXCLUSIVE if you'd like to block out readers
too. See
http://www.postgresql.org/docs/7.4/static/explicit-locking.html#LOCKING-TABLES
> when i do a regular insert statement without a function or a
> transaction block, i get no deadlocks because the INSERT statement
> automatically gets an ACCESS EXCLUSIVE LOCK from what i understand.
Don't know where you got that idea. If it did that, we'd have no
concurrency at all.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Kumar S | 2004-08-16 15:27:18 | Re: New coloumns |
Previous Message | Sean Davis | 2004-08-16 13:46:24 | Re: New coloumns |