Small bug with numeric in 7.0 (also in 6.5.3)

From: Denis Sbragion <sbragion(at)email(dot)com>
To: bugs(at)postgresql(dot)org
Subject: Small bug with numeric in 7.0 (also in 6.5.3)
Date: 2000-05-11 10:24:27
Message-ID: 4.3.1.20000511120146.00dc8aa0@pop3.InfoTecna.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello,

look at this:

pgsql=# \d aocc
Table "aocc"
Attribute | Type | Modifier
------------------+---------------+----------
nordine | integer | not null
anno | integer | not null
cliente | varchar(50) | not null
data_ordine | date | not null
rif_cliente | varchar(50) |
controvalore_ord | numeric(18,4) |
note | varchar(150) |
Indices: aocc_anno_idx,
aocc_pkey
Constraints: (anno > 1900)
(length(cliente) > 0)

pgsql=# UPDATE aocc SET controvalore_ord = 320.5 WHERE controvalore_ord = 320.5
00 AND oid = 21624;
ERROR: Unable to identify an operator '=' for types 'numeric' and 'float8'
You will have to retype this query using an explicit cast

This kind of weird query are generated by MS Query through the ODBC driver.
Furthermore I tried:

pgsql=# UPDATE aocc SET controvalore_ord = 320.5 WHERE controvalore_ord =
320.5::numeric(18,4) AND oid = 21624;
UPDATE 1
pgsql=# UPDATE aocc SET controvalore_ord = 320.5 WHERE controvalore_ord =
320.5::numeric(17,3) AND oid = 21624;
UPDATE 1
pgsql=# UPDATE aocc SET controvalore_ord = 320.5 WHERE
float8(controvalore_ord)= 320.5 AND oid = 21624;
UPDATE 1
pgsql=# UPDATE aocc SET controvalore_ord = 320.5 WHERE controvalore_ord =
'320.5' AND oid = 21624;
UPDATE 1
pgsql=# UPDATE aocc SET controvalore_ord = 320.5 WHERE controvalore_ord =
numeric(320.5) AND oid = 21624;
ERROR: parser: parse error at or near "320.5"
pgsql=# UPDATE aocc SET controvalore_ord = 320.5 WHERE controvalore_ord =
numeric(320.5,4) AND oid = 21624;
ERROR: parser: parse error at or near "320.5"

I don't know which of these queries is correct and which is wrong, anyway I
hope this could help you track the problem. It looks like there's an
automatic conversion from char to numeric, from numeric to numeric with
different precision, but not from floatX to numeric. Also the 'numeric'
function with float arguments is in the list reported by '\df numeric', but
looks like it isn't used. May be it simply shouldn't be used like i did in
the previous queries.

Bye!

P.S. My compliments for your all *great* work.
--
Denis Sbragion
InfoTecna
Tel, Fax: +39 039 2324054
URL: http://infotecna.home.dhs.org

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2000-05-11 15:12:59 Re: Number of tuples in pg_class - bug or misunderstanding?
Previous Message Martin Neumann 2000-05-11 08:04:07 Number of tuples in pg_class - bug or misunderstanding?