Re: [SQL] reliable lock inside stored procedure (SOLVED)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sebastian Böhm <psql(at)seb(dot)exse(dot)net>
Cc: Richard Huxton <dev(at)archonet(dot)com>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [SQL] reliable lock inside stored procedure (SOLVED)
Date: 2008-11-03 21:20:47
Message-ID: 23499.1225747247@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

=?ISO-8859-1?Q?Sebastian_B=F6hm?= <psql(at)seb(dot)exse(dot)net> writes:
> Am 03.11.2008 um 12:06 schrieb Richard Huxton:
>> It's not possible to have a LOCK statement outside of a
>> transaction. It's just not meaningful to have a transaction that only
>> has a LOCK statement in it.

> as postgres does not warn you about this, this may lead to not so easy
> to spot bugs.

That's a good point. We throw error for DECLARE CURSOR outside a
transaction block, since it's obviously a mistake. I wonder whether
we shouldn't equally throw error for LOCK outside a transaction block.

I can sort of imagine some corner cases where
lock-and-immediately-release would be the intended behavior, but that
sure seems a whole lot less probable than it being user error.
And you could always throw BEGIN/COMMIT into the command if that
really was what you wanted.

Objections anyone?

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hannu Krosing 2008-11-03 21:42:55 Re: Simple postgresql.conf wizard
Previous Message Tom Lane 2008-11-03 20:53:20 Re: [PATCH] PageGetTempPage cleanup

Browse pgsql-sql by date

  From Date Subject
Next Message Ryan Hansen 2008-11-03 22:57:25 Re: Date Index
Previous Message Sebastian Böhm 2008-11-03 19:42:54 Re: reliable lock inside stored procedure (SOLVED)