Received: from hobart.southcom.com.au (hobart.southcom.com.au [203.60.16.2]) by hub.org (8.9.3/8.9.3) with ESMTP id RAA13818 for ; Tue, 4 Jan 2000 17:32:22 -0500 (EST) (envelope-from shevlandj@kpi.com.au) Received: from elite (pAf6.hbt.southcom.com.au [203.60.23.247]) by hobart.southcom.com.au (8.9.3/8.9.3) with SMTP id JAA26240; Wed, 5 Jan 2000 09:32:08 +1100 (EST) (envelope-from shevlandj@kpi.com.au) Message-ID: <008201bf57a3$14d5b9a0$6464a8c0@kpi.com.au> From: "Joe Shevland" To: "The Hermit Hacker" , "Tom Lane" Cc: References: <13967.947009578@sss.pgh.pa.us> Subject: Re: [INTERFACES] escaping characters ... Date: Wed, 5 Jan 2000 09:33:56 -0800 Organization: KPI Logistics Pty Ltd MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 What about: % and ? for like clauses... I think the function in question would be a handy option though. I almost always implement one of these methods in the application code. Regards, Joe Shevland ----- Original Message ----- From: "Tom Lane" To: "The Hermit Hacker" Cc: Sent: Tuesday, January 04, 2000 10:12 AM Subject: Re: [INTERFACES] escaping characters ... > The Hermit Hacker writes: > > MySQl has 'mysql_escape_string' in it's client library. Does Pg have > > something like that? > > libpq doesn't provide any such function --- perhaps it should, but > on the other hand the amount of code involved is pretty tiny, and > issues like memory allocation/freeing would complicate the definition > of the function. > > > if not, what should be escaped? > > When generating quoted strings for use in SQL commands, you should > prefix single-quote (') and backslash (\) characters with a backslash. > I think that's all. > > COPY IN/OUT data has a different set of rules. There, you can but > don't have to backslash single quotes. You do need to convert returns > and tabs into \n and \t, and of course backslash itself must be doubled. > (If you are using some other character than tab as the field delimiter, > then it'd need backslashing instead.) > > Data returned by libpq after a SELECT is not quoted at all. > > regards, tom lane > > ************ >