Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 7A53E634631 for ; Tue, 17 Nov 2009 13:48:43 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 88817-06 for ; Tue, 17 Nov 2009 17:48:36 +0000 (UTC) X-Greylist: delayed 00:08:00.264278 by SQLgrey-1.7.6 Received: from mail-px0-f194.google.com (mail-px0-f194.google.com [209.85.216.194]) by mail.postgresql.org (Postfix) with ESMTP id C7CBC6329C0 for ; Tue, 17 Nov 2009 13:48:35 -0400 (AST) Received: by pxi32 with SMTP id 32so146229pxi.15 for ; Tue, 17 Nov 2009 09:48:34 -0800 (PST) MIME-Version: 1.0 Received: by 10.142.3.13 with SMTP id 13mr1089527wfc.302.1258479634300; Tue, 17 Nov 2009 09:40:34 -0800 (PST) Date: Tue, 17 Nov 2009 09:40:34 -0800 Message-ID: <895e58dd0911170940p4fefb12fi1fe0c5a8240ccb5@mail.gmail.com> Subject: COPY and turning off autocommit From: Maciek Sakrejda To: pgsql-jdbc@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200911/12 X-Sequence-Number: 20059 I've found that since COPY does not use the sendQueryPreamble method in QueryExecutorImpl, it fails to issue the necessary BEGIN if it's the first statement after autocommit is set to off. A workaround is to just issue a "SELECT 1" before the COPY, but this is pretty ugly. I'm not quite sure what the proper fix is: does COPY need to go through the full sendQueryPreamble code path (specifically, processDeadParsedQueries() and processDeadPortals())? Also, that code is tied into the ResultHandler interface, and COPY does not really fit well into that paradigm. I don't think we can we just call sendQueryPreamble(), sendSync(), processResults(), and *then* move to COPY code, since sendQueryPreamble() might do nothing if we're already in a transaction. I suppose we could pass in a null ResultHandler and see if the handler returned is null (in which case there is no BEGIN to process), but that seems egregiously ugly. Any thoughts? -- Maciek Sakrejda | Software Engineer | Truviso 1065 E. Hillsdale Blvd., Suite 230 Foster City, CA 94404 (650) 242-3500 Main (650) 242-3501 F www.truviso.com