Re: PQescapeLiteral in Libpq

From: "lmanorders" <lmanorders(at)gmail(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: PQescapeLiteral in Libpq
Date: 2014-01-09 21:31:19
Message-ID: F277860CE41C45F2B1BE14E272B791B2@LynnPC
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


----- Original Message -----
From: "David Johnston" <polobo(at)yahoo(dot)com>
To: <pgsql-novice(at)postgresql(dot)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(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-novice
>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Henry Drexler 2014-01-10 14:30:22 moving postgresql's data directory
Previous Message David Johnston 2014-01-09 19:35:38 Re: PQescapeLiteral in Libpq