File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -527,8 +527,9 @@ shared_ptr<DuckDBPyConnection> DuckDBPyConnection::ExecuteMany(const py::object
527527 }
528528 // Set the internal 'result' object
529529 if (query_result) {
530- auto py_result = make_shared_ptr<DuckDBPyResult>(std::move (query_result));
531- con.SetResult (CreateRelation (std::move (py_result)));
530+ // Don't use CreateRelation here — the result is stored inside the connection,
531+ // so setting connection_owner would create a ref cycle (connection → result → connection).
532+ con.SetResult (make_uniq<DuckDBPyRelation>(make_shared_ptr<DuckDBPyResult>(std::move (query_result))));
532533 }
533534
534535 return shared_from_this ();
@@ -727,8 +728,9 @@ shared_ptr<DuckDBPyConnection> DuckDBPyConnection::Execute(const py::object &que
727728
728729 // Set the internal 'result' object
729730 if (res) {
730- auto py_result = make_shared_ptr<DuckDBPyResult>(std::move (res));
731- con.SetResult (CreateRelation (std::move (py_result)));
731+ // Don't use CreateRelation here — the result is stored inside the connection,
732+ // so setting connection_owner would create a ref cycle (connection → result → connection).
733+ con.SetResult (make_uniq<DuckDBPyRelation>(make_shared_ptr<DuckDBPyResult>(std::move (res))));
732734 }
733735 return shared_from_this ();
734736}
You can’t perform that action at this time.
0 commit comments