Bug 3378

Summary: possible to support double x boolean type casting in the next update?
Product: SQL Reporter: Anthony Damico <ajdamico>
Component: allAssignee: SQL devs <bugs-sql>
Status: NEW ---    
Severity: enhancement CC: ajdamico, Stefan.Manegold
Priority: Normal    
Version: -- development   
Hardware: All   
OS: Windows   

Description Anthony Damico 2013-09-30 14:48:52 CEST
User-Agent:       Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0
Build Identifier: 

i know you don't support every type casting/conversion, but double x boolean seems like a common combination.  is it possible to start supporting this?  thanks!!

Reproducible: Always

Steps to Reproduce:
only two of these three commands work in monetdb..


# integer x boolean works
SELECT SUM( 10 * TRUE ) FROM ( values ( 1 ) ) AS temp;

# double x boolean breaks
SELECT SUM( 10.0 * TRUE ) FROM ( values ( 1 ) ) AS temp;

# double x integer works
SELECT SUM( 10.0 * CAST( TRUE AS INTEGER ) ) FROM ( values ( 1 ) ) AS temp;

Actual Results:  
sql># integer x boolean works
sql>SELECT SUM( 10 * TRUE ) FROM ( values ( 1 ) ) AS temp;
+------+
| L3   |
+======+
|   10 |
+------+
1 tuple (11.546ms)
sql>
sql># double x boolean breaks
sql>SELECT SUM( 10.0 * TRUE ) FROM ( values ( 1 ) ) AS temp;
TypeException:user.s8_2[5]:'calc.sht' undefined in: _11:any := calc.sht(_10:bit,
 _12:int, _8:int)
TypeException:user.s8_2[7]:'sql.single' undefined in: _14:bat[:oid,:int] := sql.
single(_13:dbl)
program contains errors
sql>
sql># double x integer works
sql>SELECT SUM( 10.0 * CAST( TRUE AS INTEGER ) ) FROM ( values ( 1 ) ) AS temp;
+----------------------+
| L3                   |
+======================+
|                10.00 |
+----------------------+
1 tuple (0.435ms)
sql>

Expected Results:  
convert TRUE to CAST( TRUE AS INTEGER ) i guess?
Comment 1 Stefan Manegold cwiconfidential 2013-09-30 19:00:52 CEST
FYI:

While the reported case uses / missed a BOOLEAN to DECIMAL conversion,
also the BOOLEAN to REA/DOUBLE appears to be "missing" (assuming we want that at all):

sql>\f
Current formatter: sql

sql>\f raw

sql>\f
Current formatter: raw

sql>select 10;
% .L # table_name
% single_value # name
% tinyint # type
% 2 # length
[ 10	]

sql>select 10 * true;
% .L # table_name
% sql_mul_single_value # name
% smallint # type
% 2 # length
[ 10	]

sql>select 10.0;
% .L # table_name
% single_value # name
% decimal # type
% 5 # length
[ 10.0	]

sql>select 10.0 * true;
MAPI  = monetdb@localhost:50000
QUERY = select 10.0 * true;
ERROR = !TypeException:user.s19_1[5]:'calc.sht' undefined in: _10:any := calc.sht(_9:bit, _11:int, _7:int)
        !program contains errors

sql>select cast(10.0 as real);
% .L # table_name
% single_value # name
% real # type
% 15 # length
[ 10	]

sql>select cast(10.0 as real) * true;
MAPI  = monetdb@localhost:50000
QUERY = select cast(10.0 as real) * true;
ERROR = !TypeException:user.s21_1[5]:'calc.lng' undefined in: _10:any := calc.lng(_9:bit, _11:int, _8:int)
        !program contains errors

sql>select cast(10.0 as double);
% .L # table_name
% single_value # name
% double # type
% 24 # length
[ 10	]

sql>select cast(10.0 as double) * true;
MAPI  = monetdb@localhost:50000
QUERY = select cast(10.0 as double) * true;
ERROR = !TypeException:user.s23_1[5]:'calc.lng' undefined in: _10:any := calc.lng(_9:bit, _11:int, _8:int)
        !program contains errors
Comment 2 Anthony Damico 2016-04-29 07:57:38 CEST
*** Bug 3781 has been marked as a duplicate of this bug. ***