Convert Datum* to char*

Поиск
Список
Период
Сортировка
От Masterprojekt Naumann1
Тема Convert Datum* to char*
Дата
Msg-id CANjJybQ=e60JjzY8x1_p6PEfMFnKNr2u9q5+gz33qmmig_e8Ww@mail.gmail.com
обсуждение исходный текст
Ответы Re: Convert Datum* to char*  (Heikki Linnakangas <hlinnakangas@vmware.com>)
Re: Convert Datum* to char*  (Craig Ringer <craig@2ndquadrant.com>)
Re: Convert Datum* to char*  (Thomas Fanghaenel <tfanghaenel@salesforce.com>)
Список pgsql-hackers
Hi,

I want to read an attribute value from a TupleTableSlot. When I try to convert an attribute of SQL type varchar from Datum* to char* with the help of the method TextDatumGetCString(...), sometimes there is a segmentation fault. The segmentation fault comes from the method TextDatumGetCString(...), which is defined in utils/builtins.h. Unfortunately, the fault is not always reproducible. I debugged the code and figured out that the value of result->tts_values[i] sometimes is random. It may be uninitialized memory. In other cases, the variable value is NULL. Then, I can just skip the conversion from Datum* to char*, so that there is no segmentation fault. I attached a patch with the code. The relevant line is:
char *value = TextDatumGetCString(result->tts_values[i]);
The SQL-Query is a simple "SELECT * from ..." on the TPC-H table customer. About every third execution leads to a segmentation fault.

Why is the memory of the variable uninitialized?
I am not very familiar with Postgres. Is there another method to get a varchar attribute out of a TupleTableSlot as string?

Best regards
Maria
Вложения

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

Предыдущее
От: Sandeep Thakkar
Дата:
Сообщение: Re: Compiling extensions on Windows
Следующее
От: Heikki Linnakangas
Дата:
Сообщение: Re: Convert Datum* to char*