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

BLOB Value Changes After Calling ResultSet.next() #79

Open
EastLord opened this issue Sep 6, 2024 · 0 comments · May be fixed by #103
Open

BLOB Value Changes After Calling ResultSet.next() #79

EastLord opened this issue Sep 6, 2024 · 0 comments · May be fixed by #103

Comments

@EastLord
Copy link

EastLord commented Sep 6, 2024

Environment:

JDBC Driver version: 1.0.0
DuckDB version: v1.0.0 1f98600c2c
OS: macOS 14.6.1

Description:

I encountered an issue with the DuckDB JDBC driver when retrieving BLOB data. After calling the ResultSet.next() method, the value of the BLOB unexpectedly changes. This issue was reproduced using the following Java code.

Steps to Reproduce:

  1. Create a DuckDB database.
  2. Run the following Java code:
import java.io.IOException;
import java.sql.*;

public class TestDuckDBJDBC {

    public static final String JDBC_URL = "jdbc:duckdb:/path/to/database";

    public static void main(String[] args) throws SQLException, IOException {
        Connection conn = DriverManager.getConnection(JDBC_URL);

        Statement stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery("SELECT '\\xAA'::BLOB;");
        // Correct value byte= [-86]
        Blob blob = null;
        while (rs.next()) {
            blob = rs.getBlob(1);
        }

        // But after calling rs.next(), the blob value changes
        System.out.println(new String(blob.getBinaryStream().readAllBytes()));
    }
}

Expected Behavior:

The value of the BLOB should remain the same even after calling ResultSet.next().

Actual Behavior:

The value of the BLOB changes after calling ResultSet.next(). Specifically, the BLOB returns a different value when retrieved through blob.getBinaryStream() after ResultSet.next().

You can adjust the details like versions and paths specific to your case. Let me know if you need any further modifications!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant