Re: [PATCH] Add function to_oct
От
Nathan Bossart
Тема
Re: [PATCH] Add function to_oct
Дата
Msg-id
20230820152551.GB290672@nathanxps13
Ответ на
Re: [PATCH] Add function to_oct (Dean Rasheed)
Список
Дерево обсуждения
[PATCH] Add function to_oct Eric Radman <ericshane@eradman.com>
Re: [PATCH] Add function to_oct Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Re: [PATCH] Add function to_oct Kirk Wolak <wolakk@gmail.com>
Re: [PATCH] Add function to_oct Nathan Bossart <nathandbossart@gmail.com>
Re: [PATCH] Add function to_oct Nathan Bossart <nathandbossart@gmail.com>
Re: [PATCH] Add function to_oct Nathan Bossart <nathandbossart@gmail.com>
Re: [PATCH] Add function to_oct Nathan Bossart <nathandbossart@gmail.com>
Re: [PATCH] Add function to_oct Vik Fearing <vik@postgresfriends.org>
Re: [PATCH] Add function to_oct Nathan Bossart <nathandbossart@gmail.com>
Re: [PATCH] Add function to_oct John Naylor <john.naylor@enterprisedb.com>
Re: [PATCH] Add function to_oct Nathan Bossart <nathandbossart@gmail.com>
Re: [PATCH] Add function to_oct John Naylor <john.naylor@enterprisedb.com>
Re: [PATCH] Add function to_oct Nathan Bossart <nathandbossart@gmail.com>
Re: [PATCH] Add function to_oct John Naylor <john.naylor@enterprisedb.com>
Re: [PATCH] Add function to_oct Nathan Bossart <nathandbossart@gmail.com>
Re: [PATCH] Add function to_oct Dean Rasheed <dean.a.rasheed@gmail.com>
Re: [PATCH] Add function to_oct Nathan Bossart <nathandbossart@gmail.com>
Re: [PATCH] Add function to_oct Peter Eisentraut <peter@eisentraut.org>
Re: [PATCH] Add function to_oct Nathan Bossart <nathandbossart@gmail.com>
Re: [PATCH] Add function to_oct Peter Eisentraut <peter@eisentraut.org>
Re: [PATCH] Add function to_oct Nathan Bossart <nathandbossart@gmail.com>
Re: [PATCH] Add function to_oct Dean Rasheed <dean.a.rasheed@gmail.com>
Re: [PATCH] Add function to_oct Nathan Bossart <nathandbossart@gmail.com>
Re: [PATCH] Add function to_oct Dean Rasheed <dean.a.rasheed@gmail.com>
Re: [PATCH] Add function to_oct John Naylor <john.naylor@enterprisedb.com>
Re: [PATCH] Add function to_oct John Naylor <john.naylor@enterprisedb.com>
Re: [PATCH] Add function to_oct Nathan Bossart <nathandbossart@gmail.com>
Re: [PATCH] Add function to_oct Ian Lawrence Barwick <barwick@gmail.com>
Re: [PATCH] Add function to_oct Eric Radman <ericshane@eradman.com>
Re: [PATCH] Add function to_oct Ian Lawrence Barwick <barwick@gmail.com>
Re: [PATCH] Add function to_oct Dag Lem <dag@nimrod.no>
Re: [PATCH] Add function to_oct Eric Radman <ericshane@eradman.com>
Re: [PATCH] Add function to_oct vignesh C <vignesh21@gmail.com>
Re: [PATCH] Add function to_oct Tom Lane <tgl@sss.pgh.pa.us>
On Sat, Aug 19, 2023 at 08:35:46AM +0100, Dean Rasheed wrote: > I note that there are no tests for negative inputs. I added some in v8. > 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 Good catch. In v8, I fixed this by first casting the input to uint32 for the 32-bit versions of the functions. This prevents the conversion to uint64 from setting the rest of the bits. AFAICT this behavior is pretty well defined in the standard. > The way that negative inputs are handled really should be documented, > or at least it should include a couple of examples. I used your suggestion and noted that the output is the two's complement representation [0]. [0] https://postgr.es/m/CAEZATCVbkL1ynqpsKiTDpch34%3DSCr5nnau%3DnfNmiy2nM3SJHtw%40mail.gmail.com -- Nathan Bossart Amazon Web Services: https://aws.amazon.com
В списке pgsql-hackers по дате отправления
От: Tom Lane
Дата: