From e330067303ebaab3caa6300f3cfe93171903796e Mon Sep 17 00:00:00 2001 From: Chris Kirkland Date: Tue, 9 Jul 2024 12:21:30 -0500 Subject: [PATCH 1/2] [Docs] clarify connection close behavior of context Updates the README to make it clear that `go-sql-driver/mysql` closes the current connection of the `context.Context` provided to `ExecContext`, `SelectContext`, etc. is cancelled or times out prior to the query returning. As is, that behavior is not clearly documented. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6c6abf9c4..0ddfc23dc 100644 --- a/README.md +++ b/README.md @@ -519,6 +519,8 @@ This driver supports the [`ColumnType` interface](https://golang.org/pkg/databas Go 1.8 added `database/sql` support for `context.Context`. This driver supports query timeouts and cancellation via contexts. See [context support in the database/sql package](https://golang.org/doc/go1.8#database_sql) for more details. +Importantly, the `SelectContext`, `ExecContext`, etc. variants provided by `database/sql` will cause the connection to be closed if the provided context is cancelled or timed out before the result is received by the driver. + ### `LOAD DATA LOCAL INFILE` support For this feature you need direct access to the package. Therefore you must change the import path (no `_`): From 92ef6f7d3403966cfe040a3f169877aa4d46b794 Mon Sep 17 00:00:00 2001 From: Chris Kirkland Date: Tue, 23 Jul 2024 09:04:13 -0500 Subject: [PATCH 2/2] Update README.md Co-authored-by: Inada Naoki --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0ddfc23dc..c83f4f74f 100644 --- a/README.md +++ b/README.md @@ -519,7 +519,8 @@ This driver supports the [`ColumnType` interface](https://golang.org/pkg/databas Go 1.8 added `database/sql` support for `context.Context`. This driver supports query timeouts and cancellation via contexts. See [context support in the database/sql package](https://golang.org/doc/go1.8#database_sql) for more details. -Importantly, the `SelectContext`, `ExecContext`, etc. variants provided by `database/sql` will cause the connection to be closed if the provided context is cancelled or timed out before the result is received by the driver. +> [!IMPORTANT] +> The `QueryContext`, `ExecContext`, etc. variants provided by `database/sql` will cause the connection to be closed if the provided context is cancelled or timed out before the result is received by the driver. ### `LOAD DATA LOCAL INFILE` support