Collection of small fixes to binary transfer code and unit tests - Mailing list pgsql-jdbc

From Mikko Tiihonen
Subject Collection of small fixes to binary transfer code and unit tests
Date
Msg-id 4E836AB2.9030201@nitorcreations.com
Whole thread Raw
Responses Re: Collection of small fixes to binary transfer code and unit tests
List 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

pgsql-jdbc by date:

Previous
From: Benson Margulies
Date:
Subject: setBlob(InputStream) not supported?
Next
From: Dave Cramer
Date:
Subject: Re: Collection of small fixes to binary transfer code and unit tests