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

Multiplication and cast from decimal to integer leads to 0 value #2923

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

Multiplication and cast from decimal to integer leads to 0 value #2923

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

Comments

@monetdb-team
Copy link

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

Date: 2011-11-03 10:01:31 +0100
From: sellam
To: SQL devs <>
Version: 11.5.1 (Aug2011) [obsolete]
CC: @njnes

Last updated: 2011-11-22 13:55:54 +0100

Comment 16513

Date: 2011-11-03 10:01:31 +0100
From: sellam

User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-GB; rv:1.9.2.23) Gecko/20110927 Fedora/3.6.23-1.fc14 Firefox/3.6.23
Build Identifier:

The following example illustrates the bug:

  1. Working example:

DECLARE x decimal(3,2);
set x=-1.21;
SELECT cast((x *100) as integer);

-> this returns -121, OK

  1. Bugging example:

create table test(t decimal(3,2));
insert into test (t) values (-1.21);
select cast((t * 100) as integer) from test;

-> this returns 0

Reproducible: Always

Steps to Reproduce:

create table test(t decimal(3,2));
insert into test (t) values (-1.21);
select cast((t * 100) as integer) from test;

Actual Results:

+-----------+
| sql_mul_t |
+===========+
| 0 |
+-----------+

Expected Results:

-121

bash-4.1$ hg branch
Aug2011
bash-4.1$ hg id
998089b7cdd7 (Aug2011) tip

Comment 16517

Date: 2011-11-04 11:00:54 +0100
From: @njnes

fixed by adding brackets (c - ? precedence rules :-(
Added test Multiplication_and_cast.Bug-2923.sql

Comment 16518

Date: 2011-11-04 11:04:46 +0100
From: @njnes

Changeset 4e75b961d68a made by Niels Nes niels@cwi.nl in the MonetDB repo, refers to this bug.

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

Changeset description:

fixed bug #2923. Precedence rule problem...

Comment 16564

Date: 2011-11-22 13:55:54 +0100
From: @grobian

Fixed in Aug2011-SP3

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