Обсуждение: Return Codes of BatchUpdateException in PostgreSql 9.6

Поиск
Список
Период
Сортировка

Return Codes of BatchUpdateException in PostgreSql 9.6

От
Tillmann Schulz
Дата:
Hello,

I am migrating PostgreSql 9.5 to 9.6.0 and I am using the newest JDBC driver (9.4.1211.jre6)
So I am not sure if this is an driver issue or a bug in postgres.

We are making batch updates in our Java application.
Our JUnit Tests fail on 9.6 when querying the return code of a partially failed Bulk Update.  In 9.5 everything works
fine.


The following code is used:

    private void handleBatchUpdateException(java.sql.BatchUpdateException  x )
    {
        final int[] updateCounts = x.getUpdateCounts();

==> in 9.5 only ther failed updates have return code  java.sql.Statement.EXECUTE_FAILED = -3.  This is CORRECT.

==> in 9.6 all updatecounts have status  java.sql.Statement.EXECUTE_FAILED = -3. This is NOT CORRECT.


What to do to get this bug fixed? Do you need more information?
Thank you for your response in advance.

Tillmann Schulz

Re: Return Codes of BatchUpdateException in PostgreSql 9.6

От
John R Pierce
Дата:
On 10/12/2016 3:23 AM, Tillmann Schulz wrote:
> I am migrating PostgreSql 9.5 to 9.6.0 and I am using the newest JDBC driver (9.4.1211.jre6)
> So I am not sure if this is an driver issue or a bug in postgres.

since htere's no SQL in your report, I'd suggest its probably a JDBC
issue.   no idea what you mean when you say batch updates... SQL
transactions are all or none, so if any update in a transaction fails,
the whole transaction has to be rolled back.



--
john r pierce, recycling bits in santa cruz

Re: Return Codes of BatchUpdateException in PostgreSql 9.6

От
Tillmann Schulz
Дата:
Hello again,


>>since htere's no SQL in your report, I'd suggest its probably a JDBC
>>issue.

Yes, I am talking about JDBC-Batch-Update funcionallity in Java. So it could be a jdbc driver issue.
Is there a special mailing list for the driver?


>>no idea what you mean when you say batch updates... SQL


I try to give an example.

Preparation, with SQL
-----------------------------

CREATE TABLE TESTTABLE (id INTEGER);

INSERT INTO TESTTABLE VALUES (5);


Java Code with Java JDBC Update
-----------------------------

    for( int i = 0; i < 10;i++ )
    {
        stmt.addBatch("INSERT INTO TESTTABLE VALUES('"+i+"')"    );
        stmt.executeBatch();
        con.commit();
    }
    catch( java.sql.BatchUpdateException x )
    {
        final int[] updateCounts = x.getUpdateCounts();
    }



In the sample, the 6th statement has an error, because the value 5 already exists in the database.


In this case in postgres 9.6 all fields updateCounts[0..9] are -3 (Statement.EXECUTE_FAILED)
The behavior prior 9.6 was, that only the specific entry in updateCounts[5] has the error code -3

I hope this helps,

Tillmann Schulz

Re: Return Codes of BatchUpdateException in PostgreSql 9.6

От
Bruce Momjian
Дата:
On Wed, Oct 12, 2016 at 11:42:53AM +0000, Tillmann Schulz wrote:
> Hello again,
>
>
> >>since htere's no SQL in your report, I'd suggest its probably a JDBC
> >>issue.
>
> Yes, I am talking about JDBC-Batch-Update funcionallity in Java. So it could be a jdbc driver issue.
> Is there a special mailing list for the driver?

Yep, pgsql-jdbc@postgresql.org.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +