Re: Non-decimal integer literals - Mailing list pgsql-hackers

From Dean Rasheed
Subject Re: Non-decimal integer literals
Date
Msg-id CAEZATCWBrJxCFpPf5vfpfP1-WR0PoLU8y8UMDMtyckNZ=r+M6w@mail.gmail.com
Whole thread Raw
In response to Re: Non-decimal integer literals  ("Joel Jacobson" <joel@compiler.org>)
List pgsql-hackers
On Mon, 23 Jan 2023 at 20:00, Joel Jacobson <joel@compiler.org> wrote:
>
> Nice! This also simplifies when dealing with non-negative integers represented as byte arrays,
> common in e.g. cryptography code.
>

Ah, interesting. I hadn't thought of that use-case.

> create function numeric_from_bytes(bytea) returns numeric language sql as $$
> select ('0'||right($1::text,-1))::numeric
> $$;
>
> Would we want a built-in function for this?

Not sure. It does feel a bit niche. It's quite common in other
programming languages, but that doesn't mean that a lot of Postgres
users need it. Perhaps start a new thread to gauge people's interest?

Regards,
Dean



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: run pgindent on a regular basis / scripted manner
Next
From: Nathan Bossart
Date:
Subject: Re: recovery modules