Skip site navigation (1) Skip section navigation (2)

Re: Bytea/Base64 encoders for libpq - interested?

From: "Joe Conway" <joseph(dot)conway(at)home(dot)com>
To: "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(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 04:55:23
Message-ID: 016101c134fd$ce757920$0705a8c0@jecw2k1 (view raw, whole thread or download thread mbox)
Lists: pgsql-hackerspgsql-patches
> > It might be nice to have a PQbyteaEscape or some such function available
> > the libpq client library so that arbitrary binary could be escaped on
> > client side and used in a sql statement. I actually wrote this already
as an
> > addition to the PHP PostgreSQL extension, but it would make more sense,
> > that I think about it, for it to be in libpq and called from PHP (or
> > whatever). Comments?
> Good idea.  I will commit the non-bytea escape in a day and you can base
> a bytea one on that.  You will have to pass in the length of the field
> because of course it is not null terminated.


> > On a related note, are there any other bytea functions we should have in
> > backend before freezing for 7.2? I was thinking it would be nice to have
> > way to cast bytea into text and vice-versa, so that the normal text
> > functions could be used for things like LIKE and concatenation. Any
> > in this? If so, any guidance WRT how it should be implemented?
> I can't see why you can't do that.  The only problem is passing a \0
> (null byte) back to the client.

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.

Any comments or concerns?

-- Joe

In response to


pgsql-hackers by date

Next:From: Bruce MomjianDate: 2001-09-04 05:00:49
Subject: Re: [PATCH] [LARGE] select * from cursor foo
Previous:From: Bruce MomjianDate: 2001-09-04 04:54:50
Subject: Re: Re: Toast,bytea, Text -blob all confusing

pgsql-patches by date

Next:From: Vsevolod LobkoDate: 2001-09-04 06:09:54
Subject: Re: Patch for pl/tcl Tcl_ExternalToUtf and Tcl_UtfToExternal
Previous:From: Barry LindDate: 2001-09-04 04:46:13
Subject: Re: Read transactions don't work on 7.0.x db's

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group