From: | "Joel Jacobson" <joel(at)compiler(dot)org> |
---|---|
To: | "David Fetter" <david(at)fetter(dot)org> |
Cc: | "Aleksander Alekseev" <aleksander(at)timescale(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: [PATCH] Add get_bytes() and set_bytes() functions |
Date: | 2024-08-14 17:25:51 |
Message-ID: | 68f828ab-0dfa-49a6-8bf8-844de3552e7d@app.fastmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Aug 14, 2024, at 18:31, David Fetter wrote:
> On Wed, Aug 14, 2024 at 05:39:32PM +0200, Joel Jacobson wrote:
>> On Wed, Aug 14, 2024, at 16:43, David Fetter wrote:
>> >> I also think it would be nice to provide these convenience functions:
>> >> to_bytes(bigint) -> bytea
>> >> from_bytes(bytea) -> bigint
>> >
>> > Along with these, would it make sense to have other forms of these
>> > that won't choke at 63 bits, e.g. NUMERIC or TEXT?
>>
>> I wonder what would be good names for such functions though?
>
> decimal_to_bytes(numeric), decimal_to_bytes(text) on one side
> decimal_from_bytes(bytea, typeoid)
I assume decimal_to_bytes() will only accept integer numerics,
that is, that don't have a decimal digits part?
Hmm, it's perhaps then a bit counter intuitive that the name
contains "decimal", since some people might associate the word
"decimal" stronger with "decimal digits" rather than the radix/base 10.
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);
> Naming Things™ is one of the hard problems in computer science. Bad
> joke that includes cache coherency and off-by-one included by
> reference.
So true :)
> As usual, I see "official documentation lacks helpful and/or
> non-obvious examples" as a problem best approached by making good the
> lack. I am aware that my ideas about pedagogy, documentation, etc. are
> not shared universally, but they're widely shared by people whose main
> interaction with documents is trying to get help from them.
Well spoken.
Regards,
Joel
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2024-08-14 17:37:30 | Re: libpq: Fix lots of discrepancies in PQtrace |
Previous Message | Nathan Bossart | 2024-08-14 17:20:40 | Re: Remove dependence on integer wrapping |