Re: [ADMIN] Functions and transactions

2005-03-11 Thread Tom Lane
Kris Kiger <[EMAIL PROTECTED]> writes: > Interesting. That makes sense, though. So, is there a good way to lock > a set of rows using SELECT FOR UPDATE in plpgsql? I assume using > PERFORM would yield the same problem, because it immediately discards > the results. I think PERFORM would work

Re: [ADMIN] Functions and transactions

2005-03-11 Thread Kris Kiger
Interesting. That makes sense, though. So, is there a good way to lock a set of rows using SELECT FOR UPDATE in plpgsql? I assume using PERFORM would yield the same problem, because it immediately discards the results. Thanks! Kris Tom Lane wrote: Kris Kiger <[EMAIL PROTECTED]> writes: In

Re: [ADMIN] Functions and transactions

2005-03-10 Thread Tom Lane
Kris Kiger <[EMAIL PROTECTED]> writes: > In your second paragraph, I think that you are saying that SELECT FOR > UPDATE only locks one row, even though the select itself may return > many. Am I mis-interpreting you? No, I'm saying that plpgsql's SELECT INTO operation only reads one row. The fac

Re: [ADMIN] Functions and transactions

2005-03-10 Thread Kris Kiger
In your second paragraph, I think that you are saying that SELECT FOR UPDATE only locks one row, even though the select itself may return many. Am I mis-interpreting you? Also, what do you mean by seizing on a non-active row? Your assumption about pkey_id is right, I meant for that to mean p

Re: [ADMIN] Functions and transactions

2005-03-10 Thread Tom Lane
Kris Kiger <[EMAIL PROTECTED]> writes: > Hmm.. I was trying simplify my function to get the point across with > minimal confusion. If you don't think there is enough detail, let me > know what is lacking and I will add the appropriate detail. The > function is executed BEFORE insert on table1.

Re: [ADMIN] Functions and transactions

2005-03-10 Thread Kris Kiger
Hmm.. I was trying simplify my function to get the point across with minimal confusion. If you don't think there is enough detail, let me know what is lacking and I will add the appropriate detail. The function is executed BEFORE insert on table1. Thanks again for the help all Kris Tom Lane

Re: [ADMIN] Functions and transactions

2005-03-09 Thread Tom Lane
Kris Kiger <[EMAIL PROTECTED]> writes: > Here is my problem. I have a function that is triggered on insert. For > simplicity's sake, lets say the function looks like this: > CREATE OR REPLACE FUNCTION dostuff_on_insert() RETURNS TRIGGER AS ' > DECLARE lockrows RECORD; > BEGIN > select into

Re: [ADMIN] Functions and transactions

2005-03-09 Thread Tsirkin Evgeny
I guess first we should understand why the insert B waits at all,the insert A did not commit ,right ,then how did it found any pkey_id = NEW.pkey_id? That means you have already had those while starting your experiment. So ,insert B wait for those "old" rows not for your insert (i mean an INSER

Re: [ADMIN] Functions and transactions

2005-03-09 Thread Kris Kiger
transaction_isolation --- read committed Running Postgres 7.4 btw Kris Tsirkin Evgeny wrote: What transaction level are you using? Evgeny. Kris Kiger wrote: Here is my problem. I have a function that is triggered on insert. For simplicity's sake, lets say the function looks

Re: [ADMIN] Functions and transactions

2005-03-09 Thread Tsirkin Evgeny
What transaction level are you using? Evgeny. Kris Kiger wrote: Here is my problem. I have a function that is triggered on insert. For simplicity's sake, lets say the function looks like this: CREATE OR REPLACE FUNCTION dostuff_on_insert() RETURNS TRIGGER AS ' DECLARE lockrows RECORD; BEGIN

[ADMIN] Functions and transactions

2005-03-09 Thread Kris Kiger
Here is my problem. I have a function that is triggered on insert. For simplicity's sake, lets say the function looks like this: CREATE OR REPLACE FUNCTION dostuff_on_insert() RETURNS TRIGGER AS ' DECLARE lockrows RECORD; BEGIN select into lockrows * from table1 where pkey_id = NEW.pkey_id f