Thread: Missing block Magic

Missing block Magic

From
Alejandro Carrillo
Date:
Hi,

I want to make a function in C for postgresql, this is the code:

#define _USE_32BIT_TIME_T
#define BUILDING_DLL 1

#include "postgres.h"
#include "fmgr.h"
#include "executor\spi.h" /* SPI - Server Programming Interface */

#if defined(_MSC_VER) || defined(__MINGW32__)
#define PG_GETINF_EXPORT __declspec (dllexport)
#else
#define PG_GETINF_EXPORT
#endif

PG_MODULE_MAGIC;

PG_GETINF_EXPORT PG_FUNCTION_INFO_V1(suma);

Datum suma(PG_FUNCTION_ARGS)
{
int32 arg = PG_GETARG_INT32(0);
  
PG_RETURN_INT32(arg + 1);
};

This compile sucessfull, but when I try to use:

CREATE OR REPLACE FUNCTION add_one(integer)
RETURNS integer AS
'C:\Documents and Settings\Administrador\Escritorio\test\test.dll', 'pg_finfo_suma'
LANGUAGE 'c' VOLATILE STRICT
COST 1;

I get it:

ERROR:  biblioteca «C:\Documents and Settings\Administrador\Escritorio\test\test.dll» incompatible: no se encuentra el bloque mágico
HINT:  Se requiere que las bibliotecas de extensión usen la macro PG_MODULE_MAGIC.

Please help me! I don't know to do.

Thanks

Re: Missing block Magic

From
Tom Lane
Date:
Alejandro Carrillo <fasterzip@yahoo.es> writes:
> ERROR:� biblioteca �C:\Documents and Settings\Administrador\Escritorio\test\test.dll� incompatible: no se encuentra
elbloque m�gico 
> HINT:� Se requiere que las bibliotecas de extensi�n usen la macro PG_MODULE_MAGIC.

[ scratches head ... ]  Your source code looks fine.  Are you sure you
are pointing to the right copy of the .dll file?

If you added the PG_MODULE_MAGIC; line after getting this error, it's
likely that the old version of the .dll is already loaded into the
server's memory, in which case what you need to do to get rid of it
is to restart the server, or at least start a fresh session.

            regards, tom lane

Re: Missing block Magic

From
Alejandro Carrillo
Date:
I restart and doesn't work. :(
Please help me!


De: Tom Lane <tgl@sss.pgh.pa.us>
Para: Alejandro Carrillo <fasterzip@yahoo.es>
CC: "pgsql-performance@postgresql.org" <pgsql-performance@postgresql.org>
Enviado: Martes 5 de junio de 2012 12:00
Asunto: Re: [PERFORM] Missing block Magic

Alejandro Carrillo <fasterzip@yahoo.es> writes:
> ERROR:  biblioteca «C:\Documents and Settings\Administrador\Escritorio\test\test.dll» incompatible: no se encuentra el bloque mágico
> HINT:  Se requiere que las bibliotecas de extensión usen la macro PG_MODULE_MAGIC.

[ scratches head ... ]  Your source code looks fine.  Are you sure you
are pointing to the right copy of the .dll file?

If you added the PG_MODULE_MAGIC; line after getting this error, it's
likely that the old version of the .dll is already loaded into the
server's memory, in which case what you need to do to get rid of it
is to restart the server, or at least start a fresh session.

            regards, tom lane

--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance