mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 01:23:03 +01:00
Fixed the optimizer in regard to the partitioned window functions.
This commit is contained in:
parent
ba44a37bdd
commit
e2aab75891
@ -221,16 +221,28 @@ bool OPT_computable(CompilerScratch* csb, const jrd_nod* node, SSHORT stream,
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// Check sub-stream
|
||||
if (((sub = rse->rse_boolean) && !OPT_computable(csb, sub, stream, idx_use, allowOnlyCurrentStream)) ||
|
||||
((sub = rse->rse_sorted) && !OPT_computable(csb, sub, stream, idx_use, allowOnlyCurrentStream)) ||
|
||||
if (((sub = rse->rse_boolean) && !OPT_computable(csb, sub, stream, idx_use, allowOnlyCurrentStream)) ||
|
||||
((sub = rse->rse_sorted) && !OPT_computable(csb, sub, stream, idx_use, allowOnlyCurrentStream)) ||
|
||||
((sub = rse->rse_projection) && !OPT_computable(csb, sub, stream, idx_use, allowOnlyCurrentStream)))
|
||||
{
|
||||
result = false;
|
||||
@ -254,7 +266,19 @@ bool OPT_computable(CompilerScratch* csb, const jrd_nod* node, SSHORT stream,
|
||||
// Reset streams inactive
|
||||
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))];
|
||||
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];
|
||||
|
||||
if (node->nod_type == nod_union ||
|
||||
node->nod_type == nod_aggregate ||
|
||||
node->nod_type == nod_procedure ||
|
||||
node->nod_type == nod_rse)
|
||||
if (node->nod_type == nod_relation)
|
||||
{
|
||||
River* const river = river_list.pop();
|
||||
stream_ptr[i]->stream_rsb = river->getRecordSource();
|
||||
stream_ptr[i]->stream_rsb = NULL;
|
||||
stream_ptr[i]->stream_num = (USHORT)(IPTR) node->nod_arg[e_rel_stream];
|
||||
}
|
||||
else
|
||||
{
|
||||
stream_ptr[i]->stream_rsb = NULL;
|
||||
stream_ptr[i]->stream_num = (USHORT)(IPTR) node->nod_arg[STREAM_INDEX(node)];
|
||||
River* const river = river_list.pop();
|
||||
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
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user