From: | Gregory Golberg <grisha(at)alum(dot)mit(dot)edu> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | getaddrinfo problems in pl/python |
Date: | 2010-05-29 01:28:37 |
Message-ID: | AANLkTimN-VEBbHq9pC97f3H6JPyAXIVn521gXsSRDof4@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi all,
I am having problems with getaddrinfo in plpython. Pl/Python is the
same as my system
python (2.6), this is MacOS X. Here's what happens in the python prompt:
>>> from _socket import *
>>> import _socket
>>> import sys
>>> print _socket.__file__
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/_socket.so
>>> print sys.version
2.6.1 (r261:67515, Feb 11 2010, 15:47:53)
[GCC 4.2.1 (Apple Inc. build 5646)]
>>> ga = getaddrinfo('localhost',8088,0,SOCK_STREAM)
>>> print ga
[(30, 1, 6, '', ('::1', 8088, 0, 0)), (30, 1, 6, '', ('fe80::1%lo0',
8088, 0, 1)), (2, 1, 6, '', ('127.0.0.1', 8088))]
In other words, everything is OK. (I am printing the version and the
file just so it can be compared to the
output from plpython).
Now, let's do it in pl/python:
SET client_min_messages='LOG';
CREATE OR REPLACE FUNCTION trycon(host VARCHAR) RETURNS text
AS $$
from _socket import *
import _socket
import sys
plpy.log(_socket.__file__)
plpy.log(sys.version)
ga = getaddrinfo(host,8088,0,SOCK_STREAM)
plpy.log(str(ga))
return str(ga)
$$ LANGUAGE plpythonu;
SELECT trycon('localhost');
outputs:
LOG: ('/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/_socket.so',)
LOG: ('2.6.1 (r261:67515, Feb 11 2010, 15:47:53) \n[GCC 4.2.1 (Apple
Inc. build 5646)]',)
ERROR: PL/Python: PL/Python function "trycon" failed
DETAIL: <class 'socket.gaierror'>: [Errno 8] nodename nor servname
provided, or not known
What am I missing? Thanks for the help in advance.
-gg
From | Date | Subject | |
---|---|---|---|
Next Message | Shoaib Mir | 2010-05-29 01:34:13 | Re: sintax error in script |
Previous Message | Luis Daniel Lucio Quiroz | 2010-05-29 01:09:45 | sintax error in script |