Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1crJw7-0006SX-AI for pgsql-jdbc@arkaria.postgresql.org; Fri, 24 Mar 2017 07:47:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1crJw6-0002Uc-RV for pgsql-jdbc@arkaria.postgresql.org; Fri, 24 Mar 2017 07:47:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1crJw6-0002UT-IN for pgsql-jdbc@postgresql.org; Fri, 24 Mar 2017 07:47:02 +0000 Received: from [195.159.176.226] (helo=blaine.gmane.org) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1crJw3-0004vy-Q8 for pgsql-jdbc@postgresql.org; Fri, 24 Mar 2017 07:47:01 +0000 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1crJvp-0007pr-G8 for pgsql-jdbc@postgresql.org; Fri, 24 Mar 2017 08:46:45 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-jdbc@postgresql.org From: Thomas Kellerer Subject: reWriteBatchedInserts=true not working with ON CONFLICT DO UPDATE Date: Fri, 24 Mar 2017 08:46:33 +0100 Lines: 37 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@blaine.gmane.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 X-Mozilla-News-Host: news://news.gmane.org:119 X-Host-Lookup-Failed: Reverse DNS lookup failed for 195.159.176.226 (failed) X-Pg-Spam-Score: -0.9 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org When using the new reWriteBatchedInserts=true feature, this fails when using ON CONFLICT DO UPDATE ... Assume the following table: create table testbatch (x integer primary key, y integer) And the following code: pstmt = con.prepareStatement("insert into testbatch (x, y) values (?,?) on conflict (x) do update set y = exluded.y"); pstmt.setInt(1,1); pstmt.setInt(2,1); pstmt.addBatch(); pstmt.setInt(1,2); pstmt.setInt(2,2); pstmt.addBatch(); pstmt.executeBatch(); The executeBatch() fails with: java.sql.BatchUpdateException: Batch entry 0 insert into testbatch (x, y) values (1,1) on conflict (x),(2,2) on conflict (x) do update set y = exluded.y was aborted: ERROR: syntax error at or near "," It seems the rewrite code doesn't take the on conflict clause into account properly. However, it _does_ work correctly with ON CONFLICT DO NOTHING Tested with postgresql-42.0.0.jar Regards Thomas -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc