C-functions using SPI Missing Magic Block Error

Поиск
Список
Период
Сортировка
От Saitenheini@web.de
Тема C-functions using SPI Missing Magic Block Error
Дата
Msg-id 1140819931.1269061.1278078350168.JavaMail.fmail@mwmweb051
обсуждение исходный текст
Ответы Re: C-functions using SPI Missing Magic Block Error  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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

В списке pgsql-general по дате отправления:

Предыдущее
От: Greg Smith
Дата:
Сообщение: Re: Postgresql partitioning - single hot table or distributed
Следующее
От: Geoffrey
Дата:
Сообщение: Re: pgpool-II (max_pool and num_init_children)