Re: [PATCH] Add function to_oct

Dean Rasheed <dean.a.rasheed@gmail.com>

From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: Nathan Bossart <nathandbossart@gmail.com>
Cc: John Naylor <john.naylor@enterprisedb.com>, Kirk Wolak <wolakk@gmail.com>, Peter Eisentraut <peter.eisentraut@enterprisedb.com>, Eric Radman <ericshane@eradman.com>, pgsql-hackers@postgresql.org
Date: 2023-08-19T07:35:46Z
Lists: pgsql-hackers
On Thu, 17 Aug 2023 at 16:26, Nathan Bossart <nathandbossart@gmail.com> wrote:
>
> Works for me.  I did it that way in v7.
>

I note that there are no tests for negative inputs.

Doing a quick test, shows that this changes the current behaviour,
because all inputs are now treated as 64-bit:

HEAD:

select to_hex((-1234)::int);
  to_hex
----------
 fffffb2e

With patch:

select to_hex((-1234)::int);
      to_hex
------------------
 fffffffffffffb2e

The way that negative inputs are handled really should be documented,
or at least it should include a couple of examples.

Regards,
Dean



Commits

  1. Add to_bin() and to_oct().