MXS-2304 Add contains() to test if a parameter exists
Replaces uses of config_get_param() in modules either with contains() or get_string(). The config_get_param() is moved to internal headers, as it allows seeing inside a config setting.
This commit is contained in:
7
server/modules/filter/cache/cachefilter.cc
vendored
7
server/modules/filter/cache/cachefilter.cc
vendored
@ -377,11 +377,10 @@ bool CacheFilter::process_params(MXS_CONFIG_PARAMETER* ppParams, CACHE_CONFIG& c
|
||||
|
||||
config.rules = ppParams->get_c_str_copy("rules");
|
||||
|
||||
const MXS_CONFIG_PARAMETER* pParam = config_get_param(ppParams, "storage_options");
|
||||
|
||||
if (pParam)
|
||||
string storage_options = ppParams->get_string("storage_options");
|
||||
if (!storage_options.empty())
|
||||
{
|
||||
config.storage_options = MXS_STRDUP(pParam->value);
|
||||
config.storage_options = MXS_STRDUP(storage_options.c_str());
|
||||
|
||||
if (config.storage_options)
|
||||
{
|
||||
|
@ -618,32 +618,32 @@ static MXS_FILTER* createInstance(const char* name, MXS_CONFIG_PARAMETER* params
|
||||
MXS_ABORT_IF_NULL(my_instance->obj_trg);
|
||||
}
|
||||
|
||||
MXS_CONFIG_PARAMETER* p = config_get_param(params, "logging_source_user");
|
||||
std::string value = params->get_string("logging_source_user");
|
||||
|
||||
if (p && my_instance->src_trg)
|
||||
if (!value.empty() && my_instance->src_trg)
|
||||
{
|
||||
my_instance->src_trg->user = parse_optstr(p->value, ",", &my_instance->src_trg->usize);
|
||||
my_instance->src_trg->user = parse_optstr(value.c_str(), ",", &my_instance->src_trg->usize);
|
||||
}
|
||||
|
||||
p = config_get_param(params, "logging_source_host");
|
||||
value = params->get_string("logging_source_host");
|
||||
|
||||
if (p && my_instance->src_trg)
|
||||
if (!value.empty() && my_instance->src_trg)
|
||||
{
|
||||
my_instance->src_trg->host = parse_optstr(p->value, ",", &my_instance->src_trg->hsize);
|
||||
my_instance->src_trg->host = parse_optstr(value.c_str(), ",", &my_instance->src_trg->hsize);
|
||||
}
|
||||
|
||||
p = config_get_param(params, "logging_schema");
|
||||
value = params->get_string("logging_schema");
|
||||
|
||||
if (p && my_instance->shm_trg)
|
||||
if (!value.empty() && my_instance->shm_trg)
|
||||
{
|
||||
my_instance->shm_trg->objects = parse_optstr(p->value, ",", &my_instance->shm_trg->size);
|
||||
my_instance->shm_trg->objects = parse_optstr(value.c_str(), ",", &my_instance->shm_trg->size);
|
||||
}
|
||||
|
||||
p = config_get_param(params, "logging_object");
|
||||
value = params->get_string("logging_object");
|
||||
|
||||
if (p && my_instance->obj_trg)
|
||||
if (!value.empty() && my_instance->obj_trg)
|
||||
{
|
||||
my_instance->obj_trg->objects = parse_optstr(p->value, ",", &my_instance->obj_trg->size);
|
||||
my_instance->obj_trg->objects = parse_optstr(value.c_str(), ",", &my_instance->obj_trg->size);
|
||||
}
|
||||
|
||||
my_instance->use_ssl = my_instance->ssl_client_cert
|
||||
|
@ -94,11 +94,11 @@ void Avro::read_source_service_options(SERVICE* source)
|
||||
Avro* Avro::create(SERVICE* service, SRowEventHandler handler)
|
||||
{
|
||||
SERVICE* source_service = NULL;
|
||||
MXS_CONFIG_PARAMETER* param = config_get_param(service->svc_config_param, "source");
|
||||
std::string source_name = service->svc_config_param->get_string("source");
|
||||
|
||||
if (param)
|
||||
if (!source_name.empty())
|
||||
{
|
||||
SERVICE* source = service_find(param->value);
|
||||
SERVICE* source = service_find(source_name.c_str());
|
||||
mxb_assert(source);
|
||||
|
||||
if (source)
|
||||
@ -119,7 +119,7 @@ Avro* Avro::create(SERVICE* service, SRowEventHandler handler)
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_ERROR("Service '%s' not found.", param->value);
|
||||
MXS_ERROR("Service '%s' not found.", source_name.c_str());
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -191,11 +191,11 @@ bool RWSplit::have_enough_servers() const
|
||||
return succp;
|
||||
}
|
||||
|
||||
static void log_router_options_not_supported(SERVICE* service, MXS_CONFIG_PARAMETER* p)
|
||||
static void log_router_options_not_supported(SERVICE* service, std::string router_opts)
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
for (const auto& a : mxs::strtok(p->value, ", \t"))
|
||||
for (const auto& a : mxs::strtok(router_opts, ", \t"))
|
||||
{
|
||||
ss << a << "\n";
|
||||
}
|
||||
@ -214,9 +214,10 @@ static void log_router_options_not_supported(SERVICE* service, MXS_CONFIG_PARAME
|
||||
|
||||
RWSplit* RWSplit::create(SERVICE* service, MXS_CONFIG_PARAMETER* params)
|
||||
{
|
||||
if (MXS_CONFIG_PARAMETER* p = config_get_param(params, CN_ROUTER_OPTIONS))
|
||||
|
||||
if (params->contains(CN_ROUTER_OPTIONS))
|
||||
{
|
||||
log_router_options_not_supported(service, p);
|
||||
log_router_options_not_supported(service, params->get_string(CN_ROUTER_OPTIONS));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -31,9 +31,10 @@ Config::Config(MXS_CONFIG_PARAMETER* conf)
|
||||
ignored_dbs.insert("performance_schema");
|
||||
|
||||
// TODO: Don't process this in the router
|
||||
if (MXS_CONFIG_PARAMETER* p = config_get_param(conf, "ignore_databases"))
|
||||
std::string ignored_dbs_str = conf->get_string("ignore_databases");
|
||||
if (!ignored_dbs_str.empty())
|
||||
{
|
||||
for (const auto& a : mxs::strtok(p->value, ", \t"))
|
||||
for (const auto& a : mxs::strtok(ignored_dbs_str, ", \t"))
|
||||
{
|
||||
ignored_dbs.insert(a);
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ SchemaRouter::~SchemaRouter()
|
||||
|
||||
SchemaRouter* SchemaRouter::create(SERVICE* pService, MXS_CONFIG_PARAMETER* params)
|
||||
{
|
||||
if ((config_get_param(params, "auth_all_servers")) == NULL)
|
||||
if (!params->contains("auth_all_servers"))
|
||||
{
|
||||
MXS_NOTICE("Authentication data is fetched from all servers. To disable this "
|
||||
"add 'auth_all_servers=0' to the service.");
|
||||
|
Reference in New Issue
Block a user