~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

  • Committer: Monty Taylor
  • Date: 2010-03-11 18:27:20 UTC
  • mfrom: (1333 staging)
  • mto: This revision was merged to the branch mainline in revision 1348.
  • Revision ID: mordred@inaugust.com-20100311182720-hd1h87y6cb1b1mp0
Merged trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
#include "drizzled/plugin/error_message.h"
48
48
#include "drizzled/plugin/client.h"
49
49
#include "drizzled/plugin/scheduler.h"
 
50
#include "drizzled/plugin/xa_resource_manager.h"
 
51
#include "drizzled/plugin/monitored_in_transaction.h"
50
52
#include "drizzled/probes.h"
51
53
#include "drizzled/session_list.h"
52
54
#include "drizzled/charset.h"
423
425
 
424
426
  (void) pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
425
427
 
426
 
  for( vector<Session*>::iterator it= getSessionList().begin(); it != getSessionList().end(); ++it )
 
428
  for( SessionList::iterator it= getSessionList().begin(); it != getSessionList().end(); ++it )
427
429
  {
428
430
    tmp= *it;
429
431
    tmp->killed= Session::KILL_CONNECTION;
833
835
    fprintf(stderr, _("Trying to get some variables.\n"
834
836
                      "Some pointers may be invalid and cause the "
835
837
                      "dump to abort...\n"));
836
 
    safe_print_str("session->query", session->query, 1024);
 
838
    safe_print_str("session->query", session->query.c_str(), 1024);
837
839
    fprintf(stderr, "session->thread_id=%"PRIu32"\n", (uint32_t) session->thread_id);
838
840
    fprintf(stderr, "session->killed=%s\n", kreason);
839
841
  }
945
947
static const char *load_default_groups[]= {
946
948
DRIZZLE_CONFIG_NAME, "server", 0, 0};
947
949
 
948
 
static int show_starttime(SHOW_VAR *var, char *buff)
 
950
static int show_starttime(drizzle_show_var *var, char *buff)
949
951
{
950
952
  var->type= SHOW_LONG;
951
953
  var->value= buff;
953
955
  return 0;
954
956
}
955
957
 
956
 
static int show_flushstatustime(SHOW_VAR *var, char *buff)
 
958
static int show_flushstatustime(drizzle_show_var *var, char *buff)
957
959
{
958
960
  var->type= SHOW_LONG;
959
961
  var->value= buff;
961
963
  return 0;
962
964
}
963
965
 
964
 
static int show_open_tables(SHOW_VAR *var, char *buff)
 
966
static int show_open_tables(drizzle_show_var *var, char *buff)
965
967
{
966
968
  var->type= SHOW_LONG;
967
969
  var->value= buff;
969
971
  return 0;
970
972
}
971
973
 
972
 
static int show_table_definitions(SHOW_VAR *var, char *buff)
 
974
static int show_table_definitions(drizzle_show_var *var, char *buff)
973
975
{
974
976
  var->type= SHOW_LONG;
975
977
  var->value= buff;
989
991
/*
990
992
  Variables shown by SHOW STATUS in alphabetical order
991
993
*/
992
 
static SHOW_VAR com_status_vars[]= {
993
 
  {"admin_commands",       (char*) offsetof(STATUS_VAR, com_other), SHOW_LONG_STATUS},
994
 
  {"alter_db",             (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_ALTER_DB]), SHOW_LONG_STATUS},
995
 
  {"alter_table",          (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_ALTER_TABLE]), SHOW_LONG_STATUS},
996
 
  {"analyze",              (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_ANALYZE]), SHOW_LONG_STATUS},
997
 
  {"begin",                (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_BEGIN]), SHOW_LONG_STATUS},
998
 
  {"change_db",            (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_CHANGE_DB]), SHOW_LONG_STATUS},
999
 
  {"check",                (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_CHECK]), SHOW_LONG_STATUS},
1000
 
  {"checksum",             (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_CHECKSUM]), SHOW_LONG_STATUS},
1001
 
  {"commit",               (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_COMMIT]), SHOW_LONG_STATUS},
