Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: Incorrect result in subquery with aggregate [CORE4574] #4891

Closed
firebird-issue-importer opened this issue Oct 9, 2014 · 11 comments

Comments

@firebird-issue-importer
Copy link

firebird-issue-importer commented Oct 9, 2014

Submitted by: Alex Bekhtin (afgm)

with A(ID) as
(
select 1 from rdb$database
union all
select 2 from rdb$database
union all
select 3 from rdb$database
),
B(ID1, ID2) as
(
select 1, null from rdb$database
union all
select 2, null from rdb$database
union all
select 3, null from rdb$database
)
select
sum((select count(*) from B where B.ID1 = http://A.ID))
,
sum((select count(*) from B where B.ID2 = http://A.ID))
-- must be (3,0) (FB2.5) , but not (3,3) (FB3.0)
from A

Commits: 3a6c109 FirebirdSQL/fbt-repository@8d54daa

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Oct 9, 2014

Commented by: Sean Leyne (seanleyne)

1- This would appear to be a regression, so that should be reflected in the Subject

2- I believe that the Subject of this item should read "Incorrect result using CTE with aggregate" since the issue is with CTE not with subquery functionality.

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Oct 9, 2014

Commented by: Alex Bekhtin (afgm)

to Sean Leyne

>1- This would appear to be a regression, so that should be reflected in the Subject
Ok. I can't write correct formulation. Correct it please.

> 2- I believe that the Subject of this item should read "Incorrect result using CTE with aggregate" since the issue is with CTE not with subquery functionality.
This CTE for generate example data. This regression is reproduced in the real data.

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Oct 9, 2014

Modified by: Sean Leyne (seanleyne)

summary: Incorrect result in subquery with aggregate => Regression: Incorrect result in subquery with aggregate

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Oct 9, 2014

Commented by: Sean Leyne (seanleyne)

Please provide an example of the 'real' SQL which is failing. Using a CTE for 'dummy' data, while convenient, can obscure the real issue.

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Oct 9, 2014

Modified by: @dyemanov

assignee: Dmitry Yemanov [ dimitr ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Oct 9, 2014

Commented by: @dyemanov

Adriano, at the first glance this seemed related to CORE4084, at least the problem location is the same: RseNode::dsqlMatch.

However, after comparing the node matching code with v2.5, I now wonder why we don't match RSE sub-items anymore? In v2.5, nod_rse->nod_count == 9, so PASS1_node_match is called for the every query element. But v3 checks only dsqlContext and it definitely smells like a regression.

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Oct 9, 2014

Modified by: @dyemanov

assignee: Dmitry Yemanov [ dimitr ] => Adriano dos Santos Fernandes [ asfernandes ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Oct 10, 2014

Commented by: @asfernandes

I'm now calling the super method which should compare all sub nodes.

But I see that in both versions, if the two subselects are identical, it creates two mappings, which seems not obvious nor good for performance.

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Oct 10, 2014

Modified by: @asfernandes

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 3.0 Beta 1 [ 10332 ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented May 28, 2015

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Resolved [ 5 ]

QA Status: Done successfully

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Sep 23, 2015

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants