Subject | Re: Select with lock does not lock |
---|---|
Author | Adam |
Post date | 2006-08-23T23:36:29Z |
--- In firebird-support@yahoogroups.com, "Gustavo" <gusm@...> wrote:
Tr1, what I expected was an error (exception) because of lock
conflict. But instead of that, no error occured and what Tr2 did is to
lock only the first two records with CODIGO = 'A' (the ones with
NUMERO = 1 and 2) and it did not lock the other records (the ones with
NUMERO = 4, 5, 6 and of course the one with NUMERO = 3).
SET TRANSACTION NO WAIT READ COMMITTED;
With an equivalent logic query, I get a lock conflict as you would
expect. Better check for obvious errors (connecting to different
databases, transaction isolation means that one of the transactions
doesn't see the conflicting record, etc).
Adam
>... with lock".
> Hello:
>
> I use Delphi 5, FireBird and IBX and I have a problem with "Select
>following records:
> The table EMPRESAS has two fields: CODIGO and NUMERO. It has the
>the query
> CODIGO NUMERO
> -------------------------------
> A 1
> A 2
> A 3
> A 4
> A 5
> A 6
> B 11
> B 12
> B 13
> B 14
> B 15
> B 16
> ..........
>
>
> Transaction Tr1 is read_commited and nowait. I start Tr1 and execute
>the query
> SELECT CODIGO,NUMERO FROM EMPRESAS WHERE (NUMERO = 3) WITH LOCK
>
> Transaction Tr2 is read_commited and nowait. I start Tr2 and execute
>records). As the record with CODIGO ='A' and NUMERO = 3 is locked by
> SELECT CODIGO,NUMERO FROM EMPRESAS WHERE (CODIGO = 'A') WITH LOCK
>
> The intention of Tr2 was to lock every record with CODIGO = 'A' (six
Tr1, what I expected was an error (exception) because of lock
conflict. But instead of that, no error occured and what Tr2 did is to
lock only the first two records with CODIGO = 'A' (the ones with
NUMERO = 1 and 2) and it did not lock the other records (the ones with
NUMERO = 4, 5, 6 and of course the one with NUMERO = 3).
>exception when Tr2 tryes to lock the six records with CODIGO = 'A'?
> Am I doing something wrong? Is there a way to do this and to get an
>I haven't tried with IBX, but using 2 iSQL windows, running in each:
SET TRANSACTION NO WAIT READ COMMITTED;
With an equivalent logic query, I get a lock conflict as you would
expect. Better check for obvious errors (connecting to different
databases, transaction isolation means that one of the transactions
doesn't see the conflicting record, etc).
Adam