pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: Rodrigo Madera <rodrigo.madera@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Inefficient escape codes.
Date: Tue, 18 Oct 2005 14:47:27 -0600
Message-ID: <20051018204727.GA29110@winnie.fuhr.org> (raw)
In-Reply-To: <3cf983d0510181209v3070a81dw9b21d4d09cbb5022@mail.gmail.com>
References: <3cf983d0510181107sb060171je702da5fe0c29252@mail.gmail.com>
	<20051018190324.GA92715@winnie.fuhr.org>
	<3cf983d0510181209v3070a81dw9b21d4d09cbb5022@mail.gmail.com>

[Please copy the mailing list on replies so others can participate
in and learn from the discussion.]

On Tue, Oct 18, 2005 at 07:09:08PM +0000, Rodrigo Madera wrote:
> > What language and API are you using?
> 
> I'm using libpqxx. A nice STL-style library for C++ (I am 101% C++).

I've only dabbled with libpqxx; I don't know if or how you can make
it send data in binary instead of text.  See the documentation or
ask in a mailing list like libpqxx-general or pgsql-interfaces.

> > Binary transfer sends data in binary, not by automatically converting
> > to and from text.
> 
> Uh, I'm sorry I didn't get that... If I send: insert into foo
> values('\\001\\002') will libpq send 0x01, 0x02 or "\\\\001\\\\002"??

If you do it that way libpq will send the string as text with escape
sequences; you can use a sniffer like tcpdump or ethereal to see this
for yourself.  To send the data in binary you'd call PQexecParams()
with a query like "INSERT INTO foo VALUES ($1)".  The $1 is a
placeholder; the other arguments to PQexecParams() provide the data
itself, the data type and length, and specify whether the data is in
text format or binary.  See the libpq documentation for details.

-- 
Michael Fuhr



view thread (9+ messages)  latest in thread

Message-ID: <20051018204727.GA29110@winnie.fuhr.org>
Permalink:  ../20051018204727.GA29110@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20051018204727.GA29110@winnie.fuhr.org

 · 

reply

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-performance@postgresql.org
  Cc: mike@fuhr.org, rodrigo.madera@gmail.com
  Subject: Re: Inefficient escape codes.
  In-Reply-To: <20051018204727.GA29110@winnie.fuhr.org>

* 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