aws / aws/amazon-redshift-jdbc-driver

Incorrect result of isNullable for constant values

Open
#144 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
71
Forks
42
PR merge metrics
No merged PRs in 30d

Description

`isNullable` for `SELECT 1` returns 1 (`columnNullable`) instead of 0 (`columnNoNulls`) or 2 (`columnNullableUnknown`).

```java
//DEPS com.amazon.redshift:redshift-jdbc42:2.1.0.34

import java.sql.*;

public class RedshiftDemo {
private static final String DB_URL = System.getenv("REDSHIFT_URL");
private static final String DB_USER = System.getenv("REDSHIFT_USER");
private static final String DB_PASSWORD = System.getenv("REDSHIFT_PASSWORD");

public static void main(String[] args) throws Exception {
try (Connection conn = DriverManager.getConnection(DB_URL, DB_USER, DB_PASSWORD);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT 1, 'hi'")) {

System.out.println("Nullable[1]:" + rs.getMetaData().isNullable(1));
System.out.println("Nullable[2]:" + rs.getMetaData().isNullable(2));
rs.next();
System.out.printf("Query result: %s %s%n", rs.getInt(1), rs.getObject(2));
}
}
}
```

```
Nullable[1]:1
Nullable[2]:1
Query result: 1 hi
```

Contributor guide

Open the contributing guide

Research direction

Run the provided Java JDBC reproduction against Redshift and start at ResultSet.getMetaData().isNullable(). Trace how metadata for the constant columns in SELECT 1, 'hi' is classified. Done means the constant columns return columnNoNulls or columnNullableUnknown instead of columnNullable, with regression coverage for this query.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.