I read on some forum that it's possible in Windows to compile .dll that contains needed c-language function.
I tested it on a function that returns 1. Here is mydll.c listing:
Code:
#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif
#include "postgres.h"
#include "commands/trigger.h" /* ... and triggers */
PG_FUNCTION_INFO_V1(trigf);
Datum trigf(PG_FUNCTION_ARGS)
{
PG_RETURN_INT32(1);
}
I also created .def file
then I'm trying to import the functions from .dll
Code:
CREATE FUNCTION func_name() RETURNS integer
AS 'c:/path/mydll.dll'
LANGUAGE 'C';
an error appears
Code:
ERROR: incompatible library "c:/path/mydll.dll": missing magic block
SQL state: XX000
Hint: Extension libraries are required to use the PG_MODULE_MAGIC macro.
as I read somewhere it is neccessary to include
Code:
#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif
code to source file to prevent the error, but it didn't helps.
Could someone help me with this problem? Or, may be, somebody already faced and solved it?