Concurrency problem when using named cursors --------------------------------------------
Key: CORE-3490 URL: http://tracker.firebirdsql.org/browse/CORE-3490 Project: Firebird Core Issue Type: Bug Affects Versions: 2.5.0 Environment: Windows 7 64bit, FB2.5 Classic Reporter: Roger Vellacott 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, the system crashes with the message Engine Code : 335544333 Engine Message : internal Firebird consistency check (cannot find record back version (291), file: vio.cpp line: 5024) -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://tracker.firebirdsql.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira ------------------------------------------------------------------------------ What Every C/C++ and Fortran developer Should Know! Read this article and learn how Intel has extended the reach of its next-generation tools to help Windows* and Linux* C/C++ and Fortran developers boost performance applications - including clusters. http://p.sf.net/sfu/intel-dev2devmay Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel