31
32
#include <stdexcept>
33
34
#include <boost/program_options.hpp>
34
#include "drizzled/program_options/config_file.h"
35
#include <drizzled/program_options/config_file.h>
35
36
#include <boost/thread/recursive_mutex.hpp>
36
37
#include <boost/thread/mutex.hpp>
37
38
#include <boost/thread/shared_mutex.hpp>
38
39
#include <boost/thread/condition_variable.hpp>
39
40
#include <boost/filesystem.hpp>
41
#include <boost/detail/atomic_count.hpp>
41
#include "drizzled/internal/my_sys.h"
42
#include "drizzled/internal/my_bit.h"
43
#include <drizzled/my_hash.h>
43
#include <drizzled/cached_directory.h>
44
#include <drizzled/charset.h>
45
#include <drizzled/data_home.h>
46
#include <drizzled/debug.h>
47
#include <drizzled/definition/cache.h>
48
#include <drizzled/drizzled.h>
49
#include <drizzled/errmsg_print.h>
44
50
#include <drizzled/error.h>
45
#include <drizzled/errmsg_print.h>
46
#include <drizzled/tztime.h>
51
#include <drizzled/global_buffer.h>
52
#include <drizzled/internal/my_bit.h>
53
#include <drizzled/internal/my_sys.h>
54
#include <drizzled/item/cmpfunc.h>
55
#include <drizzled/item/create.h>
56
#include <drizzled/message/cache.h>
57
#include <drizzled/module/load_list.h>
58
#include <drizzled/module/registry.h>
59
#include <drizzled/plugin/client.h>
60
#include <drizzled/plugin/error_message.h>
61
#include <drizzled/plugin/event_observer.h>
62
#include <drizzled/plugin/listen.h>
63
#include <drizzled/plugin/monitored_in_transaction.h>
64
#include <drizzled/plugin/scheduler.h>
65
#include <drizzled/plugin/storage_engine.h>
66
#include <drizzled/plugin/xa_resource_manager.h>
67
#include <drizzled/probes.h>
68
#include <drizzled/replication_services.h> /* For ReplicationServices::evaluateRegisteredPlugins() */
69
#include <drizzled/session.h>
70
#include <drizzled/session/cache.h>
71
#include <drizzled/show.h>
47
72
#include <drizzled/sql_base.h>
48
#include <drizzled/show.h>
49
73
#include <drizzled/sql_parse.h>
50
#include <drizzled/item/cmpfunc.h>
51
#include <drizzled/session.h>
52
#include <drizzled/item/create.h>
74
#include <drizzled/statistics_variables.h>
75
#include <drizzled/temporal_format.h> /* For init_temporal_formats() */
76
#include <drizzled/tztime.h>
53
77
#include <drizzled/unireg.h>
54
#include "drizzled/temporal_format.h" /* For init_temporal_formats() */
55
#include "drizzled/plugin/listen.h"
56
#include "drizzled/plugin/error_message.h"
57
#include "drizzled/plugin/client.h"
58
#include "drizzled/plugin/scheduler.h"
59
#include "drizzled/plugin/xa_resource_manager.h"
60
#include "drizzled/plugin/monitored_in_transaction.h"
61
#include "drizzled/replication_services.h" /* For ReplicationServices::evaluateRegisteredPlugins() */
62
#include "drizzled/probes.h"
63
#include "drizzled/session/cache.h"
64
#include "drizzled/charset.h"
65
#include "plugin/myisam/myisam.h"
66
#include "drizzled/drizzled.h"
67
#include "drizzled/module/registry.h"
68
#include "drizzled/module/load_list.h"
69
#include "drizzled/global_buffer.h"
71
#include "drizzled/definition/cache.h"
73
#include "drizzled/plugin/event_observer.h"
75
#include "drizzled/message/cache.h"
78
#include <plugin/myisam/myisam.h>
79
#include <drizzled/typelib.h>
80
#include <drizzled/visibility.h>
81
#include <drizzled/system_variables.h>
77
83
#include <google/protobuf/stubs/common.h>
85
#include <drizzled/refresh_version.h>
79
87
#if TIME_WITH_SYS_TIME
80
88
# include <sys/time.h>
1151
1107
config_options.add_options()
1152
1108
("help,?", po::value<bool>(&opt_help)->default_value(false)->zero_tokens(),
1153
N_("Display this help and exit."))
1109
_("Display this help and exit."))
1110
("daemon,d", po::value<bool>(&opt_daemon)->default_value(false)->zero_tokens(),
1111
_("Run as a daemon."))
1154
1112
("no-defaults", po::value<bool>()->default_value(false)->zero_tokens(),
1155
N_("Configuration file defaults are not used if no-defaults is set"))
1113
_("Configuration file defaults are not used if no-defaults is set"))
1156
1114
("defaults-file", po::value<vector<string> >()->composing()->notifier(&compose_defaults_file_list),
1157
N_("Configuration file to use"))
1115
_("Configuration file to use"))
1158
1116
("config-dir", po::value<fs::path>(&system_config_dir),
1159
N_("Base location for config files"))
1117
_("Base location for config files"))
1160
1118
("plugin-dir", po::value<fs::path>(&plugin_dir)->notifier(¬ify_plugin_dir),
1161
N_("Directory for plugins."))
1119
_("Directory for plugins."))
1164
1122
plugin_load_options.add_options()
1165
1123
("plugin-add", po::value<vector<string> >()->composing()->notifier(&compose_plugin_add),
1166
N_("Optional comma separated list of plugins to load at startup in addition "
1124
_("Optional comma separated list of plugins to load at startup in addition "
1167
1125
"to the default list of plugins. "
1168
"[for example: --plugin_add=crc32,logger_gearman]"))
1126
"[for example: --plugin_add=crc32,logger_gearman]"))
1169
1127
("plugin-remove", po::value<vector<string> >()->composing()->notifier(&compose_plugin_remove),
1170
N_("Optional comma separated list of plugins to not load at startup. Effectively "
1128
_("Optional comma separated list of plugins to not load at startup. Effectively "
1171
1129
"removes a plugin from the list of plugins to be loaded. "
1172
1130
"[for example: --plugin_remove=crc32,logger_gearman]"))
1173
1131
("plugin-load", po::value<string>()->notifier(¬ify_plugin_load)->default_value(PANDORA_PLUGIN_LIST),
1174
N_("Optional comma separated list of plugins to load at starup instead of "
1132
_("Optional comma separated list of plugins to load at starup instead of "
1175
1133
"the default plugin load list. "
1176
1134
"[for example: --plugin_load=crc32,logger_gearman]"))
1179
1137
long_options.add_options()
1180
1138
("auto-increment-increment", po::value<uint64_t>(&global_system_variables.auto_increment_increment)->default_value(1)->notifier(&check_limits_aii),
1181
N_("Auto-increment columns are incremented by this"))
1139
_("Auto-increment columns are incremented by this"))
1182
1140
("auto-increment-offset", po::value<uint64_t>(&global_system_variables.auto_increment_offset)->default_value(1)->notifier(&check_limits_aio),
1183
N_("Offset added to Auto-increment columns. Used when auto-increment-increment != 1"))
1141
_("Offset added to Auto-increment columns. Used when auto-increment-increment != 1"))
1184
1142
("basedir,b", po::value<fs::path>(&basedir),
1185
N_("Path to installation directory. All paths are usually resolved "
1143
_("Path to installation directory. All paths are usually resolved "
1186
1144
"relative to this."))
1187
1145
("chroot,r", po::value<string>(),
1188
N_("Chroot drizzled daemon during startup."))
1146
_("Chroot drizzled daemon during startup."))
1189
1147
("collation-server", po::value<string>(),
1190
N_("Set the default collation."))
1148
_("Set the default collation."))
1191
1149
("completion-type", po::value<uint32_t>(&global_system_variables.completion_type)->default_value(0)->notifier(&check_limits_completion_type),
1192
N_("Default completion type."))
1193
("core-file", N_("Write core on errors."))
1194
("datadir", po::value<fs::path>(&data_home),
1195
N_("Path to the database root."))
1150
_("Default completion type."))
1151
("core-file", _("Write core on errors."))
1152
("datadir", po::value<fs::path>(&getDataHome()),
1153
_("Path to the database root."))
1196
1154
("default-storage-engine", po::value<string>(),
1197
N_("Set the default storage engine for tables."))
1155
_("Set the default storage engine for tables."))
1198
1156
("default-time-zone", po::value<string>(),
1199
N_("Set the default time zone."))
1157
_("Set the default time zone."))
1200
1158
("exit-info,T", po::value<long>(),
1201
N_("Used for debugging; Use at your own risk!"))
1159
_("Used for debugging; Use at your own risk!"))
1202
1160
("gdb", po::value<bool>(&opt_debugging)->default_value(false)->zero_tokens(),
1203
N_("Set up signals usable for debugging"))
1161
_("Set up signals usable for debugging"))
1204
1162
("lc-time-name", po::value<string>(),
1205
N_("Set the language used for the month names and the days of the week."))
1163
_("Set the language used for the month names and the days of the week."))
1206
1164
("log-warnings,W", po::value<bool>(&global_system_variables.log_warnings)->default_value(false)->zero_tokens(),
1207
N_("Log some not critical warnings to the log file."))
1165
_("Log some not critical warnings to the log file."))
1208
1166
("pid-file", po::value<fs::path>(&pid_file),
1209
N_("Pid file used by drizzled."))
1167
_("Pid file used by drizzled."))
1210
1168
("port-open-timeout", po::value<uint32_t>(&drizzled_bind_timeout)->default_value(0),
1211
N_("Maximum time in seconds to wait for the port to become free. "))
1169
_("Maximum time in seconds to wait for the port to become free. "))
1212
1170
("replicate-query", po::value<bool>(&global_system_variables.replicate_query)->default_value(false)->zero_tokens(),
1213
N_("Include the SQL query in replicated protobuf messages."))
1171
_("Include the SQL query in replicated protobuf messages."))
1214
1172
("secure-file-priv", po::value<fs::path>(&secure_file_priv)->notifier(expand_secure_file_priv),
1215
N_("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "
1173
_("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "
1216
1174
"within specified directory"))
1217
1175
("server-id", po::value<uint32_t>(&server_id)->default_value(0),
1218
N_("Uniquely identifies the server instance in the community of "
1176
_("Uniquely identifies the server instance in the community of "
1219
1177
"replication partners."))
1220
("skip-stack-trace",
1221
N_("Don't print a stack trace on failure."))
1178
("skip-stack-trace",
1179
_("Don't print a stack trace on failure."))
1222
1180
("symbolic-links,s", po::value<bool>(&internal::my_use_symdir)->default_value(IF_PURIFY(false,true))->zero_tokens(),
1223
N_("Enable symbolic link support."))
1181
_("Enable symbolic link support."))
1224
1182
("timed-mutexes", po::value<bool>(&internal::timed_mutexes)->default_value(false)->zero_tokens(),
1225
N_("Specify whether to time mutexes (only InnoDB mutexes are currently "
1183
_("Specify whether to time mutexes (only InnoDB mutexes are currently "
1227
1185
("tmpdir,t", po::value<string>(),
1228
N_("Path for temporary files."))
1186
_("Path for temporary files."))
1229
1187
("transaction-isolation", po::value<string>(),
1230
N_("Default transaction isolation level."))
1231
("transaction-message-threshold", po::value<size_t>(&global_system_variables.transaction_message_threshold)->default_value(1024*1024)->notifier(&check_limits_transaction_message_threshold),
1232
N_("Max message size written to transaction log, valid values 131072 - 1048576 bytes."))
1188
_("Default transaction isolation level."))
1189
("transaction-message-threshold", po::value<size_t>(&transaction_message_threshold)->default_value(1024*1024)->notifier(&check_limits_transaction_message_threshold),
1190
_("Max message size written to transaction log, valid values 131072 - 1048576 bytes."))
1233
1191
("user,u", po::value<string>(),
1234
N_("Run drizzled daemon as user."))
1236
N_("Output version information and exit."))
1192
_("Run drizzled daemon as user."))
1194
_("Output version information and exit."))
1237
1195
("back-log", po::value<back_log_constraints>(&back_log),
1238
N_("The number of outstanding connection requests Drizzle can have. This "
1196
_("The number of outstanding connection requests Drizzle can have. This "
1239
1197
"comes into play when the main Drizzle thread gets very many connection "
1240
1198
"requests in a very short time."))
1241
("bulk-insert-buffer-size",
1199
("bulk-insert-buffer-size",
1242
1200
po::value<uint64_t>(&global_system_variables.bulk_insert_buff_size)->default_value(8192*1024),
1243
N_("Size of tree cache used in bulk insert optimization. Note that this is "
1201
_("Size of tree cache used in bulk insert optimization. Note that this is "
1244
1202
"a limit per thread!"))
1245
1203
("div-precision-increment", po::value<uint32_t>(&global_system_variables.div_precincrement)->default_value(4)->notifier(&check_limits_dpi),
1246
N_("Precision of the result of '/' operator will be increased on that "
1204
_("Precision of the result of '/' operator will be increased on that "
1248
1206
("group-concat-max-len", po::value<uint64_t>(&global_system_variables.group_concat_max_len)->default_value(1024)->notifier(&check_limits_gcml),
1249
N_("The maximum length of the result of function group_concat."))
1207
_("The maximum length of the result of function group_concat."))
1250
1208
("join-buffer-size", po::value<uint64_t>(&global_system_variables.join_buff_size)->default_value(128*1024L)->notifier(&check_limits_join_buffer_size),
1251
N_("The size of the buffer that is used for full joins."))
1209
_("The size of the buffer that is used for full joins."))
1252
1210
("join-heap-threshold",
1253
1211
po::value<uint64_t>()->default_value(0),
1254
N_("A global cap on the amount of memory that can be allocated by session join buffers (0 means unlimited)"))
1212
_("A global cap on the amount of memory that can be allocated by session join buffers (0 means unlimited)"))
1255
1213
("max-allowed-packet", po::value<uint32_t>(&global_system_variables.max_allowed_packet)->default_value(64*1024*1024L)->notifier(&check_limits_map),
1256
N_("Max packetlength to send/receive from to server."))
1257
("max-connect-errors", po::value<uint64_t>(&max_connect_errors)->default_value(MAX_CONNECT_ERRORS)->notifier(&check_limits_mce),
1258
N_("If there is more than this number of interrupted connections from a "
1259
"host this host will be blocked from further connections."))
1214
_("Max packetlength to send/receive from to server."))
1260
1215
("max-error-count", po::value<uint64_t>(&global_system_variables.max_error_count)->default_value(DEFAULT_ERROR_COUNT)->notifier(&check_limits_max_err_cnt),
1261
N_("Max number of errors/warnings to store for a statement."))
1216
_("Max number of errors/warnings to store for a statement."))
1262
1217
("max-heap-table-size", po::value<uint64_t>(&global_system_variables.max_heap_table_size)->default_value(16*1024*1024L)->notifier(&check_limits_mhts),
1263
N_("Don't allow creation of heap tables bigger than this."))
1264
("max-join-size", po::value<drizzled::ha_rows>(&global_system_variables.max_join_size)->default_value(INT32_MAX)->notifier(&check_limits_max_join_size),
1265
N_("Joins that are probably going to read more than max_join_size records "
1218
_("Don't allow creation of heap tables bigger than this."))
1219
("max-join-size", po::value<ha_rows>(&global_system_variables.max_join_size)->default_value(INT32_MAX)->notifier(&check_limits_max_join_size),
1220
_("Joins that are probably going to read more than max_join_size records "
1266
1221
"return an error."))
1267
1222
("max-length-for-sort-data", po::value<uint64_t>(&global_system_variables.max_length_for_sort_data)->default_value(1024)->notifier(&check_limits_mlfsd),
1268
N_("Max number of bytes in sorted records."))
1223
_("Max number of bytes in sorted records."))
1269
1224
("max-seeks-for-key", po::value<uint64_t>(&global_system_variables.max_seeks_for_key)->default_value(ULONG_MAX)->notifier(&check_limits_msfk),
1270
N_("Limit assumed max number of seeks when looking up rows based on a key"))
1271
("max-sort-length", po::value<size_t>(&global_system_variables.max_sort_length)->default_value(1024)->notifier(&check_limits_max_sort_length),
1272
N_("The number of bytes to use when sorting BLOB or TEXT values "
1225
_("Limit assumed max number of seeks when looking up rows based on a key"))
1226
("max-sort-length", po::value<size_t>(&global_system_variables.max_sort_length)->default_value(1024)->notifier(&check_limits_max_sort_length),
1227
_("The number of bytes to use when sorting BLOB or TEXT values "
1273
1228
"(only the first max_sort_length bytes of each value are used; the "
1274
1229
"rest are ignored)."))
1275
1230
("max-write-lock-count", po::value<uint64_t>(&max_write_lock_count)->default_value(UINT64_MAX),
1276
N_("After this many write locks, allow some read locks to run in between."))
1231
_("After this many write locks, allow some read locks to run in between."))
1277
1232
("min-examined-row-limit", po::value<uint64_t>(&global_system_variables.min_examined_row_limit)->default_value(0)->notifier(&check_limits_merl),
1278
N_("Don't log queries which examine less than min_examined_row_limit "
1233
_("Don't log queries which examine less than min_examined_row_limit "
1279
1234
"rows to file."))
1280
1235
("disable-optimizer-prune",
1281
N_("Do not apply any heuristic(s) during query optimization to prune, "
1236
_("Do not apply any heuristic(s) during query optimization to prune, "
1282
1237
"thus perform an exhaustive search from the optimizer search space."))
1283
1238
("optimizer-search-depth", po::value<uint32_t>(&global_system_variables.optimizer_search_depth)->default_value(0)->notifier(&check_limits_osd),
1284
N_("Maximum depth of search performed by the query optimizer. Values "
1239
_("Maximum depth of search performed by the query optimizer. Values "
1285
1240
"larger than the number of relations in a query result in better query "
1286
1241
"plans, but take longer to compile a query. Smaller values than the "
1287
1242
"number of tables in a relation result in faster optimization, but may "
1290
1245
"optimizer will switch to the original find_best (used for "
1291
1246
"testing/comparison)."))
1292
1247
("preload-buffer-size", po::value<uint64_t>(&global_system_variables.preload_buff_size)->default_value(32*1024L)->notifier(&check_limits_pbs),
1293
N_("The size of the buffer that is allocated when preloading indexes"))
1294
("query-alloc-block-size",
1248
_("The size of the buffer that is allocated when preloading indexes"))
1249
("query-alloc-block-size",
1295
1250
po::value<uint32_t>(&global_system_variables.query_alloc_block_size)->default_value(QUERY_ALLOC_BLOCK_SIZE)->notifier(&check_limits_qabs),
1296
N_("Allocation block size for query parsing and execution"))
1251
_("Allocation block size for query parsing and execution"))
1297
1252
("query-prealloc-size",
1298
1253
po::value<uint32_t>(&global_system_variables.query_prealloc_size)->default_value(QUERY_ALLOC_PREALLOC_SIZE)->notifier(&check_limits_qps),
1299
N_("Persistent buffer for query parsing and execution"))
1254
_("Persistent buffer for query parsing and execution"))
1300
1255
("range-alloc-block-size",
1301
1256
po::value<size_t>(&global_system_variables.range_alloc_block_size)->default_value(RANGE_ALLOC_BLOCK_SIZE)->notifier(&check_limits_rabs),
1302
N_("Allocation block size for storing ranges during optimization"))
1257
_("Allocation block size for storing ranges during optimization"))
1303
1258
("read-buffer-size",
1304
1259
po::value<uint32_t>(&global_system_variables.read_buff_size)->default_value(128*1024L)->notifier(&check_limits_read_buffer_size),
1305
N_("Each thread that does a sequential scan allocates a buffer of this "
1260
_("Each thread that does a sequential scan allocates a buffer of this "
1306
1261
"size for each table it scans. If you do many sequential scans, you may "
1307
1262
"want to increase this value."))
1308
1263
("read-buffer-threshold",
1309
1264
po::value<uint64_t>()->default_value(0),
1310
N_("A global cap on the size of read-buffer-size (0 means unlimited)"))
1265
_("A global cap on the size of read-buffer-size (0 means unlimited)"))
1311
1266
("read-rnd-buffer-size",
1312
1267
po::value<uint32_t>(&global_system_variables.read_rnd_buff_size)->default_value(256*1024L)->notifier(&check_limits_read_rnd_buffer_size),
1313
N_("When reading rows in sorted order after a sort, the rows are read "
1268
_("When reading rows in sorted order after a sort, the rows are read "
1314
1269
"through this buffer to avoid a disk seeks. If not set, then it's set "
1315
1270
"to the value of record_buffer."))
1316
1271
("read-rnd-threshold",
1317
1272
po::value<uint64_t>()->default_value(0),
1318
N_("A global cap on the size of read-rnd-buffer-size (0 means unlimited)"))
1273
_("A global cap on the size of read-rnd-buffer-size (0 means unlimited)"))
1319
1274
("scheduler", po::value<string>(),
1320
N_("Select scheduler to be used (by default multi-thread)."))
1275
_("Select scheduler to be used (by default multi-thread)."))
1321
1276
("sort-buffer-size",
1322
1277
po::value<size_t>(&global_system_variables.sortbuff_size)->default_value(MAX_SORT_MEMORY)->notifier(&check_limits_sort_buffer_size),
1323
N_("Each thread that needs to do a sort allocates a buffer of this size."))
1278
_("Each thread that needs to do a sort allocates a buffer of this size."))
1324
1279
("sort-heap-threshold",
1325
1280
po::value<uint64_t>()->default_value(0),
1326
N_("A global cap on the amount of memory that can be allocated by session sort buffers (0 means unlimited)"))
1281
_("A global cap on the amount of memory that can be allocated by session sort buffers (0 means unlimited)"))
1327
1282
("table-definition-cache", po::value<size_t>(&table_def_size)->default_value(128)->notifier(&check_limits_tdc),
1328
N_("The number of cached table definitions."))
1283
_("The number of cached table definitions."))
1329
1284
("table-open-cache", po::value<uint64_t>(&table_cache_size)->default_value(TABLE_OPEN_CACHE_DEFAULT)->notifier(&check_limits_toc),
1330
N_("The number of cached open tables."))
1285
_("The number of cached open tables."))
1331
1286
("table-lock-wait-timeout", po::value<uint64_t>(&table_lock_wait_timeout)->default_value(50)->notifier(&check_limits_tlwt),
1332
N_("Timeout in seconds to wait for a table level lock before returning an "
1287
_("Timeout in seconds to wait for a table level lock before returning an "
1333
1288
"error. Used only if the connection has active cursors."))
1334
1289
("thread-stack", po::value<size_t>(&my_thread_stack_size)->default_value(DEFAULT_THREAD_STACK)->notifier(&check_limits_thread_stack),
1335
N_("The stack size for each thread."))
1290
_("The stack size for each thread."))
1337
1292
po::value<uint64_t>(&global_system_variables.tmp_table_size)->default_value(16*1024*1024L)->notifier(&check_limits_tmp_table_size),
1338
N_("If an internal in-memory temporary table exceeds this size, Drizzle will"
1293
_("If an internal in-memory temporary table exceeds this size, Drizzle will"
1339
1294
" automatically convert it to an on-disk MyISAM table."))
1295
("verbose", po::value<std::string>()->default_value(error::verbose_string())->notifier(&error::check_verbosity),
1296
_("The verbosity of messages from drizzled. Possible values are INSPECT, INFO, WARN or ERROR"))
1342
1299
full_options.add(long_options);