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

ROUND produces wrong data type #6429

Closed
monetdb-team opened this issue Nov 30, 2020 · 0 comments
Closed

ROUND produces wrong data type #6429

monetdb-team opened this issue Nov 30, 2020 · 0 comments

Comments

@monetdb-team
Copy link

@monetdb-team monetdb-team commented Nov 30, 2020

Date: 2017-10-16 11:03:18 +0200
From: Gatis Ozolins <<g.ozolins>>
To: SQL devs <>
Version: 11.27.9 (Jul2017-SP2)
CC: @njnes

Last updated: 2017-12-14 14:46:06 +0100

Comment 25741

Date: 2017-10-16 11:03:18 +0200
From: Gatis Ozolins <<g.ozolins>>

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0
Build Identifier:

SELECT ROUND(123.563, 2) AS val

produces DECIMAL(2,3) data type, but it should be DECIMAL(5,2)

Reproducible: Always

Steps to Reproduce:

create table zz_round_bug as
select ROUND(123.563, 2) as val;

select c.type_digits, c.type_scale
from sys.tables t
join sys.columns c
on t.id = c.table_id
where t.name = 'zz_round_bug'
and c.name = 'val';

Actual Results:

2 3

Expected Results:

5 2

Any filtering on created table produces error:
select * from zz_round_bug where val = 1

SQL Error [22003]: value (123560) exceeds limits of type bte
java.sql.SQLException: value (123560) exceeds limits of type bte

Comment 25939

Date: 2017-12-03 23:13:34 +0100
From: @njnes

SQL it self lacks a proper definition of ROUND. Other DBMSes also seem not to
agree on the definition. Our current implementation seems to follow the sqlserver one, ie we round (positive numbers right from the dot, negative numbers left from the dot), but leave the type alone (ie stays as the input value).

Comment 25940

Date: 2017-12-04 09:01:47 +0100
From: Gatis Ozolins <<g.ozolins>>

But still it should not be possible to create situation where selecting data from table results in error

Comment 25941

Date: 2017-12-04 09:50:17 +0100
From: @sjoerdmullender

This bug was fixed with changeset 6bfbf16160a6

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

Successfully merging a pull request may close this issue.

None yet
1 participant