Re: Intervals and ISO 8601 duration - Mailing list pgsql-general

From Pavel Stehule
Subject Re: Intervals and ISO 8601 duration
Date
Msg-id CAFj8pRAo7riuO6L2jguET5BmiAh2ZQ5XE3Da9yPfLFs1yrQj0A@mail.gmail.com
Whole thread Raw
In response to Re: Intervals and ISO 8601 duration  ("Peter J. Holzer" <hjp-pgsql@hjp.at>)
List pgsql-general


so 14. 1. 2023 v 6:32 odesílatel Peter J. Holzer <hjp-pgsql@hjp.at> napsal:
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?

orafce has this function https://github.com/orafce/orafce

Regards

Pavel
 

        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 by date:

Previous
From: "Peter J. Holzer"
Date:
Subject: Dump (was: Intervals and ISO 8601 duration)
Next
From: jian he
Date:
Subject: does refreshing materialized view make the database bloat?