-
Notifications
You must be signed in to change notification settings - Fork 922
Closed
Milestone
Description
I'm submitting a question about "Tried to send an out-of-range integer as a 2-byte value"
- [ jdbc driver] bug report
- feature request
Introduce
Jdbc execute a long/batch insert sql, like: ```insert into values(?,?,?),(?,?,?),(?,?,?)...```
but client throws an error: "Tried to send an out-of-range integer as a 2-byte value:" ...
When I review the source code, and I find the implementation like below:
Background
Maven pom.xml
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.5</version>
</dependency>
Source Code
[Line: 1442] QueryExecutorImpl.java
// ....
pgStream.sendInteger2(params.getParameterCount());
// ....
[Line: 235] PGStream.java
// ....
public void sendInteger2(int val) throws IOException {
if (val < Short.MIN_VALUE || val > Short.MAX_VALUE) {
throw new IOException("Tried to send an out-of-range integer as a 2-byte value: " + val);
}
_int2buf[0] = (byte) (val >>> 8);
_int2buf[1] = (byte) val;
pg_output.write(_int2buf);
}
....
Describe the issue
A clear and concise description of what the issue is.
I don't know why param count should be greater/equals than Short.MIN_VALUE (-32768)
or less/equals than Short.MAX_VALUE (32767).
When I execute batch sql (especially build lots of columns ),
this error must be occurred. I can not guess the check whether to protect the server side?
I think the jdbc driver client should not limit the length of statement.
We can use MAX_ALLOWED_PACKET parameter which is defined in MySQL server in the server side.
Wait for your response asap !!!
Java Version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
OS Version
Mac OSX
PostgreSQL Version
EnterpriseDB 9.3.17.42 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-55), 64-bit
To Reproduce
Steps to reproduce the behaviour:
Expected behaviour
A clear and concise description of what you expected to happen.
And what actually happens
Logs
If possible PostgreSQL logs surrounding the occurrence of the issue
Additionally logs from the driver can be obtained adding
loggerLevel=TRACE&loggerFile=pgjdbc-trace.log to the connection string
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels