From: | Louis-David Mitterrand <cunctator(at)apartia(dot)ch> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: problem with float8 input format |
Date: | 2000-08-12 09:48:13 |
Message-ID: | 20000812114812.A6878@styx |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
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(at)apartia(dot)org - http://www.apartia.org
Conscience is what hurts when everything else feels so good.
From | Date | Subject | |
---|---|---|---|
Next Message | Louis-David Mitterrand | 2000-08-12 14:57:17 | solution! (was: Re: problem with float8 input format) |
Previous Message | Philip Warner | 2000-08-12 07:46:53 | Re: [HACKERS] Optimizer confusion? |
From | Date | Subject | |
---|---|---|---|
Next Message | Louis-David Mitterrand | 2000-08-12 14:57:17 | solution! (was: Re: problem with float8 input format) |
Previous Message | Philip Warner | 2000-08-12 07:46:53 | Re: [HACKERS] Optimizer confusion? |