Re: [PATCH] Add get_bytes() and set_bytes() functions - Mailing list pgsql-hackers

From Dean Rasheed
Subject Re: [PATCH] Add get_bytes() and set_bytes() functions
Date
Msg-id CAEZATCWBSqV-4U8ppTYabUT=t1tc9wZPSEwAbm57PhJh1e2eaw@mail.gmail.com
Whole thread Raw
In response to Re: [PATCH] Add get_bytes() and set_bytes() functions  ("Joel Jacobson" <joel@compiler.org>)
Responses Re: [PATCH] Add get_bytes() and set_bytes() functions
List pgsql-hackers
On Thu, 15 Aug 2024 at 05:20, Joel Jacobson <joel@compiler.org> wrote:
>
> On Wed, Aug 14, 2024, at 19:25, Joel Jacobson wrote:
> > What do we want to happen if passing a numeric with decimal digits,
> > to decimal_to_bytes()? It must be an error, right?
> >
> > Example: SELECT decimal_to_bytes(1.23);
>
> Hmm, an error feels quite ugly on second thought.
> Would be nicer if all numerics could be represented,
>
> But then what about Inf,-Inf,NaN?
>

Perhaps we should also add casts between bytea and the integer/numeric
types. That might be easier to use than functions in some
circumstances.

When casting a numeric to an integer, the result is rounded to the
nearest integer, and NaN/Inf generate errors, so we should probably do
the same here.

Regards,
Dean



pgsql-hackers by date:

Previous
From: Junwang Zhao
Date:
Subject: Re: [Patch] remove duplicated smgrclose
Next
From: Aleksander Alekseev
Date:
Subject: Re: [PATCH] Add get_bytes() and set_bytes() functions