Re: Missing magic block

From: Mario Munda <mario(dot)munda(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Missing magic block
Date: 2007-05-10 20:00:33
Message-ID: 1178827233.440481.189560@y80g2000hsf.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


"Brad Buran" je napisal:
> Hi Martijn,
>
> Thank you very much for the suggestion:
>
> > > CREATE FUNCTION add_one(IN int)
> > > RETURNS int
> > > AS 'add_one'
> > > LANGUAGE C;
>
> I corrected this to say:
>
> AS 'Project1', 'add_one'
>
> And restarted psql (rebooted for that matter as well) and am still getting
> the same error.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings

The same problem with me.

-- test_func.c

#include <postgres.h>
//#include <executor/spi.h>
//#include <commands/trigger.h>
#include <fmgr.h>
//#include <access/heapam.h>
#include <utils/syscache.h>
#include <catalog/pg_proc.h>
#include <catalog/pg_type.h>
#include "pgmagic.h"

PG_FUNCTION_INFO_V1(plsample_call_handler);

Datum plsample_call_handler(PG_FUNCTION_ARGS)
{
Datum retval;

// retval = ...

return retval;
}

I had to comment some includes out, or else i get some errors.

-- pgmagic.h

#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif

-- this is my makefile

all: gen_code.c
g++ -fpic -I/usr/local/include -I/usr/local/include/postgresql/
server/ -c test_func.c
g++ -shared -o test_func.so test_func.o

This is what psql returns (phppgadmin):

SQL error:

ERROR: incompatible library "/home/mario/tests/psql_c_func/
test_func.so": missing magic block
HINT: Extension libraries are required to use the PG_MODULE_MAGIC
macro.

In statement:
CREATE FUNCTION "plsample_call_handler" () RETURNS void AS '/home/
mario/tests/psql_c_func/test_func.so','plsample_call_handler' LANGUAGE
"C"

I have allready lost four hours for this. What is the problem??

P.S.:
select version() returns:

PostgreSQL 8.2.0 on i386-unknown-freebsd6.1, compiled by GCC gcc (GCC)
3.4.4 [FreeBSD] 20050518

Thanks in advance.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Leif B. Kristensen 2007-05-10 20:51:33 Re: Views- Advantages and Disadvantages
Previous Message John D. Burger 2007-05-10 19:56:14 Re: Pattern Matching - Range of Letters