From 8af68da806aeaac0e518dec892d6c105e5ff92a8 Mon Sep 17 00:00:00 2001 From: siddeshas07 Date: Tue, 26 Mar 2024 14:28:13 +0530 Subject: [PATCH 1/2] updated SimpleParameterList to fix thebyte-array --- .../org/postgresql/core/v3/SimpleParameterList.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pgjdbc/src/main/java/org/postgresql/core/v3/SimpleParameterList.java b/pgjdbc/src/main/java/org/postgresql/core/v3/SimpleParameterList.java index 9d236d48e5..9f9d84a75d 100644 --- a/pgjdbc/src/main/java/org/postgresql/core/v3/SimpleParameterList.java +++ b/pgjdbc/src/main/java/org/postgresql/core/v3/SimpleParameterList.java @@ -26,6 +26,7 @@ import java.io.IOException; import java.io.InputStream; +import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.sql.SQLException; import java.util.Arrays; @@ -75,8 +76,17 @@ private void bind(int index, Object value, int oid, byte binary) throws SQLExcep --index; encoded[index] = null; - paramValues[index] = value; flags[index] = (byte) (direction(index) | IN | binary); + + if (value instanceof byte[]) { + byte[] byteArray = (byte[]) value; + String hexString = new BigInteger(1, byteArray).toString(16); + paramValues[index] = hexString; // Store hex string representation + } else { + paramValues[index] = value; // Store original value for other data types + } + + // If we are setting something to an UNSPECIFIED NULL, don't overwrite // our existing type for it. We don't need the correct type info to From 8efaf56ea130824b27cf85cff65bc34801397c09 Mon Sep 17 00:00:00 2001 From: siddeshas07 Date: Tue, 26 Mar 2024 17:38:17 +0530 Subject: [PATCH 2/2] changed hexString to byteArray --- .../java/org/postgresql/core/v3/SimpleParameterList.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pgjdbc/src/main/java/org/postgresql/core/v3/SimpleParameterList.java b/pgjdbc/src/main/java/org/postgresql/core/v3/SimpleParameterList.java index 9f9d84a75d..88628de567 100644 --- a/pgjdbc/src/main/java/org/postgresql/core/v3/SimpleParameterList.java +++ b/pgjdbc/src/main/java/org/postgresql/core/v3/SimpleParameterList.java @@ -26,7 +26,6 @@ import java.io.IOException; import java.io.InputStream; -import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.sql.SQLException; import java.util.Arrays; @@ -77,17 +76,14 @@ private void bind(int index, Object value, int oid, byte binary) throws SQLExcep encoded[index] = null; flags[index] = (byte) (direction(index) | IN | binary); - + if (value instanceof byte[]) { byte[] byteArray = (byte[]) value; - String hexString = new BigInteger(1, byteArray).toString(16); - paramValues[index] = hexString; // Store hex string representation + paramValues[index] = byteArray; } else { paramValues[index] = value; // Store original value for other data types } - - // If we are setting something to an UNSPECIFIED NULL, don't overwrite // our existing type for it. We don't need the correct type info to // send this value, and we don't want to overwrite and require a