安装plpython时Postgres数据库崩溃 [英] Postgres database crash when installing plpython

查看:148
本文介绍了安装plpython时Postgres数据库崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的Postgres 9.1中安装plpython,但它使服务器崩溃:

I'm trying to install plpython in my Postgres 9.1 but it crashes the server:

postgres@dataserver1:~> /opt/postgres/9.1/bin/psql -d mydb
psql.bin (9.1.4)
Type "help" for help.

mydb=# create language 'plpythonu';
The connection to the server was lost. Attempting reset: Failed.

我安装了python 2.6.8,并且在系统中正确声明了处理程序:

I have python 2.6.8 installed and the handler is correcty declared in the system:

select tmplname, tmplhandler, tmpllibrary from pg_pltemplate where tmplname like 'plpython%'

"plpythonu"  | "plpython_call_handler"  | "$libdir/plpython2"
"plpython2u" | "plpython2_call_handler" | "$libdir/plpython2"

然后将处理程序安装在$ libdir中:

And the handler is installed in the $libdir:

postgres@dataserver1:~> ll /opt/postgres/9.1/lib/postgresql/plpython*
-rwxr-xr-x 1 root root 6686333 Aug 17 14:27 /opt/postgres/9.1/lib/postgresql/plpython2.so

关于此的任何线索都会被感化

Any clues on this will be apreciated

编辑

我尝试创建扩展插件plpythonu,plpython2u和plpython3u,它们都使服务器崩溃。

I've tried create extension plpythonu, plpython2u, and plpython3u and all of them crashes the server.

在文档中读了一点,我发现\dx命令列出了已安装的扩展:

Reading a little in the docs I found the \dx command to list the installed extensions:

mydb=# \dx
                 List of installed extensions
  Name   | Version |   Schema   |         Description
---------+---------+------------+------------------------------
 plpgsql | 1.0     | pg_catalog | PL/pgSQL procedural language
(1 row)

所以我猜唯一安装的扩展是plpgsql。

So I guess the only installed extension is plpgsql.

mydb=# select name, installed_version from pg_available_extensions where name like '%python%';
    name    | installed_version
------------+-------------------
 plpython2u |
 plpython3u |
 plpythonu  |
(3 rows)

和我的扩展名目录:

postgres@dataserver1:/opt/postgres/9.1/share/postgresql/extension> ll *python*
-rw-r--r-- 1 root root 351 Aug 20 17:32 plpython2u--1.0.sql
-rw-r--r-- 1 root root 196 Aug 20 17:32 plpython2u.control
-rw-r--r-- 1 root root 402 Aug 20 17:32 plpython2u--unpackaged--1.0.sql
-rw-r--r-- 1 root root 351 Jun  1 02:54 plpython3u--1.0.sql
-rw-r--r-- 1 root root 196 Jun  1 02:54 plpython3u.control
-rw-r--r-- 1 root root 402 Jun  1 02:54 plpython3u--unpackaged--1.0.sql
-rw-r--r-- 1 root root 347 Aug 20 17:32 plpythonu--1.0.sql
-rw-r--r-- 1 root root 194 Aug 20 17:32 plpythonu.control
-rw-r--r-- 1 root root 393 Aug 20 17:32 plpythonu--unpackaged--1.0.sql

EDIT

我正在Linux SuSE上运行,但是您明白了。

I'm running on Linux SuSE, but got your point.

在我的postgres安装中,pl-lang库位于.. ./postgres/9.1/lib/postgres。在其中有plpython2.so和plpython3.so

In my postgres instalation, the pl-lang libraries are in .../postgres/9.1/lib/postgres. Inside it there are plpython2.so and plpython3.so

检查这些文件的动态链接库:

Checking the dynamic linked libraries of these files:

alfonso@dataserver1:/opt/postgres/9.1/lib/postgresql> sudo ldd plpython2.so
        linux-vdso.so.1 =>  (0x00007fff5e945000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f64064df000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f64062da000)
        libutil.so.1 => /lib64/libutil.so.1 (0x00007f64060d7000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f6405e5e000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f6405ae9000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f6406b2e000)

没有对任何Python库的引用,也没有针对plpython3.so

There is no reference to any python library, neither for plpython3.so

,但是我已经安装了python 2.6和python 3.2。请注意,我希望为python 2安装扩展。

But I have installed python 2.6 and python 3.2. Note that I wish to install the extension for python 2.

是的,CREATE EXTENSION仍然崩溃:

And yes, CREATE EXTENSION is still crashing:

mydb=# create extension plpython2u;
The connection to the server was lost. Attempting reset: Failed.
!> \q


推荐答案

注意:从PostgreSQL 9.1开始,大多数程序语言已被制成扩展名,因此应使用 CREATE EXTENSION 而不是CREATE LANGUAGE进行安装。现在,直接使用CREATE LANGUAGE的操作应仅限于扩展安装脚本。如果您的数据库中存在裸语言(可能是升级的结果),则可以使用未打包的CREATE EXTENSION langname FROM将其转换为扩展名。

