Re: The same prepared query yield "-1" the first six times and then "-1.0"

Поиск
Список
Период
Сортировка
От Dave Cramer
Тема Re: The same prepared query yield "-1" the first six times and then "-1.0"
Дата
Msg-id CADK3HH+7j80DH8BUuuavy+U4di23J8NFUnSZMO-A9jMCkcc_XQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: The same prepared query yield "-1" the first six times and then "-1.0"  (Ron <ronljohnsonjr@gmail.com>)
Ответы Re: The same prepared query yield "-1" the first six times and then "-1.0"
Список pgsql-general


On Mon, 21 Aug 2023 at 17:17, Ron <ronljohnsonjr@gmail.com> wrote:
On 8/21/23 14:32, Dave Cramer wrote:
[snip]
It has to do with the way the data is being transferred. When the driver switches to a named statement it also switches to binary mode which means data will be transferred in binary. 

In text we get -1, in binary we get -1.0

That seems odd.  Why does it do that?

If we look at float8out_internal (text output)  https://github.com/postgres/postgres/blob/6fde2d9a005a5bc04aa059d3faeb865c8dd322ce/src/backend/utils/adt/float.c#L536 and the comment about extra float digits which states 

If >0, use shortest-decimal format for output; this is both the default and
allows for compatibility with clients that explicitly set a value here to
get round-trip-accurate results. If 0 or less, then use the old, slow,
decimal rounding method.

-1 would be the shortest-decimal format. 

whereas float8send sends the actual binary data on disk, hence -1.0

Dave
--
Born in Arizona, moved to Babylonia.

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

Предыдущее
От: Ron
Дата:
Сообщение: Re: The same prepared query yield "-1" the first six times and then "-1.0"
Следующее
От: "Peter J. Holzer"
Дата:
Сообщение: Re: The same prepared query yield "-1" the first six times and then "-1.0"