From: | Aleksander Alekseev <aleksander(at)timescale(dot)com> |
---|---|
To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Cc: | Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Joel Jacobson <joel(at)compiler(dot)org>, David Fetter <david(at)fetter(dot)org> |
Subject: | Re: [PATCH] Add get_bytes() and set_bytes() functions |
Date: | 2024-08-16 08:41:37 |
Message-ID: | CAJ7c6TOfXAnAN3VnX2b0H3p8iy4msV3EawqLRdR=B9simkdzBg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
> When we add such casts between bytea and the integer/numeric types,
> one of the problems mentioned the first of the thread, that is,
> "we don't have a convenient way of casting a bytea to an integer / bigint
> and vice versa", would seem be resolved.
>
> On the other hand, I suppose get_bytes() and set_bytes() are still useful
> for extracting bytes from byteas, etc. If casting is no longer the main
> purpose of these functions, are variations that get_bytes returns bytea
> instead of bigint, and set_bytes receives bytea as the newvalue argument
> useful? I wonder it would eliminate the restrict that size cannot be larger
> than 8.
No, casting between bytea and numeric will not replace get_bytes() /
set_bytes() for performance reasons.
Consider the case when you want to extract an int4 from a bytea.
get_bytes() is going to be very fast while substr() -> ::numeric ->
::integer chain will require unnecessary copying and conversions.
Casting between bytea and numeric is only useful when one has to deal
with integers larger than 8 bytes. Whether this happens often is a
debatable question.
> Here are my very trivial comments on the patch.
>
> + * this routine treats "bytea" as an array of bytes.
>
> Maybe, the sentence should start with "This ... ".
>
> + while(size)
> + {
>
> I wonder inserting a space after "while" is the standard style.
Thanks, fixed.
--
Best regards,
Aleksander Alekseev
Attachment | Content-Type | Size |
---|---|---|
v2-0001-Add-get_bytes-and-set_bytes-functions.patch | application/octet-stream | 9.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Nishant Sharma | 2024-08-16 09:07:40 | [PROPOSAL] : Disallow use of empty column name in (column_name '') in ALTER or CREATE of foreign table. |
Previous Message | Richard Guo | 2024-08-16 08:14:41 | Re: Eager aggregation, take 3 |