Re: [PATCH] Add crc32(text) & crc32(bytea)

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: Aleksander Alekseev <aleksander(at)timescale(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] Add crc32(text) & crc32(bytea)
Date: 2024-08-08 14:35:33
Message-ID: ZrTXtaEvAwnx7ap4@nathan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Aug 08, 2024 at 04:27:20PM +0200, Peter Eisentraut wrote:
> On 05.08.24 17:28, Nathan Bossart wrote:
>> This looks pretty good to me. The only point that I think deserves more
>> discussion is the return type. Does bytea make the most sense here? Or
>> should we consider int/bigint?
>
> The correct return type of a CRC operation in general is some kind of exact
> numerical type. Just pick the best one that fits the result. I don't think
> bytea is appropriate.

That would leave us either "integer" or "bigint". "integer" is more
correct from a size perspective, but will result in negative values because
it is signed. "bigint" uses twice as many bytes but won't display any CRC
values as negative.

I guess we could also choose "numeric", which would set a more sustainable
precedent if we added functions for CRC-64...

--
nathan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-08-08 14:49:42 Re: [PATCH] Add crc32(text) & crc32(bytea)
Previous Message Peter Eisentraut 2024-08-08 14:27:20 Re: [PATCH] Add crc32(text) & crc32(bytea)