Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Xu5zY-0007NH-Qm for pgsql-bugs@arkaria.postgresql.org; Thu, 27 Nov 2014 20:48:44 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Xu5zY-0004S4-Al for pgsql-bugs@arkaria.postgresql.org; Thu, 27 Nov 2014 20:48:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Xu5zX-0004QG-4d for pgsql-bugs@postgresql.org; Thu, 27 Nov 2014 20:48:43 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Xu5zS-0007Vv-Ck for pgsql-bugs@postgresql.org; Thu, 27 Nov 2014 20:48:42 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id sARKmXqh015614; Thu, 27 Nov 2014 15:48:34 -0500 From: Tom Lane To: Tommaso Sala cc: pgsql-bugs@postgresql.org Subject: Re: BUG #12053: Strange behavior for numeric types with unspecified precision-scale In-reply-to: References: <20141125111529.15508.34881@wrigleys.postgresql.org> <14914.1417017051@sss.pgh.pa.us> Comments: In-reply-to Tommaso Sala message dated "Thu, 27 Nov 2014 11:13:02 +0100" Date: Thu, 27 Nov 2014 15:48:33 -0500 Message-ID: <15613.1417121313@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Tommaso Sala 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