Special character pervents psql from parsing? - Mailing list pgsql-bugs

From pgsql-bugs@postgresql.org
Subject Special character pervents psql from parsing?
Date
Msg-id 200011262046.eAQKkq775336@hub.org
Whole thread Raw
List pgsql-bugs
Roland Szabo (szroland@freemail.hu) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
Special character pervents psql from parsing?

Long Description
Consider the two expressions in the example code. They are almost the same, the only difference is, that string
constant'Hibás' (faulty, that is, in  hungarian) is terminated with '' in the same line in example #1, and in a new
linein example #2.  
#1 doesn't work.
Our guess is that special character 'á' prevents psql from finding the string delimiters. CR seems to make it recover
atthe end of line, and that way (ex.#2) it does find the string terminator. 

We're using 7.0.3, but same problem occurs in earlier versions too. We have 'LANG=hu_HU' and 'PGDATASTYLE=ISO'
environmentvariables set to warn postgres about the presence of hungarian chars. 

We also tried escaping the special character by having \á in the statement. That resulted in a command error.

Sample Code
#1 The faulty expression:
CREATE FUNCTION "iiftext" (bool,bpchar,bpchar ) RETURNS bpchar AS '
begin
 if $1 then
   return $2;
 else
   RETURN $3;
 end if;
end;
' LANGUAGE 'plpgsql';
CREATE FUNCTION "hibasnev" (bool ) RETURNS bpchar AS '
select iiftext( $1, '''', ''Hibás'');
' LANGUAGE 'SQL';
---cut---
CREATE
ERROR:  Unterminated quoted string
ERROR:  parser: parse error at or near "'"

#2 Similar expression, but this one works:
CREATE FUNCTION "iiftext" (bool,bpchar,bpchar ) RETURNS bpchar AS '
begin
 if $1 then
   return $2;
 else
   RETURN $3;
 end if;
end;
' LANGUAGE 'plpgsql';
CREATE FUNCTION "hibasnev" (bool ) RETURNS bpchar AS '
select iiftext( $1, '''', ''Hibás
'');
' LANGUAGE 'SQL';


No file was uploaded with this report

pgsql-bugs by date:

Previous
From: pgsql-bugs@postgresql.org
Date:
Subject: Fails to add function from file with \i in psql
Next
From: Tom Lane
Date:
Subject: Re: Fails to add function from file with \i in psql