Re: Bytea/Base64 encoders for libpq - interested?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Joe Conway" <joseph(dot)conway(at)home(dot)com>
Cc: "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>, "Karel Zak" <zakkr(at)zf(dot)jcu(dot)cz>, "Joerg Hessdoerfer" <Joerg(dot)Hessdoerfer(at)sea-gmbh(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bytea/Base64 encoders for libpq - interested?
Date: 2001-09-04 13:50:49
Message-ID: 26073.999611449@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

"Joe Conway" <joseph(dot)conway(at)home(dot)com> writes:
> Well, ISTM the simplest (if not the most efficient) way to do bytea-to-text
> would be a function that takes the escaped string value from byteaout, and
> creates a text value directly from it. The only danger I can think of is
> that very long strings might need to be truncated in length, since the
> escaped string could be significantly longer than the binary.

> Text-to-bytea should be a straight copy, since nothing that can be
> represented as text cannot be represented as bytea.

Ugh ... if the conversion functions are not inverses then I think they
lose much of their value. I could see doing either of these:

1. Conversion functions based on byteaout/byteain.

2. Bytea to text escapes *only* null bytes, text to bytea treats only
"\0" as an escape sequence.

Or maybe both, with two pairs of conversion functions.

In any case, we have to decide whether these coercion functions should
be named after the types --- ie, should they be made invokable as
implicit coercions? I'm dubious that that's a good idea; if we do it
then all sorts of textual operations will suddenly be allowed for bytea
without any explicit conversion, which is likely to do more harm than
good. The reason for having a separate bytea type is exactly so that
you *can't* apply text ops to it without thinking.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dave Cramer 2001-09-04 13:54:27 Re: Troubles using German Umlauts with JDBC
Previous Message Karel Zak 2001-09-04 13:42:02 Re: [PATCHES] to_char and Roman Numeral (RN) bug

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2001-09-04 14:48:19 Re: multiple inserts
Previous Message Karel Zak 2001-09-04 13:42:02 Re: [PATCHES] to_char and Roman Numeral (RN) bug