我一直无法让plperl在Windows上使用Postgres 9.1。
这里描述了同样的问题,但到目前为止还没有解决方案:http://postgresql.1045698.n5.nabble.com/BUG-6204-Using-plperl-functions-generate-crash-td4802111.html
重现
从此处安装Perl 5.14 32-bit for Windows:http://downloads.activestate.com/ActivePerl/releases/5.14.2.1402/ActivePerl-5.14.2.1402-MSWin32-x86-295342.msi
将Perl添加到系统路径变量Install Postgres 9.1.2 32- www.enterprisedb.com/products/pgdownload.do#windows
现在创建一个测试DB,将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.发布于 2012-08-10 15:38:48
我很惊讶地发现谷歌在这方面没有找到好的答案。似乎Activstate对一些人有效,但对另一些人无效。有人怀疑与不同版本的windows系统库存在冲突,但没有确定的东西。但是,我最终使用strawberry perl构建了一个可以工作的plperl.dll。
下面是让plperl与草莓perl一起工作的详细步骤说明。诀窍是重新编译postgresql和plperl,但在已安装的postgresql上安装plperl。
首先,您需要以下内容:
mingw站点就像地狱一样让人迷惑。没有单独的包可供下载。您必须下载一个安装程序来下载其他所有内容。这里有一个快速链接。
http://sourceforge.net/projects/mingw/files/Installer/
在他们的安装程序中,选择C和C++,以及要安装的MSYS环境。Mingw不会污染您的环境,因此请将其安装在任何旧位置。
至于perl,我不认为activestate附带了实现这一点所需的文件(共享库),我发现草莓的CPAN支持更优越(与activestate的专有ppm站点相比),以及activestate将旧版本放在付费墙后面(并迫使其他站点删除其托管副本)的愚蠢举动。F.U. ActiveState.
Postgresql 9.1最初是针对perl 5.14构建的,所以最好还是坚持使用该版本。
解压并安装所有这些东西。Mingw将提供一个shell (在启动菜单中查找快捷方式)以在其中进行编译。启动一个shell,并且不要关闭它。
运行以下命令来安装/删除软件包:
mingw-get install libminizip
mingw-get remove mingw-perl您需要删除mingw的perl,以便构建过程使用草莓perl。您也可以使用path变量,但这种方法更简单
现在,您需要进入解压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 -lpostgrescd到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附带的那个。
发布于 2012-03-15 17:30:27
它说here,需要(ActiveState) Perl 5.14才能让它工作。我对这个品牌不太确定,因为我不得不使用postgres 9.0的草莓perl的遗留版本,它工作得很好。重要的是为Postgres 9.1使用正确的Perl版本5.14。尝试使用与您的postgres安装相匹配的二进制格式(32位与64位)。
发布于 2014-01-07 01:59:39
在试用了全新安装的PostgreSQL 9.1.11 (x64)之后,我发现了ActivePerl 5.14.1 (x64)的工作原理。关键是要确保PostgreSQL能够在其环境PATH中找到所需的perl。
在postgres lib目录内的plperl.dll上运行Dependency Walker。在PostgreSQL 9.1.11的情况下,它依赖于perl514.dll -所以更改您的环境路径以包括它所在的目录(即c:\perl\bin)。通过重新运行Dependency Walker来重新检查动态链接库是否被正确检测到,然后完全停止/启动PostgreSQL服务。
如果您发现plperl.dll依赖于不同的perl,那么您需要使用匹配的ActivePerl版本(例如,perl58.dll将匹配ActivePerl 5.8,perl510.dll将匹配ActivePerl 5.10 -确保Perl和PostgreSQL的二进制格式始终匹配(32/64位))。
https://stackoverflow.com/questions/8674995
复制相似问题