From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | ldm(at)apartia(dot)ch |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: problem with float8 input format |
Date: | 2000-08-12 00:35:03 |
Message-ID: | 18160.966040503@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
Louis-David Mitterrand <cunctator(at)apartia(dot)ch> writes:
>> May we see the C trigger? I'm suspicious it's doing something wrong...
> Please find the trigger attached to this message
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.
2. Subsequently, use "trigdata" not CurrentTriggerData.
Aside from not causing problems for recursive trigger calls, this
approach will also be a lot easier to convert to 7.1 code --- a word
to the wise eh?
If you still see flaky behavior after making this change, please let me
know and I'll probe more deeply.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | XWorkers | 2000-08-12 01:00:58 | turning of referential integrity |
Previous Message | Ian West | 2000-08-11 23:34:00 | Locking |
From | Date | Subject | |
---|---|---|---|
Next Message | Philip Warner | 2000-08-12 05:27:26 | Optimizer confusion? |
Previous Message | Tom Lane | 2000-08-12 00:17:45 | Re: Returning null from Userdefined C function |