8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 14:03:03 +01:00

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.

This commit is contained in:
asfernandes 2014-07-21 02:37:58 +00:00
parent c3aff7941c
commit 0478d4fffa
2 changed files with 14 additions and 1 deletions

View File

@ -21,7 +21,10 @@ Cursor variables
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.

View File

@ -6820,6 +6820,16 @@ void DerivedFieldNode::genBlr(DsqlCompilerScratch* dsqlScratch)
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);
}