Re: [PATCH] by request: base64 for bytea - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [PATCH] by request: base64 for bytea
Date
Msg-id 10645.993396153@sss.pgh.pa.us
Whole thread Raw
In response to [PATCH] by request: base64 for bytea  (Alex Pilosov <alex@pilosoft.com>)
Responses Re: [PATCH] by request: base64 for bytea  (Bruce Momjian <pgman@candle.pha.pa.us>)
Re: [PATCH] by request: base64 for bytea  (Alex Pilosov <alex@pilosoft.com>)
List pgsql-hackers
Alex Pilosov <alex@pilosoft.com> writes:
> Function to cast bytea as text, I think, should do proper checking that
> input did not contain nulls, and return text data back.

That is most definitely not good enough.  In MULTIBYTE installations
you'd have to also check that there were no illegal multibyte sequences.

The whole approach seems misguided to me anyway.  bytea isn't equivalent
to text and conversion functions based on providing incomplete binary
equivalence are fundamentally wrong.  hex or base64 encode/decode
functions seem like reasonable conversion paths, or you could provide
a function that mimics the existing I/O conversions for bytea, ugly as
they are.

In the case that Marko is describing, it seems to me he is providing
two independent sets of encryption functions, one for text and one
for bytea.  That they happen to share code under the hood is an
implementation detail of his code, not a reason to contort the type
system.  If someone wanted to add functions to encrypt, say, polygons,
would you start looking for ways to create a binary equivalence between
polygon and text?  I sure hope not.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: stuck spin lock with many concurrent users
Next
From: Alex Pilosov
Date:
Subject: Re: [PATCH] by request: base64 for bytea