mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 02:03:04 +01:00
Fixed CORE-3683 - Recursive query with GROUP BY in root part: wrong results if no index exists for fields that are grouped.
This commit is contained in:
parent
1fb40d535f
commit
3009484b26
@ -236,6 +236,7 @@ void AggregatedStream::print(thread_db* tdbb, string& plan,
|
||||
|
||||
void AggregatedStream::markRecursive()
|
||||
{
|
||||
m_recursive = true;
|
||||
m_next->markRecursive();
|
||||
}
|
||||
|
||||
@ -247,6 +248,10 @@ void AggregatedStream::invalidateRecords(jrd_req* request) const
|
||||
void AggregatedStream::findUsedStreams(StreamList& streams) const
|
||||
{
|
||||
RecordStream::findUsedStreams(streams);
|
||||
|
||||
if (m_recursive)
|
||||
m_next->findUsedStreams(streams);
|
||||
|
||||
if (m_bufferedStream)
|
||||
m_bufferedStream->findUsedStreams(streams);
|
||||
}
|
||||
|
@ -54,15 +54,21 @@ RecursiveStream::RecursiveStream(CompilerScratch* csb, UCHAR stream, UCHAR mapSt
|
||||
m_impure = CMP_impure(csb, sizeof(Impure));
|
||||
m_saveSize = csb->csb_impure - saveOffset;
|
||||
|
||||
m_innerStreams.resize(streamCount);
|
||||
|
||||
for (size_t i = 0; i < streamCount; i++)
|
||||
{
|
||||
m_innerStreams[i] = innerStreams[i];
|
||||
}
|
||||
|
||||
m_root->markRecursive();
|
||||
m_inner->markRecursive();
|
||||
|
||||
// To make aggregates inside the inner stream work, we need to get its own and child streams.
|
||||
// See CORE-3683 for a test case.
|
||||
StreamList childStreams;
|
||||
m_inner->findUsedStreams(childStreams);
|
||||
|
||||
m_innerStreams.resize(streamCount + childStreams.getCount());
|
||||
|
||||
for (size_t i = 0; i < streamCount; i++)
|
||||
m_innerStreams[i] = innerStreams[i];
|
||||
|
||||
for (size_t i = 0; i < childStreams.getCount(); i++)
|
||||
m_innerStreams[streamCount + i] = childStreams[i];
|
||||
}
|
||||
|
||||
void RecursiveStream::open(thread_db* tdbb) const
|
||||
|
Loading…
Reference in New Issue
Block a user