real -> numeric -> real result different through jdbc

Поиск
Список
Период
Сортировка
От Michael Nacos
Тема real -> numeric -> real result different through jdbc
Дата
Msg-id 407fa4640912110805m67b2bdfr8e4ff703647b6f8b@mail.gmail.com
обсуждение исходный текст
Ответы Re: real -> numeric -> real result different through jdbc  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Craig Ringer
Дата:
Сообщение: PATCH: Update LISTEN/NOTIFY documentation, PGConnection JavaDoc
Следующее
От: Tom Lane
Дата:
Сообщение: Re: real -> numeric -> real result different through jdbc