1 /*
2 This program is free software; you can redistribute it and/or modify
3 it under the terms of the GNU General Public License as published by
4 the Free Software Foundation; version 2 of the License.
5
6 This program is distributed in the hope that it will be useful,
7 but WITHOUT ANY WARRANTY; without even the implied warranty of
8 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 GNU General Public License for more details.
10
11 You should have received a copy of the GNU General Public License
12 along with this program; if not, write to the Free Software
13 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
14
15
16 /*
17 Variables that were present in older releases, but are now removed.
18 to get the list of variables that are present in current release
19 execute
20
21 SELECT LOWER(variable_name) from INFORMATION_SCHEMA.GLOBAL_VARIABLES ORDER BY 1
22
23 Compare the list between releases to figure out which variables have gone.
24
25 Note : the list below only includes the default-compiled server and none of the
26 loadable plugins.
27 */
28 #include <windows.h>
29 #include <initializer_list>
30 #include <stdlib.h>
31 #include <stdio.h>
32 #include <algorithm>
33
34 static const char *removed_variables[] =
35 {
36 "aria_recover",
37 "debug_crc_break",
38 "engine_condition_pushdown",
39 "have_csv",
40 "have_innodb",
41 "have_ndbcluster",
42 "have_partitioning",
43 "innodb_adaptive_flushing_method",
44 "innodb_adaptive_hash_index_partitions",
45 "innodb_additional_mem_pool_size",
46 "innodb_api_bk_commit_interval",
47 "innodb_api_disable_rowlock",
48 "innodb_api_enable_binlog",
49 "innodb_api_enable_mdl",
50 "innodb_api_trx_level",
51 "innodb_blocking_buffer_pool_restore",
52 "innodb_buffer_pool_populate",
53 "innodb_buffer_pool_restore_at_startup",
54 "innodb_buffer_pool_shm_checksum",
55 "innodb_buffer_pool_shm_key",
56 "innodb_checkpoint_age_target",
57 "innodb_checksums",
58 "innodb_cleaner_eviction_factor",
59 "innodb_cleaner_flush_chunk_size",
60 "innodb_cleaner_free_list_lwm",
61 "innodb_cleaner_lru_chunk_size",
62 "innodb_cleaner_lsn_age_factor",
63 "innodb_cleaner_max_flush_time",
64 "innodb_cleaner_max_lru_time",
65 "innodb_corrupt_table_action",
66 "innodb_dict_size_limit",
67 "innodb_doublewrite_file",
68 "innodb_empty_free_list_algorithm",
69 "innodb_fake_changes",
70 "innodb_fast_checksum",
71 "innodb_file_format",
72 "innodb_file_format_check",
73 "innodb_file_format_max",
74 "innodb_flush_neighbor_pages",
75 "innodb_foreground_preflush",
76 "innodb_ibuf_accel_rate",
77 "innodb_ibuf_active_contract",
78 "innodb_ibuf_max_size",
79 "innodb_idle_flush_pct",
80 "innodb_import_table_from_xtrabackup",
81 "innodb_instrument_semaphores",
82 "innodb_kill_idle_transaction",
83 "innodb_large_prefix",
84 "innodb_lazy_drop_table",
85 "innodb_locking_fake_changes",
86 "innodb_locks_unsafe_for_binlog",
87 "innodb_log_arch_dir",
88 "innodb_log_arch_expire_sec",
89 "innodb_log_archive",
90 "innodb_log_block_size",
91 "innodb_log_checksum_algorithm",
92 "innodb_rollback_segments",
93 "innodb_max_bitmap_file_size",
94 "innodb_max_changed_pages",
95 "innodb_merge_sort_block_size",
96 "innodb_mirrored_log_groups",
97 "innodb_mtflush_threads",
98 "innodb_persistent_stats_root_page",
99 "innodb_print_lock_wait_timeout_info",
100 "innodb_purge_run_now",
101 "innodb_purge_stop_now",
102 "innodb_read_ahead",
103 "innodb_recovery_stats",
104 "innodb_recovery_update_relay_log",
105 "innodb_show_locks_held",
106 "innodb_show_verbose_locks",
107 "innodb_stats_auto_update",
108 "innodb_stats_sample_pages",
109 "innodb_stats_update_need_lock",
110 "innodb_support_xa",
111 "innodb_thread_concurrency_timer_based",
112 "innodb_track_changed_pages",
113 "innodb_track_redo_log_now",
114 "innodb_use_fallocate",
115 "innodb_use_global_flush_log_at_trx_commit",
116 "innodb_use_mtflush",
117 "innodb_use_stacktrace",
118 "innodb_use_sys_malloc",
119 "innodb_use_sys_stats_table",
120 "innodb_use_trim",
121 "log",
122 "log_slow_queries",
123 "max_long_data_size",
124 "multi_range_count",
125 "rpl_recovery_rank",
126 "skip_bdb",
127 "sql_big_tables",
128 "sql_low_priority_updates",
129 "sql_max_join_size",
130 "thread_concurrency",
131 "timed_mutexes"
132 };
133
134
cmp_strings(const void * a,const void * b)135 static int cmp_strings(const void* a, const void *b)
136 {
137 return strcmp((const char *)a, *(const char **)b);
138 }
139
140 /**
141 Convert file from a previous version, by removing
142 */
upgrade_config_file(const char * myini_path)143 int upgrade_config_file(const char *myini_path)
144 {
145 #define MY_INI_SECTION_SIZE 32*1024 +3
146 static char section_data[MY_INI_SECTION_SIZE];
147 for (const char *section_name : { "mysqld","server","mariadb" })
148 {
149 DWORD size = GetPrivateProfileSection(section_name, section_data, MY_INI_SECTION_SIZE, myini_path);
150 if (size == MY_INI_SECTION_SIZE - 2)
151 {
152 return -1;
153 }
154
155 for (char *keyval = section_data; *keyval; keyval += strlen(keyval) + 1)
156 {
157 char varname[256];
158 char *key_end = strchr(keyval, '=');
159 if (!key_end)
160 key_end = keyval+ strlen(keyval);
161
162 if (key_end - keyval > sizeof(varname))
163 continue;
164 // copy and normalize (convert dash to underscore) to variable names
165 for (char *p = keyval, *q = varname;; p++,q++)
166 {
167 if (p == key_end)
168 {
169 *q = 0;
170 break;
171 }
172 *q = (*p == '-') ? '_' : *p;
173 }
174 const char *v = (const char *)bsearch(varname, removed_variables, sizeof(removed_variables) / sizeof(removed_variables[0]),
175 sizeof(char *), cmp_strings);
176
177 if (v)
178 {
179 fprintf(stdout, "Removing variable '%s' from config file\n", varname);
180 // delete variable
181 *key_end = 0;
182 WritePrivateProfileString(section_name, keyval, 0, myini_path);
183 }
184 }
185 }
186 return 0;
187 }
188