pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tommaso Sala <tommaso.sala@cla-it.eu>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #12053: Strange behavior for numeric types with unspecified precision-scale
Date: Thu, 27 Nov 2014 15:48:33 -0500
Message-ID: <15613.1417121313@sss.pgh.pa.us> (raw)
In-Reply-To: <CAPPt9DkAgK9MbLtLJB8B16N=5jyF4+-4jo9v2jqLudd5bwdPFQ@mail.gmail.com>
References: <20141125111529.15508.34881@wrigleys.postgresql.org>
	<14914.1417017051@sss.pgh.pa.us>
	<CAPPt9DkAgK9MbLtLJB8B16N=5jyF4+-4jo9v2jqLudd5bwdPFQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Tommaso Sala <tommaso.sala@cla-it.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


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (10+ messages)  latest in thread

Message-ID: <15613.1417121313@sss.pgh.pa.us>
Permalink:  ../15613.1417121313@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/15613.1417121313@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, tommaso.sala@cla-it.eu
  Subject: Re: BUG #12053: Strange behavior for numeric types with unspecified precision-scale
  In-Reply-To: <15613.1417121313@sss.pgh.pa.us>
  References: <20141125111529.15508.34881@wrigleys.postgresql.org> <14914.1417017051@sss.pgh.pa.us> <CAPPt9DkAgK9MbLtLJB8B16N=5jyF4+-4jo9v2jqLudd5bwdPFQ@mail.gmail.com> <15613.1417121313@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox