Re: [JDBC] LOCK TABLE oddness in PLpgSQL function called via JDBC

2001-10-02 Thread Barry Lind
Dave, I can't explain what is happening here. I think the best next step is to turn on query logging on the server and look at the actual SQL statements being executed. It really looks like some extra commits or rollbacks are occuring that is causing the locks to be released. thanks, --Barr

Re: [JDBC] LOCK TABLE oddness in PLpgSQL function called via JDBC

2001-10-02 Thread Barry Lind
Dave, I don't know why you are seeing these problems with the lock table. But the select for update should work for you. (In my product I have done exactly the same thing you are trying to do using select for update with success). I would add one minor comment on your description of the beh

Re: [JDBC] LOCK TABLE oddness in PLpgSQL function called via JDBC

2001-10-02 Thread Hiroshi Inoue
Dave Harkness wrote: > > At 01:45 PM 10/2/2001, Barry Lind wrote: > >Dave, > > > >Secondly, you don't need a table lock, you just need to lock the row > >between the select and the update. You should use 'select for update' to > >do this. That way when you issue the select to get the current val

Re: [JDBC] LOCK TABLE oddness in PLpgSQL function called via JDBC

2001-10-02 Thread Tom Lane
Dave Harkness <[EMAIL PROTECTED]> writes: > Running in serializable mode, I'm getting a Postgres exception: > ERROR: Can't serialize access due to concurrent update Well, in that case my theory about it all being one transaction is wrong; you couldn't get that error without a cross-transact

Re: [JDBC] LOCK TABLE oddness in PLpgSQL function called via JDBC

2001-10-02 Thread Dave Harkness
Barry, Tom, et al, Thanks for your help. I really appreciate it. Okay, I changed the PLpgSQL function to use select for update rather than locking the table explicitly. Now I'm getting different errors. Running in auto-commit and read-committed modes, I am seeing the same error as before: thr

Re: [JDBC] LOCK TABLE oddness in PLpgSQL function called via JDBC

2001-10-02 Thread Tom Lane
Dave Harkness <[EMAIL PROTECTED]> writes: > The problem I'm seeing is that two database transactions, > initiated via JDBC, are able to obtain simultaneous exclusive table locks > on the same table. Sounds to me like JDBC is feeding all your commands through a single database connection, which

Re: [JDBC] LOCK TABLE oddness in PLpgSQL function called via JDBC

2001-10-02 Thread Dave Harkness
At 01:45 PM 10/2/2001, Barry Lind wrote: >Dave, > >First off, are you running with autocommit turned off in JDBC? By default >autocommit is on, and thus your lock is removed as soon as it is aquired. I've tried it with auto-commit ON and OFF. With it off, I've tried it with READ_COMMITTED and

Re: [JDBC] LOCK TABLE oddness in PLpgSQL function called via JDBC

2001-10-02 Thread Barry Lind
Dave, First off, are you running with autocommit turned off in JDBC? By default autocommit is on, and thus your lock is removed as soon as it is aquired. Secondly, you don't need a table lock, you just need to lock the row between the select and the update. You should use 'select for update