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

This SQL should not compile [CORE6156] #6405

Closed
firebird-automations opened this issue Oct 11, 2019 · 5 comments
Closed

This SQL should not compile [CORE6156] #6405

firebird-automations opened this issue Oct 11, 2019 · 5 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Attila Molnár (e_pluribus_unum)

We have a similar structura SQL in our code, I rewrite it to EMPLOYEE.FDB.

SELECT
e.emp_no
FROM employee e
JOIN employee_project p ON p.emp_no = e.emp_no
GROUP BY e.emp_no
HAVING MAX((SELECT
SUM(e2.salary)
FROM employee e2
JOIN employee_project p2 ON p2.emp_no = e2.emp_no
WHERE e2.emp_no = e.emp_no AND
p2.proj_id IS NOT DISTINCT FROM p.proj_id)) <> 0

Why this is compiles? In the subselect p.proj_id should not be accepted - group does not contains it, and has no aggregate on it. What value the current engine choose when it runs, and why?

Thank you!

@firebird-automations
Copy link
Collaborator Author

Commented by: @aafemt

Subquery is inside of aggregation function so there is no problem with it.

Tracker is not a support list.

@firebird-automations
Copy link
Collaborator Author

Commented by: Attila Molnár (e_pluribus_unum)

I understand, this

SELECT
e.emp_no
FROM employee e
JOIN employee_project p ON p.emp_no = e.emp_no
GROUP BY e.emp_no
HAVING (SELECT
SUM(e2.salary)
FROM employee e2
JOIN employee_project p2 ON p2.emp_no = e2.emp_no
WHERE e2.emp_no = e.emp_no AND
p2.proj_id IS NOT DISTINCT FROM MAX(p.proj_id)) <> 0

but in the original case the aggregate was on the result of the subselect. To get the resultset what p.proj_id used in the original case?

(BTW the yahoo support group is not so alive. I reported CORE6151 there a weak before here, but still no answen on that forum. At leas this tracker is resposive.
Is there an alernative support list?)

@firebird-automations
Copy link
Collaborator Author

Commented by: Sean Leyne (seanleyne)

As Dmitry noted:

- The SQL is valid
- This is not a support list.

@firebird-automations
Copy link
Collaborator Author

Modified by: Sean Leyne (seanleyne)

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

resolution: Won't Fix [ 2 ]

@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

1 participant