Re: C Programming with postgres.h - my function crashes the database backend

Поиск
Список
Период
Сортировка
Искать
От
Alvaro Herrera
Тема
Re: C Programming with postgres.h - my function crashes the database backend
Дата
Msg-id
20031202181613.GF2386@dcc.uchile.cl
Ответ на
Список
Дерево обсуждения
C Programming with postgres.h - my function crashes the database backend Alex Page <alex.page@cancer.org.uk>
Re: C Programming with postgres.h - my function crashes the database backend Alvaro Herrera <alvherre@dcc.uchile.cl>
Re: C Programming with postgres.h - my function crashes Jan Wieck <JanWieck@Yahoo.com>
Re: C Programming with postgres.h - my function crashes Alex Page <alex.page@cancer.org.uk>
Re: C Programming with postgres.h - my function crashes Jan Wieck <JanWieck@Yahoo.com>
Re: C Programming with postgres.h - my function crashes Teodor Sigaev <teodor@sigaev.ru>
On Tue, Dec 02, 2003 at 05:56:45PM +0000, Alex Page wrote:

>   Datum enum_gender_in(PG_FUNCTION_ARGS) {
>   	text	*invalue = PG_GETARG_TEXT_P(0);
>   
>   	if ( strcmp ( VARDATA(invalue), "Male" ) ) {		/* VARDATA gets the data portion of a "varlena" struct, which is typedef'd to "text" */
>   		PG_RETURN_INT32( 0 );
>   	}
>   	PG_RETURN_INT32( 1 );
>   }

VARDATA is not 0-terminated, so you can't use strcmp on it.  Maybe you
should use memcmp instead.

-- 
Alvaro Herrera ()
"Nunca se desea ardientemente lo que solo se desea por razón" (F. Alexandre)
В списке pgsql-general по дате отправления
От: Alex Page
Дата:
От: Marc A. Leith
Дата:
Сообщение: Re: language war
FAQ