pgjdbc/pgjdbc GitHub issues and pull requests (mirror)
help / color / mirror / Atom feedFrom: rlbdv (@rlbdv) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: Re: [pgjdbc/pgjdbc] issue #3757: PreparedStatement.toString() fails for bytea parameters with at least 42.7.7
Date: Sun, 10 Aug 2025 23:47:19 +0000
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
I don't know pgjdbc well enough to have a good sense whether this is a plausible fix, but it does appear to resolve the immediate concerns.
In previous pgjdbc releases, a PGobject of type "bytea" and with a "\xHEX" value worked fine. It looks like what's happening now is that the string value is being passed directly to `toPGLiteral`, so this patch just adds a clause to handle it.
```
--- a/pgjdbc/src/main/java/org/postgresql/util/PGbytea.java
+++ b/pgjdbc/src/main/java/org/postgresql/util/PGbytea.java
@@ -182,6 +182,16 @@ public class PGbytea {
* @throws IOException in case there's underflow in the input value
*/
public static String toPGLiteral(Object value, SqlSerializationContext context) throws IOException {
+
+ if (value instanceof String) {
+ String str = (String) value;
+ StringBuilder sb = new StringBuilder(str.length() + 9);
+ sb.append("'");
+ sb.append(str);
+ sb.append("'::bytea");
+ return sb.toString();
+ }
+
if (value instanceof byte[]) {
byte[] bytes = (byte[]) value;
StringBuilder sb = new StringBuilder(bytes.length * 2 + 11);
```
view thread (17+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: github://pgjdbc/pgjdbc
Cc: [email protected], [email protected]
Subject: Re: [pgjdbc/pgjdbc] issue #3757: PreparedStatement.toString() fails for bytea parameters with at least 42.7.7
In-Reply-To: <<[email protected]>>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox