mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 09:23:03 +01:00
Fixed the optimizer in regard to the partitioned window functions.
This commit is contained in:
parent
ba44a37bdd
commit
e2aab75891
@ -221,9 +221,21 @@ bool OPT_computable(CompilerScratch* csb, const jrd_nod* node, SSHORT stream,
|
|||||||
|
|
||||||
for (ptr = rse->rse_relation, end = ptr + rse->rse_count; ptr < end; ptr++)
|
for (ptr = rse->rse_relation, end = ptr + rse->rse_count; ptr < end; ptr++)
|
||||||
{
|
{
|
||||||
if ((*ptr)->nod_type != nod_rse)
|
const jrd_nod* const node = *ptr;
|
||||||
|
|
||||||
|
if (node->nod_type == nod_window)
|
||||||
{
|
{
|
||||||
n = (USHORT)(IPTR) (*ptr)->nod_arg[STREAM_INDEX((*ptr))];
|
const jrd_nod* windows = node->nod_arg[e_win_windows];
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < windows->nod_count; ++i)
|
||||||
|
{
|
||||||
|
n = (USHORT)(IPTR) windows->nod_arg[i]->nod_arg[e_part_stream];
|
||||||
|
csb->csb_rpt[n].csb_flags |= (csb_active | csb_sub_stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (node->nod_type != nod_rse)
|
||||||
|
{
|
||||||
|
n = (USHORT)(IPTR) node->nod_arg[STREAM_INDEX(node)];
|
||||||
csb->csb_rpt[n].csb_flags |= (csb_active | csb_sub_stream);
|
csb->csb_rpt[n].csb_flags |= (csb_active | csb_sub_stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,7 +266,19 @@ bool OPT_computable(CompilerScratch* csb, const jrd_nod* node, SSHORT stream,
|
|||||||
// Reset streams inactive
|
// Reset streams inactive
|
||||||
for (ptr = rse->rse_relation, end = ptr + rse->rse_count; ptr < end; ptr++)
|
for (ptr = rse->rse_relation, end = ptr + rse->rse_count; ptr < end; ptr++)
|
||||||
{
|
{
|
||||||
if ((*ptr)->nod_type != nod_rse)
|
const jrd_nod* const node = *ptr;
|
||||||
|
|
||||||
|
if (node->nod_type == nod_window)
|
||||||
|
{
|
||||||
|
const jrd_nod* windows = node->nod_arg[e_win_windows];
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < windows->nod_count; ++i)
|
||||||
|
{
|
||||||
|
n = (USHORT)(IPTR) windows->nod_arg[i]->nod_arg[e_part_stream];
|
||||||
|
csb->csb_rpt[n].csb_flags &= ~(csb_active | csb_sub_stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (node->nod_type != nod_rse)
|
||||||
{
|
{
|
||||||
n = (USHORT)(IPTR) (*ptr)->nod_arg[STREAM_INDEX((*ptr))];
|
n = (USHORT)(IPTR) (*ptr)->nod_arg[STREAM_INDEX((*ptr))];
|
||||||
csb->csb_rpt[n].csb_flags &= ~(csb_active | csb_sub_stream);
|
csb->csb_rpt[n].csb_flags &= ~(csb_active | csb_sub_stream);
|
||||||
|
@ -2828,18 +2828,15 @@ static RecordSource* gen_outer(thread_db* tdbb,
|
|||||||
{
|
{
|
||||||
jrd_nod* const node = rse->rse_relation[i];
|
jrd_nod* const node = rse->rse_relation[i];
|
||||||
|
|
||||||
if (node->nod_type == nod_union ||
|
if (node->nod_type == nod_relation)
|
||||||
node->nod_type == nod_aggregate ||
|
|
||||||
node->nod_type == nod_procedure ||
|
|
||||||
node->nod_type == nod_rse)
|
|
||||||
{
|
{
|
||||||
River* const river = river_list.pop();
|
stream_ptr[i]->stream_rsb = NULL;
|
||||||
stream_ptr[i]->stream_rsb = river->getRecordSource();
|
stream_ptr[i]->stream_num = (USHORT)(IPTR) node->nod_arg[e_rel_stream];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stream_ptr[i]->stream_rsb = NULL;
|
River* const river = river_list.pop();
|
||||||
stream_ptr[i]->stream_num = (USHORT)(IPTR) node->nod_arg[STREAM_INDEX(node)];
|
stream_ptr[i]->stream_rsb = river->getRecordSource();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3853,7 +3850,7 @@ static RecordSource* gen_union(thread_db* tdbb,
|
|||||||
// member to allow recursive members be optimized
|
// member to allow recursive members be optimized
|
||||||
if (recurse)
|
if (recurse)
|
||||||
{
|
{
|
||||||
const SSHORT stream = (USHORT)(IPTR) union_node->nod_arg[STREAM_INDEX(union_node)];
|
const SSHORT stream = (USHORT)(IPTR) union_node->nod_arg[e_uni_stream];
|
||||||
csb->csb_rpt[stream].csb_flags |= csb_active;
|
csb->csb_rpt[stream].csb_flags |= csb_active;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user