alexbrainman / odbc

odbc driver written in go
BSD 3-Clause "New" or "Revised" License
348 stars 139 forks source link

Implement QueryerContext interface #173

Open RichardKeo opened 2 years ago

RichardKeo commented 2 years ago

The QueryerContext interface is an optional interface that a Conn can implement. It provides a conn.QueryContext() function that should honour the context passed in, and return when the context is cancelled or times out.

According to the specifications, when this interface is not implemented:

The current implementation neither have a QueryerContext interface not a Queryer one, which means that we fallback to the default behaviour.

The issue we're currently facing is that when we use QueryContext(), we pass in a context with a timeout, and if a query takes longer than desired to execute, the application may end up stuck waiting for the execution to complete and return even though the context has already expired.

Instead, when the context is cancelled or expires, it would be better if we could:

Do you think a contribution towards this would be beneficial?

alexbrainman commented 2 years ago

Thank you for creating this issue.

I don't use context package myself, but other users of github.com/alexbrainman/odbc might use it. So it could be beneficial for them.

You would have to make all code changes yourself. I am happy to review your PR.

Your changes would have to include correspondent tests for new functionality. Most tests are written against MS SQL Server (see mssql_test.go file). If you want to extend these, I should be able to test them.

Thank you.

Alex