Decimal values in

Поиск
Список
Период
Сортировка
От Masterprojekt Naumann1
Тема Decimal values in
Дата
Msg-id CANjJybTYZQ88i5JqKyF6KFbb7_4DLaZFPVLDiiEEhkupzo4U6Q@mail.gmail.com
обсуждение исходный текст
Ответы Re: Decimal values in  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Список pgsql-hackers
Dear Dev-List,

inside execProcnode.c's ExecProcNode method we want to extract the value of a tuple for a specific attribute. This works great for integers and strings, but we are not able to figure out how to do this for floating point numbers. Below is some example code snippet to show our problem:

TupleTableSlot *
ExecProcNode(PlanState *node) {
TupleTableSlot *result;
        ...
        bool isNull;
        Datum datum = slot_getattr(result,0, &isNull);

        Form_pg_attribute *attrList = result->tts_tupleDescriptor->attrs;

        if(attrList[0]->atttypid==INT4OID){
                int value = (int) (datum);
                ...
        } else if(attrList[0]->atttypid==VARCHAROID){
                char* value = TextDatumGetCString(datum);
                ...
        //this does not work :(
        } else if(attrList[0]->atttypid==<DECIMAL_OID> /*what is the right OID*/){
                //the value does not seem to be stored in the datum
                float value = (float) (datum);
                ...
        }
        ...
}

How can we get those values?

Yours sincerely, Fabian Tschirschnitz.

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: narwhal and PGDLLIMPORT
Следующее
От: Andres Freund
Дата:
Сообщение: Re: narwhal and PGDLLIMPORT