real -> numeric -> real result different through jdbc

From: Michael Nacos <m(dot)nacos(at)gmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: real -> numeric -> real result different through jdbc
Date: 2009-12-11 16:05:04
Message-ID: 407fa4640912110805m67b2bdfr8e4ff703647b6f8b@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

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

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Tom Lane 2009-12-11 16:29:23 Re: real -> numeric -> real result different through jdbc
Previous Message Craig Ringer 2009-12-11 15:52:42 PATCH: Update LISTEN/NOTIFY documentation, PGConnection JavaDoc