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