Re: [PATCH] Add get_bytes() and set_bytes() functions

From: Aleksander Alekseev <aleksander(at)timescale(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Michael Paquier <michael(at)paquier(dot)xyz>
Subject: Re: [PATCH] Add get_bytes() and set_bytes() functions
Date: 2025-01-24 13:00:29
Message-ID: CAJ7c6TO_FQfXJOiaFC1rUHcCF==d1Le4GEBbFGaFUvMNV2FPtg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Dean,

> IMO big-endian is the most convenient byte-ordering to use here,
> because then the string representation of the bytea is consistent with
> the hex representation of the integer. It's also consistent with the
> integer-to-bit casts, which output the most significant bits first,
> starting with the sign bit.
>
> As far as the docs go, it's important to document precisely what
> format is used, but I don't think it needs to explain why that choice
> was made. It should also mention the size of the result and that it's
> the two's complement representation, since there are other possible
> representations of integers. So I think it would be sufficient for the
> initial paragraph to say something like "Casting an integer to a bytea
> produces 2, 4, or 8 bytes, depending on the width of the integer type.
> The result is the two's complement representation of the integer, with
> the most significant byte first.", and then list the examples to
> demonstrate that.

Thank you. Here is the corrected patch.

--
Best regards,
Aleksander Alekseev

Attachment Content-Type Size
v9-0001-Allow-casting-between-bytea-and-integer-types.patch application/x-patch 11.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Aleksander Alekseev 2025-01-24 13:15:19 Re: Quadratic planning time for ordered paths over partitioned tables
Previous Message Maxim Orlov 2025-01-24 12:56:46 Re: Casts from jsonb to other types should cope with json null