decimal & numeric report bug

From: José Soares <jose(at)sferacarta(dot)com>
To: hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: decimal & numeric report bug
Date: 1999-06-16 13:37:17
Message-ID: 3767A88D.A06E9097@sferacarta.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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'

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message José Soares 1999-06-16 13:54:44 having bug report
Previous Message Gene Sokolov 1999-06-16 13:27:00 Re: [HACKERS] 6.5.0 - Overflow bug in AVG( )