Note: As of PostgreSQL 9.1, most procedural languages have been made into "extensions", and should therefore be installed with CREATE EXTENSION not CREATE LANGUAGE. Direct use of CREATE LANGUAGE should now be confined to extension installation scripts. If you have a "bare" language in your database, perhaps as a result of an upgrade, you can convert it to an extension using CREATE EXTENSION langname FROM unpackaged.

到在特定的数据库中安装PL / Python:

To install PL/Python in a particular database:

从shell命令行使用 createlang plpythonu dbname

from the shell command line use createlang plpythonu dbname

注意

createlang已被弃用,在以后的PostgreSQL版本中可能会删除。相反,建议直接使用CREATE EXTENSION命令。

createlang is deprecated and may be removed in a future PostgreSQL release. Direct use of the CREATE EXTENSION command is recommended instead.

http://www.postgresql.org/docs/9.1/static/plpython.html

编辑

逐步

下载postgresql-9.1.5-1-windows.exe,然后安装它。

Download the postgresql-9.1.5-1-windows.exe and install it.

首先让我们看看已经有什么了。

First let's see what's already there.

mydb=# SELECT * FROM pg_available_extensions
mydb-# WHERE name LIKE '%python%' ORDER BY name;
    name    | default_version | installed_version |                  comment

------------+-----------------+-------------------+-------------------------------------------
 plpython2u | 1.0             |                   | PL/Python2U untrusted procedural language
 plpython3u | 1.0             |                   | PL/Python3U untrusted procedural language
 plpythonu  | 1.0             |                   | PL/PythonU untrusted procedural language
(3 Zeilen)

没有安装!

仅查看lib文件夹。

.... \ PostgreSQL\9.1\lib\plpython3.dll。

....\PostgreSQL\9.1\lib\plpython3.dll.

所以我必须尝试安装plpython3u。

So I must try to install plpython3u.

mydb=# CREATE EXTENSION plpython3u;
ERROR:  unknown error »$libdir/plpython3.dll«

必须

查看 plpython3.dll 时,有对 python32.dll的引用

......

Export Table:
  Name:                          plpython3.dll
  Time Date Stamp:               0x502B366A (15.08.2012 06:40:58)
  Version:                       0.00
  Ordinal Base:                  1
  Number of Functions:           9
  Number of Names:               9

  Ordinal   Entry Point   Name
        1   0x00001005    Pg_magic_func
        2   0x00001019    PyInit_plpy
        3   0x0000101E    _PG_init
        4   0x00001023    pg_finfo_plpython3_call_handler
        5   0x0000100F    pg_finfo_plpython3_inline_handler
        6   0x0000100A    pg_finfo_plpython3_validator
        7   0x00001028    plpython3_call_handler
        8   0x00001014    plpython3_inline_handler
        9   0x0000102D    plpython3_validator

Import Table:
  libintl-8.dll
    Import Adress Table:                0x00016628
    Import Name Table:                  0x0001617C
    Time Date Stamp:                    0x00000000
    Index of first forwarder reference: 0x00000000

    0x000169E4        28   libintl_dngettext
    0x000169D0        27   libintl_dgettext

  **python32.dll**
    Import Adress Table:                0x0001686C
    Import Name Table:                  0x000163C0
    Time Date Stamp:                    0x00000000
    Index of first forwarder reference: 0x00000000
  ....




  • 我下载并安装了python-3.2.3.msi。我只找到 python3.dll

  • 将python3.dll复制到.... \PostgreSQL\9.1\lib并将其重命名为
    python32.dll

    • I download and install python-3.2.3.msi. I found only python3.dll
    • Copy the python3.dll to ....\PostgreSQL\9.1\lib and rename it to python32.dll
    • 返回我键入的SQL Shell

      mydb=# CREATE EXTENSION plpython3u FROM unpackaged;
      

      我收到了消息

      CREATE EXTENSION
      

      寻找结果的原因:

      mydb=# SELECT * FROM pg_available_extensions
      mydb-# WHERE name LIKE '%python%' ORDER BY name;
      

      plpython3u的installed_version 1.0 >

      ,我也可以在PgAdmin III中看到它

      and i also can see it in PgAdmin III

      希望有帮助!

      编辑:

      手动尝试

      步骤1


      mydb =#创建程序语言plpython2u;

      mydb=# CREATE PROCEDURAL LANGUAGE plpython2u;

      步骤2


      mydb =#程序语言注释plpython2u是'PL / Python2U不可信程序语言';

      mydb=# COMMENT ON PROCEDURAL LANGUAGE plpython2u IS 'PL/Python2U untrusted procedural language';

      第3步


      mydb =#从未打包的内容创建plpython2u;

      mydb=# CREATE EXTENSION plpython2u FROM unpackaged;

      经过Python 2.6.5测试

      Tested with Python 2.6.5

      这篇关于安装plpython时Postgres数据库崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