From: | "Sabin Coanda" <sabin(dot)coanda(at)deuromedia(dot)ro> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: plpgsql language not aware of standard_conforming_strings ? |
Date: | 2007-11-12 11:10:50 |
Message-ID: | fh9cbj$2pd2$1@news.hub.org |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
"Sabin Coanda" <sabin(dot)coanda(at)deuromedia(dot)ro> wrote in message
news:fh99cq$2cfn$1(at)news(dot)hub(dot)org(dot)(dot)(dot)
...
>
> How can I get my desired function that means when I call test( 'a\b' ) it
> will return 'a\\b' ?
>
The problem seems to be the constant evaluation in plpgsql functions which
is not aware of standard_conforming_strings.
An answer may be to build my own replace function, that doesn't use constant
evaluation inside.
For instance:
CREATE OR REPLACE FUNCTION myreplace(sText varchar, sSrc varchar, sDst
varchar) RETURNS varchar AS $BODY$
BEGIN
RETURN replace( sText, sSrc, sDst );
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
Using this function will give the expected result, when
standard_conforming_strings = 'on', so
SELECT myreplace( 'a\b', '\', '\\' ); will give the result 'a\\b' as
expected.
In fact this is an workaround :((. It would be nice to make the language to
works like that :).
Regards,
Sabin
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2007-11-12 16:05:27 | Re: show value of backslashes in string array argument |
Previous Message | Achilleas Mantzios | 2007-11-12 10:20:54 | Re: show value of backslashes in string array argument |