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

Support hexadecimal / non-decimal numeric constants #14096

Closed
james-johnston-thumbtack opened this issue Dec 20, 2023 · 1 comment · Fixed by #14262
Closed

Support hexadecimal / non-decimal numeric constants #14096

james-johnston-thumbtack opened this issue Dec 20, 2023 · 1 comment · Fixed by #14262
Assignees
Milestone

Comments

@james-johnston-thumbtack

Is your feature request related to a problem? Please describe.

I would like to be able to express integer constants in hexadecimal. Our database has bit flag columns (sigh) and so working with hex constants is best in this case.

Example:

SELECT
    b.flag_column & 0x08 != 0 AS my_special_flag, -- FLAG_MY_SPECIAL_FLAG

Describe the solution you'd like

PG 16 added support for non-decimal numeric constants, like decimal numbers: https://www.postgresql.org/docs/16/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS-NUMERIC

All are valid examples in binary, octal, and hex, from the docs:

0b100101
0B10011001
0o273
0O755
0x42f
0XFFFF

Also you are allowed to add some "comma separators" to the numbers using underscores for readability:

1_500_000_000
0b10001000_00000000
0o_1_755
0xFFFF_FFFF
1.618_034

It would be nice if RisingWave could support all the above latest PG 16 syntax.

Describe alternatives you've considered

The workaround seems to be to express the numbers in decimal. However, the flag values are harder to read in such a case, and also don't align well with the original PHP code which expresses the constants using hexadecimal.

So it hurts readability in our case.

Additional context

No response

@xiangjinwu
Copy link
Contributor

Thank you for sharing the new PostgreSQL 16 syntax. We are glad to support it as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants