From 05e8dd7d603ba5b09ff5b5aee247f664736bc297 Mon Sep 17 00:00:00 2001 From: Anshul Khandelwal Date: Fri, 15 Dec 2023 17:59:23 +0530 Subject: [PATCH] fix defer res.Close() in other places --- runtime/drivers/duckdb/transporter_duckDB_to_duckDB.go | 4 ++-- .../drivers/duckdb/transporter_motherduck_to_duckDB.go | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/runtime/drivers/duckdb/transporter_duckDB_to_duckDB.go b/runtime/drivers/duckdb/transporter_duckDB_to_duckDB.go index 3dccbb0028a..1e8e1331cd0 100644 --- a/runtime/drivers/duckdb/transporter_duckDB_to_duckDB.go +++ b/runtime/drivers/duckdb/transporter_duckDB_to_duckDB.go @@ -117,11 +117,11 @@ func (t *duckDBToDuckDB) transferFromExternalDB(ctx context.Context, srcProps *d var localDB, localSchema string for res.Next() { if err := res.Scan(&localDB, &localSchema); err != nil { - res.Close() + _ = res.Close() return err } } - res.Close() + _ = res.Close() // duckdb considers everything before first . as db name // alternative solution can be to query `show databases()` before and after to identify db name diff --git a/runtime/drivers/duckdb/transporter_motherduck_to_duckDB.go b/runtime/drivers/duckdb/transporter_motherduck_to_duckDB.go index b481c57509d..20d32d4cbc7 100644 --- a/runtime/drivers/duckdb/transporter_motherduck_to_duckDB.go +++ b/runtime/drivers/duckdb/transporter_motherduck_to_duckDB.go @@ -61,13 +61,15 @@ func (t *motherduckToDuckDB) Transfer(ctx context.Context, srcProps, sinkProps m if err != nil { return err } - defer res.Close() - res.Next() var localDB, localSchema string - if err := res.Scan(&localDB, &localSchema); err != nil { - return err + for res.Next() { + if err := res.Scan(&localDB, &localSchema); err != nil { + _ = res.Close() + return err + } } + _ = res.Close() // get token token, _ := config["token"].(string)