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

Fix JdbcRecordCursor.isNull for types mapped to slice #5711

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,15 @@ default Class<?> getJavaType()

Slice readSlice(ResultSet resultSet, int columnIndex)
throws SQLException;

@Override
default boolean isNull(ResultSet resultSet, int columnIndex)
throws SQLException
{
// JDBC is kind of dumb: we need to read the field and then ask
// if it was null, which means we are wasting effort here.
// We could save the result of the field access if it matters.
resultSet.getString(columnIndex);
Copy link
Member

Choose a reason for hiding this comment

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

I do not see a reason why resultSet.getString() should be better than resultSet.getObject().
The code is redundant and can easily be accidentally removed with a refactor.
Can we have a test for this?

Also, if this is cockrach specific behavior, the correct approach is to provide SliceReadFunction and implement isNull for that case.

return resultSet.wasNull();
}
}