From: | Saitenheini(at)web(dot)de |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | C-functions using SPI Missing Magic Block Error |
Date: | 2010-07-02 13:45:50 |
Message-ID: | 1140819931.1269061.1278078350168.JavaMail.fmail@mwmweb051 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello,
I've got a problem with user defined functions in C using SPI.
Using: PostgreSQL 8.3.7, Codeblocks (GNU GCC Compiler), Windows Server 2003 R2
I compiled the file "pgExampleSPI.c" with the following code without any error:
/* Use 32-bit timer (provided header file uses 64-bit timer, not
* compatible with Windows postgreSQL versions */
#define _USE_32BIT_TIME_T
#include "postgres.h"
#include "executor\spi.h"
#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif
extern Datum count_person (PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(count_person);
__declspec(dllexport) Datum count_person(PG_FUNCTION_ARGS) {
int32 ret;
SPI_connect();
ret = SPI_exec("SELECT count(*) FROM person", 0);
SPI_finish();
PG_RETURN_INT32(ret);
}
- then I've copied the resulting file "pgExampleSPI.dll" into the directory "G:\PostgreSQL\8.3\lib"
- I tried to load to function into PostgreSQL with the command:
CREATE FUNCTION count_person() RETURNS int
AS 'G:/PostgreSQL/8.3/lib/pgExampleSPI.dll', 'count_person'
LANGUAGE C STRICT;
- and received the following error description:
ERROR: incompatible library "G:/PostgreSQL/8.3/lib/pgExampleSPI.dll": missing magic block
TIP: Extension libraries are required to use the PG_MODULE_MAGIC macro.
After searching google for about 5 hours in couldn't find a way to solve this problem.
Can anybody help me, please?
Thanks, Max.
___________________________________________________________
WEB.DE DSL ab 19,99 Euro/Monat. Bis zu 150,- Euro Startguthaben und
50,- Euro Geldprämie inklusive! https://freundschaftswerbung.web.de
From | Date | Subject | |
---|---|---|---|
Next Message | Geoffrey | 2010-07-02 13:46:58 | Re: pgpool-II (max_pool and num_init_children) |
Previous Message | Greg Smith | 2010-07-02 13:43:40 | Re: Postgresql partitioning - single hot table or distributed |