diff options
-rw-r--r-- | scripts/mysql_create_system_tables.sh | 1 | ||||
-rw-r--r-- | scripts/mysql_fix_privilege_tables.sql | 2 | ||||
-rw-r--r-- | sql/ha_ndbcluster.cc | 28 | ||||
-rw-r--r-- | sql/handler.cc | 20 | ||||
-rw-r--r-- | sql/handler.h | 1 | ||||
-rw-r--r-- | sql/mysqld.cc | 29 | ||||
-rw-r--r-- | sql/set_var.cc | 4 | ||||
-rw-r--r-- | support-files/mysql.server.sh | 10 |
8 files changed, 77 insertions, 18 deletions
diff --git a/scripts/mysql_create_system_tables.sh b/scripts/mysql_create_system_tables.sh index bb4c2f08193..e76fc935b03 100644 --- a/scripts/mysql_create_system_tables.sh +++ b/scripts/mysql_create_system_tables.sh @@ -722,6 +722,7 @@ fi cat << END_OF_DATA use mysql; +set table_type=myisam; $c_d $i_d diff --git a/scripts/mysql_fix_privilege_tables.sql b/scripts/mysql_fix_privilege_tables.sql index dee4ebd3d2f..00fe5c053d0 100644 --- a/scripts/mysql_fix_privilege_tables.sql +++ b/scripts/mysql_fix_privilege_tables.sql @@ -9,6 +9,8 @@ -- this sql script. -- On windows you should do 'mysql --force mysql < mysql_fix_privilege_tables.sql' +set table_type=MyISAM; + CREATE TABLE IF NOT EXISTS func ( name char(64) binary DEFAULT '' NOT NULL, ret tinyint(1) DEFAULT '0' NOT NULL, diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index a522d6256fb..020a76b667e 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -67,6 +67,8 @@ static handlerton ndbcluster_hton = { #define NDB_HIDDEN_PRIMARY_KEY_LENGTH 8 +#define NDB_FAILED_AUTO_INCREMENT ~(Uint64)0 +#define NDB_AUTO_INCREMENT_RETRIES 10 #define ERR_PRINT(err) \ DBUG_PRINT("error", ("%d message: %s", err.code, err.message)) @@ -1928,7 +1930,15 @@ int ha_ndbcluster::write_row(byte *record) { // Table has hidden primary key Ndb *ndb= get_ndb(); - Uint64 auto_value= ndb->getAutoIncrementValue((const NDBTAB *) m_table); + Uint64 auto_value= NDB_FAILED_AUTO_INCREMENT; + uint retries= NDB_AUTO_INCREMENT_RETRIES; + do { + auto_value= ndb->getAutoIncrementValue((const NDBTAB *) m_table); + } while (auto_value == NDB_FAILED_AUTO_INCREMENT && + --retries && + ndb->getNdbError().status == NdbError::TemporaryError); + if (auto_value == NDB_FAILED_AUTO_INCREMENT) + ERR_RETURN(ndb->getNdbError()); if (set_hidden_key(op, table->s->fields, (const byte*)&auto_value)) ERR_RETURN(op->getNdbError()); } @@ -4119,10 +4129,18 @@ ulonglong ha_ndbcluster::get_auto_increment() : (m_rows_to_insert > m_autoincrement_prefetch) ? m_rows_to_insert : m_autoincrement_prefetch; - auto_value= - (m_skip_auto_increment) ? - ndb->readAutoIncrementValue((const NDBTAB *) m_table) - : ndb->getAutoIncrementValue((const NDBTAB *) m_table, cache_size); + auto_value= NDB_FAILED_AUTO_INCREMENT; + uint retries= NDB_AUTO_INCREMENT_RETRIES; + do { + auto_value= + (m_skip_auto_increment) ? + ndb->readAutoIncrementValue((const NDBTAB *) m_table) + : ndb->getAutoIncrementValue((const NDBTAB *) m_table, cache_size); + } while (auto_value == NDB_FAILED_AUTO_INCREMENT && + --retries && + ndb->getNdbError().status == NdbError::TemporaryError); + if (auto_value == NDB_FAILED_AUTO_INCREMENT) + ERR_RETURN(ndb->getNdbError()); DBUG_RETURN((longlong)auto_value); } diff --git a/sql/handler.cc b/sql/handler.cc index 8315ec6bb1a..14b8974ece9 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -149,18 +149,27 @@ const char *ha_get_storage_engine(enum db_type db_type) return "none"; } - /* Use other database handler if databasehandler is not incompiled */ -enum db_type ha_checktype(enum db_type database_type) +my_bool ha_storage_engine_is_enabled(enum db_type database_type) { show_table_type_st *types; - THD *thd= current_thd; for (types= sys_table_types; types->type; types++) { - if ((database_type == types->db_type) && + if ((database_type == types->db_type) && (*types->value == SHOW_OPTION_YES)) - return database_type; + return TRUE; } + return FALSE; +} + + + /* Use other database handler if databasehandler is not incompiled */ + +enum db_type ha_checktype(enum db_type database_type) +{ + THD *thd; + if (ha_storage_engine_is_enabled(database_type)) + return database_type; switch (database_type) { #ifndef NO_HASH @@ -173,6 +182,7 @@ enum db_type ha_checktype(enum db_type database_type) break; } + thd= current_thd; return ((enum db_type) thd->variables.table_type != DB_TYPE_UNKNOWN ? (enum db_type) thd->variables.table_type : (enum db_type) global_system_variables.table_type != diff --git a/sql/handler.h b/sql/handler.h index 5d26bca241a..4c06fe8299d 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -819,6 +819,7 @@ TYPELIB *ha_known_exts(void); int ha_panic(enum ha_panic_function flag); int ha_update_statistics(); void ha_close_connection(THD* thd); +my_bool ha_storage_engine_is_enabled(enum db_type database_type); bool ha_flush_logs(void); void ha_drop_database(char* path); int ha_create_table(const char *name, HA_CREATE_INFO *create_info, diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 39ec71acf34..9c592d068ee 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1185,6 +1185,7 @@ static struct passwd *check_user(const char *user) err: sql_print_error("Fatal error: Can't change to run as user '%s' ; Please check that the user exists!\n",user); + unireg_abort(1); #endif return NULL; } @@ -2436,8 +2437,10 @@ static int init_common_variables(const char *conf_file_name, int argc, { struct tm tm_tmp; localtime_r(&start_time,&tm_tmp); - strmov(system_time_zone, tzname[tm_tmp.tm_isdst != 0 ? 1 : 0]); - } + strmake(system_time_zone, tzname[tm_tmp.tm_isdst != 0 ? 1 : 0], + sizeof(system_time_zone)-1); + + } #endif /* We set SYSTEM time zone as reasonable default and @@ -3144,6 +3147,7 @@ we force server id to 2, but this MySQL server will not act as a slave."); if (opt_bootstrap) { + select_thread_in_use= 0; // Allow 'kill' to work bootstrap(stdin); end_thr_alarm(1); // Don't allow alarms unireg_abort(bootstrap_error ? 1 : 0); @@ -6383,9 +6387,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case OPT_STORAGE_ENGINE: { if ((enum db_type)((global_system_variables.table_type= - ha_resolve_by_name(argument, strlen(argument)))) == DB_TYPE_UNKNOWN) + ha_resolve_by_name(argument, strlen(argument)))) == + DB_TYPE_UNKNOWN) { - fprintf(stderr,"Unknown table type: %s\n",argument); + fprintf(stderr,"Unknown/unsupported table type: %s\n",argument); exit(1); } break; @@ -6659,6 +6664,22 @@ static void get_options(int argc,char **argv) sql_print_warning("this binary does not contain BDB storage engine"); #endif + /* + Check that the default storage engine is actually available. + */ + if (!ha_storage_engine_is_enabled((enum db_type) + global_system_variables.table_type)) + { + if (!opt_bootstrap) + { + sql_print_error("Default storage engine (%s) is not available", + ha_get_storage_engine((enum db_type) + global_system_variables.table_type)); + exit(1); + } + global_system_variables.table_type= DB_TYPE_MYISAM; + } + if (argc > 0) { fprintf(stderr, "%s: Too many arguments (first extra is '%s').\nUse --help to get a list of available options\n", my_progname, *argv); diff --git a/sql/set_var.cc b/sql/set_var.cc index fa8eddf7218..70d64b5dac6 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -3125,8 +3125,8 @@ bool sys_var_thd_storage_engine::check(THD *thd, set_var *var) enum db_type db_type; if (!(res=var->value->val_str(&str)) || !(var->save_result.ulong_value= - (ulong) (db_type= ha_resolve_by_name(res->ptr(), res->length()))) || - ha_checktype(db_type) != db_type) + (ulong) (db_type= ha_resolve_by_name(res->ptr(), res->length()))) || + ha_checktype(db_type) != db_type) { value= res ? res->c_ptr() : "NULL"; goto err; diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh index 2735ad91c6e..a03e870004d 100644 --- a/support-files/mysql.server.sh +++ b/support-files/mysql.server.sh @@ -66,8 +66,14 @@ lsb_functions="/lib/lsb/init-functions" if test -f $lsb_functions ; then source $lsb_functions else - alias log_success_msg="echo \ SUCCESS! " - alias log_failure_msg="echo \ ERROR! " + log_success_msg() + { + echo " SUCCESS! $@" + } + log_failure_msg() + { + echo " ERROR! $@" + } fi PATH=/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin |