Re: C-functions using SPI Missing Magic Block Error - Mailing list pgsql-general

From Saitenheini@web.de
Subject Re: C-functions using SPI Missing Magic Block Error
Date
Msg-id 1739244982.1343073.1278083603046.JavaMail.fmail@mwmweb050
Whole thread Raw
In response to Re: C-functions using SPI Missing Magic Block Error  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: C-functions using SPI Missing Magic Block Error
List pgsql-general
Thanks for reply Tom!

I've tried several version:

#define _USE_32BIT_TIME_T

#include "postgres.h"
#include "fmgr.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);
}

but still the same error occurs.

I also tried to include pgmagic.h, which I found in here:
http://archives.postgresql.org/pgsql-committers/2006-05/msg00369.php
http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/Attic/pgmagic.h?rev=1.1&content-type=text/x-cvsweb-markup

but this produces a compiler error:
G:\PostgreSQL\8.3\include\server\pgmagic.h|40|error: conflicting types for 'Pg_magic_struct'|
G:\PostgreSQL\8.3\include\server\fmgr.h|367|error: previous declaration of 'Pg_magic_struct' was here|
G:\PostgreSQL\8.3\include\server\pgmagic.h|45|error: conflicting types for 'PGModuleMagicFunction'|
G:\PostgreSQL\8.3\include\server\fmgr.h|383|error: previous declaration of 'PGModuleMagicFunction' was here|
G:\PostgreSQL\8.3\include\server\pgmagic.h|50|warning: "PG_MODULE_MAGIC" redefined|
G:\PostgreSQL\8.3\include\server\fmgr.h|388|warning: this is the location of the previous definition|
G:\PostgreSQL\8.3\include\server\pgmagic.h|66|warning: "PG_MODULE_MAGIC_DATA" redefined|
G:\PostgreSQL\8.3\include\server\fmgr.h|370|warning: this is the location of the previous definition|
||=== Build finished: 4 errors, 4 warnings ===|

I tried to build it in Visual C++ Express 2010 but compiler error occur (SPI_connect())

Any Idea to solve the problem ?
___________________________________________________________
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 by date:

Previous
From: Tom Lane
Date:
Subject: Re: C-functions using SPI Missing Magic Block Error
Next
From: Joe Conway
Date:
Subject: Re: C-functions using SPI Missing Magic Block Error