1002
 
  {"create_db",            (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_CREATE_DB]), SHOW_LONG_STATUS},
1003
 
  {"create_index",         (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_CREATE_INDEX]), SHOW_LONG_STATUS},
1004
 
  {"create_table",         (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_CREATE_TABLE]), SHOW_LONG_STATUS},
1005
 
  {"delete",               (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_DELETE]), SHOW_LONG_STATUS},
1006
 
  {"drop_db",              (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_DROP_DB]), SHOW_LONG_STATUS},
1007
 
  {"drop_index",           (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_DROP_INDEX]), SHOW_LONG_STATUS},
1008
 
  {"drop_table",           (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_DROP_TABLE]), SHOW_LONG_STATUS},
1009
 
  {"empty_query",          (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_EMPTY_QUERY]), SHOW_LONG_STATUS},
1010
 
  {"flush",                (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_FLUSH]), SHOW_LONG_STATUS},
1011
 
  {"insert",               (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_INSERT]), SHOW_LONG_STATUS},
1012
 
  {"insert_select",        (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_INSERT_SELECT]), SHOW_LONG_STATUS},
1013
 
  {"kill",                 (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_KILL]), SHOW_LONG_STATUS},
1014
 
  {"load",                 (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_LOAD]), SHOW_LONG_STATUS},
1015
 
  {"release_savepoint",    (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_RELEASE_SAVEPOINT]), SHOW_LONG_STATUS},
1016
 
  {"rename_table",         (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_RENAME_TABLE]), SHOW_LONG_STATUS},
1017
 
  {"replace",              (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_REPLACE]), SHOW_LONG_STATUS},
1018
 
  {"replace_select",       (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_REPLACE_SELECT]), SHOW_LONG_STATUS},
1019
 
  {"rollback",             (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_ROLLBACK]), SHOW_LONG_STATUS},
1020
 
  {"rollback_to_savepoint",(char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_ROLLBACK_TO_SAVEPOINT]), SHOW_LONG_STATUS},
1021
 
  {"savepoint",            (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SAVEPOINT]), SHOW_LONG_STATUS},
1022
 
  {"select",               (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SELECT]), SHOW_LONG_STATUS},
1023
 
  {"set_option",           (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SET_OPTION]), SHOW_LONG_STATUS},
1024
 
  {"show_create_db",       (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_CREATE_DB]), SHOW_LONG_STATUS},
1025
 
  {"show_create_table",    (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_CREATE]), SHOW_LONG_STATUS},
1026
 
  {"show_databases",       (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_DATABASES]), SHOW_LONG_STATUS},
1027
 
  {"show_errors",          (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_ERRORS]), SHOW_LONG_STATUS},
1028
 
  {"show_fields",          (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_FIELDS]), SHOW_LONG_STATUS},
1029
 
  {"show_keys",            (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_KEYS]), SHOW_LONG_STATUS},
1030
 
  {"show_processlist",     (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_PROCESSLIST]), SHOW_LONG_STATUS},
1031
 
  {"show_status",          (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_STATUS]), SHOW_LONG_STATUS},
1032
 
  {"show_table_status",    (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_TABLE_STATUS]), SHOW_LONG_STATUS},
1033
 
  {"show_tables",          (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_TABLES]), SHOW_LONG_STATUS},
1034
 
  {"show_variables",       (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_VARIABLES]), SHOW_LONG_STATUS},
1035
 
  {"show_warnings",        (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_SHOW_WARNS]), SHOW_LONG_STATUS},
1036
 
  {"truncate",             (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_TRUNCATE]), SHOW_LONG_STATUS},
1037
 
  {"unlock_tables",        (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_UNLOCK_TABLES]), SHOW_LONG_STATUS},
1038
 
  {"update",               (char*) offsetof(STATUS_VAR, com_stat[(uint32_t) SQLCOM_UPDATE]), SHOW_LONG_STATUS},
 
994
static drizzle_show_var com_status_vars[]= {
 
995
  {"admin_commands",       (char*) offsetof(system_status_var, com_other), SHOW_LONG_STATUS},
 
996
  {"alter_db",             (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_ALTER_DB]), SHOW_LONG_STATUS},
 
