Re: PostgresSQL 10 | Driver 42.2.5 | Float Conversion Issue

Поиск
Список
Период
Сортировка
От Vladimir Sitnikov
Тема Re: PostgresSQL 10 | Driver 42.2.5 | Float Conversion Issue
Дата
Msg-id CAB=Je-Fs8ZXMiubr1ByNb=EMcJOmreAyKXRS-SnErnqe6Jo6rQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: PostgresSQL 10 | Driver 42.2.5 | Float Conversion Issue  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-jdbc
TL;DR: pgjdbc 9.2-1001+ sends floats as binary by default which causes the conversion issue at the database side.
The workaround is to add binaryTransferDisable=700,701 driver connection property (the ids are for FLOAT4 and FLOAT4_ARRAY)

OP upgraded from 9.1-901 to 42.2.5 which explains the difference.

---

Vladimir> initial packet, then it upgrades to extra_float_digist=3 in case server
Vladimir> version is 9.0+
Tom>Hmm, but it's done that for a long while, no?'

And it happens to be exactly the version mentioned in the first mail.

It looks like the interesting change is as follows.
9.1-901 always used bindLiteral(parameterIndex, Float.toString(x), Oid.FLOAT8); if client uses setFloat(...) (which is exactly the call in the initial mail).
In other words, it sent the value as a string, and Java converts 1234567f as 1234567, so the value survived.
Don't ask me why the driver used FLOAT8 for sending float4 data :) I bet it was made to workaround precision loss issues like we see now.

9.2-1001 was released on 2012-10-31 and it introduced binary bind for certain primitives (see 
so the driver sends float4 as binary, and the database can't convert it to numeric anymore.

Vladimir

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: PostgresSQL 10 | Driver 42.2.5 | Float Conversion Issue
Следующее
От: Vladimir Sitnikov
Дата:
Сообщение: Re: PostgresSQL 10 | Driver 42.2.5 | Float Conversion Issue