|
From: <asf...@us...> - 2014-07-21 02:38:01
|
Revision: 59898
http://sourceforge.net/p/firebird/code/59898
Author: asfernandes
Date: 2014-07-21 02:37:58 +0000 (Mon, 21 Jul 2014)
Log Message:
-----------
Fixed CORE-4488 - Wrong results of FOR SELECT <L> FROM <T> AS CURSOR <C> and table <T> is modified inside cursor's begin...end block.
Modified Paths:
--------------
firebird/trunk/doc/sql.extensions/README.cursor_variables.txt
firebird/trunk/src/dsql/ExprNodes.cpp
Modified: firebird/trunk/doc/sql.extensions/README.cursor_variables.txt
===================================================================
--- firebird/trunk/doc/sql.extensions/README.cursor_variables.txt 2014-07-21 00:32:30 UTC (rev 59897)
+++ firebird/trunk/doc/sql.extensions/README.cursor_variables.txt 2014-07-21 02:37:58 UTC (rev 59898)
@@ -21,7 +21,10 @@
4) Cursor variables are read-only.
5) A FOR SELECT without AS CURSOR needs the use of INTO, while with AS CURSOR it's not required,
but still allowed. With FETCH, INTO is now optional.
- 6) It's allowed now to use the colon prefix when assigning to variables or NEW's fields.
+ 6) It's allowed now to use the colon prefix when assigning to variables or NEW's fields.
+ 7) Reading from a cursor variable returns the current field values. That means an UPDATE (with
+ WHERE CURRENT OF) also updates the fields for subsequent reads. And DELETE (with WHERE
+ CURRENT OF) makes subsequent reads to return NULL.
Examples:
1.
Modified: firebird/trunk/src/dsql/ExprNodes.cpp
===================================================================
--- firebird/trunk/src/dsql/ExprNodes.cpp 2014-07-21 00:32:30 UTC (rev 59897)
+++ firebird/trunk/src/dsql/ExprNodes.cpp 2014-07-21 02:37:58 UTC (rev 59898)
@@ -6820,6 +6820,16 @@
dsqlScratch->appendUChar(derivedContexts[i]);
}
}
+ else if ((context->ctx_flags & CTX_cursor) && val->is<FieldNode>())
+ {
+ // ASF: FieldNode::execute do not verify rpb_number.isValid(), and due to system triggers
+ // and also singular queries, we cannot start to do it. So to fix CORE-4488, we introduce
+ // the usage of blr_derived_expr for cursor fields, which in practice prefixes the
+ // FieldNode::execute by a test of rpb_number.isValid().
+ dsqlScratch->appendUChar(blr_derived_expr);
+ dsqlScratch->appendUChar(1);
+ GEN_stuff_context(dsqlScratch, val->as<FieldNode>()->dsqlContext);
+ }
GEN_expr(dsqlScratch, value);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|