Escaping input from COPY

From: Roger Leigh <rleigh(at)codelibre(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Escaping input from COPY
Date: 2011-12-19 11:56:55
Message-ID: 20111219115655.GD325@codelibre.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Filip Rembiałkowski 2011-12-19 12:05:20 Re: segfault with plproxy
Previous Message Marti Raudsepp 2011-12-19 09:42:35 Re: Logical Aggregate Functions (eg ANY())