diff options
author | unknown <tsmith@siva.hindu.god> | 2007-04-18 14:55:42 -0600 |
---|---|---|
committer | unknown <tsmith@siva.hindu.god> | 2007-04-18 14:55:42 -0600 |
commit | 4177856a56bae216184595f5c18987e2abe31957 (patch) | |
tree | 6095a90eae7e27fd721699fb2a8fef7d74ac69a6 /sql/mysqld.cc | |
parent | 9508b781eff5a2a6857f1467b0a39dbde06e4446 (diff) | |
parent | 9340cb193e40516d051f02cdd074dd30b99816a4 (diff) | |
download | mariadb-git-4177856a56bae216184595f5c18987e2abe31957.tar.gz |
Merge siva.hindu.god:/home/tsmith/m/bk/51
into siva.hindu.god:/home/tsmith/m/bk/maint/51
client/mysql_upgrade.c:
Auto merged
client/mysqltest.c:
Auto merged
mysql-test/lib/mtr_cases.pl:
Auto merged
mysql-test/mysql-test-run.pl:
Auto merged
mysql-test/r/type_datetime.result:
Auto merged
mysys/my_alloc.c:
Auto merged
sql/field.h:
Auto merged
sql/item.h:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/mysqld.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_select.cc:
Auto merged
Diffstat (limited to 'sql/mysqld.cc')
-rw-r--r-- | sql/mysqld.cc | 131 |
1 files changed, 51 insertions, 80 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 56fe67383e4..47f95248082 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -274,7 +274,11 @@ static TYPELIB tc_heuristic_recover_typelib= }; static const char *thread_handling_names[]= -{ "one-thread-per-connection", "no-threads", "pool-of-threads", NullS}; +{ "one-thread-per-connection", "no-threads", +#if HAVE_POOL_OF_THREADS == 1 + "pool-of-threads", +#endif + NullS}; TYPELIB thread_handling_typelib= { @@ -732,6 +736,8 @@ pthread_handler_t handle_connections_shared_memory(void *arg); #endif pthread_handler_t handle_slave(void *arg); static ulong find_bit_type(const char *x, TYPELIB *bit_lib); +static ulong find_bit_type_or_exit(const char *x, TYPELIB *bit_lib, + const char *option); static void clean_up(bool print_message); static int test_if_case_insensitive(const char *dir_name); @@ -783,7 +789,6 @@ static void close_connections(void) DBUG_PRINT("info",("Waiting for select thread")); #ifndef DONT_USE_THR_ALARM - if (pthread_kill(select_thread, thr_client_alarm)) break; // allready dead #endif set_timespec(abstime, 2); @@ -7452,11 +7457,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case (int) OPT_INIT_RPL_ROLE: { int role; - if ((role=find_type(argument, &rpl_role_typelib, 2)) <= 0) - { - fprintf(stderr, "Unknown replication role: %s\n", argument); - exit(1); - } + role= find_type_or_exit(argument, &rpl_role_typelib, opt->name); rpl_status = (role == 1) ? RPL_AUTH_MASTER : RPL_IDLE_SLAVE; break; } @@ -7512,17 +7513,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case OPT_BINLOG_FORMAT: { int id; - if ((id= find_type(argument, &binlog_format_typelib, 2)) <= 0) - { - fprintf(stderr, - "Unknown binary log format: '%s' " - "(should be one of '%s', '%s', '%s')\n", - argument, - binlog_format_names[BINLOG_FORMAT_STMT], - binlog_format_names[BINLOG_FORMAT_ROW], - binlog_format_names[BINLOG_FORMAT_MIXED]); - exit(1); - } + id= find_type_or_exit(argument, &binlog_format_typelib, opt->name); global_system_variables.binlog_format= opt_binlog_format_id= id - 1; break; } @@ -7582,13 +7573,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), else { log_output_str= argument; - if ((log_output_options= - find_bit_type(argument, &log_output_typelib)) == ~(ulong) 0) - { - fprintf(stderr, "Unknown option to log-output: %s\n", argument); - exit(1); - } - } + log_output_options= + find_bit_type_or_exit(argument, &log_output_typelib, opt->name); + } break; } #endif @@ -7731,11 +7718,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), else { int type; - if ((type=find_type(argument, &delay_key_write_typelib, 2)) <= 0) - { - fprintf(stderr,"Unknown delay_key_write type: %s\n",argument); - exit(1); - } + type= find_type_or_exit(argument, &delay_key_write_typelib, opt->name); delay_key_write_options= (uint) type-1; } break; @@ -7746,11 +7729,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case OPT_TX_ISOLATION: { int type; - if ((type=find_type(argument, &tx_isolation_typelib, 2)) <= 0) - { - fprintf(stderr,"Unknown transaction isolation type: %s\n",argument); - exit(1); - } + type= find_type_or_exit(argument, &tx_isolation_typelib, opt->name); global_system_variables.tx_isolation= (type-1); break; } @@ -7791,16 +7770,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; case OPT_NDB_DISTRIBUTION: int id; - if ((id= find_type(argument, &ndb_distribution_typelib, 2)) <= 0) - { - fprintf(stderr, - "Unknown ndb distribution type: '%s' " - "(should be '%s' or '%s')\n", - argument, - ndb_distribution_names[ND_KEYHASH], - ndb_distribution_names[ND_LINHASH]); - exit(1); - } + id= find_type_or_exit(argument, &ndb_distribution_typelib, opt->name); opt_ndb_distribution_id= (enum ndb_distribution)(id-1); break; case OPT_NDB_EXTRA_LOGGING: @@ -7840,12 +7810,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), else { myisam_recover_options_str=argument; - if ((myisam_recover_options= - find_bit_type(argument, &myisam_recover_typelib)) == ~(ulong) 0) - { - fprintf(stderr, "Unknown option to myisam-recover: %s\n",argument); - exit(1); - } + myisam_recover_options= + find_bit_type_or_exit(argument, &myisam_recover_typelib, opt->name); } ha_open_options|=HA_OPEN_ABORT_IF_CRASHED; break; @@ -7858,14 +7824,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), myisam_concurrent_insert= 0; /* --skip-concurrent-insert */ break; case OPT_TC_HEURISTIC_RECOVER: - { - if ((tc_heuristic_recover=find_type(argument, - &tc_heuristic_recover_typelib, 2)) <=0) - { - fprintf(stderr, "Unknown option to tc-heuristic-recover: %s\n",argument); - exit(1); - } - } + tc_heuristic_recover= find_type_or_exit(argument, + &tc_heuristic_recover_typelib, + opt->name); + break; case OPT_MYISAM_STATS_METHOD: { ulong method_conv; @@ -7873,11 +7835,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), LINT_INIT(method_conv); myisam_stats_method_str= argument; - if ((method=find_type(argument, &myisam_stats_method_typelib, 2)) <= 0) - { - fprintf(stderr, "Invalid value of myisam_stats_method: %s.\n", argument); - exit(1); - } + method= find_type_or_exit(argument, &myisam_stats_method_typelib, + opt->name); switch (method-1) { case 2: method_conv= MI_STATS_METHOD_IGNORE_NULLS; @@ -7896,12 +7855,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case OPT_SQL_MODE: { sql_mode_str= argument; - if ((global_system_variables.sql_mode= - find_bit_type(argument, &sql_mode_typelib)) == ~(ulong) 0) - { - fprintf(stderr, "Unknown option to sql-mode: %s\n", argument); - exit(1); - } + global_system_variables.sql_mode= + find_bit_type_or_exit(argument, &sql_mode_typelib, opt->name); global_system_variables.sql_mode= fix_sql_mode(global_system_variables. sql_mode); break; @@ -7911,16 +7866,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; case OPT_THREAD_HANDLING: { - if ((global_system_variables.thread_handling= - find_type(argument, &thread_handling_typelib, 2)) <= 0 || - (global_system_variables.thread_handling == SCHEDULER_POOL_OF_THREADS - && !HAVE_POOL_OF_THREADS)) - { - /* purecov: begin tested */ - fprintf(stderr,"Unknown/unsupported thread-handling: %s\n",argument); - exit(1); - /* purecov: end */ - } + global_system_variables.thread_handling= + find_type_or_exit(argument, &thread_handling_typelib, opt->name); break; } case OPT_FT_BOOLEAN_SYNTAX: @@ -8209,6 +8156,30 @@ static void fix_paths(void) } +static ulong find_bit_type_or_exit(const char *x, TYPELIB *bit_lib, + const char *option) +{ + ulong res; + + const char **ptr; + + if ((res= find_bit_type(x, bit_lib)) == ~(ulong) 0) + { + ptr= bit_lib->type_names; + if (!*x) + fprintf(stderr, "No option given to %s\n", option); + else + fprintf(stderr, "Wrong option to %s. Option(s) given: %s\n", option, x); + fprintf(stderr, "Alternatives are: '%s'", *ptr); + while (*++ptr) + fprintf(stderr, ",'%s'", *ptr); + fprintf(stderr, "\n"); + exit(1); + } + return res; +} + + /* Return a bitfield from a string of substrings separated by ',' returns ~(ulong) 0 on error. |