我无法在Windows上使用Postgres 9.1工作。
此处描述了同样的问题,但到目前为止还没有解决方案: http://postgresql.1045698.n5.nabble.com/BUG-6204-Using-plperl-functions-generate-crash-td4802111.html
REPRO
从这里为Windows安装Perl 5.14 32位: http://downloads.activestate.com/ActivePerl/releases/5.14.2.1402/ActivePerl-5.14.2.1402-MSWin32-x86-295342.msi
将Perl添加到系统路径变量中 从Enterprise DB安装适用于Windows的Postgres 9.1.2 32位 www.enterprisedb.com/products/pgdownload.do#windows
现在创建一个测试数据库,向其添加perl,并尝试创建一个函数:
postgres=# create database plperl_test;
CREATE DATABASE
postgres=# \c plperl_test
WARNING: Console code page (437) differs from Windows code page (1252)
8-bit characters might not work correctly. See psql reference
page "Notes for Windows users" for details.
You are now connected to database "plperl_test" as user "postgres".
plperl_test=# create language plperl;
CREATE LANGUAGE
plperl_test=# create function perl_test() returns void as
plperl_test-# $$
plperl_test$# $$
plperl_test-# language plperl;
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
请注意,这导致Postgres服务器进程关闭。糟糕!
当我查看Postgres日志文件时,我发现了这个......
2011-12-29 15:51:08 PST STATEMENT: create function perl_test() returns void as
$$
$$
language plperl;
2011-12-29 15:51:26 PST LOG: server process (PID 10364) was terminated by exception 0xC0000005
2011-12-29 15:51:26 PST HINT: See C include file "ntstatus.h" for a description of the hexadecimal value.
2011-12-29 15:51:26 PST LOG: terminating any other active server processes
2011-12-29 15:51:26 PST WARNING: terminating connection because of crash of another server process
2011-12-29 15:51:26 PST DETAIL: The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2011-12-29 15:51:26 PST HINT: In a moment you should be able to reconnect to the database and repeat your command.
2011-12-29 15:51:26 PST LOG: all server processes terminated; reinitializing
2011-12-29 15:51:36 PST FATAL: pre-existing shared memory block is still in use
2011-12-29 15:51:36 PST HINT: Check if there are any old server processes still running, and terminate them.
答案 0 :(得分:2)
我很惊讶地发现Google对此没有好的答案。似乎Activstate适用于某些人但不适用于其他人。有人怀疑与不同版本的Windows系统库发生冲突,但没有任何确定性。但是,我最终使用草莓perl构建了一个可行的plperl.dll。
这是一个逐步的痛苦步骤说明,让plperl使用草莓perl。诀窍是重新编译postgresql和plperl,但是在现有的postgresql安装上安装plperl。
首先,您需要以下内容:
mingw网站令人困惑。没有单一的软件包可供下载。您必须下载安装程序以下载其他所有内容。这是一个快速链接。
http://sourceforge.net/projects/mingw/files/Installer/
在他们的安装程序中,选择C和C ++以及要安装的MSYS环境。 Mingw不会污染您的环境,因此请将其安装在任何旧位置。
至于perl,我不认为activestate带有执行此操作所必需的文件(共享库),并且我发现草莓的CPAN支持是优越的(vs activestate专有的ppm站点)和activestate的douchebag推动移动付费墙背后的旧版本(并强制其他网站删除其托管副本)。 F.U. ActiveState的。
Postgresql 9.1最初是针对perl 5.14构建的,所以最好坚持使用该版本。
打开包装并安装所有东西。 Mingw会给你一个shell(在启动菜单中查找快捷方式)来编译。启动一个shell而不要关闭它。
运行以下命令安装/删除软件包:
mingw-get install libminizip
mingw-get remove mingw-perl
你需要删除mingw的perl,以便构建过程使用草莓perl。您可以改为使用路径变量,但这种方式更容易
现在,您需要访问解压缩postgresql源代码的目录。在mingw shell中,使用根路径/ c来引用C:驱动器。
现在只需配置并制作
./configure --with-perl
make
请注意,postgres文档说使用gmake,但是在mingw上,它就是make。
构建实际的plperl.dll文件时,构建可能会失败。那是因为构建环境没有产生构建dll的正确命令。如果你收到这样的错误:
dllwrap -o plperl.dll --dllname plperl.dll --def libplperldll.def plperl.o SPI.o Util.o -L../../../src/port -Wl,--allow-multiple-definition -Wl,--as-needed -LC:/strawberry/perl/lib/CORE -l -L../../../src/backend -lpostgres
c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/ld.exe: cannot find -l-L../../../src/backend
c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/ld.exe: cannot find -lpostgres
cd到src / pl / plperl并执行以下命令:
dllwrap -o plperl.dll --dllname plperl.dll --def libplperldll.def plperl.o SPI.o Util.o -L../../../src/port -Wl,--allow-multiple-definition -Wl,--as-needed -L/c/strawberry/perl/lib/CORE -L../../../src/backend -lpostgres -lperl514
(请注意我在c:\ strawberry中安装了perl,在c:\ mingw中安装了mingw)
此时,你已经完成了。你在该目录中有一个plperl.dll,可以替换postgresql附带的那个。
答案 1 :(得分:0)
它说here,需要(ActiveState)Perl 5.14 才能使其正常工作。我不确定这个品牌,因为我必须使用传统版本的草莓perl for postgres 9.0,它运作得很好。重要的是为Postgres 9.1使用正确的Perl版本5.14。尝试使用与postgres安装相匹配的二进制格式(32对64位)。
答案 2 :(得分:0)
在使用全新安装的PostgreSQL 9.1.11(x64)后,我发现ActivePerl 5.14.1 (x64)有效。关键是要确保PostgreSQL能够在其环境PATH
中找到所需的perl DLL。
在postgres lib目录中的plperl.dll
上运行Dependency Walker。在PostgreSQL 9.1.11的情况下,它依赖perl514.dll
- 所以改变你的环境PATH以包括它所在的目录(即c:\ perl \ bin)。通过重新运行Dependency Walker重新检查DLL是否被正确检测,然后完全停止/启动PostgreSQL服务,你应该好好去。
如果您发现plperl.dll
依赖于不同的perl DLL,那么您需要使用匹配的ActivePerl版本(即perl58.dll将匹配ActivePerl 5.8,perl510.dll将匹配ActivePerl 5.10 - 确保Perl和PostgreSQL的二进制格式始终匹配(32 / 64bit)。