dbTalk Databases Forums  

multiline PL/Python function fails in *.sql

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss multiline PL/Python function fails in *.sql in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Wolfgang Rohdewald
 
Posts: n/a

Default multiline PL/Python function fails in *.sql - 12-03-2003 , 03:52 AM






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

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo (AT) postgresql (DOT) org


Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: multiline PL/Python function fails in *.sql - 12-03-2003 , 10:07 AM






Wolfgang Rohdewald <wolfgang (AT) rohdewald (DOT) de> writes:
Quote:
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

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster



Reply With Quote
  #3  
Old   
Wolfgang Rohdewald
 
Posts: n/a

Default Re: multiline PL/Python function fails in *.sql - 12-03-2003 , 06:06 PM



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

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster


Reply With Quote
  #4  
Old   
Richard LASJUNIES
 
Posts: n/a

Default Re: multiline PL/Python function fails in *.sql - 12-28-2003 , 02:29 PM



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

Reply With Quote
  #5  
Old   
Richard LASJUNIES
 
Posts: n/a

Default Re: multiline PL/Python function fails in *.sql - 01-02-2004 , 11:47 AM



Using the pgAccess tools I could add python function / triggers.

regards

richard

Reply With Quote
  #6  
Old   
Tom Lane
 
Posts: n/a

Default Re: multiline PL/Python function fails in *.sql - 01-04-2004 , 11:41 PM



rlasjunies (AT) free (DOT) fr (Richard LASJUNIES) writes:
Quote:
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

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.