997
  {"alter_table",          (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_ALTER_TABLE]), SHOW_LONG_STATUS},
 
998
  {"analyze",              (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_ANALYZE]), SHOW_LONG_STATUS},
 
999
  {"begin",                (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_BEGIN]), SHOW_LONG_STATUS},
 
1000
  {"change_db",            (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_CHANGE_DB]), SHOW_LONG_STATUS},
 
1001
  {"check",                (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_CHECK]), SHOW_LONG_STATUS},
 
1002
  {"checksum",             (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_CHECKSUM]), SHOW_LONG_STATUS},
 
1003
  {"commit",               (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_COMMIT]), SHOW_LONG_STATUS},
 
1004
  {"create_db",            (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_CREATE_DB]), SHOW_LONG_STATUS},
 
1005
  {"create_index",         (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_CREATE_INDEX]), SHOW_LONG_STATUS},
 
1006
  {"create_table",         (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_CREATE_TABLE]), SHOW_LONG_STATUS},
 
1007
  {"delete",               (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_DELETE]), SHOW_LONG_STATUS},
 
1008
  {"drop_db",              (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_DROP_DB]), SHOW_LONG_STATUS},
 
1009
  {"drop_index",           (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_DROP_INDEX]), SHOW_LONG_STATUS},
 
1010
  {"drop_table",           (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_DROP_TABLE]), SHOW_LONG_STATUS},
 
1011
  {"empty_query",          (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_EMPTY_QUERY]), SHOW_LONG_STATUS},
 
1012
  {"flush",                (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_FLUSH]), SHOW_LONG_STATUS},
 
1013
  {"insert",               (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_INSERT]), SHOW_LONG_STATUS},
 
1014
  {"insert_select",        (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_INSERT_SELECT]), SHOW_LONG_STATUS},
 
1015
  {"kill",                 (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_KILL]), SHOW_LONG_STATUS},
 
1016
  {"load",                 (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_LOAD]), SHOW_LONG_STATUS},
 
1017
  {"release_savepoint",    (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_RELEASE_SAVEPOINT]), SHOW_LONG_STATUS},
 
1018
  {"rename_table",         (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_RENAME_TABLE]), SHOW_LONG_STATUS},
 
1019
  {"replace",              (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_REPLACE]), SHOW_LONG_STATUS},
 
1020
  {"replace_select",       (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_REPLACE_SELECT]), SHOW_LONG_STATUS},
 
1021
  {"rollback",             (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_ROLLBACK]), SHOW_LONG_STATUS},
 
1022
  {"rollback_to_savepoint",(char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_ROLLBACK_TO_SAVEPOINT]), SHOW_LONG_STATUS},
 
1023
  {"savepoint",            (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_SAVEPOINT]), SHOW_LONG_STATUS},
 
1024
  {"select",               (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_SELECT]), SHOW_LONG_STATUS},
 
1025
  {"set_option",           (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_SET_OPTION]), SHOW_LONG_STATUS},
 
1026
  {"show_create_db",       (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_SHOW_CREATE_DB]), SHOW_LONG_STATUS},
 
1027
  {"show_create_table",    (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_SHOW_CREATE]), SHOW_LONG_STATUS},
 
1028
  {"show_errors",          (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_SHOW_ERRORS]), SHOW_LONG_STATUS},
 
1029
  {"show_warnings",        (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_SHOW_WARNS]), SHOW_LONG_STATUS},
 
1030
  {"truncate",             (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_TRUNCATE]), SHOW_LONG_STATUS},
 
1031
  {"unlock_tables",        (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_UNLOCK_TABLES]), SHOW_LONG_STATUS},
 
1032
  {"update",               (char*) offsetof(system_status_var, com_stat[(uint32_t) SQLCOM_UPDATE]), SHOW_LONG_STATUS},
1039
1033
  {NULL, NULL, SHOW_LONGLONG}
1040
1034
};
1041
1035
 
1042
 
