Special character pervents psql from parsing?

From: pgsql-bugs(at)postgresql(dot)org
To: pgsql-bugs(at)postgresql(dot)org
Subject: Special character pervents psql from parsing?
Date: 2000-11-26 20:46:52
Message-ID: 200011262046.eAQKkq775336@hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Roland Szabo (szroland(at)freemail(dot)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 'Hibs' (faulty, that is, in hungarian) is terminated with '' in the same line in example #1, and in a new line in 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 at the 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' environment variables 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, '''', ''Hibs'');
' 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, '''', ''Hibs
'');
' LANGUAGE 'SQL';

No file was uploaded with this report

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2000-11-27 01:06:59 Re: Fails to add function from file with \i in psql
Previous Message pgsql-bugs 2000-11-26 20:28:24 Fails to add function from file with \i in psql