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-automations opened this issue Oct 9, 2014 · 11 comments
Closed

Comments

@firebird-automations
Copy link
Collaborator

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-automations
Copy link
Collaborator Author

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-automations
Copy link
Collaborator Author

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-automations
Copy link
Collaborator Author

Modified by: Sean Leyne (seanleyne)

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

@firebird-automations
Copy link
Collaborator Author

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-automations
Copy link
Collaborator Author

Modified by: @dyemanov

assignee: Dmitry Yemanov [ dimitr ]

@firebird-automations
Copy link
Collaborator Author

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-automations
Copy link
Collaborator Author

Modified by: @dyemanov

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

@firebird-automations
Copy link
Collaborator Author

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-automations
Copy link
Collaborator Author

Modified by: @asfernandes

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

resolution: Fixed [ 1 ]

Fix Version: 3.0 Beta 1 [ 10332 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

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

QA Status: Done successfully

@firebird-automations
Copy link
Collaborator Author

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