static SHOW_VAR status_vars[]= {
 
1036
static drizzle_show_var status_vars[]= {
1043
1037
  {"Aborted_clients",          (char*) &aborted_threads,        SHOW_LONGLONG},
1044
1038
  {"Aborted_connects",         (char*) &aborted_connects,       SHOW_LONGLONG},
1045
 
  {"Bytes_received",           (char*) offsetof(STATUS_VAR, bytes_received), SHOW_LONGLONG_STATUS},
1046
 
  {"Bytes_sent",               (char*) offsetof(STATUS_VAR, bytes_sent), SHOW_LONGLONG_STATUS},
1047
 
  {"Com",                      (char*) com_status_vars, SHOW_ARRAY},
 
1039
  {"Bytes_received",           (char*) offsetof(system_status_var, bytes_received), SHOW_LONGLONG_STATUS},
 
1040
  {"Bytes_sent",               (char*) offsetof(system_status_var, bytes_sent), SHOW_LONGLONG_STATUS},
1048
1041
  {"Connections",              (char*) &global_thread_id, SHOW_INT_NOFLUSH},
1049
 
  {"Created_tmp_disk_tables",  (char*) offsetof(STATUS_VAR, created_tmp_disk_tables), SHOW_LONG_STATUS},
1050
 
  {"Created_tmp_files",        (char*) &internal::my_tmp_file_created,SHOW_INT},
1051
 
  {"Created_tmp_tables",       (char*) offsetof(STATUS_VAR, created_tmp_tables), SHOW_LONG_STATUS},
 
1042
  {"Created_tmp_disk_tables",  (char*) offsetof(system_status_var, created_tmp_disk_tables), SHOW_LONG_STATUS},
 
1043
  {"Created_tmp_tables",       (char*) offsetof(system_status_var, created_tmp_tables), SHOW_LONG_STATUS},
1052
1044
  {"Flush_commands",           (char*) &refresh_version,    SHOW_INT_NOFLUSH},
1053
 
  {"Handler_commit",           (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS},
1054
 
  {"Handler_delete",           (char*) offsetof(STATUS_VAR, ha_delete_count), SHOW_LONG_STATUS},
1055
 
  {"Handler_prepare",          (char*) offsetof(STATUS_VAR, ha_prepare_count),  SHOW_LONG_STATUS},
1056
 
  {"Handler_read_first",       (char*) offsetof(STATUS_VAR, ha_read_first_count), SHOW_LONG_STATUS},
1057
 
  {"Handler_read_key",         (char*) offsetof(STATUS_VAR, ha_read_key_count), SHOW_LONG_STATUS},
1058
 
  {"Handler_read_next",        (char*) offsetof(STATUS_VAR, ha_read_next_count), SHOW_LONG_STATUS},
1059
 
  {"Handler_read_prev",        (char*) offsetof(STATUS_VAR, ha_read_prev_count), SHOW_LONG_STATUS},
1060
 
  {"Handler_read_rnd",         (char*) offsetof(STATUS_VAR, ha_read_rnd_count), SHOW_LONG_STATUS},
1061
 
  {"Handler_read_rnd_next",    (char*) offsetof(STATUS_VAR, ha_read_rnd_next_count), SHOW_LONG_STATUS},
1062
 
  {"Handler_rollback",         (char*) offsetof(STATUS_VAR, ha_rollback_count), SHOW_LONG_STATUS},
1063
 
  {"Handler_savepoint",        (char*) offsetof(STATUS_VAR, ha_savepoint_count), SHOW_LONG_STATUS},
1064
 
  {"Handler_savepoint_rollback",(char*) offsetof(STATUS_VAR, ha_savepoint_rollback_count), SHOW_LONG_STATUS},
1065
 
  {"Handler_update",           (char*) offsetof(STATUS_VAR, ha_update_count), SHOW_LONG_STATUS},
1066
 
  {"Handler_write",            (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONG_STATUS},
 
1045
  {"Handler_commit",           (char*) offsetof(system_status_var, ha_commit_count), SHOW_LONG_STATUS},
 
1046
  {"Handler_delete",           (char*) offsetof(system_status_var, ha_delete_count), SHOW_LONG_STATUS},
 
1047
  {"Handler_prepare",          (char*) offsetof(system_status_var, ha_prepare_count),  SHOW_LONG_STATUS},
 
1048
  {"Handler_read_first",       (char*) offsetof(system_status_var, ha_read_first_count), SHOW_LONG_STATUS},
 
1049
  {"Handler_read_key",         (char*) offsetof(system_status_var, ha_read_key_count), SHOW_LONG_STATUS},
 
1050
  {"Handler_read_next",        (char*) offsetof(system_status_var, ha_read_next_count), SHOW_LONG_STATUS},
 
1051
  {"Handler_read_prev",        (char*) offsetof(system_status_var, ha_read_prev_count), SHOW_LONG_STATUS},
 
1052
  {"Handler_read_rnd",         (char*) offsetof(system_status_var, ha_read_rnd_count), SHOW_LONG_STATUS},
 
1053
  {"Handler_read_rnd_next",    (char*) offsetof(system_status_var, ha_read_rnd_next_count), SHOW_LONG_STATUS},
 
1054
  {"Handler_rollback",         (char*) offsetof(system_status_var, ha_rollback_count), SHOW_LONG_STATUS},
 
1055
  {"Handler_savepoint",        (char*) offsetof(system_status_var, ha_savepoint_count), SHOW_LONG_STATUS},
 
1056
  {"Handler_savepoint_rollback",(char*) offsetof(system_status_var, ha_savepoint_rollback_count), SHOW_LONG_STATUS},
 
1057
  {"Handler_update",           (char*) offsetof(system_status_var, ha_update_count), SHOW_LONG_STATUS},
 
1058
  {"Handler_write",            (char*) offsetof(system_status_var, ha_write_count), SHOW_LONG_STATUS},
1067
1059
  {"Key_blocks_not_flushed",   (char*) offsetof(KEY_CACHE, global_blocks_changed), SHOW_KEY_CACHE_LONG},
1068
1060
  {"Key_blocks_unused",        (char*) offsetof(KEY_CACHE, blocks_unused), SHOW_KEY_CACHE_LONG},
1069
1061
  {"Key_blocks_used",          (char*) offsetof(KEY_CACHE, blocks_used), SHOW_KEY_CACHE_LONG},
1071
1063
  {"Key_reads",                (char*) offsetof(KEY_CACHE, global_cache_read), SHOW_KEY_CACHE_LONGLONG},
1072
1064
  {"Key_write_requests",       (char*) offsetof(KEY_CACHE, global_cache_w_requests), SHOW_KEY_CACHE_LONGLONG},
1073
1065
  {"Key_writes",               (char*) offsetof(KEY_CACHE, global_cache_write), SHOW_KEY_CACHE_LONGLONG},
1074
 
  {"Last_query_cost",          (char*) offsetof(STATUS_VAR, last_query_cost), SHOW_DOUBLE_STATUS},
 
1066
  {"Last_query_cost",          (char*) offsetof(system_status_var, last_query_cost), SHOW_DOUBLE_STATUS},
1075
1067
  {"Max_used_connections",     (char*) &max_used_connections,  SHOW_INT},
1076
 
  {"Open_files",               (char*) &internal::my_file_opened,    SHOW_INT_NOFLUSH},
1077
 
  {"Open_streams",             (char*) &internal::my_stream_opened,  SHOW_INT_NOFLUSH},
1078
1068
  {"Open_table_definitions",   (char*) &show_table_definitions_cont, SHOW_FUNC},
1079
1069
  {"Open_tables",              (char*) &show_open_tables_cont,       SHOW_FUNC},
1080
 
  {"Opened_files",             (char*) &internal::my_file_total_opened, SHOW_INT_NOFLUSH},
1081
 
  {"Opened_tables",            (char*) offsetof(STATUS_VAR, opened_tables), SHOW_LONG_STATUS},
1082
 
  {"Opened_table_definitions", (char*) offsetof(STATUS_VAR, opened_shares), SHOW_LONG_STATUS},
1083
 
  {"Questions",                (char*) offsetof(STATUS_VAR, questions), SHOW_LONG_STATUS},
1084
 
  {"Select_full_join",         (char*) offsetof(STATUS_VAR, select_full_join_count), SHOW_LONG_STATUS},
1085
 
  {"Select_full_range_join",   (char*) offsetof(STATUS_VAR, select_full_range_join_count), SHOW_LONG_STATUS},
1086
 
  {"Select_range",             (char*) offsetof(STATUS_VAR, select_range_count), SHOW_LONG_STATUS},
1087
 
  {"Select_range_check",       (char*) offsetof(STATUS_VAR, select_range_check_count), SHOW_LONG_STATUS},
1088
 
  {"Select_scan",              (char*) offsetof(STATUS_VAR, select_scan_count), SHOW_LONG_STATUS},
1089
 
  {"Slow_queries",             (char*) offsetof(STATUS_VAR, long_query_count), SHOW_LONG_STATUS},
1090
 
  {"Sort_merge_passes",        (char*) offsetof(STATUS_VAR, filesort_merge_passes), SHOW_LONG_STATUS},
1091
 
  {"Sort_range",               (char*) offsetof(STATUS_VAR, filesort_range_count), SHOW_LONG_STATUS},
1092
 
  {"Sort_rows",                (char*) offsetof(STATUS_VAR, filesort_rows), SHOW_LONG_STATUS},
1093
 
  {"Sort_scan",                (char*) offsetof(STATUS_VAR, filesort_scan_count), SHOW_LONG_STATUS},
 
1070
  {"Opened_tables",            (char*) offsetof(system_status_var, opened_tables), SHOW_LONG_STATUS},
 
1071
  {"Opened_table_definitions", (char*) offsetof(system_status_var, opened_shares), SHOW_LONG_STATUS},
 
1072
  {"Questions",                (char*) offsetof(system_status_var, questions), SHOW_LONG_STATUS},
 
1073
  {"Select_full_join",         (char*) offsetof(system_status_var, select_full_join_count), SHOW_LONG_STATUS},
 
1074
  {"Select_full_range_join",   (char*) offsetof(system_status_var, select_full_range_join_count), SHOW_LONG_STATUS},
 
1075
  {"Select_range",             (char*) offsetof(system_status_var, select_range_count), SHOW_LONG_STATUS},
 
1076
  {"Select_range_check",       (char*) offsetof(system_status_var, select_range_check_count), SHOW_LONG_STATUS},
 
1077
  {"Select_scan",              (char*) offsetof(system_status_var, select_scan_count), SHOW_LONG_STATUS},
 
1078
  {"Slow_queries",             (char*) offsetof(system_status_var, long_query_count), SHOW_LONG_STATUS},
 
1079
  {"Sort_merge_passes",        (char*) offsetof(system_status_var, filesort_merge_passes), SHOW_LONG_STATUS},
 
1080
  {"Sort_range",               (char*) offsetof(system_status_var, filesort_range_count), SHOW_LONG_STATUS},
 
1081
  {"Sort_rows",                (char*) offsetof(system_status_var, filesort_rows), SHOW_LONG_STATUS},
 
1082
  {"Sort_scan",                (char*) offsetof(system_status_var, filesort_scan_count), SHOW_LONG_STATUS},
1094
1083
  {"Table_locks_immediate",    (char*) &locks_immediate,        SHOW_INT},
1095
1084
  {"Table_locks_waited",       (char*) &locks_waited,           SHOW_INT},
1096
1085
  {"Threads_connected",        (char*) &connection_count,       SHOW_INT},
1124
1113
    strncpy(system_time_zone, tzname[tm_tmp.tm_isdst != 0 ? 1 : 0],
1125
1114
            sizeof(system_time_zone)-1);
1126
1115
 
1127
 
 }
 
1116
  }
1128
1117
  /*
1129
1118
    We set SYSTEM time zone as reasonable default and
1130
1119
    also for failure of my_tz_init() and bootstrap mode.
1136
1125
  if (gethostname(glob_hostname,sizeof(glob_hostname)) < 0)
1137
1126
  {
1138
1127
    strncpy(glob_hostname, STRING_WITH_LEN("localhost"));
1139
 
      errmsg_printf(ERRMSG_LVL_WARN, _("gethostname failed, using '%s' as hostname"),
1140
 
                      glob_hostname);
 
1128
    errmsg_printf(ERRMSG_LVL_WARN, _("gethostname failed, using '%s' as hostname"),
 
1129
                  glob_hostname);
1141
1130
    strncpy(pidfile_name, STRING_WITH_LEN("drizzle"));
1142
1131
  }
1143
1132
  else
1149
1138
    status variables that is shown by SHOW STATUS.
1150
1139
    Later, in plugin_init, new entries could be added to that list.
1151
1140
  */
 
1141
  if (add_com_status_vars(com_status_vars))
 
1142
    return 1; // an error was already reported
 
1143
 
1152
1144
  if (add_status_vars(status_vars))
1153
1145
    return 1; // an error was already reported
1154
1146
 
1177
1169
  if (default_collation_name)
1178
1170
  {
1179
1171
    const CHARSET_INFO * const default_collation= get_charset_by_name(default_collation_name);
1180
 
    if (!default_collation)
 
1172
    if (not default_collation)
1181
1173
    {
1182
 
          errmsg_printf(ERRMSG_LVL_ERROR, _(ER(ER_UNKNOWN_COLLATION)), default_collation_name);
 
1174
      errmsg_printf(ERRMSG_LVL_ERROR, _(ER(ER_UNKNOWN_COLLATION)), default_collation_name);
1183
1175
      return 1;
1184
1176
    }
1185
 
    if (!my_charset_same(default_charset_info, default_collation))
 
1177
    if (not my_charset_same(default_charset_info, default_collation))
1186
1178
    {
1187
 
          errmsg_printf(ERRMSG_LVL_ERROR, _(ER(ER_COLLATION_CHARSET_MISMATCH)),
1188
 
                      default_collation_name,
1189
 
                      default_charset_info->csname);
 
1179
      errmsg_printf(ERRMSG_LVL_ERROR, _(ER(ER_COLLATION_CHARSET_MISMATCH)),
 
1180
                    default_collation_name,
 
1181
                    default_charset_info->csname);
1190
1182
      return 1;
1191
1183
    }
1192
1184
    default_charset_info= default_collation;
1194
1186
  /* Set collactions that depends on the default collation */
1195
1187
  global_system_variables.collation_server=      default_charset_info;
1196
1188
 
1197
 
  global_system_variables.optimizer_switch= 0;
1198
 
 
1199
 
  if (!(character_set_filesystem=
1200
 
        get_charset_by_csname(character_set_filesystem_name, MY_CS_PRIMARY)))
 
1189
  if (not (character_set_filesystem=
 
1190
           get_charset_by_csname(character_set_filesystem_name, MY_CS_PRIMARY)))
1201
1191
    return 1;
1202
1192
  global_system_variables.character_set_filesystem= character_set_filesystem;
1203
1193
 
1204
1194
  if (!(my_default_lc_time_names=
1205
1195
        my_locale_by_name(lc_time_names_name)))
1206
1196
  {
1207
 
      errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown locale: '%s'"), lc_time_names_name);
 
1197
    errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown locale: '%s'"), lc_time_names_name);
1208
1198
    return 1;
1209
1199
  }
1210
1200
  global_system_variables.lc_time_names= my_default_lc_time_names;
1218
1208
 
1219
1209
static int init_thread_environment()
1220
1210
{
 
1211
   pthread_mutexattr_t attr; 
 
1212
   pthread_mutexattr_init(&attr);
 
1213
 
1221
1214
  (void) pthread_mutex_init(&LOCK_create_db, NULL);
1222
1215
  (void) pthread_mutex_init(&LOCK_open, NULL);
1223
 
  (void) pthread_mutex_init(&LOCK_thread_count,MY_MUTEX_INIT_FAST);
1224
 
  (void) pthread_mutex_init(&LOCK_status,MY_MUTEX_INIT_FAST);
1225
 
  (void) pthread_mutex_init(&LOCK_global_system_variables, MY_MUTEX_INIT_FAST);
 
1216
 
 
1217
  pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); 
 
1218
  (void) pthread_mutex_init(&LOCK_thread_count, &attr);
 
1219
  (void) pthread_mutex_init(&LOCK_global_system_variables, &attr);
 
1220
 
 
1221
  (void) pthread_mutex_init(&LOCK_status, MY_MUTEX_INIT_FAST);
1226
1222
  (void) pthread_rwlock_init(&LOCK_system_variables_hash, NULL);
1227
1223
  (void) pthread_mutex_init(&LOCK_global_read_lock, MY_MUTEX_INIT_FAST);
1228
1224
  (void) pthread_cond_init(&COND_thread_count,NULL);
1230
1226
  (void) pthread_cond_init(&COND_refresh,NULL);
1231
1227
  (void) pthread_cond_init(&COND_global_read_lock,NULL);
1232
1228
 
 
1229
  pthread_mutexattr_destroy(&attr);
 
1230
 
1233
1231
  if (pthread_key_create(&THR_Session,NULL) ||
1234
1232
      pthread_key_create(&THR_Mem_root,NULL))
1235
1233
  {
1322
1320
      unireg_abort(1);
1323
1321
  }
1324
1322
 
1325
 
  /* We have to initialize the storage engines before CSV logging */
1326
 
  if (ha_init())
1327
 
  {
1328
 
      errmsg_printf(ERRMSG_LVL_ERROR, _("Can't init databases"));
1329
 
    unireg_abort(1);
1330
 
  }
1331
 
 
1332
1323
  /*
1333
1324
    This is entirely for legacy. We will create a new "disk based" engine and a
1334
1325
    "memory" engine which will be configurable longterm.
1349
1340
    engine= plugin::StorageEngine::findByName(name);
1350
1341
    if (engine == NULL)
1351
1342
    {
1352
 
      errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown/unsupported table type: %s"),
1353
 
                    default_storage_engine_str);
1354
 
      unireg_abort(1);
1355
 
    }
1356
 
    if (!engine->is_enabled())
1357
 
    {
1358
 
      errmsg_printf(ERRMSG_LVL_ERROR, _("Default storage engine (%s) is not available"),
1359
 
                    default_storage_engine_str);
1360
 
      unireg_abort(1);
1361
 
      //assert(global_system_variables.storage_engine);
1362
 
    }
1363
 
    else
1364
 
    {
1365
 
      /*
1366
 
        Need to unlock as global_system_variables.storage_engine
1367
 
        was acquired during plugin_init()
1368
 
      */
1369
 
      global_system_variables.storage_engine= engine;
1370
 
    }
 
1343
      errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown/unsupported storage engine: %s"),
 
1344
                    default_storage_engine_str);
 
1345
      unireg_abort(1);
 
1346
    }
 
