From: | <vivek(at)staff(dot)ownmail(dot)com> |
---|---|
To: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | Re: SPI_getvalue gives a core dump |
Date: | 2006-07-28 16:27:58 |
Message-ID: | 200607281627.k6SGRwtM029266@mail009.ownmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
This is what i set my tupdesc to. => tupdesc = trigdata->tg_relation->rd_att;
i am using the code like this. the do_log function to log the flow. it gives all correct until it reaches
the line :-
disposition=SPI_getvalue(trigdata->tg_trigtuple, tupdesc, 13);
do_log("Got disposition"); ======> it stops logging from here.
do_log("Entered the main trigger logic"); =========> success
if (TRIGGER_FIRED_BEFORE(trigdata->tg_event)) when = "before";
else when = "after ";
tupdesc = trigdata->tg_relation->rd_att;
if ((ret = SPI_connect()) < 0)
do_log("SPI_connect failed");
else {
sprintf(logs,"SPI_connect success, fired %s",when); ======> success
do_log(logs);
}
ret = SPI_exec("SELECT count(*) FROM ast_cdr", 0);
if (ret < 0){
sprintf(logs, "trigf (fired %s): SPI_exec returned %d", when, ret);
do_log(logs);
}
/* count(*) returns int8, so be careful to convert */
i = DatumGetInt64(SPI_getbinval(SPI_tuptable->vals[0], tupdesc, 1, &isnull));
sprintf(logs, "trigf (fired %s): there are %d rows in ast_cdr", when, i); ====> success
do_log(logs);
disposition=SPI_getvalue(trigdata->tg_trigtuple, tupdesc, 13); =====> failed.
do_log("Got disposition"); ===============> doesnot reach here.
With warm regards.
Vivek J. Joshi.
vivek(at)staff(dot)ownmail(dot)com
Trikon electronics Pvt. Ltd.
All science is either physics or stamp collecting.
-- Ernest Rutherford
Tom Lane wrote:
> ><vivek(at)staff(dot)ownmail(dot)com> writes:
>> I dont know where am i going wrong. Here is the source.
>
>> TriggerData *trigdata = (TriggerData *) fcinfo->context;
>> TupleDesc tupdesc;
>> if (CALLED_AS_TRIGGER(fcinfo)) { ==================== it comes here and
enters inside.
>> userfield=SPI_getvalue(trigdata->tg_trigtuple,tupdesc,17);
================== it fails here because i tried to get logs before this
statement and it succeeded.
>
>Wrong tupdesc maybe? You didn't show us what you are setting tupdesc
>to.
>
> regards, tom lane
>
>---------------------------(end of broadcast)---------------------------
>TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2006-07-28 16:38:27 | Re: SPI_getvalue gives a core dump |
Previous Message | Tom Lane | 2006-07-28 16:07:25 | Re: SPI_getvalue gives a core dump |