pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Nacos <m.nacos@gmail.com>
To: pgsql-jdbc@postgresql.org
Subject: real -> numeric -> real result different through jdbc
Date: Fri, 11 Dec 2009 16:05:04 +0000
Message-ID: <407fa4640912110805m67b2bdfr8e4ff703647b6f8b@mail.gmail.com> (raw)

Hi there,

the following function:

CREATE OR REPLACE FUNCTION test_reals(OUT r1 REAL, OUT r2 NUMERIC, OUT r3
NUMERIC, OUT r4 REAL, OUT r5 NUMERIC)
    RETURNS SETOF RECORD AS $$
    DECLARE
        temp REAL[5];
    BEGIN
        SELECT ARRAY[ '0.6'::real,
                      ('0.6'::real)::numeric(5,3),
                      round(('0.6'::real)::numeric(5,3), 3),
                      round(('0.6'::real)::numeric(5,3), 3)::real,
                      round(('0.6'::real)::numeric(5,3), 3)::numeric
]::real[]
        INTO temp;
        RAISE NOTICE 'temp: %', temp;
        r1 := temp[1]; r2 := temp[2]; r3 := temp[3]; r4 := temp[4]; r5 :=
temp[5];
        RETURN NEXT;
    END;
$$ LANGUAGE 'plpgsql';

called this way:

SELECT * FROM test_reals();

emits:

NOTICE:  temp: {0.6,0.6,0.6,0.6,0.6}  if called from psql/pgadmin

and

NOTICE:  temp: {0.60000002,0.60000002,0.60000002,0.60000002,0.60000002}  if
called through jdbc

what's the story here? how can the jdbc driver affect the precision of real
to numeric / numeric to real casts within PL/pgSQL functions?

we are using the 8.4-701-jdbc4 driver, connecting to a UTF8 database on a
8.4.1 PostgreSQL server

TIA,

Michael

view thread (4+ messages)  latest in thread

Message-ID: <407fa4640912110805m67b2bdfr8e4ff703647b6f8b@mail.gmail.com>
Permalink:  ../407fa4640912110805m67b2bdfr8e4ff703647b6f8b@mail.gmail.com/
Also on:    postgresql.org/message-id/407fa4640912110805m67b2bdfr8e4ff703647b6f8b@mail.gmail.com

 · 

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-jdbc@postgresql.org
  Cc: m.nacos@gmail.com
  Subject: Re: real -> numeric -> real result different through jdbc
  In-Reply-To: <407fa4640912110805m67b2bdfr8e4ff703647b6f8b@mail.gmail.com>
  References: <407fa4640912110805m67b2bdfr8e4ff703647b6f8b@mail.gmail.com>

* 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