Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 6713E20049B for ; Mon, 14 Aug 2017 19:20:05 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 65A7816552F; Mon, 14 Aug 2017 17:20:05 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B45B0165511 for ; Mon, 14 Aug 2017 19:20:04 +0200 (CEST) Received: (qmail 99804 invoked by uid 500); 14 Aug 2017 17:20:03 -0000 Mailing-List: contact notifications-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list notifications@groovy.apache.org Received: (qmail 99758 invoked by uid 99); 14 Aug 2017 17:20:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Aug 2017 17:20:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id ABD86C0331 for ; Mon, 14 Aug 2017 17:20:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id o0FDBGSFkY3D for ; Mon, 14 Aug 2017 17:20:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 6E2A95F245 for ; Mon, 14 Aug 2017 17:20:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id B53DEE002B for ; Mon, 14 Aug 2017 17:20:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 6AE5A21408 for ; Mon, 14 Aug 2017 17:20:00 +0000 (UTC) Date: Mon, 14 Aug 2017 17:20:00 +0000 (UTC) From: "Antoine Kapps (JIRA)" To: notifications@groovy.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (GROOVY-8288) [Sql] withBatch fails when batchSize == number of addBatch call MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 14 Aug 2017 17:20:05 -0000 Antoine Kapps created GROOVY-8288: ------------------------------------- Summary: [Sql] withBatch fails when batchSize == number of addBatch call Key: GROOVY-8288 URL: https://issues.apache.org/jira/browse/GROOVY-8288 Project: Groovy Issue Type: Bug Components: SQL processing Affects Versions: 2.4.12, 2.5.0-beta-1 Reporter: Antoine Kapps {{Sql.withBatch(batchSize, ..)}} calls {{delegate.executeBatch()}} both when batchCount reaches batchSize, and at the end of the method (after the call to the "batch statement" closure). Thus, if {{batchSize}} is exactly the same as the number of {{addBatch()}} calls in the closure, one too much call to {{executeBatch()}} is made : nothing has been added to the batch. Which, at least with HSQLDB 2.4.0, leads to a SQLException on that very last call. Test to reproduce (compliant with SqlBatchTest) {code:java} void testWithBatchSizeHavingSizeSameSizeAsStatements() { def numRows = sql.rows("SELECT * FROM PERSON").size() assert numRows == 3 def myOthers = ['f4':'l4','f5':'l5','f6':'l6','f7':'l7'] def result = sql.withBatch(myOthers.size(), "insert into PERSON (id, firstname, lastname) values (?, ?, ?)") { ps -> myOthers.eachWithIndex { k, v, index -> def id = index + numRows + 1 ps.addBatch(id, k, v) } } assert result == [1] * myOthers.size() assert sql.rows("SELECT * FROM PERSON").size() == numRows + myOthers.size() // end result the same as if no batching was in place but logging should show: // FINE: Successfully executed batch with 4 command(s) } {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)