Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kdDC6-00038e-Va for pgsql-jdbc@arkaria.postgresql.org; Thu, 12 Nov 2020 14:03:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kdDC5-0007yx-Ro for pgsql-jdbc@arkaria.postgresql.org; Thu, 12 Nov 2020 14:03:21 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kdDC5-0007yq-Kt for pgsql-jdbc@lists.postgresql.org; Thu, 12 Nov 2020 14:03:21 +0000 Received: from out-20.smtp.github.com ([192.30.252.203]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kdDBy-0006jy-VY for pgsql-jdbc@lists.postgresql.org; Thu, 12 Nov 2020 14:03:20 +0000 Received: from github.com (hubbernetes-node-983ed7a.va3-iad.github.net [10.48.118.64]) by smtp.github.com (Postfix) with ESMTPA id CC3CFE1E51 for ; Thu, 12 Nov 2020 06:03:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=github.com; s=pf2014; t=1605189793; bh=YWH9hg6q2LcD56MKMYHJB0TULInItMLJPa5ZtjBQWyw=; h=Date:From:To:Subject:From; b=JAIOo/PvTcWgmrzw4VxhxDuFEvVj35WxVLNSqNdD7/IHAfBc9EuyL12tXz2aBHVvV z3GrPjez1+7k1joDWKz3dGKdA7huHnVlrbxpd5UOtkM8DsgDfferQwwLW2AYjqp8rk 64fxm2lv4zxabGz//2E6XVP8bOG2hmVZ7kEBDIlA= Date: Thu, 12 Nov 2020 06:03:13 -0800 From: Sehrope Sarkuni To: pgsql-jdbc@lists.postgresql.org Message-ID: Subject: [pgjdbc/pgjdbc] dbb30a: Fix PGCopyOutputStream out of order writes (#1854) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Approved: 58GruLoMopuc X-GitHub-Recipient-Address: pgsql-jdbc@lists.postgresql.org X-Auto-Response-Suppress: All List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Branch: refs/heads/master Home: https://github.com/pgjdbc/pgjdbc Commit: dbb30af18e2dccb6e49040dd3108245935605340 https://github.com/pgjdbc/pgjdbc/commit/dbb30af18e2dccb6e49040dd3108245935605340 Author: Sehrope Sarkuni Date: 2020-11-12 (Thu, 12 Nov 2020) Changed paths: M pgjdbc/src/main/java/org/postgresql/copy/PGCopyOutputStream.java M pgjdbc/src/test/java/org/postgresql/test/TestUtil.java M pgjdbc/src/test/java/org/postgresql/test/jdbc2/CopyTest.java Log Message: ----------- Fix PGCopyOutputStream out of order writes (#1854) * test: Add TestUtil.queryForString(...) helper Adds a helper method to execute a query and reads a single text column as a string. * test: Add failing test for interleaved usage of PGCopyOutputStream APIs Adds a failing test that writes to a PGCopyOutputStream using both the write(byte[]) and write(ByteStreamWriter) APIs to catch internal buffering breaking the order. * fix: Flush PGCopyOutputStream internal buffer before writing via ByteStreamWriter Fixes out of order writes when interleaving writes using buffered write(byte[]) and writeToCopy(ByteStreamWriter) APIs.