mirror of
https://gitee.com/wangbin579/cetus.git
synced 2024-12-02 03:47:41 +08:00
config set variables can change remote settings
This commit is contained in:
parent
1c29755e05
commit
b870a543b9
@ -1246,6 +1246,11 @@ void admin_set_config(network_mysqld_con* con, char* key, char* value)
|
||||
|
||||
g_list_free(options);
|
||||
|
||||
if(0 == ret && !chassis_config_set_remote_options(con->srv->config_manager, key, value)) {
|
||||
network_mysqld_con_send_error(con->client,C("Variable is set locally but cannot replace remote settings"));
|
||||
return;
|
||||
}
|
||||
|
||||
if(0 == ret) {
|
||||
network_mysqld_con_send_ok_full(con->client, 1, 0, SERVER_STATUS_AUTOCOMMIT, 0);
|
||||
} else if(ASSIGN_NOT_SUPPORT == ret){
|
||||
|
@ -321,6 +321,27 @@ chassis_config_load_options_mysql(chassis_config_t *conf)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
chassis_config_set_remote_options(chassis_config_t *conf, char* key, char* value)
|
||||
{
|
||||
if(conf->type == CHASSIS_CONF_MYSQL){
|
||||
MYSQL *conn = chassis_config_get_mysql_connection(conf);
|
||||
if (!conn) {
|
||||
g_warning("Cannot connect to mysql server.");
|
||||
return FALSE;
|
||||
}
|
||||
char sql[1024] = { 0 }, real_value[1024] = { 0 };
|
||||
mysql_real_escape_string(conn, real_value, value, strlen(value));
|
||||
snprintf(sql, sizeof(sql),
|
||||
"REPLACE INTO %s.`settings`(option_key,option_value) VALUES ('%s', '%s')", conf->schema, key, real_value);
|
||||
if (mysql_query(conn, sql)) {
|
||||
g_warning("sql failed: %s | error: %s", sql, mysql_error(conn));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gint chassis_config_reload_options(chassis_config_t *conf)
|
||||
{
|
||||
switch (conf->type) {
|
||||
|
@ -38,6 +38,8 @@ void chassis_config_free(chassis_config_t *);
|
||||
|
||||
gint chassis_config_reload_options(chassis_config_t *conf);
|
||||
|
||||
gboolean chassis_config_set_remote_options(chassis_config_t *conf, char* key, char* value);
|
||||
|
||||
GHashTable *chassis_config_get_options(chassis_config_t *);
|
||||
|
||||
gboolean chassis_config_parse_options(chassis_config_t *, GList *entries);
|
||||
|
Loading…
Reference in New Issue
Block a user