Escaping input from COPY - Mailing list pgsql-general

From Roger Leigh
Subject Escaping input from COPY
Date
Msg-id 20111219115655.GD325@codelibre.net
Whole thread Raw
Responses Re: Escaping input from COPY
List pgsql-general
Hi folks,

In a Perl application I would like to frequently bulk load
several hundred thousand rows of data into a temporary
table before merging the contents into the database proper.
I'm currently doing individual INSERTs into the temporary
table, which has obviously got a significant performance
penalty--the importing takes several minutes even on a
very fast machine.

I'd like to switch to COPY, which should be orders of
magnitude faster.  I see that DBD::Pg has an interface for
this, which looks just fine.  My problem is with how to
escape the data.  I need to use whatever escaping rules
are in use by the server, which I've seen documented in
the manual; but in order to cope with any future changes
to these rules, and ensure identical behaviour, are there
any standard functions I can use to escape the data before
loading it?


Thanks,
Roger

--
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux             http://people.debian.org/~rleigh/
 `. `'   Printing on GNU/Linux?       http://gutenprint.sourceforge.net/
   `-    GPG Public Key: 0x25BFB848   Please GPG sign your mail.

pgsql-general by date:

Previous
From: Marti Raudsepp
Date:
Subject: Re: Logical Aggregate Functions (eg ANY())
Next
From: Filip Rembiałkowski
Date:
Subject: Re: segfault with plproxy