【问题标题】:Has anyone gotten plperl to work with Postgres 9.1 on Windows?有没有人让 plperl 在 Windows 上使用 Postgres 9.1?
【发布时间】:2011-12-30 00:33:10
【问题描述】:

我无法让 plperl 在 Windows 上使用 Postgres 9.1。

这里描述了同样的问题,但目前还没有解决方案: http://postgresql.1045698.n5.nabble.com/BUG-6204-Using-plperl-functions-generate-crash-td4802111.html

复习

从这里为 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.

【问题讨论】:

    标签: windows perl postgresql plperl


    【解决方案1】:

    我很惊讶地发现 Google 对此没有很好的答案。 Activstate 似乎适用于某些人,但不适用于其他人。有人怀疑与不同版本的 Windows 系统库有冲突,但没有确定的。但是,我终于能够使用草莓 perl 构建一个可以工作的 plperl.dll。

    这里是让 plperl 与草莓 perl 一起工作的分步说明。诀窍是重新编译 postgresql 和 plperl,但在现有的 postgresql 安装上安装 plperl。

    首先,您需要以下内容:

    1. mingw (http://www.mingw.org)
    2. 草莓perl。 http://www.strawberryperl.org
    3. Postgresql 源。确保您获得与您的安装相匹配的版本。

    mingw 网站非常混乱。没有单个软件包可供下载。您必须下载一个安装程序来下载其他所有内容。这是它的快速链接。

    http://sourceforge.net/projects/mingw/files/Installer/

    在他们的安装程序中,选择 C ​​和 C++,以及要安装的 MSYS 环境。 Mingw 不会污染您的环境,因此请将其安装在任何旧位置。

    至于 perl,我不认为 activestate 附带执行此操作所需的文件(共享库),而且我发现草莓的 CPAN 支持更出色(与 activestate 的专有 ppm 站点相比)和 activestate 的傻瓜式放置付费墙后面的旧版本(并迫使其他网站删除其托管副本)。 FU活动状态。

    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 附带的那个。

    【讨论】:

      【解决方案2】:

      上面写着here,需要 (ActiveState) Perl 5.14 才能使其工作。我不确定这个品牌,因为我不得不为 postgres 9.0 使用旧版的草莓 perl,它工作得很好。重要的是为 Postgres 9.1 使用正确的 Perl 版本 5.14。尝试使用与您的 postgres 安装相匹配的二进制格式(32 位与 64 位)。

      【讨论】:

        【解决方案3】:

        在尝试全新安装的 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/64 位)。

        【讨论】:

          猜你喜欢
          • 2010-10-27
          • 1970-01-01
          • 2019-04-08
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-01-21
          • 1970-01-01
          • 2016-01-09
          相关资源
          最近更新 更多