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

Integer addition overflow #6205

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

Integer addition overflow #6205

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

Comments

@monetdb-team
Copy link

Date: 2017-02-06 16:10:09 +0100
From: @kutsurak
To: SQL devs <>
Version: 11.25.5 (Dec2016-SP1)
CC: @mlkersten, @njnes, @drstmane

Last updated: 2017-03-03 10:24:23 +0100

Comment 24976

Date: 2017-02-06 16:10:09 +0100
From: @kutsurak

User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0
Build Identifier:

Addition with integer literals produces overflows:

Reproducible: Always

Steps to Reproduce:

1.SELECT 20000+30000;
2.
3.

Actual Results:

+--------+
| L2 |
+========+
| -15536 |
+--------+

Expected Results:

+-------+
| L3 |
+=======+
| 50000 |
+-------+

Comment 24977

Date: 2017-02-06 20:58:04 +0100
From: @mlkersten

Indeed, the SQL compiler does not up-cast the type of the arithmetic expression.
It can not be compensated for in the MAL optimizer, which does not properly check for the overflow either.

The short term solution is to disable the constant evaluate() optimizer.

Comment 24978

Date: 2017-02-06 21:31:06 +0100
From: @drstmane

sql>declare a smallint;
operation successful (0.939ms)
sql>declare b smallint;
operation successful (1.144ms)
sql>set a = 20000;
operation successful (0.966ms)
sql>set b = 30000;
operation successful (0.974ms)
sql>select a + b;
+-------+
| L2 |
+=======+
| 50000 |
+-------+
1 tuple (1.006ms)

Comment 24979

Date: 2017-02-06 21:32:15 +0100
From: @drstmane

sql>select cast(20000 as smallint) + cast(30000 as smallint);
+-------+
| L4 |
+=======+
| 50000 |
+-------+
1 tuple (2.386ms)

Comment 24986

Date: 2017-02-08 12:42:14 +0100
From: @njnes

fixed call conversion operator (ie with proper (large enough) types.

Comment 24994

Date: 2017-02-09 12:15:39 +0100
From: MonetDB Mercurial Repository <>

Changeset 7c14a3a849fb made by Jennie Zhang y.zhang@cwi.nl in the MonetDB repo, refers to this bug.

For complete details, see http//devmonetdborg/hg/MonetDB?cmd=changeset;node=7c14a3a849fb

Changeset description:

Added test for Bug #6205

Comment 25115

Date: 2017-03-03 10:24:23 +0100
From: @sjoerdmullender

Dec2016-SP2 has been released, incorporating the fix.

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

No branches or pull requests

2 participants