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

Wrong associativity of multiply/divide #3686

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

Wrong associativity of multiply/divide #3686

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

Comments

@monetdb-team
Copy link

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

Date: 2015-03-13 12:16:22 +0100
From: Richard Hughes <<richard.monetdb>>
To: SQL devs <>
Version: 11.19.9 (Oct2014-SP2)
CC: martin.van.dinther, @njnes

Last updated: 2015-08-28 13:42:05 +0200

Comment 20712

Date: 2015-03-13 12:16:22 +0100
From: Richard Hughes <<richard.monetdb>>

Build is Oct2014 e58372859532

sql>select 12*5/3;
+----------------------+
| sql_mul_single_value |
+======================+
| 12 |
+----------------------+

Expected result is 20.

sql>plan select 12*5/3;
+-----------------------------------------------------------------------------+
| rel |
+=============================================================================+
| [ sys.sql_mul(smallint[tinyint "12"], sys.sql_div(tinyint "5", tinyint "3" |
: )) ] :
+-----------------------------------------------------------------------------+

"select (12*5)/3;" works.

Comment 20723

Date: 2015-03-19 14:22:33 +0100
From: Martin van Dinther <<martin.van.dinther>>

Also the result of the following is incorrect;

sql>select 12*3/5;
+----------------------+
| sql_mul_single_value |
+======================+
| 0 |
+----------------------+
1 tuple (0.794ms)

expected result: 7.2 such as in:
sql>select 12*3/5.0;
+----------------------+
| sql_mul_single_value |
+======================+
| 7.200 |
+----------------------+
1 tuple (0.875ms)

sql>plan select 12*3/5;
+----------------------------------------------------------------------------------+
| rel |
+==================================================================================+
| [ sys.sql_mul(smallint[tinyint "12"], sys.sql_div(tinyint "3", tinyint "5")) ] |
+----------------------------------------------------------------------------------+
1 tuple (0.466ms)

sql>plan select 12*3/5.0;
+------------------------------------------------------------------------------------------------------------------+
| rel |
+==================================================================================================================+
| [ sys.sql_mul(decimal(15)[tinyint "12"], sys.sql_div(decimal(7,4)[decimal(4,1)[tinyint "3"]], decimal(4,1)[decimal(2,1) "50"])) ] :
+------------------------------------------------------------------------------------------------------------------+
1 tuple (0.559ms)

Comment 20724

Date: 2015-03-19 16:11:11 +0100
From: @sjoerdmullender

I had a fix ready, but it had other problems, so I haven't committed it.

The problem is one of priorities, not associativity. In the SQL parser we have different priorities for / and *, but they should have the same priority according to the SQL standard. Fixing this uncovered another problem that we should fix as well.

Comment 20728

Date: 2015-03-20 09:32:24 +0100
From: MonetDB Mercurial Repository <>

Changeset ba9b1cd64364 made by Sjoerd Mullender sjoerd@acm.org in the MonetDB repo, refers to this bug.

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

Changeset description:

Added test for bug #3686.

Comment 20872

Date: 2015-05-20 18:31:48 +0200
From: @njnes

fixed in default

Comment 21201

Date: 2015-08-28 13:42:05 +0200
From: @sjoerdmullender

Jul2015 has been released.

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