From 608c12c3dbc877a97a99c2bb47f98264badbea32 Mon Sep 17 00:00:00 2001 From: Dewey Dunnington Date: Mon, 23 Oct 2023 10:39:24 -0300 Subject: [PATCH] remove bits that weren't tested --- r/adbcdrivermanager/src/driver_base.h | 42 ++++++--------------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/r/adbcdrivermanager/src/driver_base.h b/r/adbcdrivermanager/src/driver_base.h index cadaac8fd1..c523081a66 100644 --- a/r/adbcdrivermanager/src/driver_base.h +++ b/r/adbcdrivermanager/src/driver_base.h @@ -187,14 +187,15 @@ class ObjectBase { virtual ~ObjectBase() {} - virtual bool OptionKeySupported(const std::string& key, const Option& value) const { - return true; - } - virtual AdbcStatusCode Init(void* parent, AdbcError* error) { return ADBC_STATUS_OK; } virtual AdbcStatusCode Release(AdbcError* error) { return ADBC_STATUS_OK; } + virtual AdbcStatusCode SetOption(const std::string& key, const Option& value) { + options_[key] = value; + return ADBC_STATUS_OK; + } + const Option& GetOption(const std::string& key, const Option& default_value = Option()) const { auto result = options_.find(key); @@ -205,14 +206,7 @@ class ObjectBase { } } - AdbcStatusCode SetOption(const std::string& key, const Option& value) { - if (!OptionKeySupported(key, value)) { - return ADBC_STATUS_NOT_IMPLEMENTED; - } - options_[key] = value; - return ADBC_STATUS_OK; - } private: AdbcDriver* driver_; @@ -222,31 +216,21 @@ class ObjectBase { template friend class Driver; + // The AdbcDriver* struct is set right before Init() is called by the Driver + // trampoline. void set_driver(AdbcDriver* driver) { driver_ = driver; } template AdbcStatusCode CSetOption(const char* key, T value, AdbcError* error) { Option option(value); - AdbcStatusCode status = SetOption(key, option); - if (status == ADBC_STATUS_NOT_IMPLEMENTED) { - InitErrorOptionNotSupported(key, error); - return ADBC_STATUS_NOT_IMPLEMENTED; - } - - return status; + return SetOption(key, option); } AdbcStatusCode CSetOptionBytes(const char* key, const uint8_t* value, size_t length, AdbcError* error) { std::basic_string cppvalue(value, length); Option option(cppvalue); - AdbcStatusCode status = SetOption(key, option); - if (status == ADBC_STATUS_NOT_IMPLEMENTED) { - InitErrorOptionNotSupported(key, error); - return ADBC_STATUS_NOT_IMPLEMENTED; - } - - return status; + return SetOption(key, option); } template @@ -297,14 +281,6 @@ class ObjectBase { cpperror.AddDetail("adbc.r.option_key", key); cpperror.ToAdbc(error, driver_); } - - void InitErrorOptionNotSupported(const char* key, AdbcError* error) const { - std::stringstream msg_builder; - msg_builder << "Option '" << key << "' is not supported"; - Error cpperror(msg_builder.str()); - cpperror.AddDetail("adbc.r.option_key", key); - cpperror.ToAdbc(error, driver_); - } }; class DatabaseObjectBase : public ObjectBase {