On Tue, Mar 15, 2005 at 03:41:37PM +0000, Ragnar Hafstað wrote:
> actually, perl scripts with \r\n line endings will run just fine in
> unix/linux.
Indeed, and PL/Perl doesn't care. I just tested several PLs with
PostgreSQL 8.0.1 on Solaris 9 and here are the results:
PL/pgSQL CRLF ok
PL/Perl CRLF ok
PL/Ruby CRLF ok
PL/Tcl CRLF ok
PL/Python CRLF fails
PL/R CRLF fails
Details:
CREATE FUNCTION test_pgsql() RETURNS integer AS
'DECLARE x integer;\r\nBEGIN\r\nx := 123;\r\nRETURN x;\r\nEND;\r\n'
LANGUAGE plpgsql;
CREATE FUNCTION test_perl() RETURNS integer AS
'$x = 123;\r\nreturn $x;\r\n'
LANGUAGE plperl;
CREATE FUNCTION test_ruby() RETURNS integer AS
'x = 123\r\nreturn x\r\n'
LANGUAGE plruby;
CREATE FUNCTION test_tcl() RETURNS integer AS
'set x 123\r\nreturn $x\r\n'
LANGUAGE pltcl;
CREATE FUNCTION test_python() RETURNS integer AS
'x = 123\r\nreturn x\r\n'
LANGUAGE plpythonu;
CREATE FUNCTION test_r() RETURNS integer AS
'x <- 123\r\nreturn(x)\r\n'
LANGUAGE plr;
SELECT test_pgsql();
test_pgsql
------------
123
(1 row)
SELECT test_perl();
test_perl
-----------
123
(1 row)
SELECT test_ruby();
test_ruby
-----------
123
(1 row)
SELECT test_tcl();
test_tcl
----------
123
(1 row)
SELECT test_python();
ERROR: plpython: could not compile function "test_python"
DETAIL: exceptions.SyntaxError: invalid syntax (line 2)
SELECT test_r();
ERROR: R interpreter parse error
DETAIL: R parse error caught in "PLR36865 <- function() {x <- 123
return(x)
}".
CONTEXT: In PL/R function test_r
If I remove the CRs from the Python and R functions then they work:
CREATE OR REPLACE FUNCTION test_python() RETURNS integer AS
'x = 123\nreturn x\n'
LANGUAGE plpythonu;
CREATE OR REPLACE FUNCTION test_r() RETURNS integer AS
'x <- 123\nreturn(x)\n'
LANGUAGE plr;
SELECT test_python();
test_python
-------------
123
(1 row)
SELECT test_r();
test_r
--------
123
(1 row)
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/