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