Message-ID: From: "MrEasy (@MrEasy)" To: "pgjdbc/pgjdbc" Date: Mon, 26 Aug 2024 08:54:54 +0000 Subject: [pgjdbc/pgjdbc] issue #3365: EOFException on PreparedStatement#toString with unset bytea parameter since 42.7.4 List-Id: X-GitHub-Author-Id: 475403 X-GitHub-Author-Login: MrEasy X-GitHub-Issue: 3365 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-State: closed X-GitHub-Type: issue X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/3365 Content-Type: text/plain; charset=utf-8 **Description** After update from 42.7.3 to 42.7.4 we experienced a regression, which showed-up the error pasted below. Looking into it, this seems to be a side-effect of fixing https://github.com/pgjdbc/pgjdbc/issues/3169 Scenario: - Table with column of type ``bytea``. - Creating a PreparedStamtent, e.g. ``PreparedStatement ps = connection.prepareStatement("INSERT INTO tTable VALUES (?,?)");`` - Invoking a ``ps.toString();`` on the PreparedStatement object without having set the bind variables then shows error below. Seems the parameters are tried to get accessed despite not being set [(code location)](https://github.com/pgjdbc/pgjdbc/blame/master/pgjdbc/src/main/java/org/postgresql/core/v3/SimpleParameterList.java#L251) **Driver Version** 42.7.4 **Java Version** 21.0.4 (probably not related to the issue) **PostgreSQL Version** 13.6 (probably not related to the issue) **Logs** ``` org.postgresql.util.PSQLException: Unable to convert bytea parameter at position 0 to literal at org.postgresql.core.v3.SimpleParameterList.toString(SimpleParameterList.java:262) ~[?:?] at org.postgresql.core.NativeQuery.toString(NativeQuery.java:58) ~[?:?] at org.postgresql.core.v3.SimpleQuery.toString(SimpleQuery.java:58) ~[?:?] at org.postgresql.jdbc.PgPreparedStatement.toString(PgPreparedStatement.java:1081) ~[?:?] at java.lang.String.valueOf(String.java:4465) ~[?:?] at some.code.doing.PreparedStatementToString.toString(PreparedStatementToString.java:111) ~[?:?] ... Caused by: java.io.EOFException: Premature end of input stream, expected 1,057 bytes, but only read 0. at org.postgresql.util.PGbytea.toPGLiteral(PGbytea.java:199) ~[?:?] at org.postgresql.core.v3.SimpleParameterList.toString(SimpleParameterList.java:253) ~[?:?] ... 102 more ```