v9.6,win server 2012,vs 2015 成功編譯並鏈接爲x64。卡住取得Windows版本的示例C功能
創建函數失敗,說在dll中沒有'add_one'函數。
postgres=# create function add_one(integer) returns integer as
'win32project1',' add_one' language c strict;
ERROR: could not find function "add_one" in file "C:/Program Files/PostgreSQL/9.6/lib/win32project1.dll"
的功能似乎是有不過,DUMPBIN說
1 0 000112CB Pg_magic_func = @ILT+710(Pg_magic_func) 2 1 00011087 pg_finfo_add_one = @ILT+130(pg_finfo_add_one) 3 2 00011190 pg_finfo_add_one_float8 = @ILT+395(pg_finfo_add_one_float8) 4 3 000110F5 pg_finfo_concat_text = @ILT+240(pg_finfo_concat_text) 5 4 000112C1 pg_finfo_copytext = @ILT+700(pg_finfo_copytext) 6 5 0001107D pg_finfo_makepoint = @ILT+120(pg_finfo_makepoint)
我直接從9.6文檔頁面複製源文件https://www.postgresql.org/docs/9.6/static/xfunc-c.html#XFUNC-C-DYNLOAD – pm100
建議確實有效,但如果PG_FUNCTION_INFO中有PGDLLEXPORT,那麼這個額外的行就不需要了 – pm100
文檔中的示例似乎沒有針對Windows。這是一個錯誤。我會提出一個補丁。 –