Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 4A21637C681 for ; Mon, 12 Nov 2007 07:13:51 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 45240-10 for ; Mon, 12 Nov 2007 07:13:51 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by postgresql.org (Postfix) with ESMTP id 61A5237C69E for ; Mon, 12 Nov 2007 07:13:50 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.14.1/8.14.1) with ESMTP id lACBDktF093582 for ; Mon, 12 Nov 2007 07:13:46 -0400 (AST) (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.14.1/8.14.1/Submit) id lACBAiJs091556 for pgsql-sql@postgresql.org; Mon, 12 Nov 2007 07:10:44 -0400 (AST) (envelope-from news) From: "Sabin Coanda" X-Newsgroups: pgsql.sql Subject: Re: plpgsql language not aware of standard_conforming_strings ? Date: Mon, 12 Nov 2007 13:10:50 +0200 Organization: Hub.Org Networking Services Lines: 36 Message-ID: References: X-Complaints-To: usenet@news.hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-RFC2646: Format=Flowed; Response To: pgsql-sql@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200711/51 X-Sequence-Number: 29579 "Sabin Coanda" wrote in message news:fh99cq$2cfn$1@news.hub.org... ... > > 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