C Function problems

From: Kent Scott <kscott(at)logicalsi(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: C Function problems
Date: 2010-01-30 22:35:50
Message-ID: 4B64B446.5030609@logicalsi.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I have trouble creating C functions especially when using some C native code

For example, the following code works:

#include "/usr/include/postgresql/8.4/server/postgres.h"
#include <stdlib.h>
#include <stdio.h>
#include "/usr/include/postgresql/8.4/server/fmgr.h"

#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif

PG_FUNCTION_INFO_V1(Create_Future_Records);

Datum Create_Future_Records(PG_FUNCTION_ARGS)
{

PG_RETURN_INT32(0);
}

However if I use the following code :

#include "/usr/include/postgresql/8.4/server/postgres.h"
#include <stdlib.h>
#include <stdio.h>
#include "/usr/include/postgresql/8.4/server/fmgr.h"

#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif

PG_FUNCTION_INFO_V1(Create_Future_Records);

Datum Create_Future_Records(PG_FUNCTION_ARGS)
{
char test[40];

PG_RETURN_INT32(0);
}

I get the following error when trying to create the function :

ERROR: could not find function "Create_Future_Records" in file
"/usr/lib/postgresql/8.4/lib/shared.so"

Here is the create function command used in both instances :

create function Create_Future_Records(text) RETURNS integer
as '/usr/lib/postgresql/8.4/lib/shared','Create_Future_Records'
LANGUAGE C STRICT;

I actually have some code that works but starts to have this same
problem when using things like system() or sprintf(); I have been back
tracking to see if I can find out why some things works and others do
not but do not understand this particular issue is a problem. Thanks in
advance.

K Scott

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Susan M Farley 2010-01-30 23:22:51 Error installing pljava
Previous Message Didier Gasser-Morlay 2010-01-30 22:20:54 Re: PpgSQL Autovacuum