Re: problem with float8 input format

Поиск
Список
Период
Сортировка
От Louis-David Mitterrand
Тема Re: problem with float8 input format
Дата
Msg-id 20000812114812.A6878@styx
обсуждение исходный текст
Ответ на Re: problem with float8 input format  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: problem with float8 input format  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Fri, Aug 11, 2000 at 08:35:03PM -0400, Tom Lane wrote:
> Although I don't see an obvious connection to the error message you are
> getting, I am suspicious that the problem happens because you are
> expecting CurrentTriggerData to stay valid throughout the execution of
> your trigger --- through executions of sub-queries, in fact.
>
> CurrentTriggerData is a global and should be considered extremely
> volatile, because it will get changed if any other trigger is fired
> by the sub-query, and may get zeroed anyway if certain paths through
> the function manager get taken.
>
> I recommend this coding pattern for user-defined triggers:
>
> 1. Copy CurrentTriggerData into a local variable, say
>     TriggerData    *trigdata;
> *immediately* upon entry to your trigger function, and then reset
> CurrentTriggerData = NULL before doing anything else.

I did just that and the error keeps happening.


On an unrelated matter I have this expression in the trigger:

    int stop_date = DatumGetInt32(SPI_getbinval(
                SPI_tuptable->vals[0],
                SPI_tuptable->tupdesc,
                SPI_fnumber(SPI_tuptable->tupdesc,"date_part"),
                &isnull));

where "date_part" comes from "date_part('epoch', stopdate)" in a
previous query. The problem is the value of stop_date is not the number
of seconds since the epoch but some internal representation of the data.
So I can't compare stop_date with the output of
GetCurrentAbsoluteTime().

What function should I use to convert the Datum to a C int?
DatumGetInt32 doesn't seem to work here.

And what is the method for float8 Datum conversion to C double? I
couldn't find any clearcut examples in the trigger examples.

Thanks in advance,

--
Louis-David Mitterrand - ldm@apartia.org - http://www.apartia.org

Conscience is what hurts when everything else feels so good.

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

Предыдущее
От: Philip Warner
Дата:
Сообщение: Re: [HACKERS] Optimizer confusion?
Следующее
От: Louis-David Mitterrand
Дата:
Сообщение: solution! (was: Re: problem with float8 input format)