Re: PQescapeLiteral in Libpq - Mailing list pgsql-novice

From lmanorders
Subject Re: PQescapeLiteral in Libpq
Date
Msg-id F277860CE41C45F2B1BE14E272B791B2@LynnPC
Whole thread Raw
In response to Re: PQescapeLiteral in Libpq  (David Johnston <polobo@yahoo.com>)
List pgsql-novice
----- Original Message -----
From: "David Johnston" <polobo@yahoo.com>
To: <pgsql-novice@postgresql.org>
Sent: Thursday, January 09, 2014 12:35 PM
Subject: Re: [NOVICE] PQescapeLiteral in Libpq


> 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 didn't expect the " E" in front of the literal.

>
> 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
> "\\".

The second colon is a typo. I did expect the "\" to be doubled, just not the
leading " E" in the result.

Thanks for the quick responses!

>
> 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.
>
>
> --
> Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-novice
>



pgsql-novice by date:

Previous
From: David Johnston
Date:
Subject: Re: PQescapeLiteral in Libpq
Next
From: Henry Drexler
Date:
Subject: moving postgresql's data directory