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

GROUP BY groups equal BLOBs if adjacent [CORE3252] #3620

Open
firebird-automations opened this issue Nov 20, 2010 · 5 comments
Open

GROUP BY groups equal BLOBs if adjacent [CORE3252] #3620

firebird-automations opened this issue Nov 20, 2010 · 5 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @paulvink

Duplicates CORE859

Given this table:

BLOOB
S BLOB SUB_TYPE 1
-----------------------------
table
chair
chair
bed
table
bed
bed
chair

The query "select count(s), s from bloob group by s" returns:

1 table
2 chair
1 bed
1 table
2 bed
1 chair

That's pretty weird :-)
IMO, GROUP BY ought to work, or not to work, or throw an error... but not work on *some* equal values because they happen to live in adjacent rows.
Do those rows share the BLOB ID, maybe?

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

See my comment for CORE3253.

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Link: This issue duplicates CORE859 [ CORE859 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

Commented by Paul Vinkenoog:

Still would like to know:

a) How can it be that adjacent rows, if equal, are grouped together at all?

b) Can this be fixed, in the sense that they are no longer grouped together? IMO the current behaviour is the worst thinkable: an incomplete grouping that depends on the physical table order.

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

Explanation is quite simple. GROUP BY compares two subsequent (priorly ordered) values to being same or distinct, using the generic comparison routine which handles blobs correctly. But the prior ordering is incorrect, because it's based on BLOB IDs and in this case they correspond to DBKEYs, as blobs were created sequentially, along with new records added. But generally, the result would be unpredictable.

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

Commented by Paul Vinkenoog:

OK, that's clear. I still think this should be fixed (in the sense that no grouping at all takes place on BLOBs, rather than disjunct grouping), but that's up to you guys.

For the time being, I've documented this phenomenon.

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