Hi,

So I've been trying to get a plpython function that removes accented
letters, based on a Python snippet posted on another thread.  The
function is simple enough:

create or replace function unaccent(text) returns text language plpythonu as $$
import unicodedata
s = unicodedata.normalize("NFKD", args[0])
s = ''.join(c for c in s if ord(c) < 127)
return s
$$ ;

However, on HEAD this is crashing for me, and it's right when plpython
loads.  Backtrace below.

I already distclean'ed, initdb'd, rebuilt the whole thing from scratch
and I can't make it work.  This is on Python 2.5.4, Debian unstable
stuff.

On 8.3 it just fails thusly:
alvherre=# select unaccent('álvaro muñoz');
ERROR:  plpython: function "unaccent" failed
DETALLE:  <type 'exceptions.TypeError'>: normalize() argument 2 must be 
unicode, not str

Obviously I don't know Python to fix it :-)

#0  dl_open_worker (a=<value optimized out>) at dl-open.c:369
#1  0x00007f6b8bba9436 in _dl_catch_error (objname=0x7fff93db7950, 
errstring=0x7fff93db7948, 
    mallocedp=0x7fff93db795f, operate=0x7f6b8bbad780 <dl_open_worker>, 
args=0x7fff93db7900)
    at dl-error.c:178
#2  0x00007f6b8bbad2ab in _dl_open (
    file=0x1349980 
"/home/alvherre/Code/CVS/pgsql/install/00head/lib/plpython.so", 
    mode=-2147483390, caller_dlopen=0x78f1ba, nsid=-2, argc=1, 
argv=0x7fff93db8c08, env=0x127ceb0)
    at dl-open.c:596
#3  0x00007f6b8b04ef5b in dlopen_doit (a=<value optimized out>) at dlopen.c:67
#4  0x00007f6b8bba9436 in _dl_catch_error (objname=0x7f6b8b2510d0, 
errstring=0x7f6b8b2510d8, 
    mallocedp=0x7f6b8b2510c8, operate=0x7f6b8b04eef0 <dlopen_doit>, 
args=0x7fff93db7b20)
    at dl-error.c:178
#5  0x00007f6b8b04f30c in _dlerror_run (operate=0x7f6b8b04eef0 <dlopen_doit>, 
args=0x7fff93db7b20)
    at dlerror.c:164
#6  0x00007f6b8b04eec1 in __dlopen (file=<value optimized out>, mode=<value 
optimized out>)
    at dlopen.c:88
#7  0x000000000078f1ba in internal_load_library (
    libname=0x13762a0 
"/home/alvherre/Code/CVS/pgsql/install/00head/lib/plpython.so")
    at /pgsql/source/00head/src/backend/utils/fmgr/dfmgr.c:234
#8  0x000000000078ee6a in load_external_function (filename=0x1376268 
"$libdir/plpython", 
    funcname=0x13721a8 "plpython_call_handler", signalNotFound=1 '\001', 
filehandle=0x7fff93db7d08)
    at /pgsql/source/00head/src/backend/utils/fmgr/dfmgr.c:113
#9  0x0000000000790668 in fmgr_info_C_lang (functionId=16393, 
finfo=0x7fff93db7e60, 
    procedureTuple=0x7f6b8bd085c0) at 
/pgsql/source/00head/src/backend/utils/fmgr/fmgr.c:345
#10 0x00000000007904e1 in fmgr_info_cxt_security (functionId=16393, 
finfo=0x7fff93db7e60, 
    mcxt=0x13478b8, ignore_security=0 '\0')
    at /pgsql/source/00head/src/backend/utils/fmgr/fmgr.c:276
#11 0x000000000079022a in fmgr_info_cxt (functionId=16393, 
finfo=0x7fff93db7e60, mcxt=0x13478b8)
    at /pgsql/source/00head/src/backend/utils/fmgr/fmgr.c:166
#12 0x0000000000790200 in fmgr_info (functionId=16393, finfo=0x7fff93db7e60)
    at /pgsql/source/00head/src/backend/utils/fmgr/fmgr.c:156


-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to