duckdb-rs icon indicating copy to clipboard operation
duckdb-rs copied to clipboard

Cannot use `duckdb_interrupt` due to private `InnerConnection`

Open neilyio opened this issue 1 year ago • 0 comments

The Connection hides away the raw duckdb connection object in private fields:

/// A connection to a DuckDB database.
pub struct Connection {
    db: RefCell<InnerConnection>,
    cache: StatementCache,
    path: Option<PathBuf>,
}

InnerConnection contains a ffi::duckdb_connection...

pub struct InnerConnection {
    pub db: ffi::duckdb_database,
    pub con: ffi::duckdb_connection,
    owned: bool,
}

...which is required to call ffi::duckdb_interrupt:

extern "C" {
    #[doc = "Interrupt running query\n\n connection: The connection to interrupt"]
    pub fn duckdb_interrupt(connection: duckdb_connection);
}

There's no way to call duckdb_interrupt (and other ffi functions like it) with a Connection, as we can't access its fields. Exposing a Connection::interrupt() method would be one way around this.

I'm happy to make the contribution if the maintainers can advise on how you would like this implemented.

neilyio avatar Jun 20 '24 02:06 neilyio