Re: Intervals and ISO 8601 duration

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Intervals and ISO 8601 duration
Date: 2023-01-14 06:01:00
Message-ID: CAFj8pRAo7riuO6L2jguET5BmiAh2ZQ5XE3Da9yPfLFs1yrQj0A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

so 14. 1. 2023 v 6:32 odesílatel Peter J. Holzer <hjp-pgsql(at)hjp(dot)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(at)hjp(dot)at | -- Charles Stross, "Creative writing
> __/ | http://www.hjp.at/ | challenge!"
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message jian he 2023-01-14 06:04:13 does refreshing materialized view make the database bloat?
Previous Message Peter J. Holzer 2023-01-14 05:50:33 Dump (was: Intervals and ISO 8601 duration)