Re: BUG #12053: Strange behavior for numeric types with unspecified precision-scale

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tommaso Sala <tommaso(dot)sala(at)cla-it(dot)eu>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #12053: Strange behavior for numeric types with unspecified precision-scale
Date: 2014-11-27 20:48:33
Message-ID: 15613.1417121313@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Tommaso Sala <tommaso(dot)sala(at)cla-it(dot)eu> writes:
> We found that it is probably a bug in the data adapter (supplied by Devart
> http://www.devart.com/)

> But, once that weird value is written in DB by Devart adapter, there must
> be some kind of strange behavior also in Postgres.
> In fact, reading that value causes strange results:

> postgres=# select "WEIRD_FIELD" from "TABLE";
> WEIRD_FIELD
> ----------------
> 0.00
> (1 row)

> postgres=# select "WEIRD_FIELD" + 0.01 from "TABLE";
> ?column?
> ----------
> 0.01
> (1 row)

> postgres=# select "WEIRD_FIELD" * 2 from "TABLE";
> ?column?
> ----------
> 0.00
> (1 row)

> postgres=# select "WEIRD_FIELD" + 0.001 from "TABLE";
> ?column?
> ----------
> 0.002
> (1 row)

> postgres=# select 1 / "WEIRD_FIELD" from "TABLE";
> ?column?
> -----------------------
> 1000.0000000000000000
> (1 row)

> postgres=# select TO_CHAR("WEIRD_FIELD", 'FM99999999D99999999') from
> "TABLE";
> to_char
> ---------
> .001
> (1 row)

> It's always 0.001 but if selected or multiplicated it becomes 0.00.

That's pretty weird, but it's hard to debug without access to
Devart's adapter. Can you trace what the adapter is doing when
it inserts this value? (log_statement = all would help.)

An idea that comes to mind is that maybe Devart is using binary
parameters and transmitting a value that isn't 100% legal; but
that's only a guess at this stage. (It does look like numeric_recv
is pretty trusting about the input weight and dscale fields;
I'm not sure if a bad dscale would explain these symptoms, but
it seems possible.)

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message guettliml 2014-11-28 07:48:18 BUG #12086: docs: prewarm: When does prewarm happen?
Previous Message Tomas Vondra 2014-11-27 18:24:11 Re: [BUGS] BUG #12071: Stat collector went crasy (50MB/s constant writes)