Re: bytea internal encoding - Mailing list pgsql-general

From Ron Peterson
Subject Re: bytea internal encoding
Date
Msg-id 20041216140440.GB2250@mtholyoke.edu
Whole thread Raw
In response to Re: bytea internal encoding  (Michael Fuhr <mike@fuhr.org>)
Responses use pg_catalog for foreign key constraint  (Jonathan Hedstrom <jhedstrom@desc.org>)
List pgsql-general
On Wed, Dec 15, 2004 at 10:22:07PM -0700, Michael Fuhr wrote:
> On Wed, Dec 15, 2004 at 11:08:29PM -0500, Ron Peterson wrote:
>
> > How are bytea values encoded internally?
> >
> > Or maybe a better question would be what is the proper way to access
> > bytea data from within a C function?  Are there utility functions for
> > reading the bytea data as a stream of scalar values, for example?
>
> Do you mean a C function on the server side or on the client side?
>
> For examples of server-side code, take a look at functions in the
> PostgreSQL source that handle BYTEA, e.g., byteacat() in
> src/backend/utils/adt/varlena.c.  See also the comments concerning
> variable-length data and the relevant examples in the "C-Language
> Functions" section of the "Extending SQL" chapter in the documentation.

Thanks.

I was just looking at byteacat.  Because byteacat concatenates two bytea
arguments, it then seems safe enough to use memcpy in conjunction with
VARSIZE to move the data around (they're both the same type, so they'll
map one to one).

I guess maybe what I'm asking is whether or not it's safe to assume that
bytea data will always consist of a string of VARSIZE-VARHDRSZ eight bit
bytes, i.e. it's safe to assume 'byte' will always refer to 8 bit values
in the range 0..255.

--
Ron Peterson
Network & Systems Manager
Mount Holyoke College
http://www.mtholyoke.edu/~rpeterso

pgsql-general by date:

Previous
From: "Riccardo G. Facchini"
Date:
Subject: Re: Scheduler in Postgres
Next
From: Csaba Nagy
Date:
Subject: Re: Scheduler in Postgres