pgjdbc/pgjdbc GitHub issues and pull requests (mirror)
help / color / mirror / Atom feed[pgjdbc/pgjdbc] issue #3743: Retrieving the result set from the multi-dimensional array will get an error in binary mode.
5+ messages / 2 participants
[nested] [flat]
* [pgjdbc/pgjdbc] issue #3743: Retrieving the result set from the multi-dimensional array will get an error in binary mode.
@ 2025-07-28 13:30 "sly461 (@sly461)" <[email protected]>
0 siblings, 0 replies; 5+ messages in thread
From: sly461 (@sly461) @ 2025-07-28 13:30 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
Please read https://stackoverflow.com/help/minimal-reproducible-example
**Describe the issue**
I'm trying to use a three-dimensional array. However, I found that I can retrieve the result set normally in regular mode, but an error occurs **in binary mode**.
**Driver Version?**
42.7.7
**Java Version?**
java 21
**OS Version?**
Windows 10
**PostgreSQL Version?**
PostgreSQL 14.18
**To Reproduce**
Steps to reproduce the behaviour:
```
import java.sql.*;
import java.util.Properties;
public class TestMultiDimensionalArrayRetrieveResultSets {
public static void main(String []args) throws Exception {
String url = "jdbc:postgresql://localhost:5432/test";
Properties props = new Properties();
props.setProperty("user", "test");
props.setProperty("password", "test");
// forceBinary
props.setProperty("prepareThreshold", "-1");
Connection conn = DriverManager.getConnection(url, props);
Statement stmt = conn.createStatement();
stmt.execute("DROP TABLE IF EXISTS TestArray");
stmt.execute("CREATE TABLE TestArray(intarr int[])");
stmt.execute("INSERT INTO TestArray VALUES ('{{{0},{1}},{{2},{3}},{{4},{5}}}')");
ResultSet rs = stmt.executeQuery("SELECT intarr FROM TestArray");
rs.next();
// {{{0},{1}},{{2},{3}},{{4},{5}}}
Array arr = rs.getArray(1);
ResultSet arrrs = arr.getResultSet();
arrrs.next();
// {{0},{1}}
Array arr1 = arrrs.getArray(2);
ResultSet arr1rs = arr1.getResultSet();
arr1rs.next();
// {0}
Array arr11 = arr1rs.getArray(2);
ResultSet arr11rs = arr11.getResultSet();
arr11rs.next();
System.out.println(arr11rs.getInt(2));
arr11rs.next();
arr11rs.close();
arr1rs.next();
// {1}
Array arr12 = arr1rs.getArray(2);
ResultSet arr12rs = arr12.getResultSet();
arr12rs.next();
System.out.println(arr12rs.getInt(2));
arr12rs.next();
arr12rs.close();
arr1rs.next();
arr1rs.close();
}
}
```
**Expected behaviour**
I expected to be able to retrieve the values in a three-dimensional array, but it actually got an error **in binary mode**:
```
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: arraycopy: last source index 33554459 out of bounds for byte[84]
at java.base/java.lang.System.arraycopy(Native Method)
at org.postgresql.jdbc.PgArray.storeValues(PgArray.java:275)
at org.postgresql.jdbc.PgArray.readBinaryResultSet(PgArray.java:205)
at org.postgresql.jdbc.PgArray.getResultSetImpl(PgArray.java:374)
at org.postgresql.jdbc.PgArray.getResultSet(PgArray.java:336)
at org.postgresql.test.TestMultiDimensionalArrayRetrieveResultSets.main(TestMultiDimensionalArrayRetrieveResultSets.java:25)
```
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [pgjdbc/pgjdbc] issue #3743: Retrieving the result set from the multi-dimensional array will get an error in binary mode.
@ 2025-07-29 08:25 ` "sly461 (@sly461)" <[email protected]>
3 siblings, 0 replies; 5+ messages in thread
From: sly461 (@sly461) @ 2025-07-29 08:25 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
Hi @davecramer @vlsi
I've found the bug and fixed it in #3746
Please review the code, thx :-)
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [pgjdbc/pgjdbc] issue #3743: Retrieving the result set from the multi-dimensional array will get an error in binary mode.
@ 2025-07-29 10:32 ` "davecramer (@davecramer)" <[email protected]>
3 siblings, 0 replies; 5+ messages in thread
From: davecramer (@davecramer) @ 2025-07-29 10:32 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
why 2 PR's ?
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [pgjdbc/pgjdbc] issue #3743: Retrieving the result set from the multi-dimensional array will get an error in binary mode.
@ 2025-07-29 10:46 ` "sly461 (@sly461)" <[email protected]>
3 siblings, 0 replies; 5+ messages in thread
From: sly461 (@sly461) @ 2025-07-29 10:46 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
> why 2 PR's ?
@davecramer Sorry, I accidentally closed the first PR, please refer to the second PR #3746
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [pgjdbc/pgjdbc] issue #3743: Retrieving the result set from the multi-dimensional array will get an error in binary mode.
@ 2025-07-29 11:02 ` "davecramer (@davecramer)" <[email protected]>
3 siblings, 0 replies; 5+ messages in thread
From: davecramer (@davecramer) @ 2025-07-29 11:02 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
You can re-open them. No worries
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2025-07-29 11:02 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-07-28 13:30 [pgjdbc/pgjdbc] issue #3743: Retrieving the result set from the multi-dimensional array will get an error in binary mode. "sly461 (@sly461)" <[email protected]>
2025-07-29 08:25 ` "sly461 (@sly461)" <[email protected]>
2025-07-29 10:32 ` "davecramer (@davecramer)" <[email protected]>
2025-07-29 10:46 ` "sly461 (@sly461)" <[email protected]>
2025-07-29 11:02 ` "davecramer (@davecramer)" <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox