Re: bytea internal encoding

Поиск
Список
Период
Сортировка
От Ron Peterson
Тема Re: bytea internal encoding
Дата
Msg-id 20041216140440.GB2250@mtholyoke.edu
обсуждение исходный текст
Ответ на Re: bytea internal encoding  (Michael Fuhr <mike@fuhr.org>)
Ответы use pg_catalog for foreign key constraint
Список 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 по дате отправления:

Предыдущее
От: "Riccardo G. Facchini"
Дата:
Сообщение: Re: Scheduler in Postgres
Следующее
От: Csaba Nagy
Дата:
Сообщение: Re: Scheduler in Postgres