Skip to content

Commit

Permalink
Fixed CORE-2886 - Query with "NOT IN <subselect from view>" fails
Browse files Browse the repository at this point in the history
  • Loading branch information
asfernandes committed Feb 27, 2010
1 parent 0f72474 commit 1f12183
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/jrd/cmp.cpp
Expand Up @@ -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*);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
}


Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 1f12183

Please sign in to comment.