1347
    global_system_variables.storage_engine= engine;
1371
1348
  }
1372
1349
 
1373
 
  if (plugin::StorageEngine::recover(0))
 
1350
  if (plugin::XaResourceManager::recoverAllXids(0))
1374
1351
  {
1375
1352
    unireg_abort(1);
1376
1353
  }
1770
1747
  {"table_open_cache", OPT_TABLE_OPEN_CACHE,
1771
1748
   N_("The number of cached open tables."),
1772
1749
   (char**) &table_cache_size, (char**) &table_cache_size, 0, GET_UINT64,
1773
 
   REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0},
 
1750
   REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, TABLE_OPEN_CACHE_MIN, 512*1024L, 0, 1, 0},
1774
1751
  {"table_lock_wait_timeout", OPT_TABLE_LOCK_WAIT_TIMEOUT,
1775
1752
   N_("Timeout in seconds to wait for a table level lock before returning an "
1776
1753
      "error. Used only if the connection has active cursors."),
2365
2342
  */
2366
2343
  error_handler_hook= my_message_sql;
2367
2344
 
 
2345
  assert(plugin::num_trx_monitored_objects > 0);
2368
2346
  if (drizzle_rm_tmp_tables() ||
2369
2347
      my_tz_init((Session *)0, default_tz_name))
2370
2348
  {