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

sql: make decimal operations avoid negative zeros #28404

Closed
knz opened this issue Aug 9, 2018 · 2 comments · Fixed by #86106
Closed

sql: make decimal operations avoid negative zeros #28404

knz opened this issue Aug 9, 2018 · 2 comments · Fixed by #86106
Labels
A-sql-builtins SQL built-in functions and semantics thereof. A-sql-datatypes SQL column types usable in table descriptors. A-sql-semantics C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-queries SQL Queries Team

Comments

@knz
Copy link
Contributor

knz commented Aug 9, 2018

Discussed here: #28366 (comment)

@mjibson is there a way to have a flag in the apd.Context that makes the various functions flatten negative zeros to positive automatically? so that we don't have to hunt them down in cockroachdb.

No, there's no such flag or option. We'd have to create it, which probably wouldn't be so bad. Here's another way to make a -0 in cockroach that is a 0 in postgres:

select round(-.1)

So I suppose we may want to add an option to the apd Context? Sounds fine to me. Any opposition to that?

No opposition from me :)

Jira issue: CRDB-4908

@knz knz added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. A-sql-semantics A-sql-builtins SQL built-in functions and semantics thereof. A-sql-datatypes SQL column types usable in table descriptors. labels Aug 9, 2018
@github-actions
Copy link

github-actions bot commented Jun 6, 2021

We have marked this issue as stale because it has been inactive for
18 months. If this issue is still relevant, removing the stale label
or adding a comment will keep it active. Otherwise, we'll close it in
5 days to keep the issue queue tidy. Thank you for your contribution
to CockroachDB!

@knz
Copy link
Contributor Author

knz commented Jun 7, 2021

still current in 21.1

@jlinder jlinder added the T-sql-queries SQL Queries Team label Jun 16, 2021
craig bot pushed a commit that referenced this issue Nov 16, 2022
86106: sql: make round builtin avoid negative zeros r=rafiss a=nnaka2992

fixes  #28404

Previously, the round function could return -0.
In PostgreSQL, the function returns 0 without a negative sign,
so this commit changes the behavior of round to match that.

Release note (sql change): The round(decimal) builtin function
no longer returns negative 0 for any input.

Co-authored-by: nnaka2992 <[email protected]>
@craig craig bot closed this as completed in 9debf4b Nov 16, 2022
@mgartner mgartner moved this to Done in SQL Queries Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-builtins SQL built-in functions and semantics thereof. A-sql-datatypes SQL column types usable in table descriptors. A-sql-semantics C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-queries SQL Queries Team
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants