From: Kalle Hallivuori <kato@iki.fi>
To: pgsql-jdbc@postgresql.org
Subject: Proper COPY implementation for 8.x
Date: Fri, 15 Jun 2007 15:30:37 +0300
Message-ID: <c637d8bb0706150530w30fd5a1cwdf8310df8e32c795@mail.gmail.com> (raw)
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/Attachments:
pgjdbc82-copy-20070615.diff.gz (application/x-gzip, 8.7K) download
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: kato@iki.fi
Subject: Re: Proper COPY implementation for 8.x
In-Reply-To: <c637d8bb0706150530w30fd5a1cwdf8310df8e32c795@mail.gmail.com>
References: <c637d8bb0706150530w30fd5a1cwdf8310df8e32c795@mail.gmail.com>
* 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