Skip to content

home_directory won't be set after duplicating a JDBC connection #148

@goldmedal

Description

@goldmedal

What happens?

I attempted to utilize DuckDBConnection#duplicate in order to obtain a new connection. However, I noticed that the home_directory is not set in the duplicated connection. This issue does not arise in other configurations.

To Reproduce

Sample Code:

import org.duckdb.DuckDBConnection;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class JdbcTest
{
    public static void main(String[] args)
    {
        try {
            Connection connection = DriverManager.getConnection("jdbc:duckdb:");
            Statement statement = connection.createStatement();
            statement.execute("set home_directory='/tmp/duckdb'");
            statement.execute("set temp_directory='/tmp/duckdb'");
            statement.execute("select * from duckdb_settings() where name = 'home_directory' or name = 'temp_directory'");
            ResultSet resultSet = statement.getResultSet();
            while (resultSet.next()) {
                System.out.println(resultSet.getString(1));
                System.out.println(resultSet.getString(2));
            }

            Connection duplicate = ((DuckDBConnection) connection).duplicate();
            Statement statement1 = duplicate.createStatement();
            statement1.execute("select * from duckdb_settings() where name = 'home_directory' or name = 'temp_directory'");
            ResultSet resultSet1 = statement1.getResultSet();
            while (resultSet1.next()) {
                System.out.println(resultSet1.getString(1));
                System.out.println(resultSet1.getString(2));
            }

            statement.execute("select * from duckdb_settings() where name = 'home_directory' or name = 'temp_directory'");
            ResultSet resultSet2 = statement.getResultSet();
            while (resultSet2.next()) {
                System.out.println(resultSet2.getString(1));
                System.out.println(resultSet2.getString(2));
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}

STD Output

home_directory
/tmp/duckdb
temp_directory
/tmp/duckdb
home_directory

temp_directory
/tmp/duckdb
home_directory
/tmp/duckdb
temp_directory
/tmp/duckdb

OS:

MacOS

DuckDB Version:

0.9.2

DuckDB Client:

JDBC

Full Name:

Jax Liu

Affiliation:

Canner

Have you tried this on the latest main branch?

I have tested with a release build (and could not test with a main build)

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • Yes, I have

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions