Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bubL6-0007LN-Mb for pgsql-jdbc@arkaria.postgresql.org; Thu, 13 Oct 2016 08:26:09 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bubL6-0002tm-5p for pgsql-jdbc@arkaria.postgresql.org; Thu, 13 Oct 2016 08:26:08 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bubKb-0002FU-1a for pgsql-jdbc@postgresql.org; Thu, 13 Oct 2016 08:25:37 +0000 Received: from nm37-vm3.bullet.mail.ir2.yahoo.com ([212.82.97.144]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bubKY-0003bO-CC for pgsql-jdbc@postgresql.org; Thu, 13 Oct 2016 08:25:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s2048; t=1476347131; bh=ONmcNdahGKJknpZdor8rrvuPsS7SYaagihN+SCY50M4=; h=Date:From:Reply-To:To:Subject:References:From:Subject; b=Dy3Da+LAovri7hsaklL9kdzclTF20Zlu7HIjGIRrmVCabXgzV9EA5wn32Fm3c8oRu7L/aoPSlrmMopIbqgjdTc0FtNSKRPA+wwxPVjw1K7nNEwNo+1G63IaP4/sPL0d0qzFm3YIO8SnEjFmp/sTAzPv0v/aiZuUjrxaR9gE5hrART8oyY7+sFfkXtYQuwm4Gys8zhaM63pWSgdxWWKGFYhmdmbMp+nm3D2fRUjYeq8jtMlMFVEyHHWfhY9An0c12PW5YYx0WFYynV7+RUXx9L3GDvY1vhdEoNv+aWjVuRC3J32NAxXfauVFcZ6vy1wAcrlosgqp9H0uh4docly1NJA== Received: from [212.82.98.58] by nm37.bullet.mail.ir2.yahoo.com with NNFMP; 13 Oct 2016 08:25:31 -0000 Received: from [212.82.98.81] by tm11.bullet.mail.ir2.yahoo.com with NNFMP; 13 Oct 2016 08:25:31 -0000 Received: from [127.0.0.1] by omp1018.mail.ir2.yahoo.com with NNFMP; 13 Oct 2016 08:25:31 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 712348.20025.bm@omp1018.mail.ir2.yahoo.com X-YMail-OSG: LauTQfEVM1mQlrzF.c0QbuGuW8Fhcl3BiPNKvuaFjVASc4dJeBgZsLoi08lwl6u aq0cVk07AvDZ3GO.wdrKHZ7zwkV9lL1ShldPXXXokRPG7V1KQ7IBxgbwuNF80jAYEALSGQjerHyv CJLVbWJxldXb9BEqU9Hz7EkluVCLYt2lXqkbkHPSJfcwnXRehqPLYWSYgqN_TDznfs7fN3PYtX4R Uhz.ezq.ZkEq5mRVP41O.a8plpnYbvySOzDrYsOOiyNPkZ20WguPGH8qEpa58H32KSUwscO0Jqxk JYY8_GiOKzKiu7OIel6MPvjJFylacw1CEF9yIzP3I4y8jfl1depLGLrNiOwdW2gsXU8QuGi0nEdO bvHGnjrZZL9_CQXoSzC2K9cHVHFeJvPXBlRKbOG7OPBZ0DBRQPiTiGeUJJ3JmXeOQKNB4AFXGH0o 2vX2KILCPl_VWxihZfmSwAV31YH3wEZMU9Utldl6GpY1lUeYuTOUJXzSU67B76hMtpveWQECTeiT VZUD1jBN3JPcwrLoanSY- Received: from jws700048.mail.ir2.yahoo.com by sendmailws107.mail.ir2.yahoo.com; Thu, 13 Oct 2016 08:25:31 +0000; 1476347131.342 Date: Thu, 13 Oct 2016 08:25:24 +0000 (UTC) From: Tillmann Schulz Reply-To: Tillmann Schulz To: "pgsql-jdbc@postgresql.org" Message-ID: <614642043.9384313.1476347124138@mail.yahoo.com> Subject: Return Codes of BatchUpdateException in PostgreSql 9.6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit References: <614642043.9384313.1476347124138.ref@mail.yahoo.com> Content-Length: 1478 X-Pg-Spam-Score: -2.2 (--) 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 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 Batch Update. If a statement of a batch update fails, all updateCounts are marked as failed. In 9.5 everything works fine. I try to give an example: Preparation, with SQL ----------------------------- create table TESTTABLE(id integer PRIMARY KEY) ; INSERT INTO TESTTABLE VALUES (5); Java Code with Java JDBC Update ----------------------------- try{ 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 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. } 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 Thank you for your help Tillmann Schulz -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc