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

Fixed CORE-1334 - Joins with NULL RDB$DB_KEY crash the server

This commit is contained in:
asfernandes 2007-07-01 23:13:09 +00:00
parent bc3fad42f7
commit 3e33eda40b

View File

@ -328,15 +328,21 @@ RecordBitmap** EVL_bitmap(thread_db* tdbb, jrd_nod* node, RecordBitmap* bitmap_a
impure_inversion* impure = (impure_inversion*) ((SCHAR *) tdbb->tdbb_request + node->nod_impure);
RecordBitmap::reset(impure->inv_bitmap);
const dsc* desc = EVL_expr(tdbb, node->nod_arg[0]);
const USHORT id = (USHORT)(IPTR) node->nod_arg[1];
RecordNumber::Packed* numbers = reinterpret_cast<RecordNumber::Packed*>(desc->dsc_address);
RecordNumber rel_dbkey;
rel_dbkey.bid_decode(&numbers[id]);
// NS: Why the heck we decrement record number here? I have no idea, but retain the algorithm for now.
// hvlad: because from the user point of view db_key's begins from 1
rel_dbkey.decrement();
if (!bitmap_and || bitmap_and->test(rel_dbkey.getValue()))
RBM_SET(tdbb->getDefaultPool(), &impure->inv_bitmap, rel_dbkey.getValue());
if (!(tdbb->tdbb_request->req_flags & req_null) &&
desc->dsc_length == sizeof(RecordNumber::Packed))
{
const USHORT id = (USHORT)(IPTR) node->nod_arg[1];
RecordNumber::Packed* numbers = reinterpret_cast<RecordNumber::Packed*>(desc->dsc_address);
RecordNumber rel_dbkey;
rel_dbkey.bid_decode(&numbers[id]);
// NS: Why the heck we decrement record number here? I have no idea, but retain the algorithm for now.
// hvlad: because from the user point of view db_key's begins from 1
rel_dbkey.decrement();
if (!bitmap_and || bitmap_and->test(rel_dbkey.getValue()))
RBM_SET(tdbb->getDefaultPool(), &impure->inv_bitmap, rel_dbkey.getValue());
}
return &impure->inv_bitmap;
}