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

Unexpected (wrong) results with COALESCE and GROUP BY [CORE2176] #2607

Closed
firebird-automations opened this issue Nov 8, 2008 · 9 comments
Closed

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @dyemanov

Is related to QA373

Test case:

select rdb$relation_id as c from rdb$relations
group by 1
-- correct result

select * from (
select rdb$relation_id as c from rdb$relations
) group by 1
-- also correct

select coalesce(rdb$relation_id, 0) as c from rdb$relations
group by 1
-- ERROR: no zero ID is reported, the last ID is reported twice

select * from (
select coalesce(rdb$relation_id, 0) as c from rdb$relations
) group by 1
-- ERROR: single NULL is returned

I doubt the third and fourth samples represent the same bug, as if I replace COALESCE with ROUND, the third one succeeds while the fourth one still returns NULL.

Commits: 720a49c dcfdeca

====== Test Details ======

Test probably should be re-implemented: it hopes that in the future FB-versions there will be NO system tables (which currently not exists) with rdb$relations.rdb$relation_id < 30.

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

assignee: Adriano dos Santos Fernandes [ asfernandes ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

It looks like the fourth test case is related to a nod_derived_expr handling, as EVL_expr() returns NULL because the stream's rpb_number is never considered valid.

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

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

resolution: Fixed [ 1 ]

Fix Version: 2.5 Beta 1 [ 10251 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

One more test case which currently fails:

select * from (
select coalesce(rdb$relation_id, 0) as a, coalesce(rdb$relation_type, 0) as b from rdb$relations
) group by 1, 2
-- ERROR: infinite result set with all zero values

select * from (
select coalesce(rdb$relation_id, 0) as a, coalesce(rdb$relation_name, '') as b from rdb$relations
) group by 1, 2
-- ERROR: conversion error

It seems to happen in the case of multiple COALESCE instances. If those instances are the same (i.e. both refer to relation ID), then no bug appears.

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

Fixed.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Link: This issue is related to QA373 [ QA373 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @pcisar

QA test added.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

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

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

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

QA Status: Done with caveats

Test Details: Test probably should be re-implemented: it hopes that in the future FB-versions there will be NO system tables (which currently not exists) with rdb$relations.rdb$relation_id < 30.

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