Hi,
> > Or providing
> > 'uuid_encode(uuid, format text) -> text' and 'uuid_decode(text, format
> > text) -> uuid' might make sense too, but I'm not sure.
>
> I like the idea, so I drafted a prototype for discussion.
> Though I do not see what else methods should be provided along with added 
> one...

I see no reason why we should forbid the use of base32 encoding with
bytea. Or have different functions for this e.g. uuid_encode() and
encode(). To me it looks like a poor API design.

-- 
Best regards,
Aleksander Alekseev

____________________________________________

It seems that bytea is your personal interest, since you continue to impose 
your bytea when a better solution has already been found with uuid_encode() and 
uuid_decode().


The bytea proposal has a lot of drawbacks:

1. It requires unnecessary casting in addition to encoding/decoding. This 
complicates the interface and creates unnecessary cognitive load on developers. 
It also creates additional CPU load, although perhaps only a small amount.

2. The encoding function encourages developers to use the slightly more compact 
base64 encoding (see 
https://www.postgresql.org/docs/current/functions-binarystring.html), which 
doesn't preserve sort order, isn't URL-safe, is case-sensitive, and requires 
specifying the case of letters when dictating. This also creates a serious 
problem of incompatibility between UUID encodings.

3. The hashing functions used by bytea create a temptation to implement 
popular, idiotic ideas for hashing UUIDs to obscure their creation date and to 
hide internal keys from clients.

4. Other various functions for bytea allow the construction of Frankenstein 
identifiers that compete with UUIDv7, which could negatively impact the 
reputation of UUIDs.

The bytea type has nothing in common with the uuid type other than the binary 
encoding. Therefore, the bytea <-> uuid cast can only encourage abuse and 
errors, creating the illusion of unlimited developer power.


The bytea proposal has no merit whatsoever. It's the worst, most insafe, and 
most harmful design, undermining efforts to widely adopt UUIDv7 and improve 
PostgreSQL.



  

Reply via email to