939
1280
if (!session || MyFlags & ME_NOREFRESH)
940
errmsg_printf(ERRMSG_LVL_ERROR, "%s: %s",internal::my_progname,str);
1281
errmsg_printf(ERRMSG_LVL_ERROR, "%s: %s",my_progname,str); /* purecov: inspected */
944
1286
static const char *load_default_groups[]= {
945
DRIZZLE_CONFIG_NAME, "server", 0, 0};
947
static int show_starttime(drizzle_show_var *var, char *buff)
949
var->type= SHOW_LONG;
951
*((long *)buff)= (long) (time(NULL) - server_start_time);
955
static int show_flushstatustime(drizzle_show_var *var, char *buff)
957
var->type= SHOW_LONG;
959
*((long *)buff)= (long) (time(NULL) - flush_status_time);
963
static st_show_var_func_container show_starttime_cont= { &show_starttime };
965
static st_show_var_func_container show_flushstatustime_cont= { &show_flushstatustime };
968
Variables shown by SHOW STATUS in alphabetical order
970
static drizzle_show_var com_status_vars[]= {
971
{"admin_commands", (char*) offsetof(system_status_var, com_other), SHOW_LONG_STATUS},
972
{"alter_db", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_ALTER_DB]), SHOW_LONG_STATUS},
973
{"alter_table", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_ALTER_TABLE]), SHOW_LONG_STATUS},
974
{"analyze", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_ANALYZE]), SHOW_LONG_STATUS},
975
{"begin", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_BEGIN]), SHOW_LONG_STATUS},
976
{"change_db", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_CHANGE_DB]), SHOW_LONG_STATUS},
977
{"check", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_CHECK]), SHOW_LONG_STATUS},
978
{"checksum", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_CHECKSUM]), SHOW_LONG_STATUS},
979
{"commit", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_COMMIT]), SHOW_LONG_STATUS},
980
{"create_db", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_CREATE_DB]), SHOW_LONG_STATUS},
981
{"create_index", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_CREATE_INDEX]), SHOW_LONG_STATUS},
982
{"create_table", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_CREATE_TABLE]), SHOW_LONG_STATUS},
983
{"delete", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_DELETE]), SHOW_LONG_STATUS},
984
{"drop_db", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_DROP_DB]), SHOW_LONG_STATUS},
985
{"drop_index", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_DROP_INDEX]), SHOW_LONG_STATUS},
986
{"drop_table", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_DROP_TABLE]), SHOW_LONG_STATUS},
987
{"empty_query", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_EMPTY_QUERY]), SHOW_LONG_STATUS},
988
{"flush", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_FLUSH]), SHOW_LONG_STATUS},
989
{"insert", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_INSERT]), SHOW_LONG_STATUS},
990
{"insert_select", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_INSERT_SELECT]), SHOW_LONG_STATUS},
991
{"kill", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_KILL]), SHOW_LONG_STATUS},
992
{"load", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_LOAD]), SHOW_LONG_STATUS},
993
{"release_savepoint", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_RELEASE_SAVEPOINT]), SHOW_LONG_STATUS},
994
{"rename_table", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_RENAME_TABLE]), SHOW_LONG_STATUS},
995
{"replace", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_REPLACE]), SHOW_LONG_STATUS},
996
{"replace_select", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_REPLACE_SELECT]), SHOW_LONG_STATUS},
997
{"rollback", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_ROLLBACK]), SHOW_LONG_STATUS},
998
{"rollback_to_savepoint",(char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_ROLLBACK_TO_SAVEPOINT]), SHOW_LONG_STATUS},
999
{"savepoint", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_SAVEPOINT]), SHOW_LONG_STATUS},
1000
{"select", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_SELECT]), SHOW_LONG_STATUS},
1001
{"set_option", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_SET_OPTION]), SHOW_LONG_STATUS},
1002
{"show_create_db", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_SHOW_CREATE_DB]), SHOW_LONG_STATUS},
1003
{"show_create_table", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_SHOW_CREATE]), SHOW_LONG_STATUS},
1004
{"show_errors", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_SHOW_ERRORS]), SHOW_LONG_STATUS},
1005
{"show_warnings", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_SHOW_WARNS]), SHOW_LONG_STATUS},
1006
{"truncate", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_TRUNCATE]), SHOW_LONG_STATUS},
1007
{"unlock_tables", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_UNLOCK_TABLES]), SHOW_LONG_STATUS},
1008
{"update", (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_UPDATE]), SHOW_LONG_STATUS},
1009
{NULL, NULL, SHOW_LONGLONG}
1012
static drizzle_show_var status_vars[]= {
1013
{"Aborted_clients", (char*) &aborted_threads, SHOW_LONGLONG},
1014
{"Aborted_connects", (char*) &aborted_connects, SHOW_LONGLONG},
1015
{"Bytes_received", (char*) offsetof(system_status_var, bytes_received), SHOW_LONGLONG_STATUS},
1016
{"Bytes_sent", (char*) offsetof(system_status_var, bytes_sent), SHOW_LONGLONG_STATUS},
1017
{"Connections", (char*) &global_thread_id, SHOW_INT_NOFLUSH},
1018
{"Created_tmp_disk_tables", (char*) offsetof(system_status_var, created_tmp_disk_tables), SHOW_LONG_STATUS},
1019
{"Created_tmp_tables", (char*) offsetof(system_status_var, created_tmp_tables), SHOW_LONG_STATUS},
1020
{"Flush_commands", (char*) &refresh_version, SHOW_INT_NOFLUSH},
1021
{"Handler_commit", (char*) offsetof(system_status_var, ha_commit_count), SHOW_LONG_STATUS},
1022
{"Handler_delete", (char*) offsetof(system_status_var, ha_delete_count), SHOW_LONG_STATUS},
1023
{"Handler_prepare", (char*) offsetof(system_status_var, ha_prepare_count), SHOW_LONG_STATUS},
1024
{"Handler_read_first", (char*) offsetof(system_status_var, ha_read_first_count), SHOW_LONG_STATUS},
1025
{"Handler_read_key", (char*) offsetof(system_status_var, ha_read_key_count), SHOW_LONG_STATUS},
1026
{"Handler_read_next", (char*) offsetof(system_status_var, ha_read_next_count), SHOW_LONG_STATUS},
1027
{"Handler_read_prev", (char*) offsetof(system_status_var, ha_read_prev_count), SHOW_LONG_STATUS},
1028
{"Handler_read_rnd", (char*) offsetof(system_status_var, ha_read_rnd_count), SHOW_LONG_STATUS},
1029
{"Handler_read_rnd_next", (char*) offsetof(system_status_var, ha_read_rnd_next_count), SHOW_LONG_STATUS},
1030
{"Handler_rollback", (char*) offsetof(system_status_var, ha_rollback_count), SHOW_LONG_STATUS},
1031
{"Handler_savepoint", (char*) offsetof(system_status_var, ha_savepoint_count), SHOW_LONG_STATUS},
1032
{"Handler_savepoint_rollback",(char*) offsetof(system_status_var, ha_savepoint_rollback_count), SHOW_LONG_STATUS},
1033
{"Handler_update", (char*) offsetof(system_status_var, ha_update_count), SHOW_LONG_STATUS},
1034
{"Handler_write", (char*) offsetof(system_status_var, ha_write_count), SHOW_LONG_STATUS},
1035
{"Key_blocks_not_flushed", (char*) offsetof(KEY_CACHE, global_blocks_changed), SHOW_KEY_CACHE_LONG},
1036
{"Key_blocks_unused", (char*) offsetof(KEY_CACHE, blocks_unused), SHOW_KEY_CACHE_LONG},
1037
{"Key_blocks_used", (char*) offsetof(KEY_CACHE, blocks_used), SHOW_KEY_CACHE_LONG},
1038
{"Key_read_requests", (char*) offsetof(KEY_CACHE, global_cache_r_requests), SHOW_KEY_CACHE_LONGLONG},
1039
{"Key_reads", (char*) offsetof(KEY_CACHE, global_cache_read), SHOW_KEY_CACHE_LONGLONG},
1040
{"Key_write_requests", (char*) offsetof(KEY_CACHE, global_cache_w_requests), SHOW_KEY_CACHE_LONGLONG},
1041
{"Key_writes", (char*) offsetof(KEY_CACHE, global_cache_write), SHOW_KEY_CACHE_LONGLONG},
1042
{"Last_query_cost", (char*) offsetof(system_status_var, last_query_cost), SHOW_DOUBLE_STATUS},
1043
{"Max_used_connections", (char*) &max_used_connections, SHOW_INT},
1044
{"Questions", (char*) offsetof(system_status_var, questions), SHOW_LONG_STATUS},
1045
{"Select_full_join", (char*) offsetof(system_status_var, select_full_join_count), SHOW_LONG_STATUS},
1046
{"Select_full_range_join", (char*) offsetof(system_status_var, select_full_range_join_count), SHOW_LONG_STATUS},
1047
{"Select_range", (char*) offsetof(system_status_var, select_range_count), SHOW_LONG_STATUS},
1048
{"Select_range_check", (char*) offsetof(system_status_var, select_range_check_count), SHOW_LONG_STATUS},
1049
{"Select_scan", (char*) offsetof(system_status_var, select_scan_count), SHOW_LONG_STATUS},
1050
{"Slow_queries", (char*) offsetof(system_status_var, long_query_count), SHOW_LONG_STATUS},
1051
{"Sort_merge_passes", (char*) offsetof(system_status_var, filesort_merge_passes), SHOW_LONG_STATUS},
1052
{"Sort_range", (char*) offsetof(system_status_var, filesort_range_count), SHOW_LONG_STATUS},
1053
{"Sort_rows", (char*) offsetof(system_status_var, filesort_rows), SHOW_LONG_STATUS},
1054
{"Sort_scan", (char*) offsetof(system_status_var, filesort_scan_count), SHOW_LONG_STATUS},
1055
{"Table_locks_immediate", (char*) &locks_immediate, SHOW_INT},
1056
{"Table_locks_waited", (char*) &locks_waited, SHOW_INT},
1057
{"Threads_connected", (char*) &connection_count, SHOW_INT},
1058
{"Uptime", (char*) &show_starttime_cont, SHOW_FUNC},
1059
{"Uptime_since_flush_status",(char*) &show_flushstatustime_cont, SHOW_FUNC},
1287
DRIZZLE_CONFIG_NAME,"server", DRIZZLE_BASE_VERSION, 0, 0};
1289
SHOW_VAR com_status_vars[]= {
1290
{"admin_commands", (char*) offsetof(STATUS_VAR, com_other), SHOW_LONG_STATUS},
1291
{"assign_to_keycache", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_ASSIGN_TO_KEYCACHE]), SHOW_LONG_STATUS},
1292
{"alter_db", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_ALTER_DB]), SHOW_LONG_STATUS},
1293
{"alter_table", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_ALTER_TABLE]), SHOW_LONG_STATUS},
1294
{"analyze", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_ANALYZE]), SHOW_LONG_STATUS},
1295
{"begin", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_BEGIN]), SHOW_LONG_STATUS},
1296
{"change_db", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_CHANGE_DB]), SHOW_LONG_STATUS},
1297
{"check", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_CHECK]), SHOW_LONG_STATUS},
1298
{"checksum", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_CHECKSUM]), SHOW_LONG_STATUS},
1299
{"commit", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_COMMIT]), SHOW_LONG_STATUS},
1300
{"create_db", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_CREATE_DB]), SHOW_LONG_STATUS},
1301
{"create_index", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_CREATE_INDEX]), SHOW_LONG_STATUS},
1302
{"create_table", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_CREATE_TABLE]), SHOW_LONG_STATUS},
1303
{"delete", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_DELETE]), SHOW_LONG_STATUS},
1304
{"delete_multi", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_DELETE_MULTI]), SHOW_LONG_STATUS},
1305
{"drop_db", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_DROP_DB]), SHOW_LONG_STATUS},
1306
{"drop_index", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_DROP_INDEX]), SHOW_LONG_STATUS},
1307
{"drop_table", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_DROP_TABLE]), SHOW_LONG_STATUS},
1308
{"empty_query", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_EMPTY_QUERY]), SHOW_LONG_STATUS},
1309
{"flush", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_FLUSH]), SHOW_LONG_STATUS},
1310
{"insert", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_INSERT]), SHOW_LONG_STATUS},
1311
{"insert_select", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_INSERT_SELECT]), SHOW_LONG_STATUS},
1312
{"kill", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_KILL]), SHOW_LONG_STATUS},
1313
{"load", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_LOAD]), SHOW_LONG_STATUS},
1314
{"lock_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_LOCK_TABLES]), SHOW_LONG_STATUS},
1315
{"optimize", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_OPTIMIZE]), SHOW_LONG_STATUS},
1316
{"release_savepoint", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_RELEASE_SAVEPOINT]), SHOW_LONG_STATUS},
1317
{"rename_table", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_RENAME_TABLE]), SHOW_LONG_STATUS},
1318
{"repair", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_REPAIR]), SHOW_LONG_STATUS},
1319
{"replace", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_REPLACE]), SHOW_LONG_STATUS},
1320
{"replace_select", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_REPLACE_SELECT]), SHOW_LONG_STATUS},
1321
{"rollback", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_ROLLBACK]), SHOW_LONG_STATUS},
1322
{"rollback_to_savepoint",(char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_ROLLBACK_TO_SAVEPOINT]), SHOW_LONG_STATUS},
1323
{"savepoint", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SAVEPOINT]), SHOW_LONG_STATUS},
1324
{"select", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SELECT]), SHOW_LONG_STATUS},
1325
{"set_option", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SET_OPTION]), SHOW_LONG_STATUS},
1326
{"show_create_db", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_CREATE_DB]), SHOW_LONG_STATUS},
1327
{"show_create_table", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_CREATE]), SHOW_LONG_STATUS},
1328
{"show_databases", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_DATABASES]), SHOW_LONG_STATUS},
1329
{"show_engine_status", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_ENGINE_STATUS]), SHOW_LONG_STATUS},
1330
{"show_errors", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_ERRORS]), SHOW_LONG_STATUS},
1331
{"show_fields", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_FIELDS]), SHOW_LONG_STATUS},
1332
{"show_keys", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_KEYS]), SHOW_LONG_STATUS},
1333
{"show_open_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_OPEN_TABLES]), SHOW_LONG_STATUS},
1334
{"show_plugins", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_PLUGINS]), SHOW_LONG_STATUS},
1335
{"show_processlist", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_PROCESSLIST]), SHOW_LONG_STATUS},
1336
{"show_status", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_STATUS]), SHOW_LONG_STATUS},
1337
{"show_table_status", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_TABLE_STATUS]), SHOW_LONG_STATUS},
1338
{"show_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_TABLES]), SHOW_LONG_STATUS},
1339
{"show_variables", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_VARIABLES]), SHOW_LONG_STATUS},
1340
{"show_warnings", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_WARNS]), SHOW_LONG_STATUS},
1341
{"truncate", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_TRUNCATE]), SHOW_LONG_STATUS},
1342
{"unlock_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_UNLOCK_TABLES]), SHOW_LONG_STATUS},
1343
{"update", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_UPDATE]), SHOW_LONG_STATUS},
1344
{"update_multi", (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_UPDATE_MULTI]), SHOW_LONG_STATUS},
1060
1345
{NULL, NULL, SHOW_LONGLONG}
1270
1581
fprintf(stderr,
1271
1582
_("%s: Too many arguments (first extra is '%s').\n"
1272
1583
"Use --verbose --help to get a list of available options\n"),
1273
internal::my_progname, *tmp_argv);
1584
my_progname, *tmp_argv);
1274
1585
unireg_abort(1);
1278
string scheduler_name;
1281
scheduler_name= opt_scheduler;
1285
scheduler_name= opt_scheduler_default;
1288
if (plugin::Scheduler::setPlugin(scheduler_name))
1290
errmsg_printf(ERRMSG_LVL_ERROR,
1291
_("No scheduler found, cannot continue!\n"));
1589
/* We have to initialize the storage engines before CSV logging */
1592
errmsg_printf(ERRMSG_LVL_ERROR, _("Can't init databases"));
1296
1597
This is entirely for legacy. We will create a new "disk based" engine and a
1297
"memory" engine which will be configurable longterm.
1598
"memory" engine which will be configurable longterm. We should be able to
1599
remove partition and myisammrg.
1299
const std::string myisam_engine_name("MyISAM");
1300
const std::string heap_engine_name("MEMORY");
1301
myisam_engine= plugin::StorageEngine::findByName(myisam_engine_name);
1302
heap_engine= plugin::StorageEngine::findByName(heap_engine_name);
1601
const LEX_STRING myisam_engine_name= { C_STRING_WITH_LEN("MyISAM") };
1602
const LEX_STRING heap_engine_name= { C_STRING_WITH_LEN("MEMORY") };
1603
myisam_engine= ha_resolve_by_name(NULL, &myisam_engine_name);
1604
heap_engine= ha_resolve_by_name(NULL, &heap_engine_name);
1305
1607
Check that the default storage engine is actually available.
1307
1609
if (default_storage_engine_str)
1309
const std::string name(default_storage_engine_str);
1310
plugin::StorageEngine *engine;
1611
LEX_STRING name= { default_storage_engine_str,
1612
strlen(default_storage_engine_str) };
1613
StorageEngine *engine;
1312
engine= plugin::StorageEngine::findByName(name);
1315
errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown/unsupported storage engine: %s"),
1316
default_storage_engine_str);
1319
global_system_variables.storage_engine= engine;
1615
if (!(engine= ha_resolve_by_name(0, &name)))
1617
errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown/unsupported table type: %s"),
1618
default_storage_engine_str);
1621
if (!engine->is_enabled())
1623
errmsg_printf(ERRMSG_LVL_ERROR, _("Default storage engine (%s) is not available"),
1624
default_storage_engine_str);
1626
//assert(global_system_variables.storage_engine);
1631
Need to unlock as global_system_variables.storage_engine
1632
was acquired during plugin_init()
1634
global_system_variables.storage_engine= engine;
1322
if (plugin::XaResourceManager::recoverAllXids(0))
1324
1640
unireg_abort(1);
1643
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT)
1644
if (locked_in_memory && !getuid())
1646
if (setreuid((uid_t)-1, 0) == -1)
1647
{ // this should never happen
1648
sql_perror("setreuid");
1651
if (mlockall(MCL_CURRENT))
1653
if (global_system_variables.log_warnings)
1654
errmsg_printf(ERRMSG_LVL_WARN, _("Failed to lock memory. Errno: %d\n"),errno);
1655
locked_in_memory= 0;
1658
set_user(drizzled_user, user_info);
1327
1664
init_update_queries();
1669
int main(int argc, char **argv)
1671
#if defined(ENABLE_NLS)
1672
# if defined(HAVE_LOCALE_H)
1673
setlocale(LC_ALL, "");
1675
bindtextdomain("drizzle", LOCALEDIR);
1676
textdomain("drizzle");
1679
MY_INIT(argv[0]); // init my_sys library & pthreads
1680
/* nothing should come before this line ^^^ */
1682
/* Set signal used to kill Drizzle */
1683
#if defined(SIGUSR2)
1684
thr_kill_signal= thd_lib_detected == THD_LIB_LT ? SIGINT : SIGUSR2;
1686
thr_kill_signal= SIGINT;
1689
#ifdef _CUSTOMSTARTUPCONFIG_
1690
if (_cust_check_startup())
1692
/ * _cust_check_startup will report startup failure error * /
1697
if (init_common_variables(DRIZZLE_CONFIG_NAME,
1698
argc, argv, load_default_groups))
1699
unireg_abort(1); // Will do exit
1703
#ifdef TODO_MOVE_OUT_TO_SCHEDULER_API
1704
pthread_attr_setstacksize(&connection_attrib, my_thread_stack_size);
1706
#ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE
1708
/* Retrieve used stack size; Needed for checking stack overflows */
1709
size_t stack_size= 0;
1710
pthread_attr_getstacksize(&connection_attrib, &stack_size);
1711
/* We must check if stack_size = 0 as Solaris 2.9 can return 0 here */
1712
if (stack_size && stack_size < my_thread_stack_size)
1714
if (global_system_variables.log_warnings)
1716
errmsg_printf(ERRMSG_LVL_WARN, _("Asked for %"PRIu64" thread stack, "
1718
(uint64_t)my_thread_stack_size,
1719
(uint64_t)stack_size);
1721
my_thread_stack_size= stack_size;
1727
select_thread=pthread_self();
1728
select_thread_in_use=1;
1731
We have enough space for fiddling with the argv, continue
1733
check_data_home(drizzle_real_data_home);
1734
if (chdir(drizzle_real_data_home) && !opt_help)
1735
unireg_abort(1); /* purecov: inspected */
1736
drizzle_data_home= drizzle_data_home_buff;
1737
drizzle_data_home[0]=FN_CURLIB; // all paths are relative from here
1738
drizzle_data_home[1]=0;
1739
drizzle_data_home_len= 2;
1741
if ((user_info= check_user(drizzled_user)))
1743
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT)
1744
if (locked_in_memory) // getuid() == 0 here
1745
set_effective_user(user_info);
1748
set_user(drizzled_user, user_info);
1756
if (init_server_components())
1762
init signals & alarm
1763
After this we can't quit by a simple unireg_abort
1765
error_handler_hook= my_message_sql;
1767
if (drizzle_rm_tmp_tables() || my_tz_init((Session *)0, default_tz_name))
1770
select_thread_in_use=0;
1771
(void) pthread_kill(signal_thread, SIGTERM);
1773
(void) unlink(pidfile_name); // Not needed anymore
1780
errmsg_printf(ERRMSG_LVL_INFO, _(ER(ER_STARTUP)),my_progname,server_version,
1781
"", drizzled_port, COMPILATION_COMMENT);
1784
handle_connections_sockets();
1785
/* (void) pthread_attr_destroy(&connection_attrib); */
1788
(void) pthread_mutex_lock(&LOCK_thread_count);
1789
select_thread_in_use=0; // For close_connections
1790
(void) pthread_mutex_unlock(&LOCK_thread_count);
1791
(void) pthread_cond_broadcast(&COND_thread_count);
1793
/* Wait until cleanup is done */
1794
(void) pthread_mutex_lock(&LOCK_thread_count);
1795
while (!ready_to_exit)
1796
pthread_cond_wait(&COND_server_end,&LOCK_thread_count);
1797
(void) pthread_mutex_unlock(&LOCK_thread_count);
1801
my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
1807
Create new thread to handle incoming connection.
1809
This function will create new thread to handle the incoming
1810
connection. If there are idle cached threads one will be used.
1811
'session' will be pushed into 'threads'.
1813
In single-threaded mode (\#define ONE_THREAD) connection will be
1814
handled inside this function.
1816
@param[in,out] session Thread handle of future thread.
1819
static void create_new_thread(Session *session)
1821
Scheduler &thread_scheduler= get_thread_scheduler();
1825
if (connection_count > max_used_connections)
1826
max_used_connections= connection_count;
1829
The initialization of thread_id is done in create_embedded_session() for
1830
the embedded library.
1831
TODO: refactor this to avoid code duplication there
1833
session->thread_id= session->variables.pseudo_thread_id= thread_id++;
1836
If we error on creation we drop the connection and delete the session.
1838
pthread_mutex_lock(&LOCK_thread_count);
1839
session_list.append(session);
1840
pthread_mutex_unlock(&LOCK_thread_count);
1841
if (thread_scheduler.add_connection(session))
1843
char error_message_buff[DRIZZLE_ERRMSG_SIZE];
1845
session->killed= Session::KILL_CONNECTION; // Safety
1847
statistic_increment(aborted_connects, &LOCK_status);
1849
/* Can't use my_error() since store_globals has not been called. */
1850
snprintf(error_message_buff, sizeof(error_message_buff), ER(ER_CANT_CREATE_THREAD), 1); /* TODO replace will better error message */
1851
session->protocol->sendError(ER_CANT_CREATE_THREAD, error_message_buff);
1852
unlink_session(session);
1857
/* Handle new connections and spawn new process to handle them */
1859
void handle_connections_sockets()
1863
uint32_t error_count=0;
1865
struct sockaddr_storage cAddr;
1872
if ((number_of= poll(fds, pollfd_count, -1)) == -1)
1876
if (!select_errors++ && !abort_loop) /* purecov: inspected */
1877
errmsg_printf(ERRMSG_LVL_ERROR, _("drizzled: Got error %d from select"),
1878
errno); /* purecov: inspected */
1885
#ifdef FIXME_IF_WE_WERE_KEEPING_THIS
1886
assert(number_of > 1); /* Not handling this at the moment */
1894
for (x= 0, sock= -1; x < pollfd_count; x++)
1896
if (fds[x].revents == POLLIN)
1904
for (uint32_t retry=0; retry < MAX_ACCEPT_RETRY; retry++)
1906
socklen_t length= sizeof(struct sockaddr_storage);
1907
new_sock= accept(sock, (struct sockaddr *)(&cAddr),
1909
if (new_sock != -1 || (errno != EINTR && errno != EAGAIN))
1916
if ((error_count++ & 255) == 0) // This can happen often
1917
sql_perror("Error in accept");
1918
if (errno == ENFILE || errno == EMFILE)
1919
sleep(1); // Give other threads some time
1925
struct sockaddr_storage dummy;
1926
dummyLen = sizeof(dummy);
1927
if ( getsockname(new_sock,(struct sockaddr *)&dummy,
1928
(socklen_t *)&dummyLen) < 0 )
1930
sql_perror("Error on new connection socket");
1931
(void) shutdown(new_sock, SHUT_RDWR);
1932
(void) close(new_sock);
1935
dummyLen = sizeof(dummy);
1936
if ( getpeername(new_sock, (struct sockaddr *)&dummy,
1937
(socklen_t *)&dummyLen) < 0)
1939
sql_perror("Error on new connection socket");
1940
(void) shutdown(new_sock, SHUT_RDWR);
1941
(void) close(new_sock);
1947
** Don't allow too many connections
1950
if (!(protocol= get_protocol()))
1952
(void) shutdown(new_sock, SHUT_RDWR);
1957
if (!(session= new Session(protocol)))
1960
(void) shutdown(new_sock, SHUT_RDWR);
1965
if (protocol->setFileDescriptor(new_sock))
1971
create_new_thread(session);
1333
1976
/****************************************************************************
1334
1977
Handle start options
1335
1978
******************************************************************************/
1337
1980
enum options_drizzled
1984
OPT_BIND_ADDRESS, OPT_PID_FILE,
1342
1985
OPT_STORAGE_ENGINE,
1987
OPT_DELAY_KEY_WRITE_ALL,
1988
OPT_DELAY_KEY_WRITE,
1347
1993
OPT_TC_HEURISTIC_RECOVER,
1994
OPT_ENGINE_CONDITION_PUSHDOWN,
1348
1995
OPT_TEMP_POOL, OPT_TX_ISOLATION, OPT_COMPLETION_TYPE,
1349
1996
OPT_SKIP_STACK_TRACE, OPT_SKIP_SYMLINKS,
1351
1998
OPT_LOCAL_INFILE,
2000
OPT_CONNECT_TIMEOUT,
1353
2001
OPT_JOIN_BUFF_SIZE,
1354
2002
OPT_KEY_BUFFER_SIZE, OPT_KEY_CACHE_BLOCK_SIZE,
1355
2003
OPT_KEY_CACHE_DIVISION_LIMIT, OPT_KEY_CACHE_AGE_THRESHOLD,
1474
2147
(char**) &lc_time_names_name,
1475
2148
(char**) &lc_time_names_name,
1476
2149
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
2151
N_("Log connections and queries to file."),
2152
(char**) &opt_logname,
2153
(char**) &opt_logname, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
2154
{"log-isam", OPT_ISAM_LOG,
2155
N_("Log all MyISAM changes to file."),
2156
(char**) &myisam_log_filename, (char**) &myisam_log_filename, 0, GET_STR,
2157
OPT_ARG, 0, 0, 0, 0, 0, 0},
1477
2158
{"log-warnings", 'W',
1478
2159
N_("Log some not critical warnings to the log file."),
1479
2160
(char**) &global_system_variables.log_warnings,
1480
2161
(char**) &max_system_variables.log_warnings, 0, GET_BOOL, OPT_ARG, 1, 0, 0,
2163
{"memlock", OPT_MEMLOCK,
2164
N_("Lock drizzled in memory."),
2165
(char**) &locked_in_memory,
2166
(char**) &locked_in_memory, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
2167
{"myisam-recover", OPT_MYISAM_RECOVER,
2168
N_("Syntax: myisam-recover[=option[,option...]], where option can be "
2169
"DEFAULT, BACKUP, FORCE or QUICK."),
2170
(char**) &myisam_recover_options_str, (char**) &myisam_recover_options_str, 0,
2171
GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
2172
{"old-alter-table", OPT_OLD_ALTER_TABLE,
2173
N_("Use old, non-optimized alter table."),
2174
(char**) &global_system_variables.old_alter_table,
2175
(char**) &max_system_variables.old_alter_table, 0, GET_BOOL, NO_ARG,
1482
2177
{"pid-file", OPT_PID_FILE,
1483
2178
N_("Pid file used by safe_mysqld."),
1484
2179
(char**) &pidfile_name_ptr, (char**) &pidfile_name_ptr, 0, GET_STR,
1485
2180
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
2182
N_("Port number to use for connection or 0 for default to, in "
2183
"order of preference, drizzle.cnf, $DRIZZLE_TCP_PORT, "
2184
"built-in default (" STRINGIFY_ARG(DRIZZLE_PORT) ")."),
2185
(char**) &drizzled_port,
2186
(char**) &drizzled_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1486
2187
{"port-open-timeout", OPT_PORT_OPEN_TIMEOUT,
1487
2188
N_("Maximum time in seconds to wait for the port to become free. "
1488
2189
"(Default: no wait)"),
1489
(char**) &drizzled_bind_timeout,
1490
(char**) &drizzled_bind_timeout, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
2190
(char**) &drizzled_port_timeout,
2191
(char**) &drizzled_port_timeout, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1491
2192
{"secure-file-priv", OPT_SECURE_FILE_PRIV,
1492
2193
N_("Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "
1493
2194
"within specified directory"),
1724
2496
(char**) &my_thread_stack_size,
1725
2497
(char**) &my_thread_stack_size, 0, GET_SIZE,
1726
2498
REQUIRED_ARG,DEFAULT_THREAD_STACK,
1727
UINT32_C(1024*512), SIZE_MAX, 0, 1024, 0},
2499
UINT32_C(1024*128), SIZE_MAX, 0, 1024, 0},
1728
2500
{"tmp_table_size", OPT_TMP_TABLE_SIZE,
1729
2501
N_("If an internal in-memory temporary table exceeds this size, Drizzle will"
1730
2502
" automatically convert it to an on-disk MyISAM table."),
1731
2503
(char**) &global_system_variables.tmp_table_size,
1732
2504
(char**) &max_system_variables.tmp_table_size, 0, GET_ULL,
1733
2505
REQUIRED_ARG, 16*1024*1024L, 1024, MAX_MEM_TABLE_SIZE, 0, 1, 0},
2506
{"transaction_alloc_block_size", OPT_TRANS_ALLOC_BLOCK_SIZE,
2507
N_("Allocation block size for transactions to be stored in binary log"),
2508
(char**) &global_system_variables.trans_alloc_block_size,
2509
(char**) &max_system_variables.trans_alloc_block_size, 0, GET_UINT,
2510
REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ULONG_MAX, 0, 1024, 0},
2511
{"transaction_prealloc_size", OPT_TRANS_PREALLOC_SIZE,
2512
N_("Persistent buffer for transactions to be stored in binary log"),
2513
(char**) &global_system_variables.trans_prealloc_size,
2514
(char**) &max_system_variables.trans_prealloc_size, 0, GET_UINT,
2515
REQUIRED_ARG, TRANS_ALLOC_PREALLOC_SIZE, 1024, ULONG_MAX, 0, 1024, 0},
2516
{"wait_timeout", OPT_WAIT_TIMEOUT,
2517
N_("The number of seconds the server waits for activity on a connection "
2518
"before closing it."),
2519
(char**) &global_system_variables.net_wait_timeout,
2520
(char**) &max_system_variables.net_wait_timeout, 0, GET_UINT,
2521
REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, LONG_TIMEOUT,
1734
2523
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
2526
static int show_net_compression(Session *session,
2530
var->type= SHOW_MY_BOOL;
2531
var->value= (char *)&session->compression;
2535
static st_show_var_func_container
2536
show_net_compression_cont= { &show_net_compression };
2538
static int show_starttime(Session *session, SHOW_VAR *var, char *buff)
2540
var->type= SHOW_LONG;
2542
*((long *)buff)= (long) (session->query_start() - server_start_time);
2546
static st_show_var_func_container
2547
show_starttime_cont= { &show_starttime };
2549
static int show_flushstatustime(Session *session, SHOW_VAR *var, char *buff)
2551
var->type= SHOW_LONG;
2553
*((long *)buff)= (long) (session->query_start() - flush_status_time);
2557
static st_show_var_func_container
2558
show_flushstatustime_cont= { &show_flushstatustime };
2560
static int show_open_tables(Session *, SHOW_VAR *var, char *buff)
2562
var->type= SHOW_LONG;
2564
*((long *)buff)= (long)cached_open_tables();
2568
static int show_table_definitions(Session *,
2569
SHOW_VAR *var, char *buff)
2571
var->type= SHOW_LONG;
2573
*((long *)buff)= (long)cached_table_definitions();
2577
static st_show_var_func_container
2578
show_open_tables_cont= { &show_open_tables };
2579
static st_show_var_func_container
2580
show_table_definitions_cont= { &show_table_definitions };
2583
Variables shown by SHOW STATUS in alphabetical order
2586
SHOW_VAR status_vars[]= {
2587
{"Aborted_clients", (char*) &aborted_threads, SHOW_LONGLONG},
2588
{"Aborted_connects", (char*) &aborted_connects, SHOW_LONGLONG},
2589
{"Bytes_received", (char*) offsetof(STATUS_VAR, bytes_received), SHOW_LONGLONG_STATUS},
2590
{"Bytes_sent", (char*) offsetof(STATUS_VAR, bytes_sent), SHOW_LONGLONG_STATUS},
2591
{"Com", (char*) com_status_vars, SHOW_ARRAY},
2592
{"Compression", (char*) &show_net_compression_cont, SHOW_FUNC},
2593
{"Connections", (char*) &thread_id, SHOW_INT_NOFLUSH},
2594
{"Created_tmp_disk_tables", (char*) offsetof(STATUS_VAR, created_tmp_disk_tables), SHOW_LONG_STATUS},
2595
{"Created_tmp_files", (char*) &my_tmp_file_created,SHOW_INT},
2596
{"Created_tmp_tables", (char*) offsetof(STATUS_VAR, created_tmp_tables), SHOW_LONG_STATUS},
2597
{"Flush_commands", (char*) &refresh_version, SHOW_INT_NOFLUSH},
2598
{"Handler_commit", (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS},
2599
{"Handler_delete", (char*) offsetof(STATUS_VAR, ha_delete_count), SHOW_LONG_STATUS},
2600
{"Handler_prepare", (char*) offsetof(STATUS_VAR, ha_prepare_count), SHOW_LONG_STATUS},
2601
{"Handler_read_first", (char*) offsetof(STATUS_VAR, ha_read_first_count), SHOW_LONG_STATUS},
2602
{"Handler_read_key", (char*) offsetof(STATUS_VAR, ha_read_key_count), SHOW_LONG_STATUS},
2603
{"Handler_read_next", (char*) offsetof(STATUS_VAR, ha_read_next_count), SHOW_LONG_STATUS},
2604
{"Handler_read_prev", (char*) offsetof(STATUS_VAR, ha_read_prev_count), SHOW_LONG_STATUS},
2605
{"Handler_read_rnd", (char*) offsetof(STATUS_VAR, ha_read_rnd_count), SHOW_LONG_STATUS},
2606
{"Handler_read_rnd_next", (char*) offsetof(STATUS_VAR, ha_read_rnd_next_count), SHOW_LONG_STATUS},
2607
{"Handler_rollback", (char*) offsetof(STATUS_VAR, ha_rollback_count), SHOW_LONG_STATUS},
2608
{"Handler_savepoint", (char*) offsetof(STATUS_VAR, ha_savepoint_count), SHOW_LONG_STATUS},
2609
{"Handler_savepoint_rollback",(char*) offsetof(STATUS_VAR, ha_savepoint_rollback_count), SHOW_LONG_STATUS},
2610
{"Handler_update", (char*) offsetof(STATUS_VAR, ha_update_count), SHOW_LONG_STATUS},
2611
{"Handler_write", (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONG_STATUS},
2612
{"Key_blocks_not_flushed", (char*) offsetof(KEY_CACHE, global_blocks_changed), SHOW_KEY_CACHE_LONG},
2613
{"Key_blocks_unused", (char*) offsetof(KEY_CACHE, blocks_unused), SHOW_KEY_CACHE_LONG},
2614
{"Key_blocks_used", (char*) offsetof(KEY_CACHE, blocks_used), SHOW_KEY_CACHE_LONG},
2615
{"Key_read_requests", (char*) offsetof(KEY_CACHE, global_cache_r_requests), SHOW_KEY_CACHE_LONGLONG},
2616
{"Key_reads", (char*) offsetof(KEY_CACHE, global_cache_read), SHOW_KEY_CACHE_LONGLONG},
2617
{"Key_write_requests", (char*) offsetof(KEY_CACHE, global_cache_w_requests), SHOW_KEY_CACHE_LONGLONG},
2618
{"Key_writes", (char*) offsetof(KEY_CACHE, global_cache_write), SHOW_KEY_CACHE_LONGLONG},
2619
{"Last_query_cost", (char*) offsetof(STATUS_VAR, last_query_cost), SHOW_DOUBLE_STATUS},
2620
{"Max_used_connections", (char*) &max_used_connections, SHOW_INT},
2621
{"Open_files", (char*) &my_file_opened, SHOW_INT_NOFLUSH},
2622
{"Open_streams", (char*) &my_stream_opened, SHOW_INT_NOFLUSH},
2623
{"Open_table_definitions", (char*) &show_table_definitions_cont, SHOW_FUNC},
2624
{"Open_tables", (char*) &show_open_tables_cont, SHOW_FUNC},
2625
{"Opened_files", (char*) &my_file_total_opened, SHOW_INT_NOFLUSH},
2626
{"Opened_tables", (char*) offsetof(STATUS_VAR, opened_tables), SHOW_LONG_STATUS},
2627
{"Opened_table_definitions", (char*) offsetof(STATUS_VAR, opened_shares), SHOW_LONG_STATUS},
2628
{"Questions", (char*) offsetof(STATUS_VAR, questions), SHOW_LONG_STATUS},
2629
{"Select_full_join", (char*) offsetof(STATUS_VAR, select_full_join_count), SHOW_LONG_STATUS},
2630
{"Select_full_range_join", (char*) offsetof(STATUS_VAR, select_full_range_join_count), SHOW_LONG_STATUS},
2631
{"Select_range", (char*) offsetof(STATUS_VAR, select_range_count), SHOW_LONG_STATUS},
2632
{"Select_range_check", (char*) offsetof(STATUS_VAR, select_range_check_count), SHOW_LONG_STATUS},
2633
{"Select_scan", (char*) offsetof(STATUS_VAR, select_scan_count), SHOW_LONG_STATUS},
2634
{"Slow_queries", (char*) offsetof(STATUS_VAR, long_query_count), SHOW_LONG_STATUS},
2635
{"Sort_merge_passes", (char*) offsetof(STATUS_VAR, filesort_merge_passes), SHOW_LONG_STATUS},
2636
{"Sort_range", (char*) offsetof(STATUS_VAR, filesort_range_count), SHOW_LONG_STATUS},
2637
{"Sort_rows", (char*) offsetof(STATUS_VAR, filesort_rows), SHOW_LONG_STATUS},
2638
{"Sort_scan", (char*) offsetof(STATUS_VAR, filesort_scan_count), SHOW_LONG_STATUS},
2639
{"Table_locks_immediate", (char*) &locks_immediate, SHOW_INT},
2640
{"Table_locks_waited", (char*) &locks_waited, SHOW_INT},
2641
{"Threads_connected", (char*) &connection_count, SHOW_INT},
2642
{"Uptime", (char*) &show_starttime_cont, SHOW_FUNC},
2643
{"Uptime_since_flush_status",(char*) &show_flushstatustime_cont, SHOW_FUNC},
2644
{NULL, NULL, SHOW_LONGLONG}
1737
2647
static void print_version(void)
2649
set_server_version();
1740
2651
Note: the instance manager keys off the string 'Ver' so it can find the
1741
2652
version from the output of 'drizzled --version', so don't change it!
1743
printf("%s Ver %s for %s-%s on %s (%s)\n",internal::my_progname,
1744
PANDORA_RELEASE_VERSION, HOST_VENDOR, HOST_OS, HOST_CPU,
1745
COMPILATION_COMMENT);
2654
printf("%s Ver %s for %s on %s (%s)\n",my_progname,
2655
server_version,SYSTEM_TYPE,MACHINE_TYPE, COMPILATION_COMMENT);
1748
2658
static void usage(void)
2047
static void fix_paths(string &progname)
3102
static void fix_paths(void)
2049
char buff[FN_REFLEN],*pos,rp_buff[PATH_MAX];
2050
internal::convert_dirname(drizzle_home,drizzle_home,NULL);
3104
char buff[FN_REFLEN],*pos;
3105
convert_dirname(drizzle_home,drizzle_home,NULL);
2051
3106
/* Resolve symlinks to allow 'drizzle_home' to be a relative symlink */
2052
#if defined(HAVE_BROKEN_REALPATH)
2053
internal::my_load_path(drizzle_home, drizzle_home, NULL);
2055
if (!realpath(drizzle_home,rp_buff))
2056
internal::my_load_path(rp_buff, drizzle_home, NULL);
2057
rp_buff[FN_REFLEN-1]= '\0';
2058
strcpy(drizzle_home,rp_buff);
3107
my_realpath(drizzle_home,drizzle_home,MYF(0));
2059
3108
/* Ensure that drizzle_home ends in FN_LIBCHAR */
2060
3109
pos= strchr(drizzle_home, '\0');
2062
3110
if (pos[-1] != FN_LIBCHAR)
2064
3112
pos[0]= FN_LIBCHAR;
2067
internal::convert_dirname(drizzle_real_data_home,drizzle_real_data_home,NULL);
2068
(void) internal::fn_format(buff, drizzle_real_data_home, "", "",
3115
convert_dirname(drizzle_real_data_home,drizzle_real_data_home,NULL);
3116
(void) fn_format(buff, drizzle_real_data_home, "", "",
2069
3117
(MY_RETURN_REAL_PATH|MY_RESOLVE_SYMLINKS));
2070
(void) internal::unpack_dirname(drizzle_unpacked_real_data_home, buff);
2071
internal::convert_dirname(language,language,NULL);
2072
(void) internal::my_load_path(drizzle_home, drizzle_home,""); // Resolve current dir
2073
(void) internal::my_load_path(drizzle_real_data_home, drizzle_real_data_home,drizzle_home);
2074
(void) internal::my_load_path(pidfile_name, pidfile_name,drizzle_real_data_home);
2076
if (opt_plugin_dir_ptr == NULL)
2078
/* No plugin dir has been specified. Figure out where the plugins are */
2079
if (progname[0] != FN_LIBCHAR)
2081
/* We have a relative path and need to find the absolute */
2082
char working_dir[FN_REFLEN];
2083
char *working_dir_ptr= working_dir;
2084
working_dir_ptr= getcwd(working_dir_ptr, FN_REFLEN);
2085
string new_path(working_dir);
2086
if (*(new_path.end()-1) != '/')
2087
new_path.push_back('/');
2088
if (progname[0] == '.' && progname[1] == '/')
2089
new_path.append(progname.substr(2));
2091
new_path.append(progname);
2092
progname.swap(new_path);
2095
/* Now, trim off the exe name */
2096
string progdir(progname.substr(0, progname.rfind(FN_LIBCHAR)+1));
2097
if (progdir.rfind(".libs/") != string::npos)
2099
progdir.assign(progdir.substr(0, progdir.rfind(".libs/")));
2101
string testfile(progdir);
2102
testfile.append("drizzled.o");
2103
struct stat testfile_stat;
2104
if (stat(testfile.c_str(), &testfile_stat))
2106
/* drizzled.o doesn't exist - we are not in a source dir.
2109
(void) internal::my_load_path(opt_plugin_dir, get_relative_path(PKGPLUGINDIR),
2114
/* We are in a source dir! Plugin dir is ../plugin/.libs */
2115
size_t last_libchar_pos= progdir.rfind(FN_LIBCHAR,progdir.size()-2)+1;
2116
string source_plugindir(progdir.substr(0,last_libchar_pos));
2117
source_plugindir.append("plugin/.libs");
2118
(void) internal::my_load_path(opt_plugin_dir, source_plugindir.c_str(), "");
2123
(void) internal::my_load_path(opt_plugin_dir, opt_plugin_dir_ptr, drizzle_home);
3118
(void) unpack_dirname(drizzle_unpacked_real_data_home, buff);
3119
convert_dirname(language,language,NULL);
3120
(void) my_load_path(drizzle_home, drizzle_home,""); // Resolve current dir
3121
(void) my_load_path(drizzle_real_data_home, drizzle_real_data_home,drizzle_home);
3122
(void) my_load_path(pidfile_name, pidfile_name,drizzle_real_data_home);
3123
(void) my_load_path(opt_plugin_dir, opt_plugin_dir_ptr ? opt_plugin_dir_ptr :
3124
get_relative_path(PKGPLUGINDIR),
2125
3126
opt_plugin_dir_ptr= opt_plugin_dir;
2127
3128
const char *sharedir= get_relative_path(PKGDATADIR);
2128
if (internal::test_if_hard_path(sharedir))
2129
strncpy(buff,sharedir,sizeof(buff)-1);
3129
if (test_if_hard_path(sharedir))
3130
strncpy(buff,sharedir,sizeof(buff)-1); /* purecov: tested */
2132
3133
strcpy(buff, drizzle_home);
2133
3134
strncat(buff, sharedir, sizeof(buff)-strlen(drizzle_home)-1);
2135
internal::convert_dirname(buff,buff,NULL);
2136
(void) internal::my_load_path(language,language,buff);
3136
convert_dirname(buff,buff,NULL);
3137
(void) my_load_path(language,language,buff);
2139
3140
char *tmp_string;
2173
} /* namespace drizzled */
2175
using namespace drizzled;
2178
static void init_signals(void)
2181
struct sigaction sa;
2183
if (!(test_flags.test(TEST_NO_STACKTRACE) ||
2184
test_flags.test(TEST_CORE_ON_SIGNAL)))
2186
sa.sa_flags = SA_RESETHAND | SA_NODEFER;
2187
sigemptyset(&sa.sa_mask);
2188
sigprocmask(SIG_SETMASK,&sa.sa_mask,NULL);
2191
sa.sa_handler=handle_segfault;
2192
sigaction(SIGSEGV, &sa, NULL);
2193
sigaction(SIGABRT, &sa, NULL);
2195
sigaction(SIGBUS, &sa, NULL);
2197
sigaction(SIGILL, &sa, NULL);
2198
sigaction(SIGFPE, &sa, NULL);
2201
if (test_flags.test(TEST_CORE_ON_SIGNAL))
2203
/* Change limits so that we will get a core file */
2205
rl.rlim_cur = rl.rlim_max = RLIM_INFINITY;
2206
if (setrlimit(RLIMIT_CORE, &rl) && global_system_variables.log_warnings)
2207
errmsg_printf(ERRMSG_LVL_WARN,
2208
_("setrlimit could not change the size of core files "
2209
"to 'infinity'; We may not be able to generate a "
2210
"core file on signals"));
2212
(void) sigemptyset(&set);
2213
my_sigset(SIGPIPE,SIG_IGN);
2214
sigaddset(&set,SIGPIPE);
2215
#ifndef IGNORE_SIGHUP_SIGQUIT
2216
sigaddset(&set,SIGQUIT);
2217
sigaddset(&set,SIGHUP);
2219
sigaddset(&set,SIGTERM);
2221
/* Fix signals if blocked by parents (can happen on Mac OS X) */
2222
sigemptyset(&sa.sa_mask);
2224
sa.sa_handler = print_signal_warning;
2225
sigaction(SIGTERM, &sa, (struct sigaction*) 0);
2227
sa.sa_handler = print_signal_warning;
2228
sigaction(SIGHUP, &sa, (struct sigaction*) 0);
2230
sigaddset(&set,SIGTSTP);
2232
if (test_flags.test(TEST_SIGINT))
2234
my_sigset(thr_kill_signal, end_thread_signal);
2236
sigdelset(&set, thr_kill_signal);
2239
sigaddset(&set,SIGINT);
2240
sigprocmask(SIG_SETMASK,&set,NULL);
2241
pthread_sigmask(SIG_SETMASK,&set,NULL);
2245
int main(int argc, char **argv)
2247
#if defined(ENABLE_NLS)
2248
# if defined(HAVE_LOCALE_H)
2249
setlocale(LC_ALL, "");
2251
bindtextdomain("drizzle", LOCALEDIR);
2252
textdomain("drizzle");
2255
plugin::Registry &plugins= plugin::Registry::singleton();
2256
plugin::Client *client;
2259
MY_INIT(argv[0]); // init my_sys library & pthreads
2260
/* nothing should come before this line ^^^ */
2262
/* Set signal used to kill Drizzle */
2263
#if defined(SIGUSR2)
2264
thr_kill_signal= internal::thd_lib_detected == THD_LIB_LT ? SIGINT : SIGUSR2;
2266
thr_kill_signal= SIGINT;
2269
if (init_common_variables(DRIZZLE_CONFIG_NAME,
2270
argc, argv, load_default_groups))
2271
unireg_abort(1); // Will do exit
2276
select_thread=pthread_self();
2277
select_thread_in_use=1;
2279
if (chdir(drizzle_real_data_home) && !opt_help)
2281
errmsg_printf(ERRMSG_LVL_ERROR, _("Data directory %s does not exist\n"), drizzle_real_data_home);
2284
drizzle_data_home= drizzle_data_home_buff;
2285
drizzle_data_home[0]=FN_CURLIB; // all paths are relative from here
2286
drizzle_data_home[1]=0;
2287
drizzle_data_home_len= 2;
2289
if ((user_info= check_user(drizzled_user)))
2291
set_user(drizzled_user, user_info);
2299
if (init_server_components(plugins))
2302
if (plugin::Listen::setup())
2306
init signals & alarm
2307
After this we can't quit by a simple unireg_abort
2309
error_handler_hook= my_message_sql;
2311
assert(plugin::num_trx_monitored_objects > 0);
2312
if (drizzle_rm_tmp_tables() ||
2313
my_tz_init((Session *)0, default_tz_name))
2316
select_thread_in_use=0;
2317
(void) pthread_kill(signal_thread, SIGTERM);
2319
(void) unlink(pidfile_name); // Not needed anymore
3175
static uint32_t find_bit_type_or_exit(const char *x, TYPELIB *bit_lib,
3182
if ((res= find_bit_type(x, bit_lib)) == ~(uint32_t) 0)
3184
ptr= bit_lib->type_names;
3186
fprintf(stderr, _("No option given to %s\n"), option);
3188
fprintf(stderr, _("Wrong option to %s. Option(s) given: %s\n"),
3190
fprintf(stderr, _("Alternatives are: '%s'"), *ptr);
3192
fprintf(stderr, ",'%s'", *ptr);
3193
fprintf(stderr, "\n");
2326
errmsg_printf(ERRMSG_LVL_INFO, _(ER(ER_STARTUP)), internal::my_progname,
2327
PANDORA_RELEASE_VERSION, COMPILATION_COMMENT);
2330
/* Listen for new connections and start new session for each connection
2331
accepted. The listen.getClient() method will return NULL when the server
2332
should be shutdown. */
2333
while ((client= plugin::Listen::getClient()) != NULL)
3202
a bitfield from a string of substrings separated by ','
3204
~(uint32_t) 0 on error.
3207
static uint32_t find_bit_type(const char *x, TYPELIB *bit_lib)
3211
const char *end,*i,*j;
3212
const char **array, *pos;
3213
uint32_t found,found_int,bit;
3218
while (*pos == ' ') pos++;
3219
found_end= *pos == 0;
2335
if (!(session= new Session(client)))
2341
/* If we error on creation we drop the connection and delete the session. */
2342
if (session->schedule())
2343
Session::unlink(session);
3222
if ((end=strrchr(pos,',')) != NULL) /* Let end point at fieldend */
3224
while (end > pos && end[-1] == ' ')
3225
end--; /* Skip end-space */
3230
end=pos+strlen(pos);
3233
found_int=0; found_count=0;
3234
for (array=bit_lib->type_names, bit=1 ; (i= *array++) ; bit<<=1)
3239
if (my_toupper(mysqld_charset,*i++) !=
3240
my_toupper(mysqld_charset,*j++))
3249
else if (j != pos) // Half field found
3251
found_count++; // Could be one of two values
3255
if (found_count != 1)
3256
return(~(uint32_t) 0); // No unique value
2346
/* (void) pthread_attr_destroy(&connection_attrib); */
2349
(void) pthread_mutex_lock(&LOCK_thread_count);
2350
select_thread_in_use=0; // For close_connections
2351
(void) pthread_mutex_unlock(&LOCK_thread_count);
2352
(void) pthread_cond_broadcast(&COND_thread_count);
2354
/* Wait until cleanup is done */
2355
(void) pthread_mutex_lock(&LOCK_thread_count);
2356
while (!ready_to_exit)
2357
pthread_cond_wait(&COND_server_end,&LOCK_thread_count);
2358
(void) pthread_mutex_unlock(&LOCK_thread_count);
2361
plugin::Registry::shutdown();
3262
} /* find_bit_type */
3264
/*****************************************************************************
3265
Instantiate templates
3266
*****************************************************************************/
3268
#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
3269
/* Used templates */
3270
template class I_List<Session>;
3271
template class I_List_iterator<Session>;
3272
template class I_List<i_string>;
3273
template class I_List<i_string_pair>;
3274
template class I_List<NAMED_LIST>;
3275
template class I_List<Statement>;
3276
template class I_List_iterator<Statement>;