From: Joe Shevland <shevlandj@kpi.com.au>
To: The Hermit Hacker <scrappy@hub.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-interfaces@postgreSQL.org
Subject: Re: [INTERFACES] escaping characters ...
Date: Wed, 5 Jan 2000 09:33:56 -0800
Message-ID: <008201bf57a3$14d5b9a0$6464a8c0@kpi.com.au> (raw)
References: <Pine.BSF.4.21.0001041343360.18498-100000@thelab.hub.org>
<13967.947009578@sss.pgh.pa.us>
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" <tgl@sss.pgh.pa.us>
To: "The Hermit Hacker" <scrappy@hub.org>
Cc: <pgsql-interfaces@postgreSQL.org>
Sent: Tuesday, January 04, 2000 10:12 AM
Subject: Re: [INTERFACES] escaping characters ...
> The Hermit Hacker <scrappy@hub.org> 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
>
> ************
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: shevlandj@kpi.com.au, scrappy@hub.org, tgl@sss.pgh.pa.us
Subject: Re: [INTERFACES] escaping characters ...
In-Reply-To: <008201bf57a3$14d5b9a0$6464a8c0@kpi.com.au>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox