Re: [JDBC] ArrayIndexOutOfBoundsException from ByteConverter.int8when resolving generated keys
От | Vladimir Sitnikov |
---|---|
Тема | Re: [JDBC] ArrayIndexOutOfBoundsException from ByteConverter.int8when resolving generated keys |
Дата | |
Msg-id | CAB=Je-HY760Y=Dhb9rFR0DJquJS0y-cnzXs89-rtd8zgrfnDZg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: [JDBC] ArrayIndexOutOfBoundsException from ByteConverter.int8when resolving generated keys (Vladimir Sitnikov <sitnikov.vladimir@gmail.com>) |
Ответы |
Re: [JDBC] ArrayIndexOutOfBoundsException from ByteConverter.int8when resolving generated keys
Re: ArrayIndexOutOfBoundsException from ByteConverter.int8when resolving generated keys |
Список | 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 по дате отправления: