From: | "Peter J(dot) Holzer" <hjp-pgsql(at)hjp(dot)at> |
---|---|
To: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: Intervals and ISO 8601 duration |
Date: | 2023-01-14 05:32:03 |
Message-ID: | 20230114053203.ljgnrjcbxah7p3mi@hjp.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)hjp(dot)at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
From | Date | Subject | |
---|---|---|---|
Next Message | Peter J. Holzer | 2023-01-14 05:50:33 | Dump (was: Intervals and ISO 8601 duration) |
Previous Message | Tom Lane | 2023-01-14 05:31:28 | Re: synchronized standby: committed local and waiting for remote ack |