我有一个功能的 DLL
#include "postgres.h"
#include <string.h>
#include "fmgr.h"
#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif
PG_FUNCTION_INFO_V1(add_one_float8);
Datum
add_one_float8(PG_FUNCTION_ARGS)
{
float8 arg = PG_GETARG_FLOAT8(0);
PG_RETURN_FLOAT8(arg + 1.0);
}
当我尝试创建函数时:
CREATE FUNCTION add_one(double precision) RETURNS double precision
AS 'DIRECTORY\mylib.dll', 'add_one_float8'
LANGUAGE C STRICT;
我收到错误“错误:找不到函数“add_one_float8””但使用“pg_finfo_add_one_float8”创建脚本成功结束。
那么在函数名前加上“pg_finfo_”是正常的还是我做错了?
PostgreSQL 版本 9.1
谢谢你。
更新:
生成文件
PG_DIR=D:/Programs/PostgreSQL
PG_LIB=$(PG_DIR)/lib/postgres.lib
PG_INCLUDE_SERVER=$(PG_DIR)/include/server
PG_INCLUDE=$(PG_DIR)/include
PG_INCLUDE_PORT_WIN32=$(PG_DIR)/include/server/port/win32
PG_INCLUDE_PORT_WIN32_MSVC=$(PG_DIR)/include/server/port/win32_msvc
MSDK_INCLUDE="D:\Program Files\Microsoft SDKs\Windows\v7.0\Include"
COMPILER_INCLUDES=/I$(PG_INCLUDE) /I$(PG_INCLUDE_SERVER) /I $(PG_INCLUDE_PORT_WIN32) /I$(PG_INCLUDE_PORT_WIN32_MSVC) /I$(MSDK_INCLUDE)
LINKER_DLL_FLAGS=/MACHINE:X86
COMPILER_DLL_FLAGS=/c /TC /D "WIN32"
DLL_NAME=mylib
DLL_DEST=D:\lib
OBJS=myfunc.obj
.c.obj:
cl $(COMPILER_DLL_FLAGS) $(COMPILER_INCLUDES) $*.c
all:$(OBJS)
link -out:$(DLL_DEST)\$(DLL_NAME).dll /DLL $(OBJS) $(PG_LIB)