Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 0D61D9FB484 for ; Mon, 2 Jul 2007 20:27:06 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 13114-05 for ; Mon, 2 Jul 2007 20:26:56 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from rrmailscan3.safenetbox.biz (mailscan3.reynolds.com.au [203.25.40.75]) by postgresql.org (Postfix) with ESMTP id 352C69FB480 for ; Mon, 2 Jul 2007 20:27:01 -0300 (ADT) Received: from rrmailscan3.safenetbox.biz (rrmailscan3.safenetbox.biz [127.0.0.1]) by rrmailscan3.safenetbox.biz (Postfix) with ESMTP id 4F1991D48430 for ; Tue, 3 Jul 2007 09:26:59 +1000 (EST) Received: from [127.0.0.1] (online4-new.lnk.telstra.net [139.130.169.227]) (Authenticated sender: remote) by rrmailscan3.safenetbox.biz (Postfix) with ESMTP id 8F94E1D4842D for ; Tue, 3 Jul 2007 09:26:57 +1000 (EST) Message-ID: <468989C0.7020601@autoledgers.com.au> Date: Tue, 03 Jul 2007 07:26:56 +0800 From: Paul Lambert User-Agent: Thunderbird 2.0.0.4 (Windows/20070604) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: Using escape strings in an insert statement. References: <46898000.7030601@autoledgers.com.au> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/8 X-Sequence-Number: 28743 Michael Glaesemann wrote: > > On Jul 2, 2007, at 17:45 , Paul Lambert wrote: > >> tester=# insert into testing (test_text) values ('abcE'\\'123'); > > This should be > INSERT INTO testing (test_text) values (E'abc\123'); > >> The help itself (ch 4.1.2.1) tells me to use double backslash "Thus, >> to include a backslash character, write two backslashes (\\). " > > Note that the String Constants section (4.1.2.1) says put the E "before > the opening single quote". > > http://www.postgresql.org/docs/8.2/interactive/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS > > Missed that part - my apologies. Time to read the manuals more thoroughly it would seem. >> An escape string constant is specified by writing the letter E (upper >> or lower case) just before the opening single quote, e.g. E'foo'. > > Also be sure to read the Caution section. > > Using \ as an escape character is the old non-standard PostgreSQL escape > syntax that the WARNING (above) is, uh, warning you about. With > standard_conforming_strings on (i.e., follow the SQL spec), the > backslash is just a backslash character. > >> Which one is the correct syntax and how can I make it not return >> anything other than a successful insert? > > Depends on the setting of standard_conforming_strings. > > Michael Glaesemann > grzm seespotcode net > Looks like it's a toss-up between turning standard_conforming_strings on or turning escape_string_warning off, both seem to have the same effect in not giving the error anymore. I'll go with your suggestion though, I guess since it's a new install not a previous upgrade of an old it's technically more correct to conform to current standards rather than attempt to conform to old behavior. Cheers for the help - much appreciated. -- Paul Lambert Database Administrator AutoLedgers