mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 07:23:03 +01:00
Fixed CORE-2176 - Unexpected (wrong) results with COALESCE and GROUP BY
This commit is contained in:
parent
5f04e5080b
commit
dcfdeca45c
@ -9975,7 +9975,6 @@ static dsql_nod* remap_field(CompiledStatement* statement, dsql_nod* field,
|
|||||||
current_level--;
|
current_level--;
|
||||||
return field;
|
return field;
|
||||||
|
|
||||||
case nod_coalesce:
|
|
||||||
case nod_simple_case:
|
case nod_simple_case:
|
||||||
case nod_searched_case:
|
case nod_searched_case:
|
||||||
{
|
{
|
||||||
@ -9988,6 +9987,16 @@ static dsql_nod* remap_field(CompiledStatement* statement, dsql_nod* field,
|
|||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case nod_coalesce:
|
||||||
|
{
|
||||||
|
// ASF: We have deliberately change nod_count to 1, to not process the second list.
|
||||||
|
// But we should remap its fields. CORE-2176
|
||||||
|
dsql_nod** ptr = field->nod_arg;
|
||||||
|
for (const dsql_nod* const* const end = ptr + 2; ptr < end; ptr++)
|
||||||
|
*ptr = remap_field(statement, *ptr, context, current_level);
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
|
||||||
case nod_aggregate:
|
case nod_aggregate:
|
||||||
field->nod_arg[e_agg_rse] =
|
field->nod_arg[e_agg_rse] =
|
||||||
remap_field(statement, field->nod_arg[e_agg_rse], context, current_level);
|
remap_field(statement, field->nod_arg[e_agg_rse], context, current_level);
|
||||||
|
@ -3101,7 +3101,10 @@ jrd_nod* PAR_parse_node(thread_db* tdbb, CompilerScratch* csb, USHORT expected,
|
|||||||
const UCHAR streamCount = BLR_BYTE;
|
const UCHAR streamCount = BLR_BYTE;
|
||||||
USHORT* streamList = FB_NEW(*tdbb->getDefaultPool()) USHORT[streamCount];
|
USHORT* streamList = FB_NEW(*tdbb->getDefaultPool()) USHORT[streamCount];
|
||||||
for (UCHAR i = 0; i < streamCount; ++i)
|
for (UCHAR i = 0; i < streamCount; ++i)
|
||||||
|
{
|
||||||
streamList[i] = BLR_BYTE;
|
streamList[i] = BLR_BYTE;
|
||||||
|
streamList[i] = csb->csb_rpt[streamList[i]].csb_stream;
|
||||||
|
}
|
||||||
|
|
||||||
node->nod_arg[e_derived_expr_stream_list] = (jrd_nod*) streamList;
|
node->nod_arg[e_derived_expr_stream_list] = (jrd_nod*) streamList;
|
||||||
node->nod_arg[e_derived_expr_stream_count] = (jrd_nod*)(IPTR) streamCount;
|
node->nod_arg[e_derived_expr_stream_count] = (jrd_nod*)(IPTR) streamCount;
|
||||||
|
Loading…
Reference in New Issue
Block a user