This is an automated email from the ASF dual-hosted git repository.

zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git


The following commit(s) were added to refs/heads/main by this push:
     new b04acdc57 fix(go/adbc/sqldriver): properly close resources (#3731)
b04acdc57 is described below

commit b04acdc57de22e0ed7c277bb567afe62924f7a4c
Author: Matt Topol <[email protected]>
AuthorDate: Wed Nov 19 13:55:19 2025 -0500

    fix(go/adbc/sqldriver): properly close resources (#3731)
    
    fixes #3728
    
    This was a combination of two issues that are fixed in this PR:
    
    1. `sqldriver.Connector` needs to implement the `io.Closer` interface so
    that `sql.DB.Close` will call it and call `Close` on the `adbc.Database`
    object.
    2. `rows.Close` needs to also close the associated `stmt`. In the case
    of at least one driver (the duckdb driver in associated issue) not
    closing the `stmt` led to the handle to the duckdb database not being
    dropped despite calling `Close` on the database.
---
 go/adbc/sqldriver/driver.go | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/go/adbc/sqldriver/driver.go b/go/adbc/sqldriver/driver.go
index ad7e79730..97eb06907 100644
--- a/go/adbc/sqldriver/driver.go
+++ b/go/adbc/sqldriver/driver.go
@@ -104,6 +104,14 @@ func (c *connector) Connect(ctx context.Context) 
(driver.Conn, error) {
 // mainly to maintain compatibility with the Driver method on sql.DB
 func (c *connector) Driver() driver.Driver { return Driver{c.drv} }
 
+// Close closes the underlying database handle that the connector was using.
+//
+// By implementing the io.Closer interface, sql.DB will correctly call
+// Close on the connector when sql.DB.Close is called.
+func (c *connector) Close() error {
+       return c.db.Close()
+}
+
 type Driver struct {
        Driver adbc.Driver
 }
@@ -638,8 +646,10 @@ func (r *rows) Close() error {
 
        r.rdr.Release()
        r.rdr = nil
+
+       err := r.stmt.Close()
        r.stmt = nil
-       return nil
+       return err
 }
 
 func (r *rows) Next(dest []driver.Value) error {

Reply via email to