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: c637d8bb0706150530w30fd5a1cwdf8310df8e32c795@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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
adequate.

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 http://korpiq.iki.fi/

Attachment Content-Type Size
pgjdbc82-copy-20070615.diff.gz application/x-gzip 8.7 KB

Browse pgsql-jdbc by date

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