-
-
Notifications
You must be signed in to change notification settings - Fork 262
Add support bitwise aggregate functions #8768
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,39 @@ select department, | |
from employee_department | ||
group by department | ||
``` | ||
|
||
## Bitwise aggregates (Firebird 6.0) | ||
|
||
The `BIN_AND_AGG`, `BIN_OR_AGG`, and `BIN_XOR_AGG` aggregate functions perform bit operations. | ||
|
||
`NULLs` are ignored. It's returned only in the case of none evaluated records having a non-null value. | ||
|
||
The input argument must be one of the integer types (`SMALLINT`, `INTEGER`, `BIGINT`, or `INT128`). | ||
The output result is of the same type as the input argument. | ||
|
||
Syntax: | ||
|
||
``` | ||
<bin_add agg> ::= BIN_AND_AGG(<expression>) | ||
|
||
<bin_or agg> ::= BIN_OR_AGG(<expression>) | ||
|
||
<bin_xor agg> ::= BIN_XOR_AGG([ALL | DISTINCT] <expression>) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is a real use case for BIN_XOR_AGG? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally, BIN_AND_AGG and BIN_OR_AGG would have been enough for me. But since MySQL and PostgreSQL have BIT_XOR, I decided to add a similar function to Firebird. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aggregate |
||
``` | ||
|
||
The `BIN_AND_AGG` and `BIN_OR_AGG` functions do not support the `DISTINCT` keyword, since eliminating duplicates does | ||
not affect the result. However, for `BIN_XOR_AGG`, you can specify `DISTINCT` to exclude duplicates from processing. | ||
|
||
Example: | ||
|
||
``` | ||
SELECT | ||
name, | ||
BIN_AND_AGG(n) AS F_AND, | ||
BIN_OR_AGG(n) AS F_OR, | ||
BIN_XOR_AGG(n) AS F_XOR, | ||
BIN_XOR_AGG(ALL n) AS F_XOR_A, | ||
BIN_XOR_AGG(DISTINCT n) AS F_XOR_D | ||
FROM acl_masks | ||
GROUP BY name | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But in the code I see that SMALLINT and INTEGER are converted to BIGINT...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.