Skip site navigation (1) Skip section navigation (2)

Proper COPY implementation for 8.x

From: "Kalle Hallivuori" <kato(at)iki(dot)fi>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Proper COPY implementation for 8.x
Date: 2007-06-15 12:30:37
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
Hello again everybody.

Attached is a patch against postgresql-jdbc-8.2-505.src I confirmed to
apply, compile and test cleanly (though those tests are still very
minimal, I've succesfully run some millions of rows through this with
the application I'm developing). It contains thread-safe single-shot
COPY calls for streams and byte arrays. Interfaces for rolling your
own data consumers and providers are included. Documentation is

Usage is straightforward:

 int rowCount = ((PGConnection)con).getCopyAPI().copyIntoDB("COPY
footable TO STDOUT", System.out);

Backend is also quite straightforward:

synchronized int QueryExecutorImpl.copy(String sql, CopydataProvider
provider, CopydataConsumer consumer)
- issues given SQL statement
- receives handshake
- passes copy data between database and exchanger (either provider or
consumer depending on direction)
- handles state and status changes gracefully (where possible,
exceptions are delayed until connection is back in shape)

One FIXME remains for now: what to do with Notifications after reading them?

It's a sunny Friday here, I hope the same for you. And I hope this
patch (or a version for 8.3dev branch I can provide upon request) gets
accepted to the official version, so that my optimizations based on it
will be accepted here at my work :)

Kalle Hallivuori +358-41-5053073

Attachment: pgjdbc82-copy-20070615.diff.gz
Description: application/x-gzip (8.7 KB)

pgsql-jdbc by date

Next:From: Luca FerrariDate: 2007-06-16 14:07:52
Subject: a simple example of XA (not working)
Previous:From: Kalle HallivuoriDate: 2007-06-13 13:26:38
Subject: Re: FYI: porting Copy API to 8.x

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group