Re: Weird problems with C extension and bytea as input type

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: Weird problems with C extension and bytea as input type
Дата
Msg-id AANLkTinJ0TW2oMOYqqzFWm=Y4fn5son2TxYN2b0wxFr9@mail.gmail.com
обсуждение исходный текст
Ответ на Weird problems with C extension and bytea as input type  (Adrian Schreyer <ams214@cam.ac.uk>)
Ответы Re: Weird problems with C extension and bytea as input type  (Adrian Schreyer <ams214@cam.ac.uk>)
Re: Weird problems with C extension and bytea as input type  (Adrian Schreyer <ams214@cam.ac.uk>)
Список pgsql-general
On Tue, Mar 22, 2011 at 8:22 AM, Adrian Schreyer <ams214@cam.ac.uk> wrote:
> Hi,
>
> I have a weird problem with my custom functions (written in C,C++)
> that use bytea as input type (cstring works fine). The functions will
> work as expected if they are the only function that uses the bytea
> column in a query; as soon as there is a second function using the
> same column, the C function will return one of the following: an empty
> cstring, a substring of the bytea or the correct cstring. Based on
> these symptoms I assume there is something fundamental that I do wrong
> (or that is missing) with handling the bytea pointer.
>
> In one specific example, the bytea contains a binary file format that
> the function converts into a string format. I convert the bytea to a
> C++ string with string(VARDATA(b), VARSIZE(b)-VARHDRSZ).
>
> bytea *b = PG_GETARG_BYTEA_P(0);
> char *ism;
>
> ism = function(b);
>
> PG_RETURN_CSTRING(ism);

your problem is probably inside 'function' -- are you properly copying
the data out of the bytea struct?.  also, are you really sure you want
to be returning cstring type, not text?

merlin

В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: share directory on windows
Следующее
От: Geoffrey Myers
Дата:
Сообщение: Re: error messages during restore