LOAD not updating object in session - Mailing list pgsql-bugs

From Graeme Hinchliffe
Subject LOAD not updating object in session
Date
Msg-id 1092757738.1636.164.camel@office-137.zen.co.uk
Whole thread Raw
Responses Re: LOAD not updating object in session  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Hiya
    I have written a trigger in C, and during the course of this I
discovered that the LOAD command in psql wasn't updating the object when
I made a change and recompiled.

    As requested by Tom, here is an example of this behaviour.  I have just
added this as a function as it performs the same.

here is my code:

--START--
#include "postgres.h"
#include "executor/spi.h"       /* this is what you need to work with
SPI */
#include "commands/trigger.h"   /* ... and triggers */

#include <stdio.h>

int main (int argc, char **argv)
{
    printf ("This is a trigger for PostgreSQL, not a standard
executable\n\n");

    return 0;
}

extern Datum trigf(PG_FUNCTION_ARGS);

PG_FUNCTION_INFO_V1(trigf);

Datum testtrig(PG_FUNCTION_ARGS)
{
  TriggerData *trigdata = (TriggerData *) fcinfo->context;

  elog(INFO,"This is a test trigger");

  //elog(INFO,"Uncomment me and recompile for new message");

return PointerGetDatum(NULL);
}
--END--

I have compiled and linked this with the lines:

gcc -g -c test_trigger.c  -I/usr/include/pgsql/server
gcc -o testtrigger test_trigger.o  --share

without errors.

to create the function I used:

create or replace function testtrig() RETURNS trigger AS
'/home/graeme/dev/radius-centraldb/testtrigger' LANGUAGE C;


Now when I "select testtrig();"  I get :

INFO:  This is a test trigger
ERROR:  Cannot display a value of type TRIGGER

If I uncomment out the 2nd elog line and recompile and then use

LOAD '/home/graeme/dev/radius-centraldb/testtrigger';

Again running "select testtrig()" I get :

INFO:  This is a test trigger
ERROR:  Cannot display a value of type TRIGGER

So the new Object hasn't been loaded (I know about the Error on the end,
this is just a quick test).

If I quit out of psql and reconned, and then run "select testtrig()" I
now get:

INFO:  This is a test trigger
INFO:  Uncomment me and recompile for new message
ERROR:  Cannot display a value of type TRIGGER


So as you can see it doesn't appear to be refreshing the C object when I
use LOAD.  I also noticed during writing the C for this example that if
I created the function with the wrong name I got an error saying that
that function could not be found in the object as is expected, if I then
renamed the function and recompiled the object, the create would give
the same error (obviously using the already linked object).  Load didn't
fix this either.

So am I doing something wrong? or have I found something?

Thanks for your help/time

--
-----
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-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #1220: "alter table rename to" inside a transaction violates ACID ordering
Next
From: Tom Lane
Date:
Subject: Re: LOAD not updating object in session