Re: BUG advisory_lock - Mailing list pgsql-bugs

From Alvaro Herrera
Subject Re: BUG advisory_lock
Date
Msg-id 20080619142757.GQ5077@alvh.no-ip.org
Whole thread Raw
In response to BUG advisory_lock  (<Eugen.Konkov@aldec.com>)
List pgsql-bugs
Eugen.Konkov@aldec.com wrote:
> DECLARE
>   varUnlocked boolean;
> BEGIN
> varUnlocked:= pg_try_advisory_lock( 783264760123456 ); -- Try to lock function
> IF not varUnlocked THEN return NULL; END IF; -- exit if locking is unsucessfull
>
> WRONG QUERY HERE WHICH INTERRUPT EXECUTION
>
> varUnlocked:= pg_advisory_unlock( 783264760123456 ); -- unlock function
> END
>
> NEXT time when I run this function I always get NULL until server reboot
>
> EXPECTED: Pg must unlock if function execution failed

You can unlock it in an EXCEPTION block to be safe.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG advisory_lock
Next
From: "Ati Rosselet"
Date:
Subject: BUG #4255: could not write to log file: Bad file descriptor