Thread: multiline PL/Python function fails in *.sql
Hi, as the subject says - if I do the same interactively in the interpreter, it works. I tried plsql < x.sql and plsql -f x.sql, both fail with this code: create function myfunc(text) RETURNS text AS ' plpy.notice("hallo Notiz")' LANGUAGE 'plpython'; ERROR: plpython: Unable to compile function myfunc exceptions.SyntaxError: invalid syntax (line 2) This works OK in x.sql: create function myfunc(text) RETURNS text AS 'plpy.notice("hallo Notiz")' LANGUAGE 'plpython'; but multiline only works when using psql interactively. This seems to be python specific, as this one also works with plsql -f x.sql: create function simple(text) returns text as ' BEGIN RETURN $1 || $1 ; END; ' LANGUAGE 'plpgsql'; BTW I am using PostgreSQL 7.3.4 -- Wolfgang
Wolfgang Rohdewald <wolfgang@rohdewald.de> writes: > but multiline only works when using psql interactively. I'm not much of a Python user, but doesn't Python think that leading whitespace (particularly tabs) is significant? You may be losing tabs if psql tries to take them as completion commands. regards, tom lane
solution: CRLF line separators are correctly scanned in normal SQL and in PG/SQL triggers but NOT in Python triggers. I'd say this is a bug. I will retest with postgresql 7.4 when available as a debian package. -- Wolfgang
Hi, I reproduced the problem, using pgAdmin III. My postgre 7.4.1 is running on WXP SP1 / cygwin Could be link with the platform? regards richard
Using the pgAccess tools I could add python function / triggers. regards richard
rlasjunies@free.fr (Richard LASJUNIES) writes: > I reproduced the problem, using pgAdmin III. > My postgre 7.4.1 is running on WXP SP1 / cygwin Python is sensitive to leading whitespace --- perhaps whatever you are using to enter the function is mucking up your indentation? regards, tom lane