HI,
El viernes, 2 de julio de 2010 10:26:43 UTC-3, (desconocido) escribió:
> Hello,
>
> I've got a problem with Functions in C using SPI.
>
> Using: PostgreSQL 8.3, Codeblocks, 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_<WBR>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/<WBR>pgExampleSPI.dll', 'count_person'
> LANGUAGE C STRICT;
>
> - and received the following error description:
>
> ERROR: incompatible library "G:/PostgreSQL/8.3/lib/<WBR>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, please?
>
> <span style="font-size:9pt"><span style="font-family:verdana,geneva"><span style="background-color:transparent"><span
style="color:#000000"><spanstyle="color:#000000"></span></span></span></span></span></div>
>
> <table cellpadding="0" cellspacing="0" border="0"><tr><td bgcolor="#000000"><img width="1" height="1" border="0"
alt=""origsrc="https://img.web.de/p.gif"></td></tr><tr><td
style="font-family:verdana;font-size:12px;line-height:17px">GRATISfür alle <a href="http://WEB.DE"
target="_blank">WEB.DE</a>Nutzer: Die maxdome Movie-FLAT!
> Jetzt freischalten unter <a href="http://movieflat.web.de"
target="_blank">http://movieflat.web.de</a></td></tr></table>
> </div>
Hi, you must put "PG_MODULE_MAGIC" after include sentences, if you use include own put in firth .h of you call in .c
code,remenber after include section