From 9723ac5036e5d58b283b22d071d3bef840f6d0f5 Mon Sep 17 00:00:00 2001 From: Elon Azoulay Date: Tue, 20 Oct 2020 10:55:16 -0700 Subject: [PATCH] Fix JdbcRecordCursor.isNull for types mapped to slice This fixes an issue when the postgresql plugin is used to connect to cockroachdb: https://go.crdb.dev/issue-v/40195/v20.1 --- .../io/prestosql/plugin/jdbc/SliceReadFunction.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/SliceReadFunction.java b/presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/SliceReadFunction.java index 82b9aea81a3d..ba9fcaae9a2e 100644 --- a/presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/SliceReadFunction.java +++ b/presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/SliceReadFunction.java @@ -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); + return resultSet.wasNull(); + } }