Subject Re: How to get_lock() in firebird
Author chris.waldmann
--- In firebird-support@yahoogroups.com, Doru Constantin <doru.constantin@...> wrote:
>
>
>
> >
> >
> > --- In firebird-support@yahoogroups.com, Doru Constantin<doru.constantin@> wrote:
> >>
> >> Hi, all
> >>
> >> MySQL has a feature / function called: GET_LOCK(). Here is the link on
> >> mysql manual:
> >> http://dev.mysql.com/doc/refman/5.1/en/miscellaneous-functions.html#function_get-lock
> >> This GET_LOCK() function has nothing to do with blocking records.It's
> >> like a "flag".
> >> How to simulate this functionality in Firebird.
> >>
> >> Thank you for your time.
> >>
> >> ./doru
> >>
> >
> > In the docu from your link, there is written the purpose of this feature:
> > "This function can be used to implement application locks or to simulate record locks."
> >
> > Why do want do implement application locks with the database server? I think that should be done by the operating system.
> > Why do you want to simulate record locks, if real record locking is present?
> >
> > It looks like it would be the more successive way to change the application logic than to reimplement a incomplete simulation of existing features!
> >
> > Good luck
> > Christian
> >
>
> Hi Christian,
>
> Yes it *can be used* to implement application locks or to simulate
> record locks, but this is not what I'm looking for.
>
> Actually I'm looking for global variables (at database level) which can
> be accessed by all users who are connected to the database. These
> variables can be released only by one who created it or automatically by
> the server when the user who created them is no longer connected to the
> database (for whatever reason, forced or by choice)
>
> More like RDB$SET_CONTEXT() and RDB$GET_CONTEXT() but with "DATABASE"
> namespace
>
> Thanks
>
> ./doru
>
Hello
Here some elements present in firebird 2.1 to realise your concept:

- make a table to store the lock string with the unique connection ids
- make a generator to get a unique session id
- use a triggers with "on connect" to get and store the actual session id
- store the actual connection session id in a "global temprary table" with "on commmit preserve". This table will be cleared if connection closes and each connection has a seperate instance of the table
- use triggers with "on disconnect" to clean up locks in the lock string table

Hope this helps

Good lock
Chris