From: vivek@staff.ownmail.com
To: pgsql-interfaces@postgresql.org
Subject: Re: SPI_getvalue gives a core dump
Date: Fri, 28 Jul 2006 21:57:58 +0530
Message-ID: <200607281627.k6SGRwtM029266@mail009.ownmail.com> (raw)
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@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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: vivek@staff.ownmail.com
Subject: Re: SPI_getvalue gives a core dump
In-Reply-To: <200607281627.k6SGRwtM029266@mail009.ownmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox