reWriteBatchedInserts=true not working with ON CONFLICT DO UPDATE

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: reWriteBatchedInserts=true not working with ON CONFLICT DO UPDATE
Date: 2017-03-24 07:46:33
Message-ID: ob2isj$n2o$1@blaine.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

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

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2017-03-24 15:44:19 Re: Interest in allowing caller to push binary data rather than having it pulled?
Previous Message Daniel Migowski 2017-03-23 21:59:23 [pgjdbc/pgjdbc] a7e0c8: feat: improve waiting for notifications by providi...