Re: Non-decimal integer literals

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: Joel Jacobson <joel(at)compiler(dot)org>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Non-decimal integer literals
Date: 2023-01-23 21:20:45
Message-ID: CAEZATCWBrJxCFpPf5vfpfP1-WR0PoLU8y8UMDMtyckNZ=r+M6w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 23 Jan 2023 at 20:00, Joel Jacobson <joel(at)compiler(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2023-01-23 21:44:28 Re: recovery modules
Previous Message Bruce Momjian 2023-01-23 21:11:50 Re: run pgindent on a regular basis / scripted manner