Merge lp:~mordred/drizzle/boost-fs-path-work into lp:~drizzle-trunk/drizzle/development
- boost-fs-path-work
- Merge into development
Proposed by
Monty Taylor
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Monty Taylor | ||||||||
Approved revision: | 1829 | ||||||||
Merged at revision: | 1820 | ||||||||
Proposed branch: | lp:~mordred/drizzle/boost-fs-path-work | ||||||||
Merge into: | lp:~drizzle-trunk/drizzle/development | ||||||||
Diff against target: |
1800 lines (+367/-390) 33 files modified
drizzled/data_home.h (+5/-5) drizzled/drizzled.cc (+73/-163) drizzled/file_exchange.h (+2/-1) drizzled/function/str/load_file.cc (+48/-10) drizzled/main.cc (+6/-10) drizzled/module/library.cc (+13/-13) drizzled/module/library.h (+3/-1) drizzled/module/loader.cc (+0/-1) drizzled/plugin.h (+2/-1) drizzled/select_export.h (+3/-1) drizzled/select_to_file.h (+5/-2) drizzled/session.cc (+40/-31) drizzled/set_var.cc (+15/-40) drizzled/set_var.h (+43/-5) drizzled/sql_load.cc (+56/-54) drizzled/thr_lock.cc (+1/-1) plugin/innobase/handler/ha_innodb.cc (+10/-9) plugin/pbms/src/database_ms.cc (+4/-4) plugin/pbms/src/mysql_ms.cc (+3/-3) plugin/pbms/src/mysql_ms.h (+3/-1) plugin/pbms/src/pbmsdaemon_ms.cc (+1/-1) plugin/pbms/src/system_table_ms.cc (+1/-1) plugin/pbxt/src/myxt_xt.cc (+6/-6) plugin/pbxt/src/xt_defs.h (+2/-1) plugin/schema_engine/schema.cc (+1/-1) plugin/signal_handler/signal_handler.cc (+4/-4) plugin/status_dictionary/variables.h (+1/-1) tests/r/func_str.result (+1/-5) tests/r/loaddata.result (+3/-4) tests/r/outfile.result (+8/-5) tests/t/func_str.test (+1/-4) tests/t/loaddata.test (+1/-1) tests/t/outfile.test (+2/-0) |
||||||||
To merge this branch: | bzr merge lp:~mordred/drizzle/boost-fs-path-work | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Drizzle Merge Team | Pending | ||
Review via email: mp+37710@code.launchpad.net |
This proposal supersedes a proposal from 2010-10-06.
Commit message
Description of the change
A bunch of work cleaning up how paths are managed/handled.
To post a comment you must log in.
Revision history for this message
Monty Taylor (mordred) wrote : | # |
Revision history for this message
Lee Bieber (kalebral-deactivatedaccount) wrote : | # |
Fails with debug build
- 1830. By Monty Taylor
-
Fixed an alarming issue in debug builds of pbmx. Oh well.
Revision history for this message
Monty Taylor (mordred) wrote : | # |
Fixed the pbms issue.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'drizzled/data_home.h' |
2 | --- drizzled/data_home.h 2010-09-26 01:21:36 +0000 |
3 | +++ drizzled/data_home.h 2010-10-06 07:38:58 +0000 |
4 | @@ -20,15 +20,15 @@ |
5 | #ifndef DRIZZLED_DATA_HOME_H |
6 | #define DRIZZLED_DATA_HOME_H |
7 | |
8 | -#include <string> |
9 | +#include <boost/filesystem.hpp> |
10 | |
11 | namespace drizzled |
12 | { |
13 | |
14 | -std::string& getDataHome(); |
15 | -std::string& getDataHomeCatalog(); |
16 | -char *getDatadir(); |
17 | -char **getDatadirPtr(); |
18 | +extern boost::filesystem::path full_data_home; |
19 | + |
20 | +boost::filesystem::path& getDataHome(); |
21 | +boost::filesystem::path& getDataHomeCatalog(); |
22 | |
23 | } /* namespace drizzled */ |
24 | |
25 | |
26 | === modified file 'drizzled/drizzled.cc' |
27 | --- drizzled/drizzled.cc 2010-10-04 22:44:31 +0000 |
28 | +++ drizzled/drizzled.cc 2010-10-06 07:38:58 +0000 |
29 | @@ -232,8 +232,6 @@ |
30 | plugin::StorageEngine *heap_engine; |
31 | plugin::StorageEngine *myisam_engine; |
32 | |
33 | -char* opt_secure_file_priv= 0; |
34 | - |
35 | bool calling_initgroups= false; /**< Used in SIGSEGV handler. */ |
36 | |
37 | uint32_t drizzled_bind_timeout; |
38 | @@ -288,7 +286,14 @@ |
39 | time_t server_start_time; |
40 | time_t flush_status_time; |
41 | |
42 | -char drizzle_home[FN_REFLEN], pidfile_name[FN_REFLEN], system_time_zone[30]; |
43 | +fs::path basedir(PREFIX); |
44 | +fs::path pid_file; |
45 | +fs::path secure_file_priv(""); |
46 | +fs::path plugin_dir; |
47 | +fs::path system_config_dir(SYSCONFDIR); |
48 | + |
49 | + |
50 | +char system_time_zone[30]; |
51 | char *default_tz_name; |
52 | char glob_hostname[FN_REFLEN]; |
53 | |
54 | @@ -336,7 +341,6 @@ |
55 | /* Static variables */ |
56 | |
57 | int cleanup_done; |
58 | -static char *drizzle_home_ptr, *pidfile_name_ptr; |
59 | |
60 | passwd *user_info; |
61 | |
62 | @@ -352,7 +356,6 @@ |
63 | |
64 | static void drizzle_init_variables(void); |
65 | static void get_options(); |
66 | -static const char *get_relative_path(const char *path); |
67 | static void fix_paths(); |
68 | |
69 | static void usage(void); |
70 | @@ -369,34 +372,26 @@ |
71 | vector<string> unknown_options; |
72 | vector<string> defaults_file_list; |
73 | po::variables_map vm; |
74 | -char * data_dir_ptr; |
75 | + |
76 | +fs::path data_home(LOCALSTATEDIR); |
77 | +fs::path full_data_home(LOCALSTATEDIR); |
78 | |
79 | po::variables_map &getVariablesMap() |
80 | { |
81 | return vm; |
82 | } |
83 | |
84 | -std::string& getDataHome() |
85 | +fs::path& getDataHome() |
86 | { |
87 | - static string data_home(LOCALSTATEDIR); |
88 | return data_home; |
89 | } |
90 | |
91 | -std::string& getDataHomeCatalog() |
92 | +fs::path& getDataHomeCatalog() |
93 | { |
94 | - static string data_home_catalog(getDataHome()); |
95 | + static fs::path data_home_catalog(getDataHome()); |
96 | return data_home_catalog; |
97 | } |
98 | |
99 | -char *getDatadir() |
100 | -{ |
101 | - return data_dir_ptr; |
102 | -} |
103 | - |
104 | -char **getDatadirPtr() |
105 | -{ |
106 | - return &data_dir_ptr; |
107 | -} |
108 | |
109 | /**************************************************************************** |
110 | ** Code to end drizzled |
111 | @@ -511,13 +506,10 @@ |
112 | return; |
113 | |
114 | table_cache_free(); |
115 | - set_var_free(); |
116 | free_charsets(); |
117 | module::Registry &modules= module::Registry::singleton(); |
118 | modules.shutdownModules(); |
119 | xid_cache_free(); |
120 | - if (opt_secure_file_priv) |
121 | - free(opt_secure_file_priv); |
122 | |
123 | deinit_temporal_formats(); |
124 | |
125 | @@ -525,7 +517,7 @@ |
126 | google::protobuf::ShutdownProtobufLibrary(); |
127 | #endif |
128 | |
129 | - (void) unlink(pidfile_name); // This may not always exist |
130 | + (void) unlink(pid_file.file_string().c_str()); // This may not always exist |
131 | |
132 | if (print_message && server_start_time) |
133 | errmsg_printf(ERRMSG_LVL_INFO, _(ER(ER_SHUTDOWN_COMPLETE)),internal::my_progname); |
134 | @@ -535,8 +527,6 @@ |
135 | COND_server_end.notify_all(); |
136 | LOCK_thread_count.unlock(); |
137 | |
138 | - char **data_home_ptr= getDatadirPtr(); |
139 | - delete[](*data_home_ptr); |
140 | /* |
141 | The following lines may never be executed as the main thread may have |
142 | killed us |
143 | @@ -716,15 +706,29 @@ |
144 | base_plugin_dir /= "plugin"; |
145 | base_plugin_dir /= ".libs"; |
146 | } |
147 | - (void) internal::my_load_path(opt_plugin_dir, fs::path(fs::system_complete(base_plugin_dir)).file_string().c_str(), ""); |
148 | -} |
149 | - |
150 | -static void notify_plugin_dir(string in_plugin_dir) |
151 | -{ |
152 | - if (not in_plugin_dir.empty()) |
153 | - { |
154 | - (void) internal::my_load_path(opt_plugin_dir, in_plugin_dir.c_str(), drizzle_home); |
155 | - } |
156 | + |
157 | + if (plugin_dir.root_directory() == "") |
158 | + { |
159 | + fs::path full_plugin_dir(fs::system_complete(base_plugin_dir)); |
160 | + full_plugin_dir /= plugin_dir; |
161 | + plugin_dir= full_plugin_dir; |
162 | + } |
163 | +} |
164 | + |
165 | +static void notify_plugin_dir(fs::path in_plugin_dir) |
166 | +{ |
167 | + plugin_dir= in_plugin_dir; |
168 | + if (plugin_dir.root_directory() == "") |
169 | + { |
170 | + fs::path full_plugin_dir(fs::system_complete(basedir)); |
171 | + full_plugin_dir /= plugin_dir; |
172 | + plugin_dir= full_plugin_dir; |
173 | + } |
174 | +} |
175 | + |
176 | +static void expand_secure_file_priv(fs::path in_secure_file_priv) |
177 | +{ |
178 | + secure_file_priv= fs::system_complete(in_secure_file_priv); |
179 | } |
180 | |
181 | static void check_limits_aii(uint64_t in_auto_increment_increment) |
182 | @@ -906,17 +910,6 @@ |
183 | global_system_variables.max_sort_length= in_max_sort_length; |
184 | } |
185 | |
186 | -static void check_limits_mwlc(uint64_t in_min_examined_row_limit) |
187 | -{ |
188 | - global_system_variables.min_examined_row_limit= ULONG_MAX; |
189 | - if (in_min_examined_row_limit > ULONG_MAX) |
190 | - { |
191 | - cout << N_("Error: Invalid Value for min_examined_row_limit"); |
192 | - exit(-1); |
193 | - } |
194 | - global_system_variables.min_examined_row_limit= in_min_examined_row_limit; |
195 | -} |
196 | - |
197 | static void check_limits_osd(uint32_t in_optimizer_search_depth) |
198 | { |
199 | global_system_variables.optimizer_search_depth= 0; |
200 | @@ -1120,19 +1113,18 @@ |
201 | iter != defaults_file_list.end(); |
202 | ++iter) |
203 | { |
204 | - string file_location(vm["config-dir"].as<string>()); |
205 | + fs::path file_location(system_config_dir); |
206 | if ((*iter)[0] != '/') |
207 | { |
208 | /* Relative path - add config dir */ |
209 | - file_location.push_back('/'); |
210 | - file_location.append(*iter); |
211 | + file_location /= *iter; |
212 | } |
213 | else |
214 | { |
215 | file_location= *iter; |
216 | } |
217 | |
218 | - ifstream input_defaults_file(file_location.c_str()); |
219 | + ifstream input_defaults_file(file_location.file_string().c_str()); |
220 | |
221 | po::parsed_options file_parsed= |
222 | po::parse_config_file(input_defaults_file, full_options, true); |
223 | @@ -1211,15 +1203,15 @@ |
224 | strncpy(glob_hostname, STRING_WITH_LEN("localhost")); |
225 | errmsg_printf(ERRMSG_LVL_WARN, _("gethostname failed, using '%s' as hostname"), |
226 | glob_hostname); |
227 | - strncpy(pidfile_name, STRING_WITH_LEN("drizzle")); |
228 | + pid_file= "drizzle"; |
229 | } |
230 | else |
231 | - strncpy(pidfile_name, glob_hostname, sizeof(pidfile_name)-5); |
232 | - strcpy(internal::fn_ext(pidfile_name),".pid"); // Add proper extension |
233 | - |
234 | - std::string system_config_dir_drizzle(SYSCONFDIR); |
235 | - system_config_dir_drizzle.append("/drizzle"); |
236 | - |
237 | + { |
238 | + pid_file= glob_hostname; |
239 | + } |
240 | + pid_file.replace_extension(".pid"); |
241 | + |
242 | + system_config_dir /= "drizzle"; |
243 | std::string system_config_file_drizzle("drizzled.cnf"); |
244 | |
245 | config_options.add_options() |
246 | @@ -1229,9 +1221,9 @@ |
247 | N_("Configuration file defaults are not used if no-defaults is set")) |
248 | ("defaults-file", po::value<vector<string> >()->composing()->notifier(&compose_defaults_file_list), |
249 | N_("Configuration file to use")) |
250 | - ("config-dir", po::value<string>()->default_value(system_config_dir_drizzle), |
251 | + ("config-dir", po::value<fs::path>(&system_config_dir), |
252 | N_("Base location for config files")) |
253 | - ("plugin-dir", po::value<string>()->notifier(¬ify_plugin_dir), |
254 | + ("plugin-dir", po::value<fs::path>(&plugin_dir)->notifier(¬ify_plugin_dir), |
255 | N_("Directory for plugins.")) |
256 | ; |
257 | |
258 | @@ -1255,7 +1247,7 @@ |
259 | N_("Auto-increment columns are incremented by this")) |
260 | ("auto-increment-offset", po::value<uint64_t>(&global_system_variables.auto_increment_offset)->default_value(1)->notifier(&check_limits_aio), |
261 | N_("Offset added to Auto-increment columns. Used when auto-increment-increment != 1")) |
262 | - ("basedir,b", po::value<string>(), |
263 | + ("basedir,b", po::value<fs::path>(&basedir), |
264 | N_("Path to installation directory. All paths are usually resolved " |
265 | "relative to this.")) |
266 | ("chroot,r", po::value<string>(), |
267 | @@ -1265,7 +1257,7 @@ |
268 | ("completion-type", po::value<uint32_t>(&global_system_variables.completion_type)->default_value(0)->notifier(&check_limits_completion_type), |
269 | N_("Default completion type.")) |
270 | ("core-file", N_("Write core on errors.")) |
271 | - ("datadir", po::value<string>(), |
272 | + ("datadir", po::value<fs::path>(&data_home), |
273 | N_("Path to the database root.")) |
274 | ("default-storage-engine", po::value<string>(), |
275 | N_("Set the default storage engine for tables.")) |
276 | @@ -1279,11 +1271,11 @@ |
277 | N_("Set the language used for the month names and the days of the week.")) |
278 | ("log-warnings,W", po::value<string>(), |
279 | N_("Log some not critical warnings to the log file.")) |
280 | - ("pid-file", po::value<string>(), |
281 | + ("pid-file", po::value<fs::path>(&pid_file), |
282 | N_("Pid file used by drizzled.")) |
283 | ("port-open-timeout", po::value<uint32_t>(&drizzled_bind_timeout)->default_value(0), |
284 | N_("Maximum time in seconds to wait for the port to become free. ")) |
285 | - ("secure-file-priv", po::value<string>(), |
286 | + ("secure-file-priv", po::value<fs::path>(&secure_file_priv)->notifier(expand_secure_file_priv), |
287 | N_("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files " |
288 | "within specified directory")) |
289 | ("server-id", po::value<uint32_t>(&server_id)->default_value(0), |
290 | @@ -1339,7 +1331,7 @@ |
291 | N_("The number of bytes to use when sorting BLOB or TEXT values " |
292 | "(only the first max_sort_length bytes of each value are used; the " |
293 | "rest are ignored).")) |
294 | - ("max-write-lock-count", po::value<uint64_t>(&max_write_lock_count)->default_value(ULONG_MAX)->notifier(&check_limits_mwlc), |
295 | + ("max-write-lock-count", po::value<uint64_t>(&max_write_lock_count)->default_value(UINT64_MAX), |
296 | N_("After this many write locks, allow some read locks to run in between.")) |
297 | ("min-examined-row-limit", po::value<uint64_t>(&global_system_variables.min_examined_row_limit)->default_value(0)->notifier(&check_limits_merl), |
298 | N_("Don't log queries which examine less than min_examined_row_limit " |
299 | @@ -1426,9 +1418,10 @@ |
300 | system_config_file_drizzle); |
301 | } |
302 | |
303 | - string config_conf_d_location(vm["config-dir"].as<string>()); |
304 | - config_conf_d_location.append("/conf.d"); |
305 | - CachedDirectory config_conf_d(config_conf_d_location); |
306 | + fs::path config_conf_d_location(system_config_dir); |
307 | + config_conf_d_location /= "conf.d"; |
308 | + |
309 | + CachedDirectory config_conf_d(config_conf_d_location.file_string()); |
310 | if (not config_conf_d.fail()) |
311 | { |
312 | |
313 | @@ -1442,10 +1435,9 @@ |
314 | && file_entry != "." |
315 | && file_entry != "..") |
316 | { |
317 | - string the_entry(config_conf_d_location); |
318 | - the_entry.push_back('/'); |
319 | - the_entry.append(file_entry); |
320 | - defaults_file_list.push_back(the_entry); |
321 | + fs::path the_entry(config_conf_d_location); |
322 | + the_entry /= file_entry; |
323 | + defaults_file_list.push_back(the_entry.file_string()); |
324 | } |
325 | } |
326 | } |
327 | @@ -1761,7 +1753,7 @@ |
328 | {"basedir", 'b', |
329 | N_("Path to installation directory. All paths are usually resolved " |
330 | "relative to this."), |
331 | - (char**) &drizzle_home_ptr, (char**) &drizzle_home_ptr, 0, GET_STR, REQUIRED_ARG, |
332 | + NULL, NULL, 0, GET_STR, REQUIRED_ARG, |
333 | 0, 0, 0, 0, 0, 0}, |
334 | {"chroot", 'r', |
335 | N_("Chroot drizzled daemon during startup."), |
336 | @@ -1813,7 +1805,7 @@ |
337 | 0, 0, 0}, |
338 | {"pid-file", OPT_PID_FILE, |
339 | N_("Pid file used by drizzled."), |
340 | - (char**) &pidfile_name_ptr, (char**) &pidfile_name_ptr, 0, GET_STR, |
341 | + NULL, NULL, 0, GET_STR, |
342 | REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, |
343 | {"port-open-timeout", OPT_PORT_OPEN_TIMEOUT, |
344 | N_("Maximum time in seconds to wait for the port to become free. " |
345 | @@ -1823,7 +1815,7 @@ |
346 | {"secure-file-priv", OPT_SECURE_FILE_PRIV, |
347 | N_("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files " |
348 | "within specified directory"), |
349 | - (char**) &opt_secure_file_priv, (char**) &opt_secure_file_priv, 0, |
350 | + NULL, NULL, 0, |
351 | GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, |
352 | {"server-id", OPT_SERVER_ID, |
353 | N_("Uniquely identifies the server instance in the community of " |
354 | @@ -2121,9 +2113,7 @@ |
355 | static void drizzle_init_variables(void) |
356 | { |
357 | /* Things reset to zero */ |
358 | - drizzle_home[0]= pidfile_name[0]= 0; |
359 | opt_tc_log_file= (char *)"tc.log"; // no hostname in tc_log file name ! |
360 | - opt_secure_file_priv= 0; |
361 | cleanup_done= 0; |
362 | dropping_tables= ha_open_options=0; |
363 | test_flags.reset(); |
364 | @@ -2141,8 +2131,6 @@ |
365 | character_set_filesystem= &my_charset_bin; |
366 | |
367 | /* Things with default values that are not zero */ |
368 | - drizzle_home_ptr= drizzle_home; |
369 | - pidfile_name_ptr= pidfile_name; |
370 | session_startup_options= (OPTION_AUTO_IS_NULL | OPTION_SQL_NOTES); |
371 | refresh_version= 1L; /* Increments on each reload */ |
372 | global_thread_id= 1UL; |
373 | @@ -2197,11 +2185,6 @@ |
374 | have_symlink=SHOW_OPTION_YES; |
375 | #endif |
376 | |
377 | - const char *tmpenv; |
378 | - if (!(tmpenv = getenv("MY_BASEDIR_VERSION"))) |
379 | - tmpenv = PREFIX; |
380 | - (void) strncpy(drizzle_home, tmpenv, sizeof(drizzle_home)-1); |
381 | - |
382 | connection_count= 0; |
383 | } |
384 | |
385 | @@ -2213,19 +2196,9 @@ |
386 | static void get_options() |
387 | { |
388 | |
389 | - if (vm.count("base-dir")) |
390 | - { |
391 | - strncpy(drizzle_home,vm["base-dir"].as<string>().c_str(),sizeof(drizzle_home)-1); |
392 | - } |
393 | - |
394 | - if (vm.count("datadir")) |
395 | - { |
396 | - getDataHome()= vm["datadir"].as<string>(); |
397 | - } |
398 | - string &data_home_catalog= getDataHomeCatalog(); |
399 | + fs::path &data_home_catalog= getDataHomeCatalog(); |
400 | data_home_catalog= getDataHome(); |
401 | - data_home_catalog.push_back('/'); |
402 | - data_home_catalog.append("local"); |
403 | + data_home_catalog /= "local"; |
404 | |
405 | if (vm.count("user")) |
406 | { |
407 | @@ -2277,11 +2250,6 @@ |
408 | internal::my_use_symdir=0; |
409 | } |
410 | |
411 | - if (vm.count("pid-file")) |
412 | - { |
413 | - strncpy(pidfile_name, vm["pid-file"].as<string>().c_str(), sizeof(pidfile_name)-1); |
414 | - } |
415 | - |
416 | if (vm.count("transaction-isolation")) |
417 | { |
418 | int type; |
419 | @@ -2329,61 +2297,15 @@ |
420 | } |
421 | |
422 | |
423 | -static const char *get_relative_path(const char *path) |
424 | -{ |
425 | - if (internal::test_if_hard_path(path) && |
426 | - (strncmp(path, PREFIX, strlen(PREFIX)) == 0) && |
427 | - strcmp(PREFIX,FN_ROOTDIR)) |
428 | - { |
429 | - if (strlen(PREFIX) < strlen(path)) |
430 | - path+=(size_t) strlen(PREFIX); |
431 | - while (*path == FN_LIBCHAR) |
432 | - path++; |
433 | - } |
434 | - return path; |
435 | -} |
436 | - |
437 | - |
438 | static void fix_paths() |
439 | { |
440 | - char buff[FN_REFLEN],*pos,rp_buff[PATH_MAX]; |
441 | - internal::convert_dirname(drizzle_home,drizzle_home,NULL); |
442 | - /* Resolve symlinks to allow 'drizzle_home' to be a relative symlink */ |
443 | -#if defined(HAVE_BROKEN_REALPATH) |
444 | - internal::my_load_path(drizzle_home, drizzle_home, NULL); |
445 | -#else |
446 | - if (!realpath(drizzle_home,rp_buff)) |
447 | - internal::my_load_path(rp_buff, drizzle_home, NULL); |
448 | - rp_buff[FN_REFLEN-1]= '\0'; |
449 | - strcpy(drizzle_home,rp_buff); |
450 | - /* Ensure that drizzle_home ends in FN_LIBCHAR */ |
451 | - pos= strchr(drizzle_home, '\0'); |
452 | -#endif |
453 | - if (pos[-1] != FN_LIBCHAR) |
454 | - { |
455 | - pos[0]= FN_LIBCHAR; |
456 | - pos[1]= 0; |
457 | - } |
458 | - (void) internal::my_load_path(drizzle_home, drizzle_home,""); // Resolve current dir |
459 | - |
460 | - fs::path pid_file_path(pidfile_name); |
461 | + fs::path pid_file_path(pid_file); |
462 | if (pid_file_path.root_path().string() == "") |
463 | { |
464 | - pid_file_path= fs::path(getDataHome()); |
465 | - pid_file_path /= pidfile_name; |
466 | - } |
467 | - strncpy(pidfile_name, pid_file_path.file_string().c_str(), sizeof(pidfile_name)-1); |
468 | - |
469 | - |
470 | - const char *sharedir= get_relative_path(PKGDATADIR); |
471 | - if (internal::test_if_hard_path(sharedir)) |
472 | - strncpy(buff,sharedir,sizeof(buff)-1); |
473 | - else |
474 | - { |
475 | - strcpy(buff, drizzle_home); |
476 | - strncat(buff, sharedir, sizeof(buff)-strlen(drizzle_home)-1); |
477 | - } |
478 | - internal::convert_dirname(buff,buff,NULL); |
479 | + pid_file_path= getDataHome(); |
480 | + pid_file_path /= pid_file; |
481 | + } |
482 | + pid_file= pid_file_path; |
483 | |
484 | if (not opt_help) |
485 | { |
486 | @@ -2397,7 +2319,7 @@ |
487 | } |
488 | else if (tmp_string == NULL) |
489 | { |
490 | - drizzle_tmpdir.append(getDataHome()); |
491 | + drizzle_tmpdir.append(getDataHome().file_string()); |
492 | drizzle_tmpdir.push_back(FN_LIBCHAR); |
493 | drizzle_tmpdir.append(GLOBAL_TEMPORARY_EXT); |
494 | } |
495 | @@ -2425,18 +2347,6 @@ |
496 | } |
497 | } |
498 | |
499 | - /* |
500 | - Convert the secure-file-priv option to system format, allowing |
501 | - a quick strcmp to check if read or write is in an allowed dir |
502 | - */ |
503 | - if (vm.count("secure-file-priv")) |
504 | - { |
505 | - internal::convert_dirname(buff, vm["secure-file-priv"].as<string>().c_str(), NULL); |
506 | - free(opt_secure_file_priv); |
507 | - opt_secure_file_priv= strdup(buff); |
508 | - if (opt_secure_file_priv == NULL) |
509 | - exit(1); |
510 | - } |
511 | } |
512 | |
513 | } /* namespace drizzled */ |
514 | |
515 | === modified file 'drizzled/file_exchange.h' |
516 | --- drizzled/file_exchange.h 2010-02-04 08:14:46 +0000 |
517 | +++ drizzled/file_exchange.h 2010-10-06 07:38:58 +0000 |
518 | @@ -40,7 +40,8 @@ |
519 | XXX: We never call destructor for objects of this class. |
520 | */ |
521 | |
522 | -class file_exchange :public memory::SqlAlloc |
523 | +class file_exchange : |
524 | + public memory::SqlAlloc |
525 | { |
526 | public: |
527 | enum enum_filetype filetype; /* load XML, Added by Arnold & Erik */ |
528 | |
529 | === modified file 'drizzled/function/str/load_file.cc' |
530 | --- drizzled/function/str/load_file.cc 2010-09-22 07:05:47 +0000 |
531 | +++ drizzled/function/str/load_file.cc 2010-10-06 07:38:58 +0000 |
532 | @@ -25,8 +25,14 @@ |
533 | #include <drizzled/session.h> |
534 | #include "drizzled/internal/my_sys.h" |
535 | |
536 | +#include <boost/filesystem.hpp> |
537 | + |
538 | #include <fcntl.h> |
539 | #include <sys/stat.h> |
540 | +#include <iostream> |
541 | + |
542 | +namespace fs=boost::filesystem; |
543 | +using namespace std; |
544 | |
545 | namespace drizzled |
546 | { |
547 | @@ -37,27 +43,49 @@ |
548 | String *file_name; |
549 | int file; |
550 | struct stat stat_info; |
551 | - char path[FN_REFLEN]; |
552 | |
553 | if (!(file_name= args[0]->val_str(str))) |
554 | - goto err; |
555 | + { |
556 | + null_value = 1; |
557 | + return(0); |
558 | + } |
559 | |
560 | - (void) internal::fn_format(path, file_name->c_ptr(), getDataHome().c_str(), "", |
561 | - MY_RELATIVE_PATH | MY_UNPACK_FILENAME); |
562 | + fs::path target_path(fs::system_complete(getDataHomeCatalog())); |
563 | + fs::path to_file(file_name->c_ptr()); |
564 | + if (not to_file.has_root_directory()) |
565 | + { |
566 | + target_path /= to_file; |
567 | + } |
568 | + else |
569 | + { |
570 | + target_path= to_file; |
571 | + } |
572 | |
573 | /* Read only allowed from within dir specified by secure_file_priv */ |
574 | - if (opt_secure_file_priv && |
575 | - strncmp(opt_secure_file_priv, path, strlen(opt_secure_file_priv))) |
576 | - goto err; |
577 | + if (not secure_file_priv.string().empty()) |
578 | + { |
579 | + fs::path secure_file_path(fs::system_complete(secure_file_priv)); |
580 | + if (target_path.file_string().substr(0, secure_file_path.file_string().size()) != secure_file_path.file_string()) |
581 | + { |
582 | + /* Read only allowed from within dir specified by secure_file_priv */ |
583 | + my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv"); |
584 | + null_value = 1; |
585 | + return 0; |
586 | + } |
587 | + } |
588 | |
589 | - if (stat(path, &stat_info)) |
590 | + if (stat(target_path.file_string().c_str(), &stat_info)) |
591 | + { |
592 | + my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), file_name->c_ptr()); |
593 | goto err; |
594 | + } |
595 | |
596 | if (!(stat_info.st_mode & S_IROTH)) |
597 | { |
598 | - /* my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), file_name->c_ptr()); */ |
599 | + my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), file_name->c_ptr()); |
600 | goto err; |
601 | } |
602 | + |
603 | if (stat_info.st_size > (long) session.variables.max_allowed_packet) |
604 | { |
605 | push_warning_printf(&session, DRIZZLE_ERROR::WARN_LEVEL_WARN, |
606 | @@ -66,15 +94,25 @@ |
607 | func_name(), session.variables.max_allowed_packet); |
608 | goto err; |
609 | } |
610 | + |
611 | + if (stat_info.st_size == 0) |
612 | + { |
613 | + goto err; |
614 | + } |
615 | + |
616 | if (tmp_value.alloc((size_t)stat_info.st_size)) |
617 | goto err; |
618 | - if ((file = internal::my_open(file_name->c_ptr(), O_RDONLY, MYF(0))) < 0) |
619 | + if ((file = internal::my_open(target_path.file_string().c_str(), O_RDONLY, MYF(0))) < 0) |
620 | goto err; |
621 | if (internal::my_read(file, (unsigned char*) tmp_value.ptr(), (size_t)stat_info.st_size, MYF(MY_NABP))) |
622 | { |
623 | internal::my_close(file, MYF(0)); |
624 | goto err; |
625 | } |
626 | + if (strlen(tmp_value.ptr()) == 0) |
627 | + { |
628 | + goto err; |
629 | + } |
630 | tmp_value.length((size_t)stat_info.st_size); |
631 | internal::my_close(file, MYF(0)); |
632 | null_value = 0; |
633 | |
634 | === modified file 'drizzled/main.cc' |
635 | --- drizzled/main.cc 2010-10-05 08:06:38 +0000 |
636 | +++ drizzled/main.cc 2010-10-06 07:38:58 +0000 |
637 | @@ -255,11 +255,11 @@ |
638 | |
639 | if (not opt_help) |
640 | { |
641 | - if (chdir(getDataHome().c_str())) |
642 | + if (chdir(getDataHome().file_string().c_str())) |
643 | { |
644 | errmsg_printf(ERRMSG_LVL_ERROR, |
645 | _("Data directory %s does not exist\n"), |
646 | - getDataHome().c_str()); |
647 | + getDataHome().file_string().c_str()); |
648 | unireg_abort(1); |
649 | } |
650 | if (mkdir("local", 0700)) |
651 | @@ -270,15 +270,11 @@ |
652 | { |
653 | errmsg_printf(ERRMSG_LVL_ERROR, |
654 | _("Local catalog %s/local does not exist\n"), |
655 | - getDataHome().c_str()); |
656 | + getDataHome().file_string().c_str()); |
657 | unireg_abort(1); |
658 | } |
659 | - /* TODO: This is a hack until we can properly support std::string in sys_var*/ |
660 | - char **data_home_ptr= getDatadirPtr(); |
661 | - fs::path full_data_home_path(fs::system_complete(fs::path(getDataHome()))); |
662 | - std::string full_data_home(full_data_home_path.file_string()); |
663 | - *data_home_ptr= new char[full_data_home.size()+1] (); |
664 | - memcpy(*data_home_ptr, full_data_home.c_str(), full_data_home.size()); |
665 | + |
666 | + full_data_home= fs::system_complete(getDataHome()); |
667 | getDataHomeCatalog()= "./"; |
668 | getDataHome()= "../"; |
669 | } |
670 | @@ -319,7 +315,7 @@ |
671 | select_thread_in_use=0; |
672 | (void) pthread_kill(signal_thread, SIGTERM); |
673 | |
674 | - (void) unlink(pidfile_name); // Not needed anymore |
675 | + (void) unlink(pid_file.file_string().c_str()); // Not needed anymore |
676 | |
677 | exit(1); |
678 | } |
679 | |
680 | === modified file 'drizzled/module/library.cc' |
681 | --- drizzled/module/library.cc 2010-08-10 17:04:19 +0000 |
682 | +++ drizzled/module/library.cc 2010-10-06 07:38:58 +0000 |
683 | @@ -24,6 +24,8 @@ |
684 | #include <cerrno> |
685 | #include <string> |
686 | |
687 | +#include <boost/filesystem.hpp> |
688 | + |
689 | #include "drizzled/plugin.h" |
690 | #include "drizzled/definitions.h" |
691 | #include "drizzled/error.h" |
692 | @@ -31,6 +33,7 @@ |
693 | #include "drizzled/module/library.h" |
694 | |
695 | using namespace std; |
696 | +namespace fs=boost::filesystem; |
697 | |
698 | namespace drizzled |
699 | { |
700 | @@ -50,22 +53,19 @@ |
701 | */ |
702 | } |
703 | |
704 | -const string module::Library::getLibraryPath(const string &plugin_name) |
705 | +const fs::path module::Library::getLibraryPath(const string &plugin_name) |
706 | { |
707 | - /* Compile dll path */ |
708 | - string dlpath; |
709 | - dlpath.reserve(FN_REFLEN); |
710 | - dlpath.append(opt_plugin_dir); |
711 | - dlpath.append("/"); |
712 | - dlpath.append("lib"); |
713 | - dlpath.append(plugin_name); |
714 | - dlpath.append("_plugin"); |
715 | + string plugin_lib_name("lib"); |
716 | + plugin_lib_name.append(plugin_name); |
717 | + plugin_lib_name.append("_plugin"); |
718 | #if defined(TARGET_OS_OSX) |
719 | - dlpath.append(".dylib"); |
720 | + plugin_lib_name.append(".dylib"); |
721 | #else |
722 | - dlpath.append(".so"); |
723 | + plugin_lib_name.append(".so"); |
724 | #endif |
725 | - return dlpath; |
726 | + |
727 | + /* Compile dll path */ |
728 | + return plugin_dir / plugin_lib_name; |
729 | } |
730 | |
731 | module::Library *module::Library::loadLibrary(const string &plugin_name, bool builtin) |
732 | @@ -102,7 +102,7 @@ |
733 | else |
734 | { |
735 | /* Open new dll handle */ |
736 | - dlpath.assign(Library::getLibraryPath(plugin_name)); |
737 | + dlpath.assign(Library::getLibraryPath(plugin_name).file_string()); |
738 | handle= dlopen(dlpath.c_str(), RTLD_NOW|RTLD_GLOBAL); |
739 | if (handle == NULL) |
740 | { |
741 | |
742 | === modified file 'drizzled/module/library.h' |
743 | --- drizzled/module/library.h 2010-05-15 18:23:34 +0000 |
744 | +++ drizzled/module/library.h 2010-10-06 07:38:58 +0000 |
745 | @@ -30,6 +30,8 @@ |
746 | |
747 | #include <string> |
748 | |
749 | +#include <boost/filesystem.hpp> |
750 | + |
751 | namespace drizzled |
752 | { |
753 | namespace module |
754 | @@ -67,7 +69,7 @@ |
755 | return manifest; |
756 | } |
757 | |
758 | - static const std::string getLibraryPath(const std::string &plugin_name); |
759 | + static const boost::filesystem::path getLibraryPath(const std::string &plugin_name); |
760 | static Library *loadLibrary(const std::string &plugin_name, bool builtin); |
761 | }; |
762 | |
763 | |
764 | === modified file 'drizzled/module/loader.cc' |
765 | --- drizzled/module/loader.cc 2010-10-02 21:15:42 +0000 |
766 | +++ drizzled/module/loader.cc 2010-10-06 07:38:58 +0000 |
767 | @@ -75,7 +75,6 @@ |
768 | static PluginOptions opt_plugin_load; |
769 | static PluginOptions opt_plugin_add; |
770 | static PluginOptions opt_plugin_remove; |
771 | -char opt_plugin_dir[FN_REFLEN]; |
772 | const char *builtin_plugins= PANDORA_BUILTIN_LIST; |
773 | |
774 | /* Note that 'int version' must be the first field of every plugin |
775 | |
776 | === modified file 'drizzled/plugin.h' |
777 | --- drizzled/plugin.h 2010-09-27 18:14:40 +0000 |
778 | +++ drizzled/plugin.h 2010-10-06 07:38:58 +0000 |
779 | @@ -29,6 +29,7 @@ |
780 | #include "drizzled/lex_string.h" |
781 | #include "drizzled/xid.h" |
782 | #include <boost/program_options.hpp> |
783 | +#include <boost/filesystem.hpp> |
784 | |
785 | namespace drizzled |
786 | { |
787 | @@ -46,7 +47,7 @@ |
788 | typedef drizzle_lex_string LEX_STRING; |
789 | struct option; |
790 | |
791 | -extern char opt_plugin_dir[FN_REFLEN]; |
792 | +extern boost::filesystem::path plugin_dir; |
793 | |
794 | namespace plugin { class StorageEngine; } |
795 | |
796 | |
797 | === modified file 'drizzled/select_export.h' |
798 | --- drizzled/select_export.h 2010-03-29 20:16:08 +0000 |
799 | +++ drizzled/select_export.h 2010-10-06 07:38:58 +0000 |
800 | @@ -29,7 +29,9 @@ |
801 | namespace drizzled |
802 | { |
803 | |
804 | -class select_export :public select_to_file { |
805 | +class select_export : |
806 | + public select_to_file |
807 | +{ |
808 | uint32_t field_term_length; |
809 | int field_sep_char,escape_char,line_sep_char; |
810 | int field_term_char; // first char of FIELDS TERMINATED BY or MAX_INT |
811 | |
812 | === modified file 'drizzled/select_to_file.h' |
813 | --- drizzled/select_to_file.h 2010-02-04 08:14:46 +0000 |
814 | +++ drizzled/select_to_file.h 2010-10-06 07:38:58 +0000 |
815 | @@ -21,6 +21,8 @@ |
816 | #ifndef DRIZZLED_SELECT_TO_FILE_H |
817 | #define DRIZZLED_SELECT_TO_FILE_H |
818 | |
819 | +#include <boost/filesystem.hpp> |
820 | + |
821 | namespace drizzled |
822 | { |
823 | |
824 | @@ -29,14 +31,15 @@ |
825 | typedef struct st_io_cache IO_CACHE; |
826 | } |
827 | |
828 | -class select_to_file : public select_result_interceptor |
829 | +class select_to_file : |
830 | + public select_result_interceptor |
831 | { |
832 | protected: |
833 | file_exchange *exchange; |
834 | int file; |
835 | internal::IO_CACHE *cache; |
836 | ha_rows row_count; |
837 | - char path[FN_REFLEN]; |
838 | + boost::filesystem::path path; |
839 | |
840 | public: |
841 | select_to_file(file_exchange *ex); |
842 | |
843 | === modified file 'drizzled/session.cc' |
844 | --- drizzled/session.cc 2010-09-28 06:27:36 +0000 |
845 | +++ drizzled/session.cc 2010-10-06 07:38:58 +0000 |
846 | @@ -913,7 +913,7 @@ |
847 | { |
848 | (void) end_io_cache(cache); |
849 | (void) internal::my_close(file, MYF(0)); |
850 | - (void) internal::my_delete(path, MYF(0)); // Delete file on error |
851 | + (void) internal::my_delete(path.file_string().c_str(), MYF(0)); // Delete file on error |
852 | file= -1; |
853 | } |
854 | } |
855 | @@ -947,7 +947,7 @@ |
856 | (void) internal::my_close(file, MYF(0)); |
857 | file= -1; |
858 | } |
859 | - path[0]= '\0'; |
860 | + path= ""; |
861 | row_count= 0; |
862 | } |
863 | |
864 | @@ -957,7 +957,7 @@ |
865 | cache(static_cast<internal::IO_CACHE *>(memory::sql_calloc(sizeof(internal::IO_CACHE)))), |
866 | row_count(0L) |
867 | { |
868 | - path[0]=0; |
869 | + path= ""; |
870 | } |
871 | |
872 | select_to_file::~select_to_file() |
873 | @@ -991,31 +991,40 @@ |
874 | */ |
875 | |
876 | |
877 | -static int create_file(Session *session, char *path, file_exchange *exchange, internal::IO_CACHE *cache) |
878 | +static int create_file(Session *session, |
879 | + fs::path &target_path, |
880 | + file_exchange *exchange, |
881 | + internal::IO_CACHE *cache) |
882 | { |
883 | + fs::path to_file(exchange->file_name); |
884 | int file; |
885 | - uint32_t option= MY_UNPACK_FILENAME | MY_RELATIVE_PATH; |
886 | - |
887 | -#ifdef DONT_ALLOW_FULL_LOAD_DATA_PATHS |
888 | - option|= MY_REPLACE_DIR; // Force use of db directory |
889 | -#endif |
890 | - |
891 | - if (!internal::dirname_length(exchange->file_name)) |
892 | + |
893 | + if (not to_file.has_root_directory()) |
894 | { |
895 | - strcpy(path, getDataHomeCatalog().c_str()); |
896 | - strncat(path, "/", 1); |
897 | - if (! session->db.empty()) |
898 | - strncat(path, session->db.c_str(), FN_REFLEN-getDataHomeCatalog().size()); |
899 | - (void) internal::fn_format(path, exchange->file_name, path, "", option); |
900 | + target_path= fs::system_complete(getDataHomeCatalog()); |
901 | + if (not session->db.empty()) |
902 | + { |
903 | + int count_elements= 0; |
904 | + for (fs::path::iterator iter= to_file.begin(); |
905 | + iter != to_file.end(); |
906 | + ++iter, ++count_elements) |
907 | + { } |
908 | + |
909 | + if (count_elements == 1) |
910 | + { |
911 | + target_path /= session->db; |
912 | + } |
913 | + } |
914 | + target_path /= to_file; |
915 | } |
916 | else |
917 | - (void) internal::fn_format(path, exchange->file_name, getDataHomeCatalog().c_str(), "", option); |
918 | + { |
919 | + target_path = exchange->file_name; |
920 | + } |
921 | |
922 | - if (opt_secure_file_priv) |
923 | + if (not secure_file_priv.string().empty()) |
924 | { |
925 | - fs::path secure_file_path(fs::system_complete(fs::path(opt_secure_file_priv))); |
926 | - fs::path target_path(fs::system_complete(fs::path(path))); |
927 | - if (target_path.file_string().substr(0, secure_file_path.file_string().size()) != secure_file_path.file_string()) |
928 | + if (target_path.file_string().substr(0, secure_file_priv.file_string().size()) != secure_file_priv.file_string()) |
929 | { |
930 | /* Write only allowed to dir or subdir specified by secure_file_priv */ |
931 | my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv"); |
932 | @@ -1023,19 +1032,19 @@ |
933 | } |
934 | } |
935 | |
936 | - if (!access(path, F_OK)) |
937 | + if (!access(target_path.file_string().c_str(), F_OK)) |
938 | { |
939 | my_error(ER_FILE_EXISTS_ERROR, MYF(0), exchange->file_name); |
940 | return -1; |
941 | } |
942 | /* Create the file world readable */ |
943 | - if ((file= internal::my_create(path, 0666, O_WRONLY|O_EXCL, MYF(MY_WME))) < 0) |
944 | + if ((file= internal::my_create(target_path.file_string().c_str(), 0666, O_WRONLY|O_EXCL, MYF(MY_WME))) < 0) |
945 | return file; |
946 | (void) fchmod(file, 0666); // Because of umask() |
947 | if (init_io_cache(cache, file, 0L, internal::WRITE_CACHE, 0L, 1, MYF(MY_WME))) |
948 | { |
949 | internal::my_close(file, MYF(0)); |
950 | - internal::my_delete(path, MYF(0)); // Delete file on error, it was just created |
951 | + internal::my_delete(target_path.file_string().c_str(), MYF(0)); // Delete file on error, it was just created |
952 | return -1; |
953 | } |
954 | return file; |
955 | @@ -1049,7 +1058,9 @@ |
956 | bool string_results= false, non_string_results= false; |
957 | unit= u; |
958 | if ((uint32_t) strlen(exchange->file_name) + NAME_LEN >= FN_REFLEN) |
959 | - strncpy(path,exchange->file_name,FN_REFLEN-1); |
960 | + { |
961 | + path= exchange->file_name; |
962 | + } |
963 | |
964 | /* Check if there is any blobs in data */ |
965 | { |
966 | @@ -1318,7 +1329,7 @@ |
967 | if (row_count++ > 1) |
968 | { |
969 | my_message(ER_TOO_MANY_ROWS, ER(ER_TOO_MANY_ROWS), MYF(0)); |
970 | - goto err; |
971 | + return 1; |
972 | } |
973 | while ((item=li++)) |
974 | { |
975 | @@ -1326,17 +1337,15 @@ |
976 | if (!res) // If NULL |
977 | { |
978 | if (my_b_write(cache,(unsigned char*) "",1)) |
979 | - goto err; |
980 | + return 1; |
981 | } |
982 | else if (my_b_write(cache,(unsigned char*) res->ptr(),res->length())) |
983 | { |
984 | - my_error(ER_ERROR_ON_WRITE, MYF(0), path, errno); |
985 | - goto err; |
986 | + my_error(ER_ERROR_ON_WRITE, MYF(0), path.file_string().c_str(), errno); |
987 | + return 1; |
988 | } |
989 | } |
990 | return(0); |
991 | -err: |
992 | - return(1); |
993 | } |
994 | |
995 | |
996 | |
997 | === modified file 'drizzled/set_var.cc' |
998 | --- drizzled/set_var.cc 2010-09-29 16:49:08 +0000 |
999 | +++ drizzled/set_var.cc 2010-10-06 07:38:58 +0000 |
1000 | @@ -86,7 +86,6 @@ |
1001 | extern size_t my_thread_stack_size; |
1002 | |
1003 | class sys_var_pluginvar; |
1004 | -static DYNAMIC_ARRAY fixed_show_vars; |
1005 | typedef map<string, sys_var *> SystemVariableMap; |
1006 | static SystemVariableMap system_variable_map; |
1007 | extern char *opt_drizzle_tmpdir; |
1008 | @@ -135,7 +134,14 @@ |
1009 | sys_auto_increment_offset(&vars, "auto_increment_offset", |
1010 | &system_variables::auto_increment_offset); |
1011 | |
1012 | -static sys_var_const_str sys_basedir(&vars, "basedir", drizzle_home); |
1013 | +static sys_var_fs_path sys_basedir(&vars, "basedir", basedir); |
1014 | +static sys_var_fs_path sys_pid_file(&vars, "pid_file", pid_file); |
1015 | +static sys_var_fs_path sys_plugin_dir(&vars, "plugin_dir", plugin_dir); |
1016 | + |
1017 | +static sys_var_size_t_ptr sys_thread_stack_size(&vars, "thread_stack", |
1018 | + &my_thread_stack_size); |
1019 | +static sys_var_uint32_t_ptr sys_back_log(&vars, "back_log", &back_log); |
1020 | + |
1021 | static sys_var_session_uint64_t sys_bulk_insert_buff_size(&vars, "bulk_insert_buffer_size", |
1022 | &system_variables::bulk_insert_buff_size); |
1023 | static sys_var_session_uint32_t sys_completion_type(&vars, "completion_type", |
1024 | @@ -144,7 +150,7 @@ |
1025 | fix_completion_type); |
1026 | static sys_var_collation_sv |
1027 | sys_collation_server(&vars, "collation_server", &system_variables::collation_server, &default_charset_info); |
1028 | -static sys_var_const_str_ptr sys_datadir(&vars, "datadir", getDatadirPtr()); |
1029 | +static sys_var_fs_path sys_datadir(&vars, "datadir", getDataHome()); |
1030 | |
1031 | static sys_var_session_uint64_t sys_join_buffer_size(&vars, "join_buffer_size", |
1032 | &system_variables::join_buff_size); |
1033 | @@ -198,8 +204,8 @@ |
1034 | false, fix_session_mem_root); |
1035 | static sys_var_readonly sys_tmpdir(&vars, "tmpdir", OPT_GLOBAL, SHOW_CHAR, get_tmpdir); |
1036 | |
1037 | -static sys_var_const_str_ptr sys_secure_file_priv(&vars, "secure_file_priv", |
1038 | - &opt_secure_file_priv); |
1039 | +static sys_var_fs_path sys_secure_file_priv(&vars, "secure_file_priv", |
1040 | + secure_file_priv); |
1041 | |
1042 | static sys_var_const_str_ptr sys_scheduler(&vars, "scheduler", |
1043 | (char**)&opt_scheduler); |
1044 | @@ -307,21 +313,6 @@ |
1045 | /* Global read-only variable containing hostname */ |
1046 | static sys_var_const_str sys_hostname(&vars, "hostname", glob_hostname); |
1047 | |
1048 | -/* |
1049 | - Additional variables (not derived from sys_var class, not accessible as |
1050 | - @@varname in SELECT or SET). Sorted in alphabetical order to facilitate |
1051 | - maintenance - SHOW VARIABLES will sort its output. |
1052 | - TODO: remove this list completely |
1053 | -*/ |
1054 | - |
1055 | -#define FIXED_VARS_SIZE (sizeof(fixed_vars) / sizeof(drizzle_show_var)) |
1056 | -static drizzle_show_var fixed_vars[]= { |
1057 | - {"back_log", (char*) &back_log, SHOW_INT}, |
1058 | - {"pid_file", (char*) pidfile_name, SHOW_CHAR}, |
1059 | - {"plugin_dir", (char*) opt_plugin_dir, SHOW_CHAR}, |
1060 | - {"thread_stack", (char*) &my_thread_stack_size, SHOW_INT}, |
1061 | -}; |
1062 | - |
1063 | bool sys_var::check(Session *, set_var *var) |
1064 | { |
1065 | var->save_result.uint64_t_value= var->value->val_int(); |
1066 | @@ -1562,23 +1553,20 @@ |
1067 | SYNOPSIS |
1068 | enumerate_sys_vars() |
1069 | session current thread |
1070 | - sorted If TRUE, the system variables should be sorted |
1071 | |
1072 | RETURN VALUES |
1073 | pointer Array of drizzle_show_var elements for display |
1074 | NULL FAILURE |
1075 | */ |
1076 | |
1077 | -drizzle_show_var* enumerate_sys_vars(Session *session, bool) |
1078 | +drizzle_show_var* enumerate_sys_vars(Session *session) |
1079 | { |
1080 | - int fixed_count= fixed_show_vars.elements; |
1081 | - int size= sizeof(drizzle_show_var) * (system_variable_map.size() + fixed_count + 1); |
1082 | + int size= sizeof(drizzle_show_var) * (system_variable_map.size() + 1); |
1083 | drizzle_show_var *result= (drizzle_show_var*) session->alloc(size); |
1084 | |
1085 | if (result) |
1086 | { |
1087 | - drizzle_show_var *show= result + fixed_count; |
1088 | - memcpy(result, fixed_show_vars.buffer, fixed_count * sizeof(drizzle_show_var)); |
1089 | + drizzle_show_var *show= result; |
1090 | |
1091 | SystemVariableMap::const_iterator iter= system_variable_map.begin(); |
1092 | while (iter != system_variable_map.end()) |
1093 | @@ -1587,7 +1575,7 @@ |
1094 | show->name= var->getName().c_str(); |
1095 | show->value= (char*) var; |
1096 | show->type= SHOW_SYS; |
1097 | - show++; |
1098 | + ++show; |
1099 | ++iter; |
1100 | } |
1101 | |
1102 | @@ -1615,13 +1603,6 @@ |
1103 | |
1104 | for (sys_var *var= vars.first; var; var= var->getNext(), count++) {}; |
1105 | |
1106 | - if (my_init_dynamic_array(&fixed_show_vars, sizeof(drizzle_show_var), |
1107 | - FIXED_VARS_SIZE + 64, 64)) |
1108 | - goto error; |
1109 | - |
1110 | - fixed_show_vars.elements= FIXED_VARS_SIZE; |
1111 | - memcpy(fixed_show_vars.buffer, fixed_vars, sizeof(fixed_vars)); |
1112 | - |
1113 | vars.last->setNext(NULL); |
1114 | if (mysql_add_sys_var_chain(vars.first, my_long_options)) |
1115 | goto error; |
1116 | @@ -1634,12 +1615,6 @@ |
1117 | } |
1118 | |
1119 | |
1120 | -void set_var_free() |
1121 | -{ |
1122 | - delete_dynamic(&fixed_show_vars); |
1123 | -} |
1124 | - |
1125 | - |
1126 | /** |
1127 | Find a user set-table variable. |
1128 | |
1129 | |
1130 | === modified file 'drizzled/set_var.h' |
1131 | --- drizzled/set_var.h 2010-09-29 16:49:08 +0000 |
1132 | +++ drizzled/set_var.h 2010-10-06 07:38:58 +0000 |
1133 | @@ -21,6 +21,7 @@ |
1134 | #define DRIZZLED_SET_VAR_H |
1135 | |
1136 | #include <string> |
1137 | +#include <boost/filesystem.hpp> |
1138 | |
1139 | #include "drizzled/function/func.h" |
1140 | #include "drizzled/function/set_user_var.h" |
1141 | @@ -62,8 +63,9 @@ |
1142 | extern const char *in_additional_cond; |
1143 | extern const char *in_having_cond; |
1144 | extern char glob_hostname[FN_REFLEN]; |
1145 | -extern char drizzle_home[FN_REFLEN]; |
1146 | -extern char pidfile_name[FN_REFLEN]; |
1147 | +extern boost::filesystem::path basedir; |
1148 | +extern boost::filesystem::path pid_file; |
1149 | +extern boost::filesystem::path secure_file_priv; |
1150 | extern char system_time_zone[30]; |
1151 | extern char *opt_tc_log_file; |
1152 | extern uint64_t session_startup_options; |
1153 | @@ -80,7 +82,6 @@ |
1154 | extern uint32_t volatile thread_running; |
1155 | extern uint32_t volatile global_read_lock; |
1156 | extern bool opt_readonly; |
1157 | -extern char* opt_secure_file_priv; |
1158 | extern char *default_tz_name; |
1159 | extern const char *opt_scheduler; |
1160 | |
1161 | @@ -360,6 +361,44 @@ |
1162 | }; |
1163 | |
1164 | |
1165 | +class sys_var_fs_path : |
1166 | + public sys_var |
1167 | +{ |
1168 | + const boost::filesystem::path &value; |
1169 | +public: |
1170 | + sys_var_fs_path(sys_var_chain *chain, |
1171 | + const char *name_arg, |
1172 | + const boost::filesystem::path& value_arg) : |
1173 | + sys_var(name_arg), |
1174 | + value(value_arg) |
1175 | + { |
1176 | + chain_sys_var(chain); |
1177 | + } |
1178 | + |
1179 | + inline void set(char *) |
1180 | + { } |
1181 | + |
1182 | + bool check(Session *, set_var *) |
1183 | + { |
1184 | + return true; |
1185 | + } |
1186 | + bool update(Session *, set_var *) |
1187 | + { |
1188 | + return true; |
1189 | + } |
1190 | + SHOW_TYPE show_type() { return SHOW_CHAR; } |
1191 | + unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *) |
1192 | + { |
1193 | + return (unsigned char*)(value.file_string().c_str()); |
1194 | + } |
1195 | + bool check_update_type(Item_result) |
1196 | + { |
1197 | + return true; |
1198 | + } |
1199 | + bool check_default(sql_var_t) { return true; } |
1200 | + bool is_readonly() const { return true; } |
1201 | +}; |
1202 | + |
1203 | class sys_var_const_str :public sys_var |
1204 | { |
1205 | char *value; // Pointer to const value |
1206 | @@ -912,8 +951,7 @@ |
1207 | */ |
1208 | |
1209 | int set_var_init(); |
1210 | -void set_var_free(); |
1211 | -drizzle_show_var* enumerate_sys_vars(Session *session, bool sorted); |
1212 | +drizzle_show_var* enumerate_sys_vars(Session *session); |
1213 | void drizzle_add_plugin_sysvar(sys_var_pluginvar *var); |
1214 | void drizzle_del_plugin_sysvar(); |
1215 | int mysql_add_sys_var_chain(sys_var *chain, struct option *long_options); |
1216 | |
1217 | === modified file 'drizzled/sql_load.cc' |
1218 | --- drizzled/sql_load.cc 2010-10-02 21:15:42 +0000 |
1219 | +++ drizzled/sql_load.cc 2010-10-06 07:38:58 +0000 |
1220 | @@ -124,7 +124,6 @@ |
1221 | List<Item> &set_values, |
1222 | enum enum_duplicates handle_duplicates, bool ignore) |
1223 | { |
1224 | - char name[FN_REFLEN]; |
1225 | int file; |
1226 | Table *table= NULL; |
1227 | int error; |
1228 | @@ -254,61 +253,62 @@ |
1229 | return(true); |
1230 | } |
1231 | |
1232 | - { |
1233 | -#ifdef DONT_ALLOW_FULL_LOAD_DATA_PATHS |
1234 | - ex->file_name+=dirname_length(ex->file_name); |
1235 | -#endif |
1236 | - if (!internal::dirname_length(ex->file_name)) |
1237 | - { |
1238 | - strcpy(name, getDataHomeCatalog().c_str()); |
1239 | - strncat(name, "/", 1); |
1240 | - strncat(name, tdb, FN_REFLEN-getDataHomeCatalog().size()); |
1241 | - (void) internal::fn_format(name, ex->file_name, name, "", |
1242 | - MY_RELATIVE_PATH | MY_UNPACK_FILENAME); |
1243 | - } |
1244 | - else |
1245 | - { |
1246 | - (void) internal::fn_format(name, ex->file_name, getDataHomeCatalog().c_str(), "", |
1247 | - MY_RELATIVE_PATH | MY_UNPACK_FILENAME); |
1248 | - |
1249 | - if (opt_secure_file_priv) |
1250 | - { |
1251 | - fs::path secure_file_path(fs::system_complete(fs::path(opt_secure_file_priv))); |
1252 | - fs::path target_path(fs::system_complete(fs::path(name))); |
1253 | - if (target_path.file_string().substr(0, secure_file_path.file_string().size()) != secure_file_path.file_string()) |
1254 | - { |
1255 | - /* Read only allowed from within dir specified by secure_file_priv */ |
1256 | - my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv"); |
1257 | - return(true); |
1258 | - } |
1259 | - } |
1260 | - |
1261 | - struct stat stat_info; |
1262 | - if (stat(name,&stat_info)) |
1263 | - { |
1264 | - my_error(ER_FILE_NOT_FOUND, MYF(0), name, errno); |
1265 | - return(true); |
1266 | - } |
1267 | - |
1268 | - // if we are not in slave thread, the cursor must be: |
1269 | - if (!((stat_info.st_mode & S_IROTH) == S_IROTH && // readable by others |
1270 | - (stat_info.st_mode & S_IFLNK) != S_IFLNK && // and not a symlink |
1271 | - ((stat_info.st_mode & S_IFREG) == S_IFREG || |
1272 | - (stat_info.st_mode & S_IFIFO) == S_IFIFO))) |
1273 | - { |
1274 | - my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), name); |
1275 | - return(true); |
1276 | - } |
1277 | - if ((stat_info.st_mode & S_IFIFO) == S_IFIFO) |
1278 | - is_fifo = 1; |
1279 | - } |
1280 | - if ((file=internal::my_open(name,O_RDONLY,MYF(MY_WME))) < 0) |
1281 | - { |
1282 | - my_error(ER_CANT_OPEN_FILE, MYF(0), name, errno); |
1283 | + fs::path to_file(ex->file_name); |
1284 | + fs::path target_path(fs::system_complete(getDataHomeCatalog())); |
1285 | + if (not to_file.has_root_directory()) |
1286 | + { |
1287 | + int count_elements= 0; |
1288 | + for (fs::path::iterator iter= to_file.begin(); |
1289 | + iter != to_file.end(); |
1290 | + ++iter, ++count_elements) |
1291 | + { } |
1292 | + |
1293 | + if (count_elements == 1) |
1294 | + { |
1295 | + target_path /= tdb; |
1296 | + } |
1297 | + target_path /= to_file; |
1298 | + } |
1299 | + else |
1300 | + { |
1301 | + target_path= to_file; |
1302 | + } |
1303 | + |
1304 | + if (not secure_file_priv.string().empty()) |
1305 | + { |
1306 | + if (target_path.file_string().substr(0, secure_file_priv.file_string().size()) != secure_file_priv.file_string()) |
1307 | + { |
1308 | + /* Read only allowed from within dir specified by secure_file_priv */ |
1309 | + my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv"); |
1310 | return(true); |
1311 | } |
1312 | } |
1313 | |
1314 | + struct stat stat_info; |
1315 | + if (stat(target_path.file_string().c_str(), &stat_info)) |
1316 | + { |
1317 | + my_error(ER_FILE_NOT_FOUND, MYF(0), target_path.file_string().c_str(), errno); |
1318 | + return(true); |
1319 | + } |
1320 | + |
1321 | + // if we are not in slave thread, the cursor must be: |
1322 | + if (!((stat_info.st_mode & S_IROTH) == S_IROTH && // readable by others |
1323 | + (stat_info.st_mode & S_IFLNK) != S_IFLNK && // and not a symlink |
1324 | + ((stat_info.st_mode & S_IFREG) == S_IFREG || |
1325 | + (stat_info.st_mode & S_IFIFO) == S_IFIFO))) |
1326 | + { |
1327 | + my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), target_path.file_string().c_str()); |
1328 | + return(true); |
1329 | + } |
1330 | + if ((stat_info.st_mode & S_IFIFO) == S_IFIFO) |
1331 | + is_fifo = 1; |
1332 | + |
1333 | + |
1334 | + if ((file=internal::my_open(target_path.file_string().c_str(), O_RDONLY,MYF(MY_WME))) < 0) |
1335 | + { |
1336 | + my_error(ER_CANT_OPEN_FILE, MYF(0), target_path.file_string().c_str(), errno); |
1337 | + return(true); |
1338 | + } |
1339 | CopyInfo info; |
1340 | memset(&info, 0, sizeof(info)); |
1341 | info.ignore= ignore; |
1342 | @@ -395,14 +395,16 @@ |
1343 | error= -1; // Error on read |
1344 | goto err; |
1345 | } |
1346 | - snprintf(name, sizeof(name), ER(ER_LOAD_INFO), info.records, info.deleted, |
1347 | + |
1348 | + char msg[FN_REFLEN]; |
1349 | + snprintf(msg, sizeof(msg), ER(ER_LOAD_INFO), info.records, info.deleted, |
1350 | (info.records - info.copied), session->cuted_fields); |
1351 | |
1352 | if (session->transaction.stmt.hasModifiedNonTransData()) |
1353 | session->transaction.all.markModifiedNonTransData(); |
1354 | |
1355 | /* ok to client sent only after binlog write and engine commit */ |
1356 | - session->my_ok(info.copied + info.deleted, 0, 0L, name); |
1357 | + session->my_ok(info.copied + info.deleted, 0, 0L, msg); |
1358 | err: |
1359 | assert(transactional_table || !(info.copied || info.deleted) || |
1360 | session->transaction.stmt.hasModifiedNonTransData()); |
1361 | |
1362 | === modified file 'drizzled/thr_lock.cc' |
1363 | --- drizzled/thr_lock.cc 2010-10-02 21:15:42 +0000 |
1364 | +++ drizzled/thr_lock.cc 2010-10-06 07:38:58 +0000 |
1365 | @@ -89,7 +89,7 @@ |
1366 | static enum thr_lock_type thr_upgraded_concurrent_insert_lock = TL_WRITE; |
1367 | |
1368 | |
1369 | -uint64_t max_write_lock_count= ~(uint64_t) 0L; |
1370 | +uint64_t max_write_lock_count= UINT64_MAX; |
1371 | |
1372 | /* |
1373 | ** For the future (now the thread specific cond is alloced by my_pthread.c) |
1374 | |
1375 | === modified file 'plugin/innobase/handler/ha_innodb.cc' |
1376 | --- plugin/innobase/handler/ha_innodb.cc 2010-10-02 21:15:42 +0000 |
1377 | +++ plugin/innobase/handler/ha_innodb.cc 2010-10-06 07:38:58 +0000 |
1378 | @@ -90,10 +90,12 @@ |
1379 | |
1380 | #include <boost/algorithm/string.hpp> |
1381 | #include <boost/program_options.hpp> |
1382 | +#include <boost/filesystem.hpp> |
1383 | #include <drizzled/module/option_map.h> |
1384 | #include <iostream> |
1385 | |
1386 | namespace po= boost::program_options; |
1387 | +namespace fs=boost::filesystem; |
1388 | using namespace std; |
1389 | |
1390 | /** @file ha_innodb.cc */ |
1391 | @@ -307,6 +309,7 @@ |
1392 | |
1393 | /* These get strdup'd from vm variables */ |
1394 | free(innobase_data_home_dir); |
1395 | + free(innobase_log_group_home_dir); |
1396 | |
1397 | } |
1398 | |
1399 | @@ -1839,7 +1842,7 @@ |
1400 | } |
1401 | else |
1402 | { |
1403 | - innobase_data_home_dir= strdup(getDataHome().c_str()); |
1404 | + innobase_data_home_dir= strdup(getDataHome().file_string().c_str()); |
1405 | } |
1406 | |
1407 | if (vm.count("fast-shutdown")) |
1408 | @@ -2160,11 +2163,11 @@ |
1409 | |
1410 | if (vm.count("log-group-home-dir")) |
1411 | { |
1412 | - innobase_log_group_home_dir= const_cast<char *>(vm["log-group-home-dir"].as<string>().c_str()); |
1413 | + innobase_log_group_home_dir= strdup(vm["log-group-home-dir"].as<string>().c_str()); |
1414 | } |
1415 | else |
1416 | { |
1417 | - innobase_log_group_home_dir = const_cast<char *>(getDataHome().c_str()); |
1418 | + innobase_log_group_home_dir = strdup(getDataHome().file_string().c_str()); |
1419 | } |
1420 | |
1421 | #ifdef UNIV_LOG_ARCHIVE |
1422 | @@ -6435,7 +6438,6 @@ |
1423 | ib_int64_t n_rows; |
1424 | ulong j; |
1425 | ulong i; |
1426 | - char path[FN_REFLEN]; |
1427 | os_file_stat_t stat_info; |
1428 | |
1429 | /* If we are forcing recovery at a high level, we will suppress |
1430 | @@ -6479,15 +6481,14 @@ |
1431 | prebuilt->trx->op_info = "returning various info to MySQL"; |
1432 | } |
1433 | |
1434 | - snprintf(path, sizeof(path), "%s/%s%s", |
1435 | - getDataHomeCatalog().c_str(), ib_table->name, ".dfe"); |
1436 | - |
1437 | - internal::unpack_filename(path,path); |
1438 | + fs::path get_status_path(getDataHomeCatalog()); |
1439 | + get_status_path /= ib_table->name; |
1440 | + fs::change_extension(get_status_path, "dfe"); |
1441 | |
1442 | /* Note that we do not know the access time of the table, |
1443 | nor the CHECK TABLE time, nor the UPDATE or INSERT time. */ |
1444 | |
1445 | - if (os_file_get_status(path,&stat_info)) { |
1446 | + if (os_file_get_status(get_status_path.file_string().c_str(), &stat_info)) { |
1447 | stats.create_time = (ulong) stat_info.ctime; |
1448 | } |
1449 | } |
1450 | |
1451 | === modified file 'plugin/pbms/src/database_ms.cc' |
1452 | --- plugin/pbms/src/database_ms.cc 2010-10-02 21:15:42 +0000 |
1453 | +++ plugin/pbms/src/database_ms.cc 2010-10-06 07:38:58 +0000 |
1454 | @@ -1259,7 +1259,7 @@ |
1455 | * The database name is case sensitive here if the file system names are |
1456 | * case sensitive. This is desirable. |
1457 | */ |
1458 | - path = CSPath::newPath(ms_my_get_mysql_home_path(), RETAIN(db_name)); |
1459 | + path = CSPath::newPath(ms_my_get_mysql_home_path().c_str(), RETAIN(db_name)); |
1460 | push_(path); |
1461 | if (create && !path->exists()) { |
1462 | CSException::throwException(CS_CONTEXT, MS_ERR_UNKNOWN_DB, db_name->getCString()); |
1463 | @@ -1605,7 +1605,7 @@ |
1464 | bool create = false; |
1465 | uint32_t db_id; |
1466 | |
1467 | - path = createDatabasePath(ms_my_get_mysql_home_path(), CSString::newString(db_name), &db_id, &create); |
1468 | + path = createDatabasePath(ms_my_get_mysql_home_path().c_str(), CSString::newString(db_name), &db_id, &create); |
1469 | |
1470 | if (path) { |
1471 | MSTransactionManager::dropDatabase(db_id); |
1472 | @@ -1636,7 +1636,7 @@ |
1473 | // 3: <database>/<table> |
1474 | bool MSDatabase::convertTablePathToIDs(const char *table_path, uint32_t *db_id, uint32_t *tab_id, bool create) |
1475 | { |
1476 | - const char *base = ms_my_get_mysql_home_path(); |
1477 | + const char *base = ms_my_get_mysql_home_path().c_str(); |
1478 | CSString *table_url; |
1479 | CSString *db_path = NULL; |
1480 | CSString *db_name = NULL; |
1481 | @@ -1736,7 +1736,7 @@ |
1482 | MSDatabase *db; |
1483 | enter_(); |
1484 | |
1485 | - db = newDatabase(ms_my_get_mysql_home_path(), db_name, 0, create); |
1486 | + db = newDatabase(ms_my_get_mysql_home_path().c_str(), db_name, 0, create); |
1487 | |
1488 | if (db) { |
1489 | push_(db); |
1490 | |
1491 | === modified file 'plugin/pbms/src/mysql_ms.cc' |
1492 | --- plugin/pbms/src/mysql_ms.cc 2010-10-02 21:15:42 +0000 |
1493 | +++ plugin/pbms/src/mysql_ms.cc 2010-10-06 07:38:58 +0000 |
1494 | @@ -56,9 +56,9 @@ |
1495 | } |
1496 | |
1497 | #ifdef DRIZZLED |
1498 | -const char *ms_my_get_mysql_home_path() |
1499 | +const std::string ms_my_get_mysql_home_path() |
1500 | { |
1501 | - return drizzled::getDataHomeCatalog().c_str(); |
1502 | + return drizzled::getDataHomeCatalog().file_string(); |
1503 | } |
1504 | |
1505 | bool ms_is_autocommit() |
1506 | @@ -67,7 +67,7 @@ |
1507 | } |
1508 | |
1509 | #else |
1510 | -const char *ms_my_get_mysql_home_path() |
1511 | +const std::string ms_my_get_mysql_home_path() |
1512 | { |
1513 | return mysql_real_data_home; |
1514 | } |
1515 | |
1516 | === modified file 'plugin/pbms/src/mysql_ms.h' |
1517 | --- plugin/pbms/src/mysql_ms.h 2010-10-02 21:15:42 +0000 |
1518 | +++ plugin/pbms/src/mysql_ms.h 2010-10-06 07:38:58 +0000 |
1519 | @@ -30,9 +30,11 @@ |
1520 | #ifndef __MS_MYSQL_H__ |
1521 | #define __MS_MYSQL_H__ |
1522 | |
1523 | +#include <string> |
1524 | + |
1525 | void *ms_my_get_thread(); |
1526 | uint64_t ms_my_1970_to_mysql_time(time_t t); |
1527 | -const char *ms_my_get_mysql_home_path(); |
1528 | +const std::string ms_my_get_mysql_home_path(); |
1529 | void ms_my_set_column_name(const char *table, uint16_t col_index, char *col_name); |
1530 | bool ms_is_autocommit(); |
1531 | |
1532 | |
1533 | === modified file 'plugin/pbms/src/pbmsdaemon_ms.cc' |
1534 | --- plugin/pbms/src/pbmsdaemon_ms.cc 2010-06-24 19:00:02 +0000 |
1535 | +++ plugin/pbms/src/pbmsdaemon_ms.cc 2010-10-06 07:38:58 +0000 |
1536 | @@ -59,6 +59,6 @@ |
1537 | pbd_state = state; |
1538 | |
1539 | if (pbd_state == DaemonStartUp) { // In theory we could allow this to be set with a commandline option. |
1540 | - cs_make_absolute_path(PATH_MAX, pbd_home_dir, "pbms", ms_my_get_mysql_home_path()); |
1541 | + cs_make_absolute_path(PATH_MAX, pbd_home_dir, "pbms", ms_my_get_mysql_home_path().c_str()); |
1542 | } |
1543 | } |
1544 | |
1545 | === modified file 'plugin/pbms/src/system_table_ms.cc' |
1546 | --- plugin/pbms/src/system_table_ms.cc 2010-10-02 21:15:42 +0000 |
1547 | +++ plugin/pbms/src/system_table_ms.cc 2010-10-06 07:38:58 +0000 |
1548 | @@ -423,7 +423,7 @@ |
1549 | if (!db) |
1550 | return false; |
1551 | |
1552 | - cs_strcpy(PATH_MAX, path, ms_my_get_mysql_home_path()); |
1553 | + cs_strcpy(PATH_MAX, path, ms_my_get_mysql_home_path().c_str()); |
1554 | cs_add_name_to_path(PATH_MAX, path, db); |
1555 | |
1556 | if (stat(path, &stat_info) == 0) |
1557 | |
1558 | === modified file 'plugin/pbxt/src/myxt_xt.cc' |
1559 | --- plugin/pbxt/src/myxt_xt.cc 2010-10-02 21:15:42 +0000 |
1560 | +++ plugin/pbxt/src/myxt_xt.cc 2010-10-06 07:38:58 +0000 |
1561 | @@ -44,9 +44,11 @@ |
1562 | #include <drizzled/charset_info.h> |
1563 | #include <plugin/myisam/my_handler.h> |
1564 | #include <plugin/myisam/myisampack.h> |
1565 | +#include <boost/filesystem.hpp> |
1566 | //extern "C" struct charset_info_st *session_charset(Session *session); |
1567 | extern pthread_key_t THR_Session; |
1568 | |
1569 | +namespace fs=boost::filesystem; |
1570 | using namespace drizzled; |
1571 | #else |
1572 | #include "mysql_priv.h" |
1573 | @@ -2029,12 +2031,10 @@ |
1574 | message::Table::STANDARD); |
1575 | } |
1576 | else { |
1577 | - std::string n(getDataHomeCatalog()); |
1578 | - n.append("/"); |
1579 | - n.append(database_name); |
1580 | - n.append("/"); |
1581 | - n.append(tab_file_name); |
1582 | - ident = new TableIdentifier(database_name, tab_name, n); |
1583 | + fs::path n(getDataHomeCatalog()); |
1584 | + n /= database_name; |
1585 | + n /= tab_file_name; |
1586 | + ident = new TableIdentifier(database_name, tab_name, n.file_string()); |
1587 | } |
1588 | |
1589 | share = new TableShare(message::Table::STANDARD); |
1590 | |
1591 | === modified file 'plugin/pbxt/src/xt_defs.h' |
1592 | --- plugin/pbxt/src/xt_defs.h 2010-10-02 21:15:42 +0000 |
1593 | +++ plugin/pbxt/src/xt_defs.h 2010-10-06 07:38:58 +0000 |
1594 | @@ -941,7 +941,8 @@ |
1595 | |
1596 | #define my_pthread_setspecific_ptr(T, V) pthread_setspecific(T, (void*) (V)) |
1597 | |
1598 | -#define mysql_real_data_home ::drizzled::getDataHomeCatalog().c_str() |
1599 | +/* TODO: This is dangerous! */ |
1600 | +#define mysql_real_data_home ::drizzled::getDataHomeCatalog().file_string().c_str() |
1601 | |
1602 | #define mi_int4store(T,A) { uint32_t def_temp= (uint32_t) (A);\ |
1603 | ((unsigned char*) (T))[3]= (unsigned char) (def_temp);\ |
1604 | |
1605 | === modified file 'plugin/schema_engine/schema.cc' |
1606 | --- plugin/schema_engine/schema.cc 2010-09-22 07:05:47 +0000 |
1607 | +++ plugin/schema_engine/schema.cc 2010-10-06 07:38:58 +0000 |
1608 | @@ -67,7 +67,7 @@ |
1609 | |
1610 | void Schema::prime() |
1611 | { |
1612 | - CachedDirectory directory(getDataHomeCatalog(), CachedDirectory::DIRECTORY); |
1613 | + CachedDirectory directory(getDataHomeCatalog().file_string(), CachedDirectory::DIRECTORY); |
1614 | CachedDirectory::Entries files= directory.getEntries(); |
1615 | |
1616 | mutex.lock(); |
1617 | |
1618 | === modified file 'plugin/signal_handler/signal_handler.cc' |
1619 | --- plugin/signal_handler/signal_handler.cc 2010-09-27 23:26:59 +0000 |
1620 | +++ plugin/signal_handler/signal_handler.cc 2010-10-06 07:38:58 +0000 |
1621 | @@ -28,6 +28,7 @@ |
1622 | #include "drizzled/drizzled.h" |
1623 | |
1624 | #include <boost/thread/thread.hpp> |
1625 | +#include <boost/filesystem.hpp> |
1626 | |
1627 | #include <sys/stat.h> |
1628 | #include <fcntl.h> |
1629 | @@ -41,7 +42,7 @@ |
1630 | extern int cleanup_done; |
1631 | extern bool volatile abort_loop; |
1632 | extern bool volatile shutdown_in_progress; |
1633 | -extern char pidfile_name[FN_REFLEN]; |
1634 | +extern boost::filesystem::path pid_file; |
1635 | /* Prototypes -> all of these should be factored out into a propper shutdown */ |
1636 | extern void close_connections(void); |
1637 | extern std::bitset<12> test_flags; |
1638 | @@ -88,8 +89,7 @@ |
1639 | int file; |
1640 | char buff[1024]; |
1641 | |
1642 | - assert(pidfile_name[0]); |
1643 | - if ((file = open(pidfile_name, O_CREAT|O_WRONLY|O_TRUNC, S_IRWXU|S_IRGRP|S_IROTH)) > 0) |
1644 | + if ((file = open(pid_file.file_string().c_str(), O_CREAT|O_WRONLY|O_TRUNC, S_IRWXU|S_IRGRP|S_IROTH)) > 0) |
1645 | { |
1646 | int length; |
1647 | |
1648 | @@ -103,7 +103,7 @@ |
1649 | (void)close(file); /* We can ignore the error, since we are going to error anyway at this point */ |
1650 | } |
1651 | memset(buff, 0, sizeof(buff)); |
1652 | - snprintf(buff, sizeof(buff)-1, "Can't start server: can't create PID file (%s)", pidfile_name); |
1653 | + snprintf(buff, sizeof(buff)-1, "Can't start server: can't create PID file (%s)", pid_file.file_string().c_str()); |
1654 | sql_perror(buff); |
1655 | exit(1); |
1656 | } |
1657 | |
1658 | === modified file 'plugin/status_dictionary/variables.h' |
1659 | --- plugin/status_dictionary/variables.h 2010-02-16 00:36:58 +0000 |
1660 | +++ plugin/status_dictionary/variables.h 2010-10-06 07:38:58 +0000 |
1661 | @@ -37,7 +37,7 @@ |
1662 | |
1663 | drizzled::drizzle_show_var *getVariables() |
1664 | { |
1665 | - return enumerate_sys_vars(current_session, false); // Final value unused |
1666 | + return enumerate_sys_vars(current_session); // Final value unused |
1667 | } |
1668 | }; |
1669 | |
1670 | |
1671 | === modified file 'tests/r/func_str.result' |
1672 | --- tests/r/func_str.result 2010-08-18 21:57:15 +0000 |
1673 | +++ tests/r/func_str.result 2010-10-06 07:38:58 +0000 |
1674 | @@ -721,11 +721,7 @@ |
1675 | 1 |
1676 | drop table t1; |
1677 | select load_file("lkjlkj"); |
1678 | -load_file("lkjlkj") |
1679 | -NULL |
1680 | -select ifnull(load_file("lkjlkj"),"it's null"); |
1681 | -ifnull(load_file("lkjlkj"),"it's null") |
1682 | -it's null |
1683 | +ERROR HY000: The file 'lkjlkj' must be in the database directory or be readable by all |
1684 | CREATE TABLE t1 (a varchar(10)); |
1685 | INSERT INTO t1 VALUES ('abc'), ('xyz'); |
1686 | SELECT a, CONCAT(a,' ',a) AS c FROM t1 |
1687 | |
1688 | === modified file 'tests/r/loaddata.result' |
1689 | --- tests/r/loaddata.result 2010-09-23 01:53:13 +0000 |
1690 | +++ tests/r/loaddata.result 2010-10-06 07:38:58 +0000 |
1691 | @@ -150,10 +150,10 @@ |
1692 | 15 NULL Ten |
1693 | show variables like "secure_file_pri%"; |
1694 | Variable_name Value |
1695 | -secure_file_priv MYSQLTEST_VARDIR/ |
1696 | +secure_file_priv MYSQLTEST_VARDIR |
1697 | select @@secure_file_priv; |
1698 | @@secure_file_priv |
1699 | -MYSQLTEST_VARDIR/ |
1700 | +MYSQLTEST_VARDIR |
1701 | set @@secure_file_priv= 0; |
1702 | ERROR HY000: Variable 'secure_file_priv' is a read only variable |
1703 | truncate table t1; |
1704 | @@ -162,8 +162,7 @@ |
1705 | select * from t1; |
1706 | a b c |
1707 | select load_file("DRIZZLE_TEST_DIR/t/loaddata.test"); |
1708 | -load_file("DRIZZLE_TEST_DIR/t/loaddata.test") |
1709 | -NULL |
1710 | +ERROR HY000: The Drizzle server is running with the --secure-file-priv option so it cannot execute this statement |
1711 | drop table t1, t2; |
1712 | create table t1(f1 int, f2 timestamp not null default current_timestamp); |
1713 | create table t2(f1 int); |
1714 | |
1715 | === modified file 'tests/r/outfile.result' |
1716 | --- tests/r/outfile.result 2010-09-23 01:53:13 +0000 |
1717 | +++ tests/r/outfile.result 2010-10-06 07:38:58 +0000 |
1718 | @@ -3,10 +3,13 @@ |
1719 | insert into t1 values("hello world"),("Hello mars"),(NULL); |
1720 | select load_file(concat(@tmpdir,"/outfile-test.1")); |
1721 | load_file(concat(@tmpdir,"/outfile-test.1")) |
1722 | -NULL |
1723 | +hello world |
1724 | +Hello mars |
1725 | +\N |
1726 | + |
1727 | select load_file(concat(@tmpdir,"/outfile-test.2")); |
1728 | load_file(concat(@tmpdir,"/outfile-test.2")) |
1729 | -NULL |
1730 | +hello world |
1731 | select load_file(concat(@tmpdir,"/outfile-test.3")); |
1732 | load_file(concat(@tmpdir,"/outfile-test.3")) |
1733 | NULL |
1734 | @@ -14,12 +17,12 @@ |
1735 | ERROR HY000: File '../../tmp/outfile-test.2' already exists |
1736 | ERROR HY000: File '../../tmp/outfile-test.3' already exists |
1737 | select load_file(concat(@tmpdir,"/outfile-test.not-exist")); |
1738 | -load_file(concat(@tmpdir,"/outfile-test.not-exist")) |
1739 | -NULL |
1740 | +ERROR HY000: The file '../../tmp/outfile-test.not-exist' must be in the database directory or be readable by all |
1741 | drop table t1; |
1742 | select load_file(concat(@tmpdir,"/outfile-test.4")); |
1743 | load_file(concat(@tmpdir,"/outfile-test.4")) |
1744 | -NULL |
1745 | +1 |
1746 | + |
1747 | CREATE TABLE t1 (a INT); |
1748 | EXPLAIN |
1749 | SELECT * |
1750 | |
1751 | === modified file 'tests/t/func_str.test' |
1752 | --- tests/t/func_str.test 2010-08-26 21:56:15 +0000 |
1753 | +++ tests/t/func_str.test 2010-10-06 07:38:58 +0000 |
1754 | @@ -469,12 +469,9 @@ |
1755 | --disable_metadata |
1756 | drop table t1; |
1757 | |
1758 | -# |
1759 | -# Bug #10418: LOAD_FILE does not behave like in manual if file does not exist |
1760 | -# |
1761 | |
1762 | +--error ER_TEXTFILE_NOT_READABLE |
1763 | select load_file("lkjlkj"); |
1764 | -select ifnull(load_file("lkjlkj"),"it's null"); |
1765 | |
1766 | # |
1767 | # Bug#18243: REVERSE changes its argument |
1768 | |
1769 | === modified file 'tests/t/loaddata.test' |
1770 | --- tests/t/loaddata.test 2010-09-23 01:53:13 +0000 |
1771 | +++ tests/t/loaddata.test 2010-10-06 07:38:58 +0000 |
1772 | @@ -135,8 +135,8 @@ |
1773 | eval load data infile '$DRIZZLE_TEST_DIR/t/loaddata.test' into table t1; |
1774 | select * from t1; |
1775 | |
1776 | -# Test "load_file" returns NULL |
1777 | --replace_result $DRIZZLE_TEST_DIR DRIZZLE_TEST_DIR |
1778 | +--error ER_OPTION_PREVENTS_STATEMENT |
1779 | eval select load_file("$DRIZZLE_TEST_DIR/t/loaddata.test"); |
1780 | |
1781 | # cleanup |
1782 | |
1783 | === modified file 'tests/t/outfile.test' |
1784 | --- tests/t/outfile.test 2010-09-23 01:53:13 +0000 |
1785 | +++ tests/t/outfile.test 2010-10-06 07:38:58 +0000 |
1786 | @@ -38,6 +38,7 @@ |
1787 | --error ER_FILE_EXISTS_ERROR |
1788 | eval select * into dumpfile "../../tmp/outfile-test.3" from t1; |
1789 | enable_query_log; |
1790 | +--error ER_TEXTFILE_NOT_READABLE |
1791 | select load_file(concat(@tmpdir,"/outfile-test.not-exist")); |
1792 | --remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.1 |
1793 | --remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.2 |
1794 | @@ -48,6 +49,7 @@ |
1795 | disable_query_log; |
1796 | eval select 1 into outfile "../../tmp/outfile-test.4"; |
1797 | enable_query_log; |
1798 | +--replace_result $DRIZZLE_TEST_DIR DRIZZLE_TEST_DIR |
1799 | select load_file(concat(@tmpdir,"/outfile-test.4")); |
1800 | --remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4 |
1801 |
This was approved before, but I rebased and repushed under a different name.