Re: more custom C function fun

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: more custom C function fun
Дата
Msg-id 20080506155944.GI19090@svana.org
обсуждение исходный текст
Ответ на Re: more custom C function fun  ("Dan \"Heron\" Myers" <heron@xnapid.com>)
Список pgsql-general
On Tue, May 06, 2008 at 09:39:50AM -0600, Dan Heron Myers wrote:
> Using DatumToCString(mytextvariable), I get single-character-length
> strings that do not match the data actually in the fields.

Correct, because it's not a cstring. Pretending it is one gives you
garbage.

> Using VARDATA(mytextvariable) as the char*, I get things like this (name
> obscured) (using strlen to get the string's length):

Not null terminated.

> Which is what I need.  Perhaps we could get some documentation about how
> to use this stuff?  I was unable to find any on the Postgres site, if
> there is any.

Well, here's an example of how you should do it:

http://www.postgresql.org/docs/8.2/interactive/spi-examples.html

Not the most obvious place. The best place is the source,
utils/adt/text contains lots of functions on text variables, so you can
see how they work.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

Вложения

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

Предыдущее
От: "Dan \"Heron\" Myers"
Дата:
Сообщение: Re: more custom C function fun
Следующее
От: "Kynn Jones"
Дата:
Сообщение: GROUP BY, ORDER & LIMIT ?