Getting char * from timestamp in a composite type

Поиск
Список
Период
Сортировка
От Michael Akinde
Тема Getting char * from timestamp in a composite type
Дата
Msg-id 47693B76.2080105@met.no
обсуждение исходный текст
Ответы Re: Getting char * from timestamp in a composite type
Список pgsql-general
Hi,

I need to extract a text string representation of a timestamp from a
user-defined row type; e.g., from the composite type ('1980-01-01
12:00:00', 'Random Comment'), I'd like to extract the C string
1980-01-01 12:00:00 in my user-defined C function.

As I understand it, I should be able to do something like (assuming
"time" is the attribute name):

    bool isNull;
    HeapTupleHeader t = DatumGetHeapTupleHeader(row);
    Datum var = GetAttributeByName( row, "time", & isNull );
    // Check for null
    char * ret = DatumGetCString( DirectFunctionCall1(textout, var ) );

However, the code above (and every other variant I've tried) invariable
segmentation faults the postmaster. so obviously I am doing something
wrong. Can someone explain (or point to an example that works) of how to
do this?

Regards,

Michael A.

Вложения

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Password as a command line argument to createuser
Следующее
От: Erik Jones
Дата:
Сообщение: Re: thank you