-
Notifications
You must be signed in to change notification settings - Fork 831
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
feat: support getObject(int, byte[].class) for bytea #3274
base: master
Are you sure you want to change the base?
Conversation
@@ -3875,6 +3875,13 @@ public void updateArray(String columnName, @Nullable Array x) throws SQLExceptio | |||
throw new PSQLException(GT.tr("conversion to {0} from {1} not supported", type, getPGType(columnIndex)), | |||
PSQLState.INVALID_PARAMETER_VALUE); | |||
} | |||
} else if (type == byte[].class) { | |||
if (sqlType == Types.BINARY) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about Types.VARBINARY
, Types.LONGVARBINARY
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about it, but decided against because Blob only checks for BINARY. Besides, sqlType here is what PG thinks is appropriate for BYTEA, its not a user input, so actually it should never (?) be multiple values.
Do you think other *BINARY values are needed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If someone stored VARBINARY
or LONGVARBINARY
the driver still needs to be able to handle it
PreparedStatement insertPS = conn.prepareStatement(TestUtil.insertSQL("table1", "bytea_column", "?")); | ||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WDYT of try-with-resources
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, will do, I just copy-pasted Blob test )
@Test | ||
void getBytea() throws SQLException { | ||
Statement stmt = conn.createStatement(); | ||
conn.setAutoCommit(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why autoCommit
modification is needed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, its still copy-paste from getBlob(), but AFAIK without it the select statement could take too much memory: https://postgrespro.ru/list/thread-id/2502309
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but you should never run out of memory in this test.
*/ | ||
@Test | ||
void getBytea() throws SQLException { | ||
Statement stmt = conn.createStatement(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WDYT of moving the declaration of stmt
closer to its usage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
The change looks good to me, however I wonder:
|
insertPS.setBytes(1, data); | ||
insertPS.executeUpdate(); | ||
} finally { | ||
insertPS.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please use try with resources. We are now trying to move all new code to that style
Ok, I think I fixed all comments. |
New Feature Submissions:
yes
./gradlew styleCheck
pass ?yes
I did, though they weren't
Changes to Existing Features:
no
see Feature: please support getObject(int, byte[].class) for bytea #3269
yes
yes
All Submissions:
yes
yes