#include "instance_map.h"#include <my_global.h>#include <m_ctype.h>#include <mysql_com.h>#include "buffer.h"#include "guardian.h"#include "instance.h"#include "log.h"#include "manager.h"#include "mysqld_error.h"#include "mysql_manager_error.h"#include "options.h"#include "priv.h"Include dependency graph for instance_map.cc:

Go to the source code of this file.
Functions | |
| static C_MODE_START byte * | get_instance_key (const byte *u, uint *len, my_bool __attribute__((unused)) t) |
| static void | delete_instance (void *u) |
| static int | process_option (void *ctx, const char *group, const char *option) |
| static C_MODE_END void | parse_option (const char *option_str, char *option_name_buf, char *option_value_buf) |
| int | create_instance_in_file (const LEX_STRING *instance_name, const Named_value_arr *options) |
| int create_instance_in_file | ( | const LEX_STRING * | instance_name, | |
| const Named_value_arr * | options | |||
| ) |
Definition at line 561 of file instance_map.cc.
References Options::Main::config_file, ER_ACCESS_OPTION_FILE, ER_CONF_FILE_DOES_NOT_EXIST, errno, Named_value::get_name(), Named_value::get_value(), LEX_STRING::length, log_error(), MAX_OPTION_LEN, MAX_OPTION_STR_LEN, my_access, my_close(), MY_NABP, my_open(), my_write, MYF, NEWLINE, NEWLINE_LEN, NullS, options(), LEX_STRING::str, strxnmov(), and W_OK.
Referenced by Instance_map::complete_initialization(), and Create_instance::execute().
00563 { 00564 File cnf_file; 00565 00566 if (my_access(Options::Main::config_file, W_OK)) 00567 { 00568 log_error("Error: configuration file (%s) does not exist.", 00569 (const char *) Options::Main::config_file); 00570 return ER_CONF_FILE_DOES_NOT_EXIST; 00571 } 00572 00573 cnf_file= my_open(Options::Main::config_file, O_WRONLY | O_APPEND, MYF(0)); 00574 00575 if (cnf_file <= 0) 00576 { 00577 log_error("Error: can not open configuration file (%s): %s.", 00578 (const char *) Options::Main::config_file, 00579 (const char *) strerror(errno)); 00580 return ER_ACCESS_OPTION_FILE; 00581 } 00582 00583 if (my_write(cnf_file, (byte*)NEWLINE, NEWLINE_LEN, MYF(MY_NABP)) || 00584 my_write(cnf_file, (byte*)"[", 1, MYF(MY_NABP)) || 00585 my_write(cnf_file, (byte*)instance_name->str, instance_name->length, 00586 MYF(MY_NABP)) || 00587 my_write(cnf_file, (byte*)"]", 1, MYF(MY_NABP)) || 00588 my_write(cnf_file, (byte*)NEWLINE, NEWLINE_LEN, MYF(MY_NABP))) 00589 { 00590 log_error("Error: can not write to configuration file (%s): %s.", 00591 (const char *) Options::Main::config_file, 00592 (const char *) strerror(errno)); 00593 my_close(cnf_file, MYF(0)); 00594 return ER_ACCESS_OPTION_FILE; 00595 } 00596 00597 for (int i= 0; options && i < options->get_size(); ++i) 00598 { 00599 char option_str[MAX_OPTION_STR_LEN]; 00600 char *ptr; 00601 int option_str_len; 00602 Named_value option= options->get_element(i); 00603 00604 ptr= strxnmov(option_str, MAX_OPTION_LEN + 1, option.get_name(), NullS); 00605 00606 if (option.get_value()[0]) 00607 ptr= strxnmov(ptr, MAX_OPTION_LEN + 2, "=", option.get_value(), NullS); 00608 00609 option_str_len= ptr - option_str; 00610 00611 if (my_write(cnf_file, (byte*)option_str, option_str_len, MYF(MY_NABP)) || 00612 my_write(cnf_file, (byte*)NEWLINE, NEWLINE_LEN, MYF(MY_NABP))) 00613 { 00614 log_error("Error: can not write to configuration file (%s): %s.", 00615 (const char *) Options::Main::config_file, 00616 (const char *) strerror(errno)); 00617 my_close(cnf_file, MYF(0)); 00618 return ER_ACCESS_OPTION_FILE; 00619 } 00620 } 00621 00622 my_close(cnf_file, MYF(0)); 00623 00624 return 0; 00625 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void delete_instance | ( | void * | u | ) | [static] |
Definition at line 57 of file instance_map.cc.
Referenced by Instance_map::flush_instances(), and Instance_map::init().
Here is the caller graph for this function:

| static C_MODE_START byte* get_instance_key | ( | const byte * | u, | |
| uint * | len, | |||
| my_bool __attribute__((unused)) | t | |||
| ) | [static] |
Definition at line 49 of file instance_map.cc.
References Instance_options::instance_name, LEX_STRING::length, Instance::options, and LEX_STRING::str.
Referenced by Instance_map::flush_instances(), and Instance_map::init().
00051 { 00052 const Instance *instance= (const Instance *) u; 00053 *len= instance->options.instance_name.length; 00054 return (byte *) instance->options.instance_name.str; 00055 }
Here is the caller graph for this function:

| static C_MODE_END void parse_option | ( | const char * | option_str, | |
| char * | option_name_buf, | |||
| char * | option_value_buf | |||
| ) | [static] |
Definition at line 115 of file instance_map.cc.
References MAX_OPTION_LEN, strchr(), and strmake().
Referenced by Instance_map::process_one_option().
00118 { 00119 const char *eq_pos; 00120 const char *ptr= option_str; 00121 00122 while (*ptr == '-') 00123 ++ptr; 00124 00125 strmake(option_name_buf, ptr, MAX_OPTION_LEN + 1); 00126 00127 eq_pos= strchr(ptr, '='); 00128 if (eq_pos) 00129 { 00130 option_name_buf[eq_pos - ptr]= 0; 00131 strmake(option_value_buf, eq_pos + 1, MAX_OPTION_LEN + 1); 00132 } 00133 else 00134 { 00135 option_value_buf[0]= 0; 00136 } 00137 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static int process_option | ( | void * | ctx, | |
| const char * | group, | |||
| const char * | option | |||
| ) | [static] |
Definition at line 85 of file instance_map.cc.
References LEX_STRING::length, map, LEX_STRING::str, and strlen().
Referenced by Instance_map::load().
00086 { 00087 Instance_map *map= (Instance_map*) ctx; 00088 LEX_STRING group_str; 00089 00090 group_str.str= (char *) group; 00091 group_str.length= strlen(group); 00092 00093 return map->process_one_option(&group_str, option); 00094 }
Here is the call graph for this function:

Here is the caller graph for this function:

1.4.7

