Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SELECT WITH LOCK with no fields are accessed clears the data [CORE2633] #3041

Closed
firebird-automations opened this issue Sep 17, 2009 · 11 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: prenosil (prenosil)

Is related to QA416

"SELECT ... WITH LOCK" inside Execute Block corrupts data, even subsequent ROLLBACK does not help.
In the following script, the first select will show

SELECT * FROM T;
A B
==================== ===========
aaaa 1
bbbb 2
cccc 3

while the subsequent selects (before and after Rollback) will show
SELECT * FROM T;
A B
==================== ===========
0
0
0

--------------------
CREATE DATABASE 'C:\TESTDB.FDB';
CREATE TABLE T (A VARCHAR(20), B INTEGER);
INSERT INTO T(A,B) VALUES('aaaa',1);
INSERT INTO T(A,B) VALUES('bbbb',2);
INSERT INTO T(A,B) VALUES('cccc',3);
COMMIT;

SELECT * FROM T;

SET TERM ^;
EXECUTE BLOCK AS
DECLARE I INTEGER;
BEGIN
FOR SELECT 1 FROM T WITH LOCK INTO :I DO I=I;
END^
SET TERM ;^

SELECT * FROM T;

ROLLBACK;

SELECT * FROM T;

DROP DATABASE;
--------------------

Commits: 89d72e5

@firebird-automations
Copy link
Collaborator Author

Commented by: Sean Leyne (seanleyne)

Edited the case summary/title to provide clearer details for possible readers

@firebird-automations
Copy link
Collaborator Author

Modified by: Sean Leyne (seanleyne)

summary: SELECT WITH LOCK corrupts data => SELECT WITH LOCK within EXECUTE BLOCK corrupts data

@firebird-automations
Copy link
Collaborator Author

Modified by: @hvlad

assignee: Vlad Khorsun [ hvlad ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @hvlad

The bug is related to the feature CORE1598 (Optimize data retrieval for tables when no fields are accessed).
If no fields ia accessed engine not creates record in memory. If NO LOCK also specified engine must create
dummy update and (as there is no record in memory) writes empty backversion on disk. ROLLBACK have no
effect as restored backversion have all fields set to empty values.

I see two ways to fix it :
a) disable feature if NO LOCK is used, or
b) re-fetch the record in VIO_writelock if there is no record in memory

I think (a) is better and will commit it.

@firebird-automations
Copy link
Collaborator Author

Commented by: @hvlad

More exact description

@firebird-automations
Copy link
Collaborator Author

Modified by: @hvlad

Version: 2.5 Beta 2 [ 10300 ]

Version: 2.5 Alpha 1 [ 10224 ]

summary: SELECT WITH LOCK within EXECUTE BLOCK corrupts data => SELECT WITH LOCK with no fields are accessed clears the data

@firebird-automations
Copy link
Collaborator Author

Modified by: @hvlad

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 2.5 RC1 [ 10362 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @hvlad

priority: Major [ 3 ] => Critical [ 2 ]

Version: 2.5 RC1 [ 10362 ] =>

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Link: This issue is related to QA416 [ QA416 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pmakowski

status: Resolved [ 5 ] => Closed [ 6 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Closed [ 6 ] => Closed [ 6 ]

QA Status: Done successfully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment