
|
If you were logged in you would be able to see more operations.
|
|
|
|
Environment:
|
Windows 7 64bit, FB2.5 Classic
|
|
| Planning Status: |
Unspecified
|
|
If, in PSQL, I open a named cursor on a record, and some other operation changes
a field in that record, then the change is lost when I post using the cursor,
even if the cursor does not fetch the changed field.
If I define the cursor as FOR UPDATE OF MY_FIELD WITH LOCK, then the system
crashes if, after some other operation changes the record, I try to post using
the cursor.
Here is a simple example, using FB 2.5 classic. The example is unrealistic, and can be easily avoided, but equivalent updates to records already open in cursors can easily happen when triggers operate recusrively.
CREATE TABLE MY_TABLE (A INTEGER, B INTEGER,C INTEGER);
INSERT INTO MY_TABLE(A,B,C) VALUES (1,1,1);
set term ^ ;
EXECUTE BLOCK AS
DECLARE MY_CURSOR CURSOR FOR
(SELECT B FROM MY_TABLE
WHERE A = 1 /* FOR UPDATE OF B WITH LOCK */ ) ;
DECLARE B INTEGER;
BEGIN
OPEN MY_CURSOR;
FETCH MY_CURSOR INTO :B;
UPDATE MY_TABLE SET C = 2
WHERE A = 1;
UPDATE MY_TABLE SET B = 2
WHERE CURRENT OF MY_CURSOR;
END^
SELECT * FROM MY_TABLE gives the result 1,2,1
If "FOR_UPDATE OF B WITH LOCK" is uncommented, Flamerobin crashes with the
message
Engine Code : 335544333
Engine Message :
internal Firebird consistency check (cannot find record back version (291),
file: vio.cpp line: 5024)
|
|
Description
|
If, in PSQL, I open a named cursor on a record, and some other operation changes
a field in that record, then the change is lost when I post using the cursor,
even if the cursor does not fetch the changed field.
If I define the cursor as FOR UPDATE OF MY_FIELD WITH LOCK, then the system
crashes if, after some other operation changes the record, I try to post using
the cursor.
Here is a simple example, using FB 2.5 classic. The example is unrealistic, and can be easily avoided, but equivalent updates to records already open in cursors can easily happen when triggers operate recusrively.
CREATE TABLE MY_TABLE (A INTEGER, B INTEGER,C INTEGER);
INSERT INTO MY_TABLE(A,B,C) VALUES (1,1,1);
set term ^ ;
EXECUTE BLOCK AS
DECLARE MY_CURSOR CURSOR FOR
(SELECT B FROM MY_TABLE
WHERE A = 1 /* FOR UPDATE OF B WITH LOCK */ ) ;
DECLARE B INTEGER;
BEGIN
OPEN MY_CURSOR;
FETCH MY_CURSOR INTO :B;
UPDATE MY_TABLE SET C = 2
WHERE A = 1;
UPDATE MY_TABLE SET B = 2
WHERE CURRENT OF MY_CURSOR;
END^
SELECT * FROM MY_TABLE gives the result 1,2,1
If "FOR_UPDATE OF B WITH LOCK" is uncommented, Flamerobin crashes with the
message
Engine Code : 335544333
Engine Message :
internal Firebird consistency check (cannot find record back version (291),
file: vio.cpp line: 5024)
|
Show » |
|
UPDATE MY_TABLE SET A = 0 WHERE A = 1;
After its execution, the fetched record won't satisfy the cursor's search condition anymore. Should we ignore this and update the record once more? Or should we re-evaluate the predicate against the refreshed record and filter it out? If the latter, how should the second (cursor based) update behave - as a no-op or throw an error?