Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated SimpleParameterList to fix the byte-array - Addresses a bug that caused syntax errors when executing SELECT statements with parameterized byte arrays #3181

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -75,8 +76,17 @@
--index;

encoded[index] = null;
paramValues[index] = value;
flags[index] = (byte) (direction(index) | IN | binary);

Check failure on line 80 in pgjdbc/src/main/java/org/postgresql/core/v3/SimpleParameterList.java

View workflow job for this annotation

GitHub Actions / Code style

Replace 1 line 80..80 with
if (value instanceof byte[]) {
byte[] byteArray = (byte[]) value;
String hexString = new BigInteger(1, byteArray).toString(16);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty sure this isn't going to work

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
Expand Down