diff --git a/src/jrd/cmp.cpp b/src/jrd/cmp.cpp index 8b24aff36c..39833ef67b 100644 --- a/src/jrd/cmp.cpp +++ b/src/jrd/cmp.cpp @@ -133,7 +133,7 @@ using namespace Firebird; static UCHAR* alloc_map(thread_db*, CompilerScratch*, USHORT); static jrd_nod* catenate_nodes(thread_db*, NodeStack&); -static jrd_nod* convertNeqAllToNotAny(thread_db* tdbb, jrd_nod* node); +static jrd_nod* convertNeqAllToNotAny(thread_db* tdbb, CompilerScratch* csb, jrd_nod* node); static jrd_nod* copy(thread_db*, CompilerScratch*, jrd_nod*, UCHAR *, USHORT, jrd_nod*, bool); static void expand_view_nodes(thread_db*, CompilerScratch*, USHORT, NodeStack&, nod_t, bool); static void ignore_dbkey(thread_db*, CompilerScratch*, RecordSelExpr*, const jrd_rel*); @@ -2641,7 +2641,7 @@ static jrd_nod* catenate_nodes(thread_db* tdbb, NodeStack& stack) // // Because the second form can use indexes. // Returns NULL when not converted, and a new node to be processed when converted. -static jrd_nod* convertNeqAllToNotAny(thread_db* tdbb, jrd_nod* node) +static jrd_nod* convertNeqAllToNotAny(thread_db* tdbb, CompilerScratch* csb, jrd_nod* node) { SET_TDBB(tdbb); @@ -2722,7 +2722,13 @@ static jrd_nod* convertNeqAllToNotAny(thread_db* tdbb, jrd_nod* node) newInnerRse->rse_boolean = boolean; - return newNode; + UCHAR localMap[MAP_LENGTH]; + // Initialize the map so all streams initially resolve to the original number. As soon copy + // creates new streams, the map are being overwritten. + for (unsigned i = 0; i < MAP_LENGTH; ++i) + localMap[i] = i; + + return copy(tdbb, csb, newNode, localMap, 0, NULL, false); } @@ -4122,7 +4128,7 @@ jrd_nod* CMP_pass1(thread_db* tdbb, CompilerScratch* csb, jrd_nod* node) case nod_ansi_all: { - jrd_nod* newNode = convertNeqAllToNotAny(tdbb, node); + jrd_nod* newNode = convertNeqAllToNotAny(tdbb, csb, node); if (newNode) return CMP_pass1(tdbb, csb, newNode);