C Function causes backend to die in 7.4.3 - Mailing list pgsql-general

From Graeme Hinchliffe
Subject C Function causes backend to die in 7.4.3
Date
Msg-id 1094132569.6790.23.camel@office-137.zen.co.uk
Whole thread Raw
Responses Re: C Function causes backend to die in 7.4.3  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: plpgsql function
Next
From: Tom Lane
Date:
Subject: Re: zombie primary key lurches out of database to devour the brains of the unwary