Re: PQescapeLiteral in Libpq

From: David Johnston <polobo(at)yahoo(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: PQescapeLiteral in Libpq
Date: 2014-01-09 19:35:38
Message-ID: 1389296138266-5786147.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

lmanorders wrote
> I'm using the libpq.dll libraries to connect to postgress. When I issue a
> call to PQescapeLiteral with a file path as the argument, the result
> string seems to always start with a bogus " E". For example, "C:\MyFile"
> is returned as " E'C:\\:MyFile'" (not including the double quotes). Is
> this a normal result or can't PQescapeLiteral be used to escape a file
> path literal? If not, are there any functions that can be used to "escape"
> a file path?
>
> Thanks, Lynn

What do you expect it to give in this instance?

I don't get why there is an extra colon in your output (typo on your part?)
but the "E" and the double-backslash are present because the "E" converts
the literal into one that accepts escape sequences (of the form
backslash-something, e.g., \n for a newline). Since backslash is an escape
indicator in order to output a literal "\" you have to double/escape it
"\\".

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/PQescapeLiteral-in-Libpq-tp5786141p5786147.html
Sent from the PostgreSQL - novice mailing list archive at Nabble.com.

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message lmanorders 2014-01-09 21:31:19 Re: PQescapeLiteral in Libpq
Previous Message Tom Lane 2014-01-09 19:32:37 Re: PQescapeLiteral in Libpq