From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-jdbc@postgresql.org
Subject: reWriteBatchedInserts=true not working with ON CONFLICT DO UPDATE
Date: Fri, 24 Mar 2017 08:46:33 +0100
Message-ID: <ob2isj$n2o$1@blaine.gmane.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
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: spam_eater@gmx.net
Subject: Re: reWriteBatchedInserts=true not working with ON CONFLICT DO UPDATE
In-Reply-To: <ob2isj$n2o$1@blaine.gmane.org>
References: <ob2isj$n2o$1@blaine.gmane.org>
* 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