From: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
---|---|
To: | "D(dot) Stimits" <stimits(at)comcast(dot)net> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: C API, PQconnectdb and options Q. |
Date: | 2003-09-10 18:26:12 |
Message-ID: | 20030910112103.I6711-100000@megazone.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, 10 Sep 2003, D. Stimits wrote:
> D. Stimits wrote:
>
> > I'm using a Redhat version of PostgreSQL 7.2.3 with the C API. Mostly
> > things work right, but I need more debug output, as I have a query that
> > works fine from psql, but fails with the C API (perhaps this is because
> > I use PQescapeString). The only way to know there is an error is that
> > the insert never happens, and that the system log reports a parse error
> > at or near the first field of an insert. What I am wonder is (a) how to
> > use the tty= in the string passed to PQconnectdb, and (b) a reference
> > URL for what options are available in the options= part of the string
> > parameters accepted by PQconnectdb. So far all I end up with if I try to
> > name a file for tty= or a tty from /dev/ for tty= is a core dump.
> >
> > D. Stimits
> >
> I found a partial answer to this...it seems to be a bug in
> PQescapeString(). Turns out that if I do something with an insert using
> quotes for a varchar field, e.g.:
> INSERT INTO foo VALUES ('bar')
>
> ...then it escapes this to:
> INSERT INTO foo VALUES (''bar'')
I don't think you're using it correctly...
"PQescapeString escapes a string for use within an SQL commmand."
...
"The single quotes that must surround PostgreSQL string literals are not
included in the result string; they should be provided in the SQL
command that the result is inserted into."
The intent is not for PQescapeString to take a query string, but a
string for use within a query string (for example, the literal bar in the
above).
From | Date | Subject | |
---|---|---|---|
Next Message | Network Administrator | 2003-09-10 18:54:45 | Re: Picture with Postgres and Delphi |
Previous Message | Richard Huxton | 2003-09-10 18:20:49 | Re: C API, PQconnectdb and options Q. |