Re: SPI_getvalue gives a core dump - Mailing list pgsql-interfaces
From | |
---|---|
Subject | Re: SPI_getvalue gives a core dump |
Date | |
Msg-id | 200607281627.k6SGRwtM029266@mail009.ownmail.com Whole thread Raw |
In response to | SPI_getvalue gives a core dump (<vivek@staff.ownmail.com>) |
Responses |
Re: SPI_getvalue gives a core dump
(Tom Lane <tgl@sss.pgh.pa.us>)
|
List | 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"); ======> itstops 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): thereare %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@staff.ownmail.com Trikon electronics Pvt. Ltd. All science is either physics or stamp collecting. -- Ernest Rutherford Tom Lane wrote: > ><vivek@staff.ownmail.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
pgsql-interfaces by date: