decimal & numeric report bug

Started by José Soaresover 26 years ago2 messages
#1José Soares
jose@sferacarta.com

DECIMA/NUMERCI Report bug:

CREATE TABLE Test (num DEC(7,2), flt8 FLOAT(15));
ERROR: Unable to locate type name 'dec' in catalog

The required syntax for DECIMAL is:
DEC[IMAL] [ ( precision [ ,scale ] ) ]

from SQL/92 draft:
<exact numeric type> ::=
NUMERIC [ <left paren> <precision> [ <comma> <scale> ]
<right pa
| DECIMAL [ <left paren> <precision> [ <comma> <scale> ]
<right pa
| DEC [ <left paren> <precision> [ <comma> <scale> ]
<right paren>

Remarks: DECIMAL can be abbreviated as DEC.

CREATE TABLE Test (num DECimal(7,2), flt8 FLOAT(15));
CREATE
INSERT INTO Test VALUES (1,1);
INSERT 207242 1
INSERT INTO Test VALUES (2.343,2.343);
INSERT 207243 1
INSERT INTO Test VALUES (-3.0,-3.0);
INSERT 207244 1
select * from test;
num| flt8
-----+-----
1.00| 1
2.34|2.343
-3.00| -3
(3 rows)

--numeric and decimal doesn't support arithmetic operations with
floats...

SELECT num-flt8 FROM Test;
ERROR: Unable to identify an operator '-' for types 'numeric' and
'float8'
You will have to retype this query using an explicit cast
SELECT num+flt8 FROM Test;
ERROR: Unable to identify an operator '+' for types 'numeric' and
'float8'
You will have to retype this query using an explicit cast
SELECT num*flt8 FROM Test;
ERROR: Unable to identify an operator '*' for types 'numeric' and
'float8'
You will have to retype this query using an explicit cast
SELECT num/flt8 FROM Test;
ERROR: Unable to identify an operator '/' for types 'numeric' and
'float8'
You will have to retype this query using an explicit cast
SELECT * FROM Test WHERE num < flt8;
ERROR: Unable to identify an operator '<' for types 'numeric' and
'float8'
You will have to retype this query using an explicit cast

--create operator doesn't know numeric/decimal type:

create operator < (
leftarg=numeric,
rightarg=float8,
procedure=dec_float8_lt
);
ERROR: parser: parse error at or near "numeric"
--
___________________________________________________________________
PostgreSQL 6.5.0 on i586-pc-linux-gnulibc1, compiled by gcc 2.7.2.1
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jose'

#2Thomas Lockhart
lockhart@alumni.caltech.edu
In reply to: José Soares (#1)
Re: [HACKERS] decimal & numeric report bug

Thanks for the report Jose'. Jan, can I help with this? A few of the
items could be fixed for v6.5.1, while others which touch system
tables should wait until v6.6...

- Thomas

--
Thomas Lockhart lockhart@alumni.caltech.edu
South Pasadena, California