From fe01201cd44a5c1fa95e3f5d247c78df18152ead Mon Sep 17 00:00:00 2001 From: dimitr Date: Mon, 2 Apr 2012 15:25:36 +0000 Subject: [PATCH] Fixed CORE-3806: Wrong data returned if a sub-query or a computed field refers to the base table in the ORDER BY clause. --- src/jrd/recsrc/SortedStream.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/jrd/recsrc/SortedStream.cpp b/src/jrd/recsrc/SortedStream.cpp index 7349d1ab09..ef2ac2b4e9 100644 --- a/src/jrd/recsrc/SortedStream.cpp +++ b/src/jrd/recsrc/SortedStream.cpp @@ -268,7 +268,7 @@ Sort* SortedStream::init(thread_db* tdbb) const scb->sort(tdbb); // For the sake of prudence, set all record parameter blocks to contain - // the most recent format. This will guarentee that all fields mapped + // the most recent format. This will guarantee that all fields mapped // back to records by get_sort() have homes in the target record. if (records) @@ -287,7 +287,10 @@ Sort* SortedStream::init(thread_db* tdbb) const stream = item->stream; record_param* const rpb = &request->req_rpb[stream]; - if (rpb->rpb_relation) + // dimitr: I've added the check for !isValid to ensure that we don't overwrite + // the format for an active rpb (i.e. the one having some record fetched). + // See CORE-3806 for example. + if (rpb->rpb_relation && !rpb->rpb_number.isValid()) VIO_record(tdbb, rpb, MET_current(tdbb, rpb->rpb_relation), tdbb->getDefaultPool()); } }