サンプルからそのまま取り出したコードを次に示します。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;
}
コンパイル、リンクOKです。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 つです。