C Function causes backend to die in 7.4.3

From: Graeme Hinchliffe <graeme(dot)hinchliffe(at)zeninternet(dot)co(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: C Function causes backend to die in 7.4.3
Date: 2004-09-02 13:42:50
Message-ID: 1094132569.6790.23.camel@office-137.zen.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hiya,
I have written a C function for postgres. I developed and got this
function working on postgres 7.3.2, however the production system was
7.4.3.

On my initial dev setup it worked perfectly, however on the 7.4.3 it
caused the backend to terminate abnormaly!, I upgraded my dev system to
be the same version to ensure it wasn't just the production box, and
sure enough the function now also fails on my dev system!

I have commented out the entire function body looking for the cause of
the crash, and it seems that it is being cause by calling
PointerGetDatum() on the return. If I set return to NULL, then the
insert on the table doesn't cause a crash of the backend.

Any ideas? The C segment for my code on 7.4.3 which is crashing is as
follows:

extern Datum updatetrig(PG_FUNCTION_ARGS);

PG_FUNCTION_INFO_V1(updatetrig);

Datum updatetrig(PG_FUNCTION_ARGS)
{
TriggerData *trigdata = (TriggerData *) fcinfo->context;
char *name;
char *data; // Temporary string
char *ptr; // Temp string for building

char *sql; // The SQL statement to add the update row
char *id; // The id of the row the update is for
char *idfield; // The field name of the id column
char *table; // The name of the table being modified
char *action; // The action undertaken by the update
char *update; // The update SQL itself

int noatts=0; // Number of attributes
int len=0; // Length of string needed
int a=0;

HeapTuple rettuple;

// Commented out code is here

return PointerGetDatum(rettuple);
}

thanks for any help

--
-----
Graeme Hinchliffe (BSc)
Core Internet Systems Designer
Zen Internet (http://www.zen.co.uk/)

Direct: 0845 058 9074
Main : 0845 058 9000
Fax : 0845 058 9005

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-09-02 13:45:11 Re: plpgsql function
Previous Message Tom Lane 2004-09-02 13:39:33 Re: The future of built-in geometric data types