C-Functions using SPI - Missing Magic Block

From: Saitenheini(at)web(dot)de
To: pgsql-general(at)postgresql(dot)org
Subject: C-Functions using SPI - Missing Magic Block
Date: 2010-07-02 13:26:43
Message-ID: 1452910903.1355851.1278077203570.JavaMail.fmail@mwmweb049
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

<body bgcolor="#ffffff" background="https://img.web.de/v/p.gif" class="bgRepeatYes" style="background-repeat: repeat; ; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-family: verdana,geneva; font-size: 9pt; padding-left: 0px;"><div style="min-height: 200px; background-image: url(https://img.web.de/v/p.gif); background-repeat: repeat; background-color: #ffffff; font-family: verdana,geneva; font-size: 9pt; padding-left: 0px;">Hello,<br /><br />I've got a problem with Functions in C using SPI.<br /><br />Using: PostgreSQL 8.3, Codeblocks, Windows Server 2003 R2<br /><br />I compiled the file "pgExampleSPI.c" with the following code without any error:<br /><br />/* Use 32-bit timer (provided header file uses 64-bit timer, not<br />* compatible with Windows postgreSQL versions */<br />#define _USE_32BIT_TIME_T<br /><br />#include "postgres.h"<br />#include "executor\spi.h"<br /><br />#ifdef PG_MODULE_MAGIC<br />PG_MODULE_MAGIC;<br />#endif<br /><br />extern Datum count_person (PG_FUNCTION_ARGS);<br /><br />PG_FUNCTION_INFO_V1(count_person);<br /><br />__declspec(dllexport) Datum count_person(PG_FUNCTION_ARGS) {<br />&nbsp;&nbsp;&nbsp; int32&nbsp;&nbsp; &nbsp;ret;<br />&nbsp;&nbsp;&nbsp; SPI_connect();<br />&nbsp;&nbsp;&nbsp; ret = SPI_exec("SELECT count(*) FROM person", 0);<br />&nbsp;&nbsp;&nbsp; SPI_finish();<br />&nbsp;&nbsp;&nbsp; PG_RETURN_INT32(ret);<br />}<br /><br />- then I've copied the resulting file "pgExampleSPI.dll" into the directory "G:\PostgreSQL\8.3\lib"<br />- I tried to load to function into PostgreSQL with the command:<br /><br />CREATE FUNCTION count_person() RETURNS int<br />&nbsp;&nbsp;&nbsp;&nbsp; AS 'G:/PostgreSQL/8.3/lib/pgExampleSPI.dll', 'count_person'<br />&nbsp;&nbsp;&nbsp;&nbsp; LANGUAGE C STRICT;<br /><br />- and received the following error description:<br /><br />ERROR:&nbsp; incompatible library "G:/PostgreSQL/8.3/lib/pgExampleSPI.dll": missing magic block<br />TIP:&nbsp; Extension libraries are required to use the PG_MODULE_MAGIC macro.<br /><br /><br />After searching google for about 5 hours in couldn't find a way to solve this problem.<br /><br />Can anybody help, please?<br /><br /><span style="font-size: 9pt;"><span style="font-family: verdana,geneva;"><span style="background-color: transparent;"><span style="color: #000000;"><span style="color: #000000;"></span></span></span></span></span></div>&nbsp;&nbsp;<br><br><table cellpadding="0" cellspacing="0" border="0"><tr><td bgcolor="#000000"><img src="https://img.web.de/p.gif" width="1" height="1" border="0" alt="" /></td></tr><tr><td style="font-family:verdana; font-size:12px; line-height:17px;">GRATIS f&uuml;r alle WEB.DE Nutzer: Die maxdome Movie-FLAT!&nbsp;&nbsp;&nbsp;<br>Jetzt freischalten unter http://movieflat.web.de</td></tr></table>
</body>

Attachment Content-Type Size
unknown_filename text/html 2.7 KB

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Greg Smith 2010-07-02 13:43:40 Re: Postgresql partitioning - single hot table or distributed
Previous Message Norberto Delle 2010-07-02 12:10:44 Autovacuum and pg_largeobject