Re: Intervals and ISO 8601 duration

Поиск
Список
Период
Сортировка
От Peter J. Holzer
Тема Re: Intervals and ISO 8601 duration
Дата
Msg-id 20230114053203.ljgnrjcbxah7p3mi@hjp.at
обсуждение исходный текст
Ответ на Re: Intervals and ISO 8601 duration  ("Martin L. Buchanan" <martinlbuchanan@gmail.com>)
Ответы Dump (was: Intervals and ISO 8601 duration)  ("Peter J. Holzer" <hjp-pgsql@hjp.at>)
Re: Intervals and ISO 8601 duration  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-general
On 2023-01-13 17:07:17 -0700, Martin L. Buchanan wrote:
> Just tried casting interval to bytea to see the binary layout, but that direct
> cast is not allowed.

A cast generally doesn't just reinterpret the same bit pattern as a
different type, it converts the value.

For example, in C (to choose a language "closer to the metal" than
SQL), «int a = 3; float f = (float)a;» assigns 3.0 to f, not 4.2E-45
(which would be 0x0000_0003 interpreted as an IEEE-754 single precision
FP value).

So there's no guarantee that a cast to bytea would have done what you
expected even if it existed.

Oracle has a function which returns the internal representation of a
value as a series of (decimal) byte values. Back in the days when I was
new to Oracle I used this to figure out how Oracle stores NUMBER, but
now I've forgotten the name of the function. Maybe adding something like
this to PostgreSQL would be worthwhile?

        hp

--
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Вложения

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: synchronized standby: committed local and waiting for remote ack
Следующее
От: "Peter J. Holzer"
Дата:
Сообщение: Dump (was: Intervals and ISO 8601 duration)