1 /* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 2 3 This program is free software; you can redistribute it and/or modify 4 it under the terms of the GNU General Public License, version 2.0, 5 as published by the Free Software Foundation. 6 7 This program is also distributed with certain software (including 8 but not limited to OpenSSL) that is licensed under separate terms, 9 as designated in a particular file or component or in included license 10 documentation. The authors of MySQL hereby grant you an additional 11 permission to link the program and your derivative works with the 12 separately licensed software that they have included with MySQL. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License, version 2.0, for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software 21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 23 #ifndef RPL_INFO_FILE_H 24 #define RPL_INFO_FILE_H 25 26 #include <my_global.h> 27 #include <sql_priv.h> 28 #include "rpl_info_handler.h" 29 30 class Rpl_info_factory; 31 32 /** 33 Defines a file hander. 34 */ 35 class Rpl_info_file : public Rpl_info_handler 36 { 37 friend class Rpl_info_factory; 38 39 public: 40 virtual ~Rpl_info_file(); 41 42 private: 43 /** 44 This uniquely identifies a file. 45 46 When introducing multi-master replication one needs to ensure 47 that files' names are unique. If tables are used, there is no 48 issue at all. It is highly recommend to avoid using files as 49 they do not provide an atomic behavior. 50 */ 51 char info_fname[FN_REFLEN + 128]; 52 53 /** 54 This is used to identified a name's pattern. For instance, 55 worker-relay-log.info.*. 56 */ 57 char pattern_fname[FN_REFLEN + 128]; 58 59 /* 60 info_fd - file descriptor of the info file. set only during 61 initialization or clean up - safe to read anytime 62 */ 63 File info_fd; 64 65 /* IO_CACHE of the info file - set only during init or end */ 66 IO_CACHE info_file; 67 68 /* 69 The flag indicates whether the file name include the instance number or not. 70 */ 71 bool name_indexed; 72 73 int do_init_info(); 74 int do_init_info(uint instance); 75 enum_return_check do_check_info(); 76 enum_return_check do_check_info(uint instance); 77 void do_end_info(); 78 int do_flush_info(const bool force); 79 int do_remove_info(); 80 int do_clean_info(); 81 /** 82 Returns the number of files that corresponds to param_info_fname. 83 If param_info_fname is a regular expression, @code expression is 84 set. 85 86 @param[in] nparam Number of fields in the file. 87 @param[in] param_pattern_fname File's name. 88 @param[out] counter Number of files found. 89 90 @retval false Success 91 @retval true Error 92 */ 93 static bool do_count_info(const int nparam, 94 const char* param_pattern_fname, 95 bool name_indexed, 96 uint* counter); 97 static int do_reset_info(int const nparam, 98 const char* param_pattern_fname, 99 bool name_indexed); 100 101 int do_prepare_info_for_read(); 102 int do_prepare_info_for_write(); 103 bool do_set_info(const int pos, const char *value); 104 bool do_set_info(const int pos, const uchar *value, 105 const size_t size); 106 bool do_set_info(const int pos, const int value); 107 bool do_set_info(const int pos, const ulong value); 108 bool do_set_info(const int pos, const float value); 109 bool do_set_info(const int pos, const Dynamic_ids *value); 110 bool do_get_info(const int pos, char *value, const size_t size, 111 const char *default_value); 112 bool do_get_info(const int pos, uchar *value, const size_t size, 113 const uchar *default_value); 114 bool do_get_info(const int pos, int *value, 115 const int default_value); 116 bool do_get_info(const int pos, ulong *value, 117 const ulong default_value); 118 bool do_get_info(const int pos, float *value, 119 const float default_value); 120 bool do_get_info(const int pos, Dynamic_ids *value, 121 const Dynamic_ids *default_value); 122 char* do_get_description_info(); 123 uint do_get_rpl_info_type(); 124 125 bool do_is_transactional(); 126 bool do_update_is_transactional(); 127 128 Rpl_info_file(int const nparam, const char* param_pattern_fname, 129 const char* param_info_fname, bool name_indexed); 130 131 Rpl_info_file(const Rpl_info_file& info); 132 Rpl_info_file& operator=(const Rpl_info_file& info); 133 }; 134 #endif /* RPL_INFO_FILE_H */ 135