Collection of small fixes to binary transfer code and unit tests

From: Mikko Tiihonen <mikko(dot)tiihonen(at)nitorcreations(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Collection of small fixes to binary transfer code and unit tests
Date: 2011-09-28 18:42:58
Message-ID: 4E836AB2.9030201@nitorcreations.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi,

I just tried to run the unit tests with forcebinary=true and preparethreshold=1 and got 10 new failures.
Of them 3 are real bugs (corner cases, but still bugs), rest are just problems in tests.

So here are some patches to fix them:

binary-force-harder-tests.patch
- forces prepare threshold to 1 when forcebinary=true and thus makes the bugs visible

binary-fix-some-serverprepared-tests-with-force.patch
- the previous patch forcing prepare threshold of 1 breaks 2 tests that test disabling of preparethreshold
- just skip part of the tests when forcebinary=true

binary-fix-maxfieldlength-test.patch
- test used getBytes on integer field which returns different bytes for txt vs bin transfers
- fixes the unit test to cope with both bin and txt encoding

binary-fix-date-infinity.patch (bug)
- the backend sends a smaller infinity value for DATE than TIMESTAMP fields (4 bytes vs 8 bytes)
- to ensure compatibility with text protocol convert smaller infinity values
to larger infinity values when receiving DATE from backend

binary-fix-arrays-with-zero-dimensions.patch (bug)
- the new binary code for arrays did not handle arrays with dimension of zero
- fix it and add a new test case for array.getResultSet()

binary-fix-batch-with-generated-keys.patch (bug)
- when executing batch with generated keys returned for each insert the same
Query object is shared by the statements, and along with it the field definitions
- when the prepare threshold is exceeded during the batch execution the first
row of generated keys return text values and latter rows binary values
- to fix we detect the situation and force a separate describe round-trip when
batch is about to exceed the prepare threshold limit so that all generated
in the same result set will be binary

binary-fix-timezonetests.patch
- based on my patch from 2007 to make the timezonetests 'fair' so that binary transfer has a chance of passing them
- some tests in TimezoneTest never actually exercised the correct code paths because they just used getString which
just returns the text from the server and does not cause the jdbc driver to try to parse the output
- it is not possible in binary transfer mode for the jdbc driver to generate the exactly same getString output for
all time values than what the server does - instead it uses the toString() method of the official java.sql classes
- fixes the testSetTimestampOnTime, testSetTimestamp, testSetDate, testSetTime to use proper getTime/getTimestamp
etc methods when fetching columns instead of relying on the getString
- also changes the code verifying that inserts worked correctly to request the server for the actual values in the
database casted to text type so that both binary and text transfer get the same results

-Mikko

Attachment Content-Type Size
binary-force-harder-tests.patch text/plain 707 bytes
binary-fix-some-serverprepared-tests-with-force.patch text/plain 1.4 KB
binary-fix-maxfieldlength-test.patch text/plain 848 bytes
binary-fix-date-infinity.patch text/plain 1.7 KB
binary-fix-arrays-with-zero-dimensions.patch text/plain 2.1 KB
binary-fix-batch-with-generated-keys.patch text/plain 4.3 KB
binary-fix-timezonetests.patch text/plain 23.2 KB

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2011-09-29 11:53:23 Re: Collection of small fixes to binary transfer code and unit tests
Previous Message Benson Margulies 2011-09-28 11:34:49 setBlob(InputStream) not supported?