【发布时间】:2020-10-19 07:16:46
【问题描述】:
这是直接来自示例的代码。 64 位安装,x64 构建。
#include "postgres.h"
#include "executor/spi.h"
#include "commands/trigger.h"
#include "fmgr.h"
#include "access/heapam.h"
#include "utils/syscache.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif
PGDLLEXPORT Datum plsample_call_handler(PG_FUNCTION_ARGS); // <-- the answer!!
PG_FUNCTION_INFO_V1(plsample_call_handler);
Datum
plsample_call_handler(PG_FUNCTION_ARGS)
{
Datum retval;
retval = 42;
return retval;
}
它可以编译和链接。这是 SQL:
CREATE FUNCTION plsample_call_handler() RETURNS language_handler
AS 'TryPostgresPl.dll'
LANGUAGE C;
CREATE LANGUAGE plsample
HANDLER plsample_call_handler;
这是错误信息。
ERROR: could not find function "plsample_call_handler" in file "C:/Program Files/PostgreSQL/9.5/lib/TryPostgresPl.dll"
SQL state: 42883
那么近,却又那么远。真的不知道去哪里找。
根据 Nick Barnes 进行编辑以显示答案。请注意,查看 depends.exe 之前显示了 2 个导出,现在是 3 个。
【问题讨论】:
-
@NickBarnes:谢谢!发现。编辑以显示答案。如果您想将您的评论转换为答案,我会接受。顺便说一句,那篇文章中还有其他内容——很好的链接。
标签: postgresql visual-c++ postgresql-extensions