Merge lp:~mordred/drizzle/boost-fs-path-work into lp:~drizzle-trunk/drizzle/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
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.

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 :

This was approved before, but I rebased and repushed under a different name.

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
=== modified file 'drizzled/data_home.h'
--- drizzled/data_home.h 2010-09-26 01:21:36 +0000
+++ drizzled/data_home.h 2010-10-06 07:38:58 +0000
@@ -20,15 +20,15 @@
20#ifndef DRIZZLED_DATA_HOME_H20#ifndef DRIZZLED_DATA_HOME_H
21#define DRIZZLED_DATA_HOME_H21#define DRIZZLED_DATA_HOME_H
2222
23#include <string>23#include <boost/filesystem.hpp>
2424
25namespace drizzled25namespace drizzled
26{26{
2727
28std::string& getDataHome();28extern boost::filesystem::path full_data_home;
29std::string& getDataHomeCatalog();29
30char *getDatadir();30boost::filesystem::path& getDataHome();
31char **getDatadirPtr();31boost::filesystem::path& getDataHomeCatalog();
3232
33} /* namespace drizzled */33} /* namespace drizzled */
3434
3535
=== modified file 'drizzled/drizzled.cc'
--- drizzled/drizzled.cc 2010-10-04 22:44:31 +0000
+++ drizzled/drizzled.cc 2010-10-06 07:38:58 +0000
@@ -232,8 +232,6 @@
232plugin::StorageEngine *heap_engine;232plugin::StorageEngine *heap_engine;
233plugin::StorageEngine *myisam_engine;233plugin::StorageEngine *myisam_engine;
234234
235char* opt_secure_file_priv= 0;
236
237bool calling_initgroups= false; /**< Used in SIGSEGV handler. */235bool calling_initgroups= false; /**< Used in SIGSEGV handler. */
238236
239uint32_t drizzled_bind_timeout;237uint32_t drizzled_bind_timeout;
@@ -288,7 +286,14 @@
288time_t server_start_time;286time_t server_start_time;
289time_t flush_status_time;287time_t flush_status_time;
290288
291char drizzle_home[FN_REFLEN], pidfile_name[FN_REFLEN], system_time_zone[30];289fs::path basedir(PREFIX);
290fs::path pid_file;
291fs::path secure_file_priv("");
292fs::path plugin_dir;
293fs::path system_config_dir(SYSCONFDIR);
294
295
296char system_time_zone[30];
292char *default_tz_name;297char *default_tz_name;
293char glob_hostname[FN_REFLEN];298char glob_hostname[FN_REFLEN];
294299
@@ -336,7 +341,6 @@
336/* Static variables */341/* Static variables */
337342
338int cleanup_done;343int cleanup_done;
339static char *drizzle_home_ptr, *pidfile_name_ptr;
340344
341passwd *user_info;345passwd *user_info;
342346
@@ -352,7 +356,6 @@
352356
353static void drizzle_init_variables(void);357static void drizzle_init_variables(void);
354static void get_options();358static void get_options();
355static const char *get_relative_path(const char *path);
356static void fix_paths();359static void fix_paths();
357360
358static void usage(void);361static void usage(void);
@@ -369,34 +372,26 @@
369vector<string> unknown_options;372vector<string> unknown_options;
370vector<string> defaults_file_list;373vector<string> defaults_file_list;
371po::variables_map vm;374po::variables_map vm;
372char * data_dir_ptr;375
376fs::path data_home(LOCALSTATEDIR);
377fs::path full_data_home(LOCALSTATEDIR);
373378
374po::variables_map &getVariablesMap()379po::variables_map &getVariablesMap()
375{380{
376 return vm;381 return vm;
377}382}
378383
379std::string& getDataHome()384fs::path& getDataHome()
380{385{
381 static string data_home(LOCALSTATEDIR);
382 return data_home;386 return data_home;
383}387}
384388
385std::string& getDataHomeCatalog()389fs::path& getDataHomeCatalog()
386{390{
387 static string data_home_catalog(getDataHome());391 static fs::path data_home_catalog(getDataHome());
388 return data_home_catalog;392 return data_home_catalog;
389}393}
390394
391char *getDatadir()
392{
393 return data_dir_ptr;
394}
395
396char **getDatadirPtr()
397{
398 return &data_dir_ptr;
399}
400 395
401/****************************************************************************396/****************************************************************************
402** Code to end drizzled397** Code to end drizzled
@@ -511,13 +506,10 @@
511 return;506 return;
512507
513 table_cache_free();508 table_cache_free();
514 set_var_free();
515 free_charsets();509 free_charsets();
516 module::Registry &modules= module::Registry::singleton();510 module::Registry &modules= module::Registry::singleton();
517 modules.shutdownModules();511 modules.shutdownModules();
518 xid_cache_free();512 xid_cache_free();
519 if (opt_secure_file_priv)
520 free(opt_secure_file_priv);
521513
522 deinit_temporal_formats();514 deinit_temporal_formats();
523515
@@ -525,7 +517,7 @@
525 google::protobuf::ShutdownProtobufLibrary();517 google::protobuf::ShutdownProtobufLibrary();
526#endif518#endif
527519
528 (void) unlink(pidfile_name); // This may not always exist520 (void) unlink(pid_file.file_string().c_str()); // This may not always exist
529521
530 if (print_message && server_start_time)522 if (print_message && server_start_time)
531 errmsg_printf(ERRMSG_LVL_INFO, _(ER(ER_SHUTDOWN_COMPLETE)),internal::my_progname);523 errmsg_printf(ERRMSG_LVL_INFO, _(ER(ER_SHUTDOWN_COMPLETE)),internal::my_progname);
@@ -535,8 +527,6 @@
535 COND_server_end.notify_all();527 COND_server_end.notify_all();
536 LOCK_thread_count.unlock();528 LOCK_thread_count.unlock();
537529
538 char **data_home_ptr= getDatadirPtr();
539 delete[](*data_home_ptr);
540 /*530 /*
541 The following lines may never be executed as the main thread may have531 The following lines may never be executed as the main thread may have
542 killed us532 killed us
@@ -716,15 +706,29 @@
716 base_plugin_dir /= "plugin";706 base_plugin_dir /= "plugin";
717 base_plugin_dir /= ".libs";707 base_plugin_dir /= ".libs";
718 }708 }
719 (void) internal::my_load_path(opt_plugin_dir, fs::path(fs::system_complete(base_plugin_dir)).file_string().c_str(), "");709
720}710 if (plugin_dir.root_directory() == "")
721711 {
722static void notify_plugin_dir(string in_plugin_dir)712 fs::path full_plugin_dir(fs::system_complete(base_plugin_dir));
723{713 full_plugin_dir /= plugin_dir;
724 if (not in_plugin_dir.empty())714 plugin_dir= full_plugin_dir;
725 {715 }
726 (void) internal::my_load_path(opt_plugin_dir, in_plugin_dir.c_str(), drizzle_home);716}
727 }717
718static void notify_plugin_dir(fs::path in_plugin_dir)
719{
720 plugin_dir= in_plugin_dir;
721 if (plugin_dir.root_directory() == "")
722 {
723 fs::path full_plugin_dir(fs::system_complete(basedir));
724 full_plugin_dir /= plugin_dir;
725 plugin_dir= full_plugin_dir;
726 }
727}
728
729static void expand_secure_file_priv(fs::path in_secure_file_priv)
730{
731 secure_file_priv= fs::system_complete(in_secure_file_priv);
728}732}
729733
730static void check_limits_aii(uint64_t in_auto_increment_increment)734static void check_limits_aii(uint64_t in_auto_increment_increment)
@@ -906,17 +910,6 @@
906 global_system_variables.max_sort_length= in_max_sort_length;910 global_system_variables.max_sort_length= in_max_sort_length;
907}911}
908912
909static void check_limits_mwlc(uint64_t in_min_examined_row_limit)
910{
911 global_system_variables.min_examined_row_limit= ULONG_MAX;
912 if (in_min_examined_row_limit > ULONG_MAX)
913 {
914 cout << N_("Error: Invalid Value for min_examined_row_limit");
915 exit(-1);
916 }
917 global_system_variables.min_examined_row_limit= in_min_examined_row_limit;
918}
919
920static void check_limits_osd(uint32_t in_optimizer_search_depth)913static void check_limits_osd(uint32_t in_optimizer_search_depth)
921{914{
922 global_system_variables.optimizer_search_depth= 0;915 global_system_variables.optimizer_search_depth= 0;
@@ -1120,19 +1113,18 @@
1120 iter != defaults_file_list.end();1113 iter != defaults_file_list.end();
1121 ++iter)1114 ++iter)
1122 {1115 {
1123 string file_location(vm["config-dir"].as<string>());1116 fs::path file_location(system_config_dir);
1124 if ((*iter)[0] != '/')1117 if ((*iter)[0] != '/')
1125 {1118 {
1126 /* Relative path - add config dir */1119 /* Relative path - add config dir */
1127 file_location.push_back('/');1120 file_location /= *iter;
1128 file_location.append(*iter);
1129 }1121 }
1130 else1122 else
1131 {1123 {
1132 file_location= *iter;1124 file_location= *iter;
1133 }1125 }
11341126
1135 ifstream input_defaults_file(file_location.c_str());1127 ifstream input_defaults_file(file_location.file_string().c_str());
1136 1128
1137 po::parsed_options file_parsed=1129 po::parsed_options file_parsed=
1138 po::parse_config_file(input_defaults_file, full_options, true);1130 po::parse_config_file(input_defaults_file, full_options, true);
@@ -1211,15 +1203,15 @@
1211 strncpy(glob_hostname, STRING_WITH_LEN("localhost"));1203 strncpy(glob_hostname, STRING_WITH_LEN("localhost"));
1212 errmsg_printf(ERRMSG_LVL_WARN, _("gethostname failed, using '%s' as hostname"),1204 errmsg_printf(ERRMSG_LVL_WARN, _("gethostname failed, using '%s' as hostname"),
1213 glob_hostname);1205 glob_hostname);
1214 strncpy(pidfile_name, STRING_WITH_LEN("drizzle"));1206 pid_file= "drizzle";
1215 }1207 }
1216 else1208 else
1217 strncpy(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);1209 {
1218 strcpy(internal::fn_ext(pidfile_name),".pid"); // Add proper extension1210 pid_file= glob_hostname;
12191211 }
1220 std::string system_config_dir_drizzle(SYSCONFDIR);1212 pid_file.replace_extension(".pid");
1221 system_config_dir_drizzle.append("/drizzle");1213
12221214 system_config_dir /= "drizzle";
1223 std::string system_config_file_drizzle("drizzled.cnf");1215 std::string system_config_file_drizzle("drizzled.cnf");
12241216
1225 config_options.add_options()1217 config_options.add_options()
@@ -1229,9 +1221,9 @@
1229 N_("Configuration file defaults are not used if no-defaults is set"))1221 N_("Configuration file defaults are not used if no-defaults is set"))
1230 ("defaults-file", po::value<vector<string> >()->composing()->notifier(&compose_defaults_file_list),1222 ("defaults-file", po::value<vector<string> >()->composing()->notifier(&compose_defaults_file_list),
1231 N_("Configuration file to use"))1223 N_("Configuration file to use"))
1232 ("config-dir", po::value<string>()->default_value(system_config_dir_drizzle),1224 ("config-dir", po::value<fs::path>(&system_config_dir),
1233 N_("Base location for config files"))1225 N_("Base location for config files"))
1234 ("plugin-dir", po::value<string>()->notifier(&notify_plugin_dir),1226 ("plugin-dir", po::value<fs::path>(&plugin_dir)->notifier(&notify_plugin_dir),
1235 N_("Directory for plugins."))1227 N_("Directory for plugins."))
1236 ;1228 ;
12371229
@@ -1255,7 +1247,7 @@
1255 N_("Auto-increment columns are incremented by this"))1247 N_("Auto-increment columns are incremented by this"))
1256 ("auto-increment-offset", po::value<uint64_t>(&global_system_variables.auto_increment_offset)->default_value(1)->notifier(&check_limits_aio),1248 ("auto-increment-offset", po::value<uint64_t>(&global_system_variables.auto_increment_offset)->default_value(1)->notifier(&check_limits_aio),
1257 N_("Offset added to Auto-increment columns. Used when auto-increment-increment != 1"))1249 N_("Offset added to Auto-increment columns. Used when auto-increment-increment != 1"))
1258 ("basedir,b", po::value<string>(),1250 ("basedir,b", po::value<fs::path>(&basedir),
1259 N_("Path to installation directory. All paths are usually resolved "1251 N_("Path to installation directory. All paths are usually resolved "
1260 "relative to this."))1252 "relative to this."))
1261 ("chroot,r", po::value<string>(),1253 ("chroot,r", po::value<string>(),
@@ -1265,7 +1257,7 @@
1265 ("completion-type", po::value<uint32_t>(&global_system_variables.completion_type)->default_value(0)->notifier(&check_limits_completion_type),1257 ("completion-type", po::value<uint32_t>(&global_system_variables.completion_type)->default_value(0)->notifier(&check_limits_completion_type),
1266 N_("Default completion type."))1258 N_("Default completion type."))
1267 ("core-file", N_("Write core on errors."))1259 ("core-file", N_("Write core on errors."))
1268 ("datadir", po::value<string>(),1260 ("datadir", po::value<fs::path>(&data_home),
1269 N_("Path to the database root."))1261 N_("Path to the database root."))
1270 ("default-storage-engine", po::value<string>(),1262 ("default-storage-engine", po::value<string>(),
1271 N_("Set the default storage engine for tables."))1263 N_("Set the default storage engine for tables."))
@@ -1279,11 +1271,11 @@
1279 N_("Set the language used for the month names and the days of the week."))1271 N_("Set the language used for the month names and the days of the week."))
1280 ("log-warnings,W", po::value<string>(),1272 ("log-warnings,W", po::value<string>(),
1281 N_("Log some not critical warnings to the log file.")) 1273 N_("Log some not critical warnings to the log file."))
1282 ("pid-file", po::value<string>(),1274 ("pid-file", po::value<fs::path>(&pid_file),
1283 N_("Pid file used by drizzled."))1275 N_("Pid file used by drizzled."))
1284 ("port-open-timeout", po::value<uint32_t>(&drizzled_bind_timeout)->default_value(0),1276 ("port-open-timeout", po::value<uint32_t>(&drizzled_bind_timeout)->default_value(0),
1285 N_("Maximum time in seconds to wait for the port to become free. "))1277 N_("Maximum time in seconds to wait for the port to become free. "))
1286 ("secure-file-priv", po::value<string>(),1278 ("secure-file-priv", po::value<fs::path>(&secure_file_priv)->notifier(expand_secure_file_priv),
1287 N_("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "1279 N_("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "
1288 "within specified directory"))1280 "within specified directory"))
1289 ("server-id", po::value<uint32_t>(&server_id)->default_value(0),1281 ("server-id", po::value<uint32_t>(&server_id)->default_value(0),
@@ -1339,7 +1331,7 @@
1339 N_("The number of bytes to use when sorting BLOB or TEXT values "1331 N_("The number of bytes to use when sorting BLOB or TEXT values "
1340 "(only the first max_sort_length bytes of each value are used; the "1332 "(only the first max_sort_length bytes of each value are used; the "
1341 "rest are ignored)."))1333 "rest are ignored)."))
1342 ("max-write-lock-count", po::value<uint64_t>(&max_write_lock_count)->default_value(ULONG_MAX)->notifier(&check_limits_mwlc),1334 ("max-write-lock-count", po::value<uint64_t>(&max_write_lock_count)->default_value(UINT64_MAX),
1343 N_("After this many write locks, allow some read locks to run in between."))1335 N_("After this many write locks, allow some read locks to run in between."))
1344 ("min-examined-row-limit", po::value<uint64_t>(&global_system_variables.min_examined_row_limit)->default_value(0)->notifier(&check_limits_merl),1336 ("min-examined-row-limit", po::value<uint64_t>(&global_system_variables.min_examined_row_limit)->default_value(0)->notifier(&check_limits_merl),
1345 N_("Don't log queries which examine less than min_examined_row_limit "1337 N_("Don't log queries which examine less than min_examined_row_limit "
@@ -1426,9 +1418,10 @@
1426 system_config_file_drizzle);1418 system_config_file_drizzle);
1427 }1419 }
14281420
1429 string config_conf_d_location(vm["config-dir"].as<string>());1421 fs::path config_conf_d_location(system_config_dir);
1430 config_conf_d_location.append("/conf.d");1422 config_conf_d_location /= "conf.d";
1431 CachedDirectory config_conf_d(config_conf_d_location);1423
1424 CachedDirectory config_conf_d(config_conf_d_location.file_string());
1432 if (not config_conf_d.fail())1425 if (not config_conf_d.fail())
1433 {1426 {
14341427
@@ -1442,10 +1435,9 @@
1442 && file_entry != "."1435 && file_entry != "."
1443 && file_entry != "..")1436 && file_entry != "..")
1444 {1437 {
1445 string the_entry(config_conf_d_location);1438 fs::path the_entry(config_conf_d_location);
1446 the_entry.push_back('/');1439 the_entry /= file_entry;
1447 the_entry.append(file_entry);1440 defaults_file_list.push_back(the_entry.file_string());
1448 defaults_file_list.push_back(the_entry);
1449 }1441 }
1450 }1442 }
1451 }1443 }
@@ -1761,7 +1753,7 @@
1761 {"basedir", 'b',1753 {"basedir", 'b',
1762 N_("Path to installation directory. All paths are usually resolved "1754 N_("Path to installation directory. All paths are usually resolved "
1763 "relative to this."),1755 "relative to this."),
1764 (char**) &drizzle_home_ptr, (char**) &drizzle_home_ptr, 0, GET_STR, REQUIRED_ARG,1756 NULL, NULL, 0, GET_STR, REQUIRED_ARG,
1765 0, 0, 0, 0, 0, 0},1757 0, 0, 0, 0, 0, 0},
1766 {"chroot", 'r',1758 {"chroot", 'r',
1767 N_("Chroot drizzled daemon during startup."),1759 N_("Chroot drizzled daemon during startup."),
@@ -1813,7 +1805,7 @@
1813 0, 0, 0},1805 0, 0, 0},
1814 {"pid-file", OPT_PID_FILE,1806 {"pid-file", OPT_PID_FILE,
1815 N_("Pid file used by drizzled."),1807 N_("Pid file used by drizzled."),
1816 (char**) &pidfile_name_ptr, (char**) &pidfile_name_ptr, 0, GET_STR,1808 NULL, NULL, 0, GET_STR,
1817 REQUIRED_ARG, 0, 0, 0, 0, 0, 0},1809 REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1818 {"port-open-timeout", OPT_PORT_OPEN_TIMEOUT,1810 {"port-open-timeout", OPT_PORT_OPEN_TIMEOUT,
1819 N_("Maximum time in seconds to wait for the port to become free. "1811 N_("Maximum time in seconds to wait for the port to become free. "
@@ -1823,7 +1815,7 @@
1823 {"secure-file-priv", OPT_SECURE_FILE_PRIV,1815 {"secure-file-priv", OPT_SECURE_FILE_PRIV,
1824 N_("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "1816 N_("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "
1825 "within specified directory"),1817 "within specified directory"),
1826 (char**) &opt_secure_file_priv, (char**) &opt_secure_file_priv, 0,1818 NULL, NULL, 0,
1827 GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},1819 GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1828 {"server-id", OPT_SERVER_ID,1820 {"server-id", OPT_SERVER_ID,
1829 N_("Uniquely identifies the server instance in the community of "1821 N_("Uniquely identifies the server instance in the community of "
@@ -2121,9 +2113,7 @@
2121static void drizzle_init_variables(void)2113static void drizzle_init_variables(void)
2122{2114{
2123 /* Things reset to zero */2115 /* Things reset to zero */
2124 drizzle_home[0]= pidfile_name[0]= 0;
2125 opt_tc_log_file= (char *)"tc.log"; // no hostname in tc_log file name !2116 opt_tc_log_file= (char *)"tc.log"; // no hostname in tc_log file name !
2126 opt_secure_file_priv= 0;
2127 cleanup_done= 0;2117 cleanup_done= 0;
2128 dropping_tables= ha_open_options=0;2118 dropping_tables= ha_open_options=0;
2129 test_flags.reset();2119 test_flags.reset();
@@ -2141,8 +2131,6 @@
2141 character_set_filesystem= &my_charset_bin;2131 character_set_filesystem= &my_charset_bin;
21422132
2143 /* Things with default values that are not zero */2133 /* Things with default values that are not zero */
2144 drizzle_home_ptr= drizzle_home;
2145 pidfile_name_ptr= pidfile_name;
2146 session_startup_options= (OPTION_AUTO_IS_NULL | OPTION_SQL_NOTES);2134 session_startup_options= (OPTION_AUTO_IS_NULL | OPTION_SQL_NOTES);
2147 refresh_version= 1L; /* Increments on each reload */2135 refresh_version= 1L; /* Increments on each reload */
2148 global_thread_id= 1UL;2136 global_thread_id= 1UL;
@@ -2197,11 +2185,6 @@
2197 have_symlink=SHOW_OPTION_YES;2185 have_symlink=SHOW_OPTION_YES;
2198#endif2186#endif
21992187
2200 const char *tmpenv;
2201 if (!(tmpenv = getenv("MY_BASEDIR_VERSION")))
2202 tmpenv = PREFIX;
2203 (void) strncpy(drizzle_home, tmpenv, sizeof(drizzle_home)-1);
2204
2205 connection_count= 0;2188 connection_count= 0;
2206}2189}
22072190
@@ -2213,19 +2196,9 @@
2213static void get_options()2196static void get_options()
2214{2197{
22152198
2216 if (vm.count("base-dir"))2199 fs::path &data_home_catalog= getDataHomeCatalog();
2217 {
2218 strncpy(drizzle_home,vm["base-dir"].as<string>().c_str(),sizeof(drizzle_home)-1);
2219 }
2220
2221 if (vm.count("datadir"))
2222 {
2223 getDataHome()= vm["datadir"].as<string>();
2224 }
2225 string &data_home_catalog= getDataHomeCatalog();
2226 data_home_catalog= getDataHome();2200 data_home_catalog= getDataHome();
2227 data_home_catalog.push_back('/');2201 data_home_catalog /= "local";
2228 data_home_catalog.append("local");
22292202
2230 if (vm.count("user"))2203 if (vm.count("user"))
2231 {2204 {
@@ -2277,11 +2250,6 @@
2277 internal::my_use_symdir=0;2250 internal::my_use_symdir=0;
2278 }2251 }
22792252
2280 if (vm.count("pid-file"))
2281 {
2282 strncpy(pidfile_name, vm["pid-file"].as<string>().c_str(), sizeof(pidfile_name)-1);
2283 }
2284
2285 if (vm.count("transaction-isolation"))2253 if (vm.count("transaction-isolation"))
2286 {2254 {
2287 int type;2255 int type;
@@ -2329,61 +2297,15 @@
2329}2297}
23302298
23312299
2332static const char *get_relative_path(const char *path)
2333{
2334 if (internal::test_if_hard_path(path) &&
2335 (strncmp(path, PREFIX, strlen(PREFIX)) == 0) &&
2336 strcmp(PREFIX,FN_ROOTDIR))
2337 {
2338 if (strlen(PREFIX) < strlen(path))
2339 path+=(size_t) strlen(PREFIX);
2340 while (*path == FN_LIBCHAR)
2341 path++;
2342 }
2343 return path;
2344}
2345
2346
2347static void fix_paths()2300static void fix_paths()
2348{2301{
2349 char buff[FN_REFLEN],*pos,rp_buff[PATH_MAX];2302 fs::path pid_file_path(pid_file);
2350 internal::convert_dirname(drizzle_home,drizzle_home,NULL);
2351 /* Resolve symlinks to allow 'drizzle_home' to be a relative symlink */
2352#if defined(HAVE_BROKEN_REALPATH)
2353 internal::my_load_path(drizzle_home, drizzle_home, NULL);
2354#else
2355 if (!realpath(drizzle_home,rp_buff))
2356 internal::my_load_path(rp_buff, drizzle_home, NULL);
2357 rp_buff[FN_REFLEN-1]= '\0';
2358 strcpy(drizzle_home,rp_buff);
2359 /* Ensure that drizzle_home ends in FN_LIBCHAR */
2360 pos= strchr(drizzle_home, '\0');
2361#endif
2362 if (pos[-1] != FN_LIBCHAR)
2363 {
2364 pos[0]= FN_LIBCHAR;
2365 pos[1]= 0;
2366 }
2367 (void) internal::my_load_path(drizzle_home, drizzle_home,""); // Resolve current dir
2368
2369 fs::path pid_file_path(pidfile_name);
2370 if (pid_file_path.root_path().string() == "")2303 if (pid_file_path.root_path().string() == "")
2371 {2304 {
2372 pid_file_path= fs::path(getDataHome());2305 pid_file_path= getDataHome();
2373 pid_file_path /= pidfile_name;2306 pid_file_path /= pid_file;
2374 }2307 }
2375 strncpy(pidfile_name, pid_file_path.file_string().c_str(), sizeof(pidfile_name)-1);2308 pid_file= pid_file_path;
2376
2377
2378 const char *sharedir= get_relative_path(PKGDATADIR);
2379 if (internal::test_if_hard_path(sharedir))
2380 strncpy(buff,sharedir,sizeof(buff)-1);
2381 else
2382 {
2383 strcpy(buff, drizzle_home);
2384 strncat(buff, sharedir, sizeof(buff)-strlen(drizzle_home)-1);
2385 }
2386 internal::convert_dirname(buff,buff,NULL);
23872309
2388 if (not opt_help)2310 if (not opt_help)
2389 {2311 {
@@ -2397,7 +2319,7 @@
2397 }2319 }
2398 else if (tmp_string == NULL)2320 else if (tmp_string == NULL)
2399 {2321 {
2400 drizzle_tmpdir.append(getDataHome());2322 drizzle_tmpdir.append(getDataHome().file_string());
2401 drizzle_tmpdir.push_back(FN_LIBCHAR);2323 drizzle_tmpdir.push_back(FN_LIBCHAR);
2402 drizzle_tmpdir.append(GLOBAL_TEMPORARY_EXT);2324 drizzle_tmpdir.append(GLOBAL_TEMPORARY_EXT);
2403 }2325 }
@@ -2425,18 +2347,6 @@
2425 }2347 }
2426 }2348 }
24272349
2428 /*
2429 Convert the secure-file-priv option to system format, allowing
2430 a quick strcmp to check if read or write is in an allowed dir
2431 */
2432 if (vm.count("secure-file-priv"))
2433 {
2434 internal::convert_dirname(buff, vm["secure-file-priv"].as<string>().c_str(), NULL);
2435 free(opt_secure_file_priv);
2436 opt_secure_file_priv= strdup(buff);
2437 if (opt_secure_file_priv == NULL)
2438 exit(1);
2439 }
2440}2350}
24412351
2442} /* namespace drizzled */2352} /* namespace drizzled */
24432353
=== modified file 'drizzled/file_exchange.h'
--- drizzled/file_exchange.h 2010-02-04 08:14:46 +0000
+++ drizzled/file_exchange.h 2010-10-06 07:38:58 +0000
@@ -40,7 +40,8 @@
40 XXX: We never call destructor for objects of this class.40 XXX: We never call destructor for objects of this class.
41*/41*/
4242
43class file_exchange :public memory::SqlAlloc43class file_exchange :
44 public memory::SqlAlloc
44{45{
45public:46public:
46 enum enum_filetype filetype; /* load XML, Added by Arnold & Erik */47 enum enum_filetype filetype; /* load XML, Added by Arnold & Erik */
4748
=== modified file 'drizzled/function/str/load_file.cc'
--- drizzled/function/str/load_file.cc 2010-09-22 07:05:47 +0000
+++ drizzled/function/str/load_file.cc 2010-10-06 07:38:58 +0000
@@ -25,8 +25,14 @@
25#include <drizzled/session.h>25#include <drizzled/session.h>
26#include "drizzled/internal/my_sys.h"26#include "drizzled/internal/my_sys.h"
2727
28#include <boost/filesystem.hpp>
29
28#include <fcntl.h>30#include <fcntl.h>
29#include <sys/stat.h>31#include <sys/stat.h>
32#include <iostream>
33
34namespace fs=boost::filesystem;
35using namespace std;
3036
31namespace drizzled37namespace drizzled
32{38{
@@ -37,27 +43,49 @@
37 String *file_name;43 String *file_name;
38 int file;44 int file;
39 struct stat stat_info;45 struct stat stat_info;
40 char path[FN_REFLEN];
4146
42 if (!(file_name= args[0]->val_str(str)))47 if (!(file_name= args[0]->val_str(str)))
43 goto err;48 {
49 null_value = 1;
50 return(0);
51 }
4452
45 (void) internal::fn_format(path, file_name->c_ptr(), getDataHome().c_str(), "",53 fs::path target_path(fs::system_complete(getDataHomeCatalog()));
46 MY_RELATIVE_PATH | MY_UNPACK_FILENAME);54 fs::path to_file(file_name->c_ptr());
55 if (not to_file.has_root_directory())
56 {
57 target_path /= to_file;
58 }
59 else
60 {
61 target_path= to_file;
62 }
4763
48 /* Read only allowed from within dir specified by secure_file_priv */64 /* Read only allowed from within dir specified by secure_file_priv */
49 if (opt_secure_file_priv &&65 if (not secure_file_priv.string().empty())
50 strncmp(opt_secure_file_priv, path, strlen(opt_secure_file_priv)))66 {
51 goto err;67 fs::path secure_file_path(fs::system_complete(secure_file_priv));
68 if (target_path.file_string().substr(0, secure_file_path.file_string().size()) != secure_file_path.file_string())
69 {
70 /* Read only allowed from within dir specified by secure_file_priv */
71 my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
72 null_value = 1;
73 return 0;
74 }
75 }
5276
53 if (stat(path, &stat_info))77 if (stat(target_path.file_string().c_str(), &stat_info))
78 {
79 my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), file_name->c_ptr());
54 goto err;80 goto err;
81 }
5582
56 if (!(stat_info.st_mode & S_IROTH))83 if (!(stat_info.st_mode & S_IROTH))
57 {84 {
58 /* my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), file_name->c_ptr()); */85 my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), file_name->c_ptr());
59 goto err;86 goto err;
60 }87 }
88
61 if (stat_info.st_size > (long) session.variables.max_allowed_packet)89 if (stat_info.st_size > (long) session.variables.max_allowed_packet)
62 {90 {
63 push_warning_printf(&session, DRIZZLE_ERROR::WARN_LEVEL_WARN,91 push_warning_printf(&session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
@@ -66,15 +94,25 @@
66 func_name(), session.variables.max_allowed_packet);94 func_name(), session.variables.max_allowed_packet);
67 goto err;95 goto err;
68 }96 }
97
98 if (stat_info.st_size == 0)
99 {
100 goto err;
101 }
102
69 if (tmp_value.alloc((size_t)stat_info.st_size))103 if (tmp_value.alloc((size_t)stat_info.st_size))
70 goto err;104 goto err;
71 if ((file = internal::my_open(file_name->c_ptr(), O_RDONLY, MYF(0))) < 0)105 if ((file = internal::my_open(target_path.file_string().c_str(), O_RDONLY, MYF(0))) < 0)
72 goto err;106 goto err;
73 if (internal::my_read(file, (unsigned char*) tmp_value.ptr(), (size_t)stat_info.st_size, MYF(MY_NABP)))107 if (internal::my_read(file, (unsigned char*) tmp_value.ptr(), (size_t)stat_info.st_size, MYF(MY_NABP)))
74 {108 {
75 internal::my_close(file, MYF(0));109 internal::my_close(file, MYF(0));
76 goto err;110 goto err;
77 }111 }
112 if (strlen(tmp_value.ptr()) == 0)
113 {
114 goto err;
115 }
78 tmp_value.length((size_t)stat_info.st_size);116 tmp_value.length((size_t)stat_info.st_size);
79 internal::my_close(file, MYF(0));117 internal::my_close(file, MYF(0));
80 null_value = 0;118 null_value = 0;
81119
=== modified file 'drizzled/main.cc'
--- drizzled/main.cc 2010-10-05 08:06:38 +0000
+++ drizzled/main.cc 2010-10-06 07:38:58 +0000
@@ -255,11 +255,11 @@
255255
256 if (not opt_help)256 if (not opt_help)
257 {257 {
258 if (chdir(getDataHome().c_str()))258 if (chdir(getDataHome().file_string().c_str()))
259 {259 {
260 errmsg_printf(ERRMSG_LVL_ERROR,260 errmsg_printf(ERRMSG_LVL_ERROR,
261 _("Data directory %s does not exist\n"),261 _("Data directory %s does not exist\n"),
262 getDataHome().c_str());262 getDataHome().file_string().c_str());
263 unireg_abort(1);263 unireg_abort(1);
264 }264 }
265 if (mkdir("local", 0700))265 if (mkdir("local", 0700))
@@ -270,15 +270,11 @@
270 {270 {
271 errmsg_printf(ERRMSG_LVL_ERROR,271 errmsg_printf(ERRMSG_LVL_ERROR,
272 _("Local catalog %s/local does not exist\n"),272 _("Local catalog %s/local does not exist\n"),
273 getDataHome().c_str());273 getDataHome().file_string().c_str());
274 unireg_abort(1);274 unireg_abort(1);
275 }275 }
276 /* TODO: This is a hack until we can properly support std::string in sys_var*/276
277 char **data_home_ptr= getDatadirPtr();277 full_data_home= fs::system_complete(getDataHome());
278 fs::path full_data_home_path(fs::system_complete(fs::path(getDataHome())));
279 std::string full_data_home(full_data_home_path.file_string());
280 *data_home_ptr= new char[full_data_home.size()+1] ();
281 memcpy(*data_home_ptr, full_data_home.c_str(), full_data_home.size());
282 getDataHomeCatalog()= "./";278 getDataHomeCatalog()= "./";
283 getDataHome()= "../";279 getDataHome()= "../";
284 }280 }
@@ -319,7 +315,7 @@
319 select_thread_in_use=0;315 select_thread_in_use=0;
320 (void) pthread_kill(signal_thread, SIGTERM);316 (void) pthread_kill(signal_thread, SIGTERM);
321317
322 (void) unlink(pidfile_name); // Not needed anymore318 (void) unlink(pid_file.file_string().c_str()); // Not needed anymore
323319
324 exit(1);320 exit(1);
325 }321 }
326322
=== modified file 'drizzled/module/library.cc'
--- drizzled/module/library.cc 2010-08-10 17:04:19 +0000
+++ drizzled/module/library.cc 2010-10-06 07:38:58 +0000
@@ -24,6 +24,8 @@
24#include <cerrno>24#include <cerrno>
25#include <string>25#include <string>
2626
27#include <boost/filesystem.hpp>
28
27#include "drizzled/plugin.h"29#include "drizzled/plugin.h"
28#include "drizzled/definitions.h"30#include "drizzled/definitions.h"
29#include "drizzled/error.h"31#include "drizzled/error.h"
@@ -31,6 +33,7 @@
31#include "drizzled/module/library.h"33#include "drizzled/module/library.h"
3234
33using namespace std;35using namespace std;
36namespace fs=boost::filesystem;
3437
35namespace drizzled38namespace drizzled
36{39{
@@ -50,22 +53,19 @@
50 */53 */
51}54}
5255
53const string module::Library::getLibraryPath(const string &plugin_name)56const fs::path module::Library::getLibraryPath(const string &plugin_name)
54{57{
55 /* Compile dll path */58 string plugin_lib_name("lib");
56 string dlpath;59 plugin_lib_name.append(plugin_name);
57 dlpath.reserve(FN_REFLEN);60 plugin_lib_name.append("_plugin");
58 dlpath.append(opt_plugin_dir);
59 dlpath.append("/");
60 dlpath.append("lib");
61 dlpath.append(plugin_name);
62 dlpath.append("_plugin");
63#if defined(TARGET_OS_OSX)61#if defined(TARGET_OS_OSX)
64 dlpath.append(".dylib");62 plugin_lib_name.append(".dylib");
65#else63#else
66 dlpath.append(".so");64 plugin_lib_name.append(".so");
67#endif65#endif
68 return dlpath;66
67 /* Compile dll path */
68 return plugin_dir / plugin_lib_name;
69}69}
7070
71module::Library *module::Library::loadLibrary(const string &plugin_name, bool builtin)71module::Library *module::Library::loadLibrary(const string &plugin_name, bool builtin)
@@ -102,7 +102,7 @@
102 else102 else
103 {103 {
104 /* Open new dll handle */104 /* Open new dll handle */
105 dlpath.assign(Library::getLibraryPath(plugin_name));105 dlpath.assign(Library::getLibraryPath(plugin_name).file_string());
106 handle= dlopen(dlpath.c_str(), RTLD_NOW|RTLD_GLOBAL);106 handle= dlopen(dlpath.c_str(), RTLD_NOW|RTLD_GLOBAL);
107 if (handle == NULL)107 if (handle == NULL)
108 {108 {
109109
=== modified file 'drizzled/module/library.h'
--- drizzled/module/library.h 2010-05-15 18:23:34 +0000
+++ drizzled/module/library.h 2010-10-06 07:38:58 +0000
@@ -30,6 +30,8 @@
3030
31#include <string>31#include <string>
3232
33#include <boost/filesystem.hpp>
34
33namespace drizzled35namespace drizzled
34{36{
35namespace module37namespace module
@@ -67,7 +69,7 @@
67 return manifest;69 return manifest;
68 }70 }
6971
70 static const std::string getLibraryPath(const std::string &plugin_name);72 static const boost::filesystem::path getLibraryPath(const std::string &plugin_name);
71 static Library *loadLibrary(const std::string &plugin_name, bool builtin);73 static Library *loadLibrary(const std::string &plugin_name, bool builtin);
72};74};
7375
7476
=== modified file 'drizzled/module/loader.cc'
--- drizzled/module/loader.cc 2010-10-02 21:15:42 +0000
+++ drizzled/module/loader.cc 2010-10-06 07:38:58 +0000
@@ -75,7 +75,6 @@
75static PluginOptions opt_plugin_load;75static PluginOptions opt_plugin_load;
76static PluginOptions opt_plugin_add;76static PluginOptions opt_plugin_add;
77static PluginOptions opt_plugin_remove;77static PluginOptions opt_plugin_remove;
78char opt_plugin_dir[FN_REFLEN];
79const char *builtin_plugins= PANDORA_BUILTIN_LIST;78const char *builtin_plugins= PANDORA_BUILTIN_LIST;
8079
81/* Note that 'int version' must be the first field of every plugin80/* Note that 'int version' must be the first field of every plugin
8281
=== modified file 'drizzled/plugin.h'
--- drizzled/plugin.h 2010-09-27 18:14:40 +0000
+++ drizzled/plugin.h 2010-10-06 07:38:58 +0000
@@ -29,6 +29,7 @@
29#include "drizzled/lex_string.h"29#include "drizzled/lex_string.h"
30#include "drizzled/xid.h"30#include "drizzled/xid.h"
31#include <boost/program_options.hpp>31#include <boost/program_options.hpp>
32#include <boost/filesystem.hpp>
3233
33namespace drizzled34namespace drizzled
34{35{
@@ -46,7 +47,7 @@
46typedef drizzle_lex_string LEX_STRING;47typedef drizzle_lex_string LEX_STRING;
47struct option;48struct option;
4849
49extern char opt_plugin_dir[FN_REFLEN];50extern boost::filesystem::path plugin_dir;
5051
51namespace plugin { class StorageEngine; }52namespace plugin { class StorageEngine; }
5253
5354
=== modified file 'drizzled/select_export.h'
--- drizzled/select_export.h 2010-03-29 20:16:08 +0000
+++ drizzled/select_export.h 2010-10-06 07:38:58 +0000
@@ -29,7 +29,9 @@
29namespace drizzled29namespace drizzled
30{30{
3131
32class select_export :public select_to_file {32class select_export :
33 public select_to_file
34{
33 uint32_t field_term_length;35 uint32_t field_term_length;
34 int field_sep_char,escape_char,line_sep_char;36 int field_sep_char,escape_char,line_sep_char;
35 int field_term_char; // first char of FIELDS TERMINATED BY or MAX_INT37 int field_term_char; // first char of FIELDS TERMINATED BY or MAX_INT
3638
=== modified file 'drizzled/select_to_file.h'
--- drizzled/select_to_file.h 2010-02-04 08:14:46 +0000
+++ drizzled/select_to_file.h 2010-10-06 07:38:58 +0000
@@ -21,6 +21,8 @@
21#ifndef DRIZZLED_SELECT_TO_FILE_H21#ifndef DRIZZLED_SELECT_TO_FILE_H
22#define DRIZZLED_SELECT_TO_FILE_H22#define DRIZZLED_SELECT_TO_FILE_H
2323
24#include <boost/filesystem.hpp>
25
24namespace drizzled26namespace drizzled
25{27{
2628
@@ -29,14 +31,15 @@
29typedef struct st_io_cache IO_CACHE;31typedef struct st_io_cache IO_CACHE;
30}32}
3133
32class select_to_file : public select_result_interceptor34class select_to_file :
35 public select_result_interceptor
33{36{
34protected:37protected:
35 file_exchange *exchange;38 file_exchange *exchange;
36 int file;39 int file;
37 internal::IO_CACHE *cache;40 internal::IO_CACHE *cache;
38 ha_rows row_count;41 ha_rows row_count;
39 char path[FN_REFLEN];42 boost::filesystem::path path;
4043
41public:44public:
42 select_to_file(file_exchange *ex);45 select_to_file(file_exchange *ex);
4346
=== modified file 'drizzled/session.cc'
--- drizzled/session.cc 2010-09-28 06:27:36 +0000
+++ drizzled/session.cc 2010-10-06 07:38:58 +0000
@@ -913,7 +913,7 @@
913 {913 {
914 (void) end_io_cache(cache);914 (void) end_io_cache(cache);
915 (void) internal::my_close(file, MYF(0));915 (void) internal::my_close(file, MYF(0));
916 (void) internal::my_delete(path, MYF(0)); // Delete file on error916 (void) internal::my_delete(path.file_string().c_str(), MYF(0)); // Delete file on error
917 file= -1;917 file= -1;
918 }918 }
919}919}
@@ -947,7 +947,7 @@
947 (void) internal::my_close(file, MYF(0));947 (void) internal::my_close(file, MYF(0));
948 file= -1;948 file= -1;
949 }949 }
950 path[0]= '\0';950 path= "";
951 row_count= 0;951 row_count= 0;
952}952}
953953
@@ -957,7 +957,7 @@
957 cache(static_cast<internal::IO_CACHE *>(memory::sql_calloc(sizeof(internal::IO_CACHE)))),957 cache(static_cast<internal::IO_CACHE *>(memory::sql_calloc(sizeof(internal::IO_CACHE)))),
958 row_count(0L)958 row_count(0L)
959{959{
960 path[0]=0;960 path= "";
961}961}
962962
963select_to_file::~select_to_file()963select_to_file::~select_to_file()
@@ -991,31 +991,40 @@
991*/991*/
992992
993993
994static int create_file(Session *session, char *path, file_exchange *exchange, internal::IO_CACHE *cache)994static int create_file(Session *session,
995 fs::path &target_path,
996 file_exchange *exchange,
997 internal::IO_CACHE *cache)
995{998{
999 fs::path to_file(exchange->file_name);
996 int file;1000 int file;
997 uint32_t option= MY_UNPACK_FILENAME | MY_RELATIVE_PATH;1001
9981002 if (not to_file.has_root_directory())
999#ifdef DONT_ALLOW_FULL_LOAD_DATA_PATHS
1000 option|= MY_REPLACE_DIR; // Force use of db directory
1001#endif
1002
1003 if (!internal::dirname_length(exchange->file_name))
1004 {1003 {
1005 strcpy(path, getDataHomeCatalog().c_str());1004 target_path= fs::system_complete(getDataHomeCatalog());
1006 strncat(path, "/", 1);1005 if (not session->db.empty())
1007 if (! session->db.empty())1006 {
1008 strncat(path, session->db.c_str(), FN_REFLEN-getDataHomeCatalog().size());1007 int count_elements= 0;
1009 (void) internal::fn_format(path, exchange->file_name, path, "", option);1008 for (fs::path::iterator iter= to_file.begin();
1009 iter != to_file.end();
1010 ++iter, ++count_elements)
1011 { }
1012
1013 if (count_elements == 1)
1014 {
1015 target_path /= session->db;
1016 }
1017 }
1018 target_path /= to_file;
1010 }1019 }
1011 else1020 else
1012 (void) internal::fn_format(path, exchange->file_name, getDataHomeCatalog().c_str(), "", option);1021 {
1022 target_path = exchange->file_name;
1023 }
10131024
1014 if (opt_secure_file_priv)1025 if (not secure_file_priv.string().empty())
1015 {1026 {
1016 fs::path secure_file_path(fs::system_complete(fs::path(opt_secure_file_priv)));1027 if (target_path.file_string().substr(0, secure_file_priv.file_string().size()) != secure_file_priv.file_string())
1017 fs::path target_path(fs::system_complete(fs::path(path)));
1018 if (target_path.file_string().substr(0, secure_file_path.file_string().size()) != secure_file_path.file_string())
1019 {1028 {
1020 /* Write only allowed to dir or subdir specified by secure_file_priv */1029 /* Write only allowed to dir or subdir specified by secure_file_priv */
1021 my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");1030 my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
@@ -1023,19 +1032,19 @@
1023 }1032 }
1024 }1033 }
10251034
1026 if (!access(path, F_OK))1035 if (!access(target_path.file_string().c_str(), F_OK))
1027 {1036 {
1028 my_error(ER_FILE_EXISTS_ERROR, MYF(0), exchange->file_name);1037 my_error(ER_FILE_EXISTS_ERROR, MYF(0), exchange->file_name);
1029 return -1;1038 return -1;
1030 }1039 }
1031 /* Create the file world readable */1040 /* Create the file world readable */
1032 if ((file= internal::my_create(path, 0666, O_WRONLY|O_EXCL, MYF(MY_WME))) < 0)1041 if ((file= internal::my_create(target_path.file_string().c_str(), 0666, O_WRONLY|O_EXCL, MYF(MY_WME))) < 0)
1033 return file;1042 return file;
1034 (void) fchmod(file, 0666); // Because of umask()1043 (void) fchmod(file, 0666); // Because of umask()
1035 if (init_io_cache(cache, file, 0L, internal::WRITE_CACHE, 0L, 1, MYF(MY_WME)))1044 if (init_io_cache(cache, file, 0L, internal::WRITE_CACHE, 0L, 1, MYF(MY_WME)))
1036 {1045 {
1037 internal::my_close(file, MYF(0));1046 internal::my_close(file, MYF(0));
1038 internal::my_delete(path, MYF(0)); // Delete file on error, it was just created1047 internal::my_delete(target_path.file_string().c_str(), MYF(0)); // Delete file on error, it was just created
1039 return -1;1048 return -1;
1040 }1049 }
1041 return file;1050 return file;
@@ -1049,7 +1058,9 @@
1049 bool string_results= false, non_string_results= false;1058 bool string_results= false, non_string_results= false;
1050 unit= u;1059 unit= u;
1051 if ((uint32_t) strlen(exchange->file_name) + NAME_LEN >= FN_REFLEN)1060 if ((uint32_t) strlen(exchange->file_name) + NAME_LEN >= FN_REFLEN)
1052 strncpy(path,exchange->file_name,FN_REFLEN-1);1061 {
1062 path= exchange->file_name;
1063 }
10531064
1054 /* Check if there is any blobs in data */1065 /* Check if there is any blobs in data */
1055 {1066 {
@@ -1318,7 +1329,7 @@
1318 if (row_count++ > 1)1329 if (row_count++ > 1)
1319 {1330 {
1320 my_message(ER_TOO_MANY_ROWS, ER(ER_TOO_MANY_ROWS), MYF(0));1331 my_message(ER_TOO_MANY_ROWS, ER(ER_TOO_MANY_ROWS), MYF(0));
1321 goto err;1332 return 1;
1322 }1333 }
1323 while ((item=li++))1334 while ((item=li++))
1324 {1335 {
@@ -1326,17 +1337,15 @@
1326 if (!res) // If NULL1337 if (!res) // If NULL
1327 {1338 {
1328 if (my_b_write(cache,(unsigned char*) "",1))1339 if (my_b_write(cache,(unsigned char*) "",1))
1329 goto err;1340 return 1;
1330 }1341 }
1331 else if (my_b_write(cache,(unsigned char*) res->ptr(),res->length()))1342 else if (my_b_write(cache,(unsigned char*) res->ptr(),res->length()))
1332 {1343 {
1333 my_error(ER_ERROR_ON_WRITE, MYF(0), path, errno);1344 my_error(ER_ERROR_ON_WRITE, MYF(0), path.file_string().c_str(), errno);
1334 goto err;1345 return 1;
1335 }1346 }
1336 }1347 }
1337 return(0);1348 return(0);
1338err:
1339 return(1);
1340}1349}
13411350
13421351
13431352
=== modified file 'drizzled/set_var.cc'
--- drizzled/set_var.cc 2010-09-29 16:49:08 +0000
+++ drizzled/set_var.cc 2010-10-06 07:38:58 +0000
@@ -86,7 +86,6 @@
86extern size_t my_thread_stack_size;86extern size_t my_thread_stack_size;
8787
88class sys_var_pluginvar;88class sys_var_pluginvar;
89static DYNAMIC_ARRAY fixed_show_vars;
90typedef map<string, sys_var *> SystemVariableMap;89typedef map<string, sys_var *> SystemVariableMap;
91static SystemVariableMap system_variable_map;90static SystemVariableMap system_variable_map;
92extern char *opt_drizzle_tmpdir;91extern char *opt_drizzle_tmpdir;
@@ -135,7 +134,14 @@
135sys_auto_increment_offset(&vars, "auto_increment_offset",134sys_auto_increment_offset(&vars, "auto_increment_offset",
136 &system_variables::auto_increment_offset);135 &system_variables::auto_increment_offset);
137136
138static sys_var_const_str sys_basedir(&vars, "basedir", drizzle_home);137static sys_var_fs_path sys_basedir(&vars, "basedir", basedir);
138static sys_var_fs_path sys_pid_file(&vars, "pid_file", pid_file);
139static sys_var_fs_path sys_plugin_dir(&vars, "plugin_dir", plugin_dir);
140
141static sys_var_size_t_ptr sys_thread_stack_size(&vars, "thread_stack",
142 &my_thread_stack_size);
143static sys_var_uint32_t_ptr sys_back_log(&vars, "back_log", &back_log);
144
139static sys_var_session_uint64_t sys_bulk_insert_buff_size(&vars, "bulk_insert_buffer_size",145static sys_var_session_uint64_t sys_bulk_insert_buff_size(&vars, "bulk_insert_buffer_size",
140 &system_variables::bulk_insert_buff_size);146 &system_variables::bulk_insert_buff_size);
141static sys_var_session_uint32_t sys_completion_type(&vars, "completion_type",147static sys_var_session_uint32_t sys_completion_type(&vars, "completion_type",
@@ -144,7 +150,7 @@
144 fix_completion_type);150 fix_completion_type);
145static sys_var_collation_sv151static sys_var_collation_sv
146sys_collation_server(&vars, "collation_server", &system_variables::collation_server, &default_charset_info);152sys_collation_server(&vars, "collation_server", &system_variables::collation_server, &default_charset_info);
147static sys_var_const_str_ptr sys_datadir(&vars, "datadir", getDatadirPtr());153static sys_var_fs_path sys_datadir(&vars, "datadir", getDataHome());
148154
149static sys_var_session_uint64_t sys_join_buffer_size(&vars, "join_buffer_size",155static sys_var_session_uint64_t sys_join_buffer_size(&vars, "join_buffer_size",
150 &system_variables::join_buff_size);156 &system_variables::join_buff_size);
@@ -198,8 +204,8 @@
198 false, fix_session_mem_root);204 false, fix_session_mem_root);
199static sys_var_readonly sys_tmpdir(&vars, "tmpdir", OPT_GLOBAL, SHOW_CHAR, get_tmpdir);205static sys_var_readonly sys_tmpdir(&vars, "tmpdir", OPT_GLOBAL, SHOW_CHAR, get_tmpdir);
200206
201static sys_var_const_str_ptr sys_secure_file_priv(&vars, "secure_file_priv",207static sys_var_fs_path sys_secure_file_priv(&vars, "secure_file_priv",
202 &opt_secure_file_priv);208 secure_file_priv);
203209
204static sys_var_const_str_ptr sys_scheduler(&vars, "scheduler",210static sys_var_const_str_ptr sys_scheduler(&vars, "scheduler",
205 (char**)&opt_scheduler);211 (char**)&opt_scheduler);
@@ -307,21 +313,6 @@
307/* Global read-only variable containing hostname */313/* Global read-only variable containing hostname */
308static sys_var_const_str sys_hostname(&vars, "hostname", glob_hostname);314static sys_var_const_str sys_hostname(&vars, "hostname", glob_hostname);
309315
310/*
311 Additional variables (not derived from sys_var class, not accessible as
312 @@varname in SELECT or SET). Sorted in alphabetical order to facilitate
313 maintenance - SHOW VARIABLES will sort its output.
314 TODO: remove this list completely
315*/
316
317#define FIXED_VARS_SIZE (sizeof(fixed_vars) / sizeof(drizzle_show_var))
318static drizzle_show_var fixed_vars[]= {
319 {"back_log", (char*) &back_log, SHOW_INT},
320 {"pid_file", (char*) pidfile_name, SHOW_CHAR},
321 {"plugin_dir", (char*) opt_plugin_dir, SHOW_CHAR},
322 {"thread_stack", (char*) &my_thread_stack_size, SHOW_INT},
323};
324
325bool sys_var::check(Session *, set_var *var)316bool sys_var::check(Session *, set_var *var)
326{317{
327 var->save_result.uint64_t_value= var->value->val_int();318 var->save_result.uint64_t_value= var->value->val_int();
@@ -1562,23 +1553,20 @@
1562 SYNOPSIS1553 SYNOPSIS
1563 enumerate_sys_vars()1554 enumerate_sys_vars()
1564 session current thread1555 session current thread
1565 sorted If TRUE, the system variables should be sorted
15661556
1567 RETURN VALUES1557 RETURN VALUES
1568 pointer Array of drizzle_show_var elements for display1558 pointer Array of drizzle_show_var elements for display
1569 NULL FAILURE1559 NULL FAILURE
1570*/1560*/
15711561
1572drizzle_show_var* enumerate_sys_vars(Session *session, bool)1562drizzle_show_var* enumerate_sys_vars(Session *session)
1573{1563{
1574 int fixed_count= fixed_show_vars.elements;1564 int size= sizeof(drizzle_show_var) * (system_variable_map.size() + 1);
1575 int size= sizeof(drizzle_show_var) * (system_variable_map.size() + fixed_count + 1);
1576 drizzle_show_var *result= (drizzle_show_var*) session->alloc(size);1565 drizzle_show_var *result= (drizzle_show_var*) session->alloc(size);
15771566
1578 if (result)1567 if (result)
1579 {1568 {
1580 drizzle_show_var *show= result + fixed_count;1569 drizzle_show_var *show= result;
1581 memcpy(result, fixed_show_vars.buffer, fixed_count * sizeof(drizzle_show_var));
15821570
1583 SystemVariableMap::const_iterator iter= system_variable_map.begin();1571 SystemVariableMap::const_iterator iter= system_variable_map.begin();
1584 while (iter != system_variable_map.end())1572 while (iter != system_variable_map.end())
@@ -1587,7 +1575,7 @@
1587 show->name= var->getName().c_str();1575 show->name= var->getName().c_str();
1588 show->value= (char*) var;1576 show->value= (char*) var;
1589 show->type= SHOW_SYS;1577 show->type= SHOW_SYS;
1590 show++;1578 ++show;
1591 ++iter;1579 ++iter;
1592 }1580 }
15931581
@@ -1615,13 +1603,6 @@
16151603
1616 for (sys_var *var= vars.first; var; var= var->getNext(), count++) {};1604 for (sys_var *var= vars.first; var; var= var->getNext(), count++) {};
16171605
1618 if (my_init_dynamic_array(&fixed_show_vars, sizeof(drizzle_show_var),
1619 FIXED_VARS_SIZE + 64, 64))
1620 goto error;
1621
1622 fixed_show_vars.elements= FIXED_VARS_SIZE;
1623 memcpy(fixed_show_vars.buffer, fixed_vars, sizeof(fixed_vars));
1624
1625 vars.last->setNext(NULL);1606 vars.last->setNext(NULL);
1626 if (mysql_add_sys_var_chain(vars.first, my_long_options))1607 if (mysql_add_sys_var_chain(vars.first, my_long_options))
1627 goto error;1608 goto error;
@@ -1634,12 +1615,6 @@
1634}1615}
16351616
16361617
1637void set_var_free()
1638{
1639 delete_dynamic(&fixed_show_vars);
1640}
1641
1642
1643/**1618/**
1644 Find a user set-table variable.1619 Find a user set-table variable.
16451620
16461621
=== modified file 'drizzled/set_var.h'
--- drizzled/set_var.h 2010-09-29 16:49:08 +0000
+++ drizzled/set_var.h 2010-10-06 07:38:58 +0000
@@ -21,6 +21,7 @@
21#define DRIZZLED_SET_VAR_H21#define DRIZZLED_SET_VAR_H
2222
23#include <string>23#include <string>
24#include <boost/filesystem.hpp>
2425
25#include "drizzled/function/func.h"26#include "drizzled/function/func.h"
26#include "drizzled/function/set_user_var.h"27#include "drizzled/function/set_user_var.h"
@@ -62,8 +63,9 @@
62extern const char *in_additional_cond;63extern const char *in_additional_cond;
63extern const char *in_having_cond;64extern const char *in_having_cond;
64extern char glob_hostname[FN_REFLEN];65extern char glob_hostname[FN_REFLEN];
65extern char drizzle_home[FN_REFLEN];66extern boost::filesystem::path basedir;
66extern char pidfile_name[FN_REFLEN];67extern boost::filesystem::path pid_file;
68extern boost::filesystem::path secure_file_priv;
67extern char system_time_zone[30];69extern char system_time_zone[30];
68extern char *opt_tc_log_file;70extern char *opt_tc_log_file;
69extern uint64_t session_startup_options;71extern uint64_t session_startup_options;
@@ -80,7 +82,6 @@
80extern uint32_t volatile thread_running;82extern uint32_t volatile thread_running;
81extern uint32_t volatile global_read_lock;83extern uint32_t volatile global_read_lock;
82extern bool opt_readonly;84extern bool opt_readonly;
83extern char* opt_secure_file_priv;
84extern char *default_tz_name;85extern char *default_tz_name;
85extern const char *opt_scheduler;86extern const char *opt_scheduler;
8687
@@ -360,6 +361,44 @@
360};361};
361362
362363
364class sys_var_fs_path :
365 public sys_var
366{
367 const boost::filesystem::path &value;
368public:
369 sys_var_fs_path(sys_var_chain *chain,
370 const char *name_arg,
371 const boost::filesystem::path& value_arg) :
372 sys_var(name_arg),
373 value(value_arg)
374 {
375 chain_sys_var(chain);
376 }
377
378 inline void set(char *)
379 { }
380
381 bool check(Session *, set_var *)
382 {
383 return true;
384 }
385 bool update(Session *, set_var *)
386 {
387 return true;
388 }
389 SHOW_TYPE show_type() { return SHOW_CHAR; }
390 unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
391 {
392 return (unsigned char*)(value.file_string().c_str());
393 }
394 bool check_update_type(Item_result)
395 {
396 return true;
397 }
398 bool check_default(sql_var_t) { return true; }
399 bool is_readonly() const { return true; }
400};
401
363class sys_var_const_str :public sys_var402class sys_var_const_str :public sys_var
364{403{
365 char *value; // Pointer to const value404 char *value; // Pointer to const value
@@ -912,8 +951,7 @@
912*/951*/
913952
914int set_var_init();953int set_var_init();
915void set_var_free();954drizzle_show_var* enumerate_sys_vars(Session *session);
916drizzle_show_var* enumerate_sys_vars(Session *session, bool sorted);
917void drizzle_add_plugin_sysvar(sys_var_pluginvar *var);955void drizzle_add_plugin_sysvar(sys_var_pluginvar *var);
918void drizzle_del_plugin_sysvar();956void drizzle_del_plugin_sysvar();
919int mysql_add_sys_var_chain(sys_var *chain, struct option *long_options);957int mysql_add_sys_var_chain(sys_var *chain, struct option *long_options);
920958
=== modified file 'drizzled/sql_load.cc'
--- drizzled/sql_load.cc 2010-10-02 21:15:42 +0000
+++ drizzled/sql_load.cc 2010-10-06 07:38:58 +0000
@@ -124,7 +124,6 @@
124 List<Item> &set_values,124 List<Item> &set_values,
125 enum enum_duplicates handle_duplicates, bool ignore)125 enum enum_duplicates handle_duplicates, bool ignore)
126{126{
127 char name[FN_REFLEN];
128 int file;127 int file;
129 Table *table= NULL;128 Table *table= NULL;
130 int error;129 int error;
@@ -254,61 +253,62 @@
254 return(true);253 return(true);
255 }254 }
256255
257 {256 fs::path to_file(ex->file_name);
258#ifdef DONT_ALLOW_FULL_LOAD_DATA_PATHS257 fs::path target_path(fs::system_complete(getDataHomeCatalog()));
259 ex->file_name+=dirname_length(ex->file_name);258 if (not to_file.has_root_directory())
260#endif259 {
261 if (!internal::dirname_length(ex->file_name))260 int count_elements= 0;
262 {261 for (fs::path::iterator iter= to_file.begin();
263 strcpy(name, getDataHomeCatalog().c_str());262 iter != to_file.end();
264 strncat(name, "/", 1);263 ++iter, ++count_elements)
265 strncat(name, tdb, FN_REFLEN-getDataHomeCatalog().size());264 { }
266 (void) internal::fn_format(name, ex->file_name, name, "",265
267 MY_RELATIVE_PATH | MY_UNPACK_FILENAME);266 if (count_elements == 1)
268 }267 {
269 else268 target_path /= tdb;
270 {269 }
271 (void) internal::fn_format(name, ex->file_name, getDataHomeCatalog().c_str(), "",270 target_path /= to_file;
272 MY_RELATIVE_PATH | MY_UNPACK_FILENAME);271 }
273272 else
274 if (opt_secure_file_priv)273 {
275 {274 target_path= to_file;
276 fs::path secure_file_path(fs::system_complete(fs::path(opt_secure_file_priv)));275 }
277 fs::path target_path(fs::system_complete(fs::path(name)));276
278 if (target_path.file_string().substr(0, secure_file_path.file_string().size()) != secure_file_path.file_string())277 if (not secure_file_priv.string().empty())
279 {278 {
280 /* Read only allowed from within dir specified by secure_file_priv */279 if (target_path.file_string().substr(0, secure_file_priv.file_string().size()) != secure_file_priv.file_string())
281 my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");280 {
282 return(true);281 /* Read only allowed from within dir specified by secure_file_priv */
283 }282 my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
284 }
285
286 struct stat stat_info;
287 if (stat(name,&stat_info))
288 {
289 my_error(ER_FILE_NOT_FOUND, MYF(0), name, errno);
290 return(true);
291 }
292
293 // if we are not in slave thread, the cursor must be:
294 if (!((stat_info.st_mode & S_IROTH) == S_IROTH && // readable by others
295 (stat_info.st_mode & S_IFLNK) != S_IFLNK && // and not a symlink
296 ((stat_info.st_mode & S_IFREG) == S_IFREG ||
297 (stat_info.st_mode & S_IFIFO) == S_IFIFO)))
298 {
299 my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), name);
300 return(true);
301 }
302 if ((stat_info.st_mode & S_IFIFO) == S_IFIFO)
303 is_fifo = 1;
304 }
305 if ((file=internal::my_open(name,O_RDONLY,MYF(MY_WME))) < 0)
306 {
307 my_error(ER_CANT_OPEN_FILE, MYF(0), name, errno);
308 return(true);283 return(true);
309 }284 }
310 }285 }
311286
287 struct stat stat_info;
288 if (stat(target_path.file_string().c_str(), &stat_info))
289 {
290 my_error(ER_FILE_NOT_FOUND, MYF(0), target_path.file_string().c_str(), errno);
291 return(true);
292 }
293
294 // if we are not in slave thread, the cursor must be:
295 if (!((stat_info.st_mode & S_IROTH) == S_IROTH && // readable by others
296 (stat_info.st_mode & S_IFLNK) != S_IFLNK && // and not a symlink
297 ((stat_info.st_mode & S_IFREG) == S_IFREG ||
298 (stat_info.st_mode & S_IFIFO) == S_IFIFO)))
299 {
300 my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), target_path.file_string().c_str());
301 return(true);
302 }
303 if ((stat_info.st_mode & S_IFIFO) == S_IFIFO)
304 is_fifo = 1;
305
306
307 if ((file=internal::my_open(target_path.file_string().c_str(), O_RDONLY,MYF(MY_WME))) < 0)
308 {
309 my_error(ER_CANT_OPEN_FILE, MYF(0), target_path.file_string().c_str(), errno);
310 return(true);
311 }
312 CopyInfo info;312 CopyInfo info;
313 memset(&info, 0, sizeof(info));313 memset(&info, 0, sizeof(info));
314 info.ignore= ignore;314 info.ignore= ignore;
@@ -395,14 +395,16 @@
395 error= -1; // Error on read395 error= -1; // Error on read
396 goto err;396 goto err;
397 }397 }
398 snprintf(name, sizeof(name), ER(ER_LOAD_INFO), info.records, info.deleted,398
399 char msg[FN_REFLEN];
400 snprintf(msg, sizeof(msg), ER(ER_LOAD_INFO), info.records, info.deleted,
399 (info.records - info.copied), session->cuted_fields);401 (info.records - info.copied), session->cuted_fields);
400402
401 if (session->transaction.stmt.hasModifiedNonTransData())403 if (session->transaction.stmt.hasModifiedNonTransData())
402 session->transaction.all.markModifiedNonTransData();404 session->transaction.all.markModifiedNonTransData();
403405
404 /* ok to client sent only after binlog write and engine commit */406 /* ok to client sent only after binlog write and engine commit */
405 session->my_ok(info.copied + info.deleted, 0, 0L, name);407 session->my_ok(info.copied + info.deleted, 0, 0L, msg);
406err:408err:
407 assert(transactional_table || !(info.copied || info.deleted) ||409 assert(transactional_table || !(info.copied || info.deleted) ||
408 session->transaction.stmt.hasModifiedNonTransData());410 session->transaction.stmt.hasModifiedNonTransData());
409411
=== modified file 'drizzled/thr_lock.cc'
--- drizzled/thr_lock.cc 2010-10-02 21:15:42 +0000
+++ drizzled/thr_lock.cc 2010-10-06 07:38:58 +0000
@@ -89,7 +89,7 @@
89static enum thr_lock_type thr_upgraded_concurrent_insert_lock = TL_WRITE;89static enum thr_lock_type thr_upgraded_concurrent_insert_lock = TL_WRITE;
9090
9191
92uint64_t max_write_lock_count= ~(uint64_t) 0L;92uint64_t max_write_lock_count= UINT64_MAX;
9393
94/*94/*
95** For the future (now the thread specific cond is alloced by my_pthread.c)95** For the future (now the thread specific cond is alloced by my_pthread.c)
9696
=== modified file 'plugin/innobase/handler/ha_innodb.cc'
--- plugin/innobase/handler/ha_innodb.cc 2010-10-02 21:15:42 +0000
+++ plugin/innobase/handler/ha_innodb.cc 2010-10-06 07:38:58 +0000
@@ -90,10 +90,12 @@
9090
91#include <boost/algorithm/string.hpp>91#include <boost/algorithm/string.hpp>
92#include <boost/program_options.hpp>92#include <boost/program_options.hpp>
93#include <boost/filesystem.hpp>
93#include <drizzled/module/option_map.h>94#include <drizzled/module/option_map.h>
94#include <iostream>95#include <iostream>
9596
96namespace po= boost::program_options;97namespace po= boost::program_options;
98namespace fs=boost::filesystem;
97using namespace std;99using namespace std;
98100
99/** @file ha_innodb.cc */101/** @file ha_innodb.cc */
@@ -307,6 +309,7 @@
307 309
308 /* These get strdup'd from vm variables */310 /* These get strdup'd from vm variables */
309 free(innobase_data_home_dir);311 free(innobase_data_home_dir);
312 free(innobase_log_group_home_dir);
310313
311 }314 }
312315
@@ -1839,7 +1842,7 @@
1839 }1842 }
1840 else1843 else
1841 {1844 {
1842 innobase_data_home_dir= strdup(getDataHome().c_str());1845 innobase_data_home_dir= strdup(getDataHome().file_string().c_str());
1843 }1846 }
18441847
1845 if (vm.count("fast-shutdown"))1848 if (vm.count("fast-shutdown"))
@@ -2160,11 +2163,11 @@
21602163
2161 if (vm.count("log-group-home-dir"))2164 if (vm.count("log-group-home-dir"))
2162 {2165 {
2163 innobase_log_group_home_dir= const_cast<char *>(vm["log-group-home-dir"].as<string>().c_str());2166 innobase_log_group_home_dir= strdup(vm["log-group-home-dir"].as<string>().c_str());
2164 }2167 }
2165 else2168 else
2166 {2169 {
2167 innobase_log_group_home_dir = const_cast<char *>(getDataHome().c_str());2170 innobase_log_group_home_dir = strdup(getDataHome().file_string().c_str());
2168 }2171 }
21692172
2170#ifdef UNIV_LOG_ARCHIVE2173#ifdef UNIV_LOG_ARCHIVE
@@ -6435,7 +6438,6 @@
6435 ib_int64_t n_rows;6438 ib_int64_t n_rows;
6436 ulong j;6439 ulong j;
6437 ulong i;6440 ulong i;
6438 char path[FN_REFLEN];
6439 os_file_stat_t stat_info;6441 os_file_stat_t stat_info;
64406442
6441 /* If we are forcing recovery at a high level, we will suppress6443 /* If we are forcing recovery at a high level, we will suppress
@@ -6479,15 +6481,14 @@
6479 prebuilt->trx->op_info = "returning various info to MySQL";6481 prebuilt->trx->op_info = "returning various info to MySQL";
6480 }6482 }
64816483
6482 snprintf(path, sizeof(path), "%s/%s%s",6484 fs::path get_status_path(getDataHomeCatalog());
6483 getDataHomeCatalog().c_str(), ib_table->name, ".dfe");6485 get_status_path /= ib_table->name;
64846486 fs::change_extension(get_status_path, "dfe");
6485 internal::unpack_filename(path,path);
64866487
6487 /* Note that we do not know the access time of the table,6488 /* Note that we do not know the access time of the table,
6488 nor the CHECK TABLE time, nor the UPDATE or INSERT time. */6489 nor the CHECK TABLE time, nor the UPDATE or INSERT time. */
64896490
6490 if (os_file_get_status(path,&stat_info)) {6491 if (os_file_get_status(get_status_path.file_string().c_str(), &stat_info)) {
6491 stats.create_time = (ulong) stat_info.ctime;6492 stats.create_time = (ulong) stat_info.ctime;
6492 }6493 }
6493 }6494 }
64946495
=== modified file 'plugin/pbms/src/database_ms.cc'
--- plugin/pbms/src/database_ms.cc 2010-10-02 21:15:42 +0000
+++ plugin/pbms/src/database_ms.cc 2010-10-06 07:38:58 +0000
@@ -1259,7 +1259,7 @@
1259 * The database name is case sensitive here if the file system names are1259 * The database name is case sensitive here if the file system names are
1260 * case sensitive. This is desirable.1260 * case sensitive. This is desirable.
1261 */1261 */
1262 path = CSPath::newPath(ms_my_get_mysql_home_path(), RETAIN(db_name));1262 path = CSPath::newPath(ms_my_get_mysql_home_path().c_str(), RETAIN(db_name));
1263 push_(path);1263 push_(path);
1264 if (create && !path->exists()) {1264 if (create && !path->exists()) {
1265 CSException::throwException(CS_CONTEXT, MS_ERR_UNKNOWN_DB, db_name->getCString());1265 CSException::throwException(CS_CONTEXT, MS_ERR_UNKNOWN_DB, db_name->getCString());
@@ -1605,7 +1605,7 @@
1605 bool create = false;1605 bool create = false;
1606 uint32_t db_id;1606 uint32_t db_id;
1607 1607
1608 path = createDatabasePath(ms_my_get_mysql_home_path(), CSString::newString(db_name), &db_id, &create);1608 path = createDatabasePath(ms_my_get_mysql_home_path().c_str(), CSString::newString(db_name), &db_id, &create);
1609 1609
1610 if (path) {1610 if (path) {
1611 MSTransactionManager::dropDatabase(db_id);1611 MSTransactionManager::dropDatabase(db_id);
@@ -1636,7 +1636,7 @@
1636// 3: <database>/<table>1636// 3: <database>/<table>
1637bool MSDatabase::convertTablePathToIDs(const char *table_path, uint32_t *db_id, uint32_t *tab_id, bool create) 1637bool MSDatabase::convertTablePathToIDs(const char *table_path, uint32_t *db_id, uint32_t *tab_id, bool create)
1638{1638{
1639 const char *base = ms_my_get_mysql_home_path();1639 const char *base = ms_my_get_mysql_home_path().c_str();
1640 CSString *table_url;1640 CSString *table_url;
1641 CSString *db_path = NULL;1641 CSString *db_path = NULL;
1642 CSString *db_name = NULL;1642 CSString *db_name = NULL;
@@ -1736,7 +1736,7 @@
1736 MSDatabase *db;1736 MSDatabase *db;
1737 enter_();1737 enter_();
1738 1738
1739 db = newDatabase(ms_my_get_mysql_home_path(), db_name, 0, create);1739 db = newDatabase(ms_my_get_mysql_home_path().c_str(), db_name, 0, create);
1740 1740
1741 if (db) {1741 if (db) {
1742 push_(db);1742 push_(db);
17431743
=== modified file 'plugin/pbms/src/mysql_ms.cc'
--- plugin/pbms/src/mysql_ms.cc 2010-10-02 21:15:42 +0000
+++ plugin/pbms/src/mysql_ms.cc 2010-10-06 07:38:58 +0000
@@ -56,9 +56,9 @@
56}56}
5757
58#ifdef DRIZZLED58#ifdef DRIZZLED
59const char *ms_my_get_mysql_home_path()59const std::string ms_my_get_mysql_home_path()
60{60{
61 return drizzled::getDataHomeCatalog().c_str();61 return drizzled::getDataHomeCatalog().file_string();
62}62}
6363
64bool ms_is_autocommit()64bool ms_is_autocommit()
@@ -67,7 +67,7 @@
67}67}
6868
69#else69#else
70const char *ms_my_get_mysql_home_path()70const std::string ms_my_get_mysql_home_path()
71{71{
72 return mysql_real_data_home;72 return mysql_real_data_home;
73}73}
7474
=== modified file 'plugin/pbms/src/mysql_ms.h'
--- plugin/pbms/src/mysql_ms.h 2010-10-02 21:15:42 +0000
+++ plugin/pbms/src/mysql_ms.h 2010-10-06 07:38:58 +0000
@@ -30,9 +30,11 @@
30#ifndef __MS_MYSQL_H__30#ifndef __MS_MYSQL_H__
31#define __MS_MYSQL_H__31#define __MS_MYSQL_H__
3232
33#include <string>
34
33void *ms_my_get_thread();35void *ms_my_get_thread();
34uint64_t ms_my_1970_to_mysql_time(time_t t);36uint64_t ms_my_1970_to_mysql_time(time_t t);
35const char *ms_my_get_mysql_home_path();37const std::string ms_my_get_mysql_home_path();
36void ms_my_set_column_name(const char *table, uint16_t col_index, char *col_name);38void ms_my_set_column_name(const char *table, uint16_t col_index, char *col_name);
37bool ms_is_autocommit();39bool ms_is_autocommit();
3840
3941
=== modified file 'plugin/pbms/src/pbmsdaemon_ms.cc'
--- plugin/pbms/src/pbmsdaemon_ms.cc 2010-06-24 19:00:02 +0000
+++ plugin/pbms/src/pbmsdaemon_ms.cc 2010-10-06 07:38:58 +0000
@@ -59,6 +59,6 @@
59 pbd_state = state;59 pbd_state = state;
60 60
61 if (pbd_state == DaemonStartUp) { // In theory we could allow this to be set with a commandline option.61 if (pbd_state == DaemonStartUp) { // In theory we could allow this to be set with a commandline option.
62 cs_make_absolute_path(PATH_MAX, pbd_home_dir, "pbms", ms_my_get_mysql_home_path()); 62 cs_make_absolute_path(PATH_MAX, pbd_home_dir, "pbms", ms_my_get_mysql_home_path().c_str());
63 }63 }
64}64}
6565
=== modified file 'plugin/pbms/src/system_table_ms.cc'
--- plugin/pbms/src/system_table_ms.cc 2010-10-02 21:15:42 +0000
+++ plugin/pbms/src/system_table_ms.cc 2010-10-06 07:38:58 +0000
@@ -423,7 +423,7 @@
423 if (!db)423 if (!db)
424 return false;424 return false;
425 425
426 cs_strcpy(PATH_MAX, path, ms_my_get_mysql_home_path());426 cs_strcpy(PATH_MAX, path, ms_my_get_mysql_home_path().c_str());
427 cs_add_name_to_path(PATH_MAX, path, db);427 cs_add_name_to_path(PATH_MAX, path, db);
428 428
429 if (stat(path, &stat_info) == 0)429 if (stat(path, &stat_info) == 0)
430430
=== modified file 'plugin/pbxt/src/myxt_xt.cc'
--- plugin/pbxt/src/myxt_xt.cc 2010-10-02 21:15:42 +0000
+++ plugin/pbxt/src/myxt_xt.cc 2010-10-06 07:38:58 +0000
@@ -44,9 +44,11 @@
44#include <drizzled/charset_info.h>44#include <drizzled/charset_info.h>
45#include <plugin/myisam/my_handler.h>45#include <plugin/myisam/my_handler.h>
46#include <plugin/myisam/myisampack.h>46#include <plugin/myisam/myisampack.h>
47#include <boost/filesystem.hpp>
47//extern "C" struct charset_info_st *session_charset(Session *session);48//extern "C" struct charset_info_st *session_charset(Session *session);
48extern pthread_key_t THR_Session;49extern pthread_key_t THR_Session;
4950
51namespace fs=boost::filesystem;
50using namespace drizzled;52using namespace drizzled;
51#else53#else
52#include "mysql_priv.h"54#include "mysql_priv.h"
@@ -2029,12 +2031,10 @@
2029 message::Table::STANDARD);2031 message::Table::STANDARD);
2030 }2032 }
2031 else {2033 else {
2032 std::string n(getDataHomeCatalog());2034 fs::path n(getDataHomeCatalog());
2033 n.append("/");2035 n /= database_name;
2034 n.append(database_name);2036 n /= tab_file_name;
2035 n.append("/");2037 ident = new TableIdentifier(database_name, tab_name, n.file_string());
2036 n.append(tab_file_name);
2037 ident = new TableIdentifier(database_name, tab_name, n);
2038 }2038 }
2039 2039
2040 share = new TableShare(message::Table::STANDARD);2040 share = new TableShare(message::Table::STANDARD);
20412041
=== modified file 'plugin/pbxt/src/xt_defs.h'
--- plugin/pbxt/src/xt_defs.h 2010-10-02 21:15:42 +0000
+++ plugin/pbxt/src/xt_defs.h 2010-10-06 07:38:58 +0000
@@ -941,7 +941,8 @@
941941
942#define my_pthread_setspecific_ptr(T, V) pthread_setspecific(T, (void*) (V))942#define my_pthread_setspecific_ptr(T, V) pthread_setspecific(T, (void*) (V))
943943
944#define mysql_real_data_home ::drizzled::getDataHomeCatalog().c_str()944/* TODO: This is dangerous! */
945#define mysql_real_data_home ::drizzled::getDataHomeCatalog().file_string().c_str()
945946
946#define mi_int4store(T,A) { uint32_t def_temp= (uint32_t) (A);\947#define mi_int4store(T,A) { uint32_t def_temp= (uint32_t) (A);\
947 ((unsigned char*) (T))[3]= (unsigned char) (def_temp);\948 ((unsigned char*) (T))[3]= (unsigned char) (def_temp);\
948949
=== modified file 'plugin/schema_engine/schema.cc'
--- plugin/schema_engine/schema.cc 2010-09-22 07:05:47 +0000
+++ plugin/schema_engine/schema.cc 2010-10-06 07:38:58 +0000
@@ -67,7 +67,7 @@
6767
68void Schema::prime()68void Schema::prime()
69{69{
70 CachedDirectory directory(getDataHomeCatalog(), CachedDirectory::DIRECTORY);70 CachedDirectory directory(getDataHomeCatalog().file_string(), CachedDirectory::DIRECTORY);
71 CachedDirectory::Entries files= directory.getEntries();71 CachedDirectory::Entries files= directory.getEntries();
7272
73 mutex.lock();73 mutex.lock();
7474
=== modified file 'plugin/signal_handler/signal_handler.cc'
--- plugin/signal_handler/signal_handler.cc 2010-09-27 23:26:59 +0000
+++ plugin/signal_handler/signal_handler.cc 2010-10-06 07:38:58 +0000
@@ -28,6 +28,7 @@
28#include "drizzled/drizzled.h"28#include "drizzled/drizzled.h"
2929
30#include <boost/thread/thread.hpp>30#include <boost/thread/thread.hpp>
31#include <boost/filesystem.hpp>
3132
32#include <sys/stat.h>33#include <sys/stat.h>
33#include <fcntl.h>34#include <fcntl.h>
@@ -41,7 +42,7 @@
41extern int cleanup_done;42extern int cleanup_done;
42extern bool volatile abort_loop;43extern bool volatile abort_loop;
43extern bool volatile shutdown_in_progress;44extern bool volatile shutdown_in_progress;
44extern char pidfile_name[FN_REFLEN];45extern boost::filesystem::path pid_file;
45/* Prototypes -> all of these should be factored out into a propper shutdown */46/* Prototypes -> all of these should be factored out into a propper shutdown */
46extern void close_connections(void);47extern void close_connections(void);
47extern std::bitset<12> test_flags;48extern std::bitset<12> test_flags;
@@ -88,8 +89,7 @@
88 int file;89 int file;
89 char buff[1024];90 char buff[1024];
9091
91 assert(pidfile_name[0]);92 if ((file = open(pid_file.file_string().c_str(), O_CREAT|O_WRONLY|O_TRUNC, S_IRWXU|S_IRGRP|S_IROTH)) > 0)
92 if ((file = open(pidfile_name, O_CREAT|O_WRONLY|O_TRUNC, S_IRWXU|S_IRGRP|S_IROTH)) > 0)
93 {93 {
94 int length;94 int length;
9595
@@ -103,7 +103,7 @@
103 (void)close(file); /* We can ignore the error, since we are going to error anyway at this point */103 (void)close(file); /* We can ignore the error, since we are going to error anyway at this point */
104 }104 }
105 memset(buff, 0, sizeof(buff));105 memset(buff, 0, sizeof(buff));
106 snprintf(buff, sizeof(buff)-1, "Can't start server: can't create PID file (%s)", pidfile_name);106 snprintf(buff, sizeof(buff)-1, "Can't start server: can't create PID file (%s)", pid_file.file_string().c_str());
107 sql_perror(buff);107 sql_perror(buff);
108 exit(1);108 exit(1);
109}109}
110110
=== modified file 'plugin/status_dictionary/variables.h'
--- plugin/status_dictionary/variables.h 2010-02-16 00:36:58 +0000
+++ plugin/status_dictionary/variables.h 2010-10-06 07:38:58 +0000
@@ -37,7 +37,7 @@
3737
38 drizzled::drizzle_show_var *getVariables()38 drizzled::drizzle_show_var *getVariables()
39 {39 {
40 return enumerate_sys_vars(current_session, false); // Final value unused40 return enumerate_sys_vars(current_session); // Final value unused
41 }41 }
42};42};
4343
4444
=== modified file 'tests/r/func_str.result'
--- tests/r/func_str.result 2010-08-18 21:57:15 +0000
+++ tests/r/func_str.result 2010-10-06 07:38:58 +0000
@@ -721,11 +721,7 @@
7211 7211
722drop table t1;722drop table t1;
723select load_file("lkjlkj");723select load_file("lkjlkj");
724load_file("lkjlkj")724ERROR HY000: The file 'lkjlkj' must be in the database directory or be readable by all
725NULL
726select ifnull(load_file("lkjlkj"),"it's null");
727ifnull(load_file("lkjlkj"),"it's null")
728it's null
729CREATE TABLE t1 (a varchar(10));725CREATE TABLE t1 (a varchar(10));
730INSERT INTO t1 VALUES ('abc'), ('xyz');726INSERT INTO t1 VALUES ('abc'), ('xyz');
731SELECT a, CONCAT(a,' ',a) AS c FROM t1727SELECT a, CONCAT(a,' ',a) AS c FROM t1
732728
=== modified file 'tests/r/loaddata.result'
--- tests/r/loaddata.result 2010-09-23 01:53:13 +0000
+++ tests/r/loaddata.result 2010-10-06 07:38:58 +0000
@@ -150,10 +150,10 @@
15015 NULL Ten15015 NULL Ten
151show variables like "secure_file_pri%";151show variables like "secure_file_pri%";
152Variable_name Value152Variable_name Value
153secure_file_priv MYSQLTEST_VARDIR/153secure_file_priv MYSQLTEST_VARDIR
154select @@secure_file_priv;154select @@secure_file_priv;
155@@secure_file_priv155@@secure_file_priv
156MYSQLTEST_VARDIR/156MYSQLTEST_VARDIR
157set @@secure_file_priv= 0;157set @@secure_file_priv= 0;
158ERROR HY000: Variable 'secure_file_priv' is a read only variable158ERROR HY000: Variable 'secure_file_priv' is a read only variable
159truncate table t1;159truncate table t1;
@@ -162,8 +162,7 @@
162select * from t1;162select * from t1;
163a b c163a b c
164select load_file("DRIZZLE_TEST_DIR/t/loaddata.test");164select load_file("DRIZZLE_TEST_DIR/t/loaddata.test");
165load_file("DRIZZLE_TEST_DIR/t/loaddata.test")165ERROR HY000: The Drizzle server is running with the --secure-file-priv option so it cannot execute this statement
166NULL
167drop table t1, t2;166drop table t1, t2;
168create table t1(f1 int, f2 timestamp not null default current_timestamp);167create table t1(f1 int, f2 timestamp not null default current_timestamp);
169create table t2(f1 int);168create table t2(f1 int);
170169
=== modified file 'tests/r/outfile.result'
--- tests/r/outfile.result 2010-09-23 01:53:13 +0000
+++ tests/r/outfile.result 2010-10-06 07:38:58 +0000
@@ -3,10 +3,13 @@
3insert into t1 values("hello world"),("Hello mars"),(NULL);3insert into t1 values("hello world"),("Hello mars"),(NULL);
4select load_file(concat(@tmpdir,"/outfile-test.1"));4select load_file(concat(@tmpdir,"/outfile-test.1"));
5load_file(concat(@tmpdir,"/outfile-test.1"))5load_file(concat(@tmpdir,"/outfile-test.1"))
6NULL6hello world
7Hello mars
8\N
9
7select load_file(concat(@tmpdir,"/outfile-test.2"));10select load_file(concat(@tmpdir,"/outfile-test.2"));
8load_file(concat(@tmpdir,"/outfile-test.2"))11load_file(concat(@tmpdir,"/outfile-test.2"))
9NULL12hello world
10select load_file(concat(@tmpdir,"/outfile-test.3"));13select load_file(concat(@tmpdir,"/outfile-test.3"));
11load_file(concat(@tmpdir,"/outfile-test.3"))14load_file(concat(@tmpdir,"/outfile-test.3"))
12NULL15NULL
@@ -14,12 +17,12 @@
14ERROR HY000: File '../../tmp/outfile-test.2' already exists17ERROR HY000: File '../../tmp/outfile-test.2' already exists
15ERROR HY000: File '../../tmp/outfile-test.3' already exists18ERROR HY000: File '../../tmp/outfile-test.3' already exists
16select load_file(concat(@tmpdir,"/outfile-test.not-exist"));19select load_file(concat(@tmpdir,"/outfile-test.not-exist"));
17load_file(concat(@tmpdir,"/outfile-test.not-exist"))20ERROR HY000: The file '../../tmp/outfile-test.not-exist' must be in the database directory or be readable by all
18NULL
19drop table t1;21drop table t1;
20select load_file(concat(@tmpdir,"/outfile-test.4"));22select load_file(concat(@tmpdir,"/outfile-test.4"));
21load_file(concat(@tmpdir,"/outfile-test.4"))23load_file(concat(@tmpdir,"/outfile-test.4"))
22NULL241
25
23CREATE TABLE t1 (a INT);26CREATE TABLE t1 (a INT);
24EXPLAIN 27EXPLAIN
25SELECT *28SELECT *
2629
=== modified file 'tests/t/func_str.test'
--- tests/t/func_str.test 2010-08-26 21:56:15 +0000
+++ tests/t/func_str.test 2010-10-06 07:38:58 +0000
@@ -469,12 +469,9 @@
469--disable_metadata469--disable_metadata
470drop table t1;470drop table t1;
471471
472#
473# Bug #10418: LOAD_FILE does not behave like in manual if file does not exist
474#
475472
473--error ER_TEXTFILE_NOT_READABLE
476select load_file("lkjlkj");474select load_file("lkjlkj");
477select ifnull(load_file("lkjlkj"),"it's null");
478475
479#476#
480# Bug#18243: REVERSE changes its argument477# Bug#18243: REVERSE changes its argument
481478
=== modified file 'tests/t/loaddata.test'
--- tests/t/loaddata.test 2010-09-23 01:53:13 +0000
+++ tests/t/loaddata.test 2010-10-06 07:38:58 +0000
@@ -135,8 +135,8 @@
135eval load data infile '$DRIZZLE_TEST_DIR/t/loaddata.test' into table t1;135eval load data infile '$DRIZZLE_TEST_DIR/t/loaddata.test' into table t1;
136select * from t1;136select * from t1;
137137
138# Test "load_file" returns NULL
139--replace_result $DRIZZLE_TEST_DIR DRIZZLE_TEST_DIR138--replace_result $DRIZZLE_TEST_DIR DRIZZLE_TEST_DIR
139--error ER_OPTION_PREVENTS_STATEMENT
140eval select load_file("$DRIZZLE_TEST_DIR/t/loaddata.test");140eval select load_file("$DRIZZLE_TEST_DIR/t/loaddata.test");
141141
142# cleanup142# cleanup
143143
=== modified file 'tests/t/outfile.test'
--- tests/t/outfile.test 2010-09-23 01:53:13 +0000
+++ tests/t/outfile.test 2010-10-06 07:38:58 +0000
@@ -38,6 +38,7 @@
38--error ER_FILE_EXISTS_ERROR38--error ER_FILE_EXISTS_ERROR
39eval select * into dumpfile "../../tmp/outfile-test.3" from t1;39eval select * into dumpfile "../../tmp/outfile-test.3" from t1;
40enable_query_log;40enable_query_log;
41--error ER_TEXTFILE_NOT_READABLE
41select load_file(concat(@tmpdir,"/outfile-test.not-exist"));42select load_file(concat(@tmpdir,"/outfile-test.not-exist"));
42--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.143--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.1
43--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.244--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.2
@@ -48,6 +49,7 @@
48disable_query_log;49disable_query_log;
49eval select 1 into outfile "../../tmp/outfile-test.4";50eval select 1 into outfile "../../tmp/outfile-test.4";
50enable_query_log;51enable_query_log;
52--replace_result $DRIZZLE_TEST_DIR DRIZZLE_TEST_DIR
51select load_file(concat(@tmpdir,"/outfile-test.4"));53select load_file(concat(@tmpdir,"/outfile-test.4"));
52--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.454--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4
5355