Re: [PATCH] by request: base64 for bytea

From: Alex Pilosov <alex(at)pilosoft(dot)com>
To: Marko Kreen <marko(at)l-t(dot)ee>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH] by request: base64 for bytea
Date: 2001-06-24 15:13:04
Message-ID: Pine.BSO.4.10.10106241108290.9446-100000@spider.pilosoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, 24 Jun 2001, Marko Kreen wrote:

> On Sat, Jun 23, 2001 at 10:46:46PM -0400, Tom Lane wrote:
> > Marko Kreen <marko(at)l-t(dot)ee> writes:
> > > Question to -hackers: currently there is not possible to cast
> > > bytea to text and vice-versa. Is this intentional or bug?
> >
> > Intentional. text and friends do not like embedded nulls.
> >
> > If there were a cast it would have to be one that implies
> > an I/O conversion, just like any other type that contains
> > non-textual data.
>
> Well, I have functions that should work on both - encode(),
> digest(), hmac(). Probably should do then several entries. Ok.
>
> But what should be return type of decrypt()? I imagine well
> situations where user wants to crypt both bytea and text data.
> When there is even not a way to cast them to each other, then
> he is stuck for no good reason.
There SHOULD be a text_bytea function to cast a text as bytea, as it is
always safe. (It doesn't exist yet, but its a trivial patch)

Function to cast bytea as text, I think, should do proper checking that
input did not contain nulls, and return text data back.

Your encrypt/decrypt should take bytea and return bytea. Its user's
responsibility to cast the things to bytea when needed.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2001-06-24 15:22:33 Re: [PATCH] by request: base64 for bytea
Previous Message Alex Pilosov 2001-06-24 15:08:01 RE: Extracting metadata about attributes from catalog