Re: Multiline plpython procedure - Mailing list pgsql-general

From Hong Yuan
Subject Re: Multiline plpython procedure
Date
Msg-id 41EC8C58.5010900@homemaster.cn
Whole thread Raw
In response to Re: Multiline plpython procedure  (Adrian Klaver <aklaver@comcast.net>)
Responses Re: Multiline plpython procedure  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Adrian Klaver wrote:

>On Monday 17 January 2005 01:54 am, Hong Yuan wrote:
>I entered the multilineversion of this function exactly as written here and it
>ran properly. This was with version 8.0 of Postgres.  You might want to do
>a /df+ circ in psql to see if your editor is putting a space at the beginning
>of line 2.
>
>
The strange thing is that if I create the function in psql, the function
works. But if I create the function from PgAdmin III, there was an
error, although with \df+ circ I can not identify any visual difference
between the two versions of function. See below:


.... I create the function with psql ....

homemaster=# \df+ circ
                                            List of functions
 Result data type | Schema | Name | Argument data types |  Owner  |
Language  | Source code | Description
------------------+--------+------+---------------------+---------+-----------+-------------+-------------
 double precision | public | circ | double precision    | zopeapp |
plpythonu |
from math import pi
return 2*pi*args[0]            |
(1 row)

homemaster=# select circ(1);
     circ
---------------
 6.28318530718
(1 row)

.... Now I recreate the function with pgAdmin ....

homemaster=# \df+ circ
                                            List of functions
 Result data type | Schema | Name | Argument data types |  Owner  |
Language  | Source code | Description
------------------+--------+------+---------------------+---------+-----------+-------------+-------------
 double precision | public | circ | double precision    | zopeapp |
plpythonu |
from math import pi
return 2*pi*args[0]            |
(1 row)

homemaster=# select circ(1);
ERROR:  plpython: could not compile function "circ"
DETAIL:  exceptions.SyntaxError: invalid syntax (line 2)

I suppose there are some invisible characters inserted into the function
body by pgAdmin. I am using pgAdmin III Version 1.2.0 under Chinese
Windows XP, while the database is 7.4.6 under Linux.

Should be a bug of pgAdmin with encoding or something. At least I know
the workaround now. Thanks.

--
HONG Yuan
Homemaster Trading Co., Ltd.
No. 601, Bldg. 41, 288 Shuangyang Rd. (N)
Shanghai 200433, P.R.C.
Tel: +86 21 55056553
Fax: +86 21 55067325
E-mail: hongyuan@homemaster.cn


pgsql-general by date:

Previous
From: William Yu
Date:
Subject: Re: ext3
Next
From: Michael Fuhr
Date:
Subject: Re: Logging question