Re: [JDBC] ArrayIndexOutOfBoundsException from ByteConverter.int8when resolving generated keys - Mailing list pgsql-jdbc

From Vladimir Sitnikov
Subject Re: [JDBC] ArrayIndexOutOfBoundsException from ByteConverter.int8when resolving generated keys
Date
Msg-id CAB=Je-HY760Y=Dhb9rFR0DJquJS0y-cnzXs89-rtd8zgrfnDZg@mail.gmail.com
Whole thread Raw
In response to Re: [JDBC] ArrayIndexOutOfBoundsException from ByteConverter.int8when resolving generated keys  (Vladimir Sitnikov <sitnikov.vladimir@gmail.com>)
Responses Re: [JDBC] ArrayIndexOutOfBoundsException from ByteConverter.int8when resolving generated keys  (Dave Cramer <pg@fastcrypt.com>)
Re: ArrayIndexOutOfBoundsException from ByteConverter.int8when resolving generated keys  (Dave Cramer <pg@fastcrypt.com>)
List pgsql-jdbc
Here's the case:
1) Execute "insert" via non-batch multiple times. This causes pgjdbc to server-prepare the insert and use binary transfer for the generated keys.
Note: so far so good, it is perfectly fine.
2) Execute the same SQL via batch API. Here things break. Batch-insert wants generated keys in text format (there's QUERY_NO_BINARY_TRANSFER flag exactly for that case), and it does ask backend to send the data in text format. However, query metadata at pgjdbc side specify that "output columns are in binary format", thus generated keys resultset tries to access columns as binary and fails.

So possible workarounds are:
WA1) Add special marker (that is a comment) to batch SQL. That will make sure batch-insert uses its own statement.
WA2) mark INT8 as text-only. It is something like binaryTransferDisable=INT8 connection property

Vladimir

ср, 10 мая 2017 г. в 14:37, Vladimir Sitnikov <sitnikov.vladimir@gmail.com>:
Erko>2) There was a similar problem discussed in 2012, which ended with an explanation: https://www.postgresql.org/message-id/alpine.BSO.2.00.1211081338240.29600%40leary.csoft.net

I though "text-binary" flip might cause issue here. bigserial is an alias for int8, and int8 binary representation is 8 bytes always.

Erko, if you file a pull request https://github.com/pgjdbc/pgjdbc with a test case, then it would get executed and we'll know if the issue is still there and/or which DB versions are affected.

Vladimir

pgsql-jdbc by date:

Previous
From: Vladimir Sitnikov
Date:
Subject: Re: ArrayIndexOutOfBoundsException from ByteConverter.int8when resolving generated keys
Next
From: Dave Cramer
Date:
Subject: Re: [JDBC] ArrayIndexOutOfBoundsException from ByteConverter.int8when resolving generated keys