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 bf523d1ed fix(go/adbc/sqldriver): ignore NotImplemented errors for
optional transaction options (#3759)
bf523d1ed is described below
commit bf523d1edbaad59306b2319b3e36445248af44b5
Author: Mandukhai Alimaa <[email protected]>
AuthorDate: Mon Dec 8 15:47:24 2025 -0600
fix(go/adbc/sqldriver): ignore NotImplemented errors for optional
transaction options (#3759)
This change adds graceful handling for StatusNotImplemented errors when
setting optional transaction features (isolation level and read-only
mode), allowing transactions to work with drivers that don't implement
these optional features.
---
go/adbc/sqldriver/driver.go | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/go/adbc/sqldriver/driver.go b/go/adbc/sqldriver/driver.go
index 97eb06907..394be6a42 100644
--- a/go/adbc/sqldriver/driver.go
+++ b/go/adbc/sqldriver/driver.go
@@ -217,6 +217,20 @@ func (c *conn) Begin() (driver.Tx, error) {
return nil, &adbc.Error{Code: adbc.StatusNotImplemented}
}
+// setOptionIgnoreNotImplemented sets an option, but ignores
StatusNotImplemented errors
+// since not all drivers support all optional features
+func setOptionIgnoreNotImplemented(setter interface{ SetOption(string, string)
error }, key, value string) error {
+ if err := setter.SetOption(key, value); err != nil {
+ var adbcErr adbc.Error
+ if errors.As(err, &adbcErr) && adbcErr.Code ==
adbc.StatusNotImplemented {
+ // Driver doesn't support this option - continue
without it
+ return nil
+ }
+ return err
+ }
+ return nil
+}
+
func (c *conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx,
error) {
if postopt, ok := c.Conn.(adbc.PostInitOptions); ok {
if err := postopt.SetOption(adbc.OptionKeyAutoCommit,
adbc.OptionValueDisabled); err != nil {
@@ -227,12 +241,12 @@ func (c *conn) BeginTx(ctx context.Context, opts
driver.TxOptions) (driver.Tx, e
return nil, &adbc.Error{Code: adbc.StatusNotImplemented}
}
- if err := postopt.SetOption(adbc.OptionKeyIsolationLevel,
string(isolationLevel)); err != nil {
+ if err := setOptionIgnoreNotImplemented(postopt,
adbc.OptionKeyIsolationLevel, string(isolationLevel)); err != nil {
return nil, err
}
if opts.ReadOnly {
- if err := postopt.SetOption(adbc.OptionKeyReadOnly,
adbc.OptionValueEnabled); err != nil {
+ if err := setOptionIgnoreNotImplemented(postopt,
adbc.OptionKeyReadOnly, adbc.OptionValueEnabled); err != nil {
return nil, err
}
}