From 47ab7c87851fa49495230927d4156ed0259fa5e5 Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Wed, 13 Apr 2005 15:43:29 -0700 Subject: [PATCH 1/7] Don't allow the server to start up when an invalid user is specified via --user or in configuration. (Bug #9833) --- sql/mysqld.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b568b75fbad..115c21a95d8 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1165,6 +1165,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; } From 6632ed5ce75987d98ea05542d90e359d201aced0 Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Wed, 13 Apr 2005 18:25:31 -0700 Subject: [PATCH 2/7] Check that the default storage engine is really available, and refuse to start up if it is not. (Bug #9815) --- sql/handler.cc | 14 ++++++++++++++ sql/handler.h | 1 + sql/mysqld.cc | 12 ++++++++++++ 3 files changed, 27 insertions(+) diff --git a/sql/handler.cc b/sql/handler.cc index b12032ccd81..7d8fc5d8110 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -145,6 +145,20 @@ const char *ha_get_storage_engine(enum db_type db_type) return "none"; } + +my_bool ha_storage_engine_is_enabled(enum db_type database_type) +{ + show_table_type_st *types; + for (types= sys_table_types; types->type; types++) + { + if ((database_type == types->db_type) && + (*types->value == SHOW_OPTION_YES)) + return TRUE; + } + return FALSE; +} + + /* Use other database handler if databasehandler is not incompiled */ enum db_type ha_checktype(enum db_type database_type) diff --git a/sql/handler.h b/sql/handler.h index 4c31da6a492..d2f77c4149a 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -542,6 +542,7 @@ int ha_init(void); int ha_panic(enum ha_panic_function flag); void ha_close_connection(THD* thd); enum db_type ha_checktype(enum db_type database_type); +my_bool ha_storage_engine_is_enabled(enum db_type database_type); int ha_create_table(const char *name, HA_CREATE_INFO *create_info, bool update_create_info); int ha_create_table_from_engine(THD* thd, const char *db, const char *name, diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b568b75fbad..41e3069a6c0 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -6435,6 +6435,18 @@ 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)) + { + sql_print_error("Default storage engine (%s) is not available", + ha_get_storage_engine((enum db_type) + global_system_variables.table_type)); + exit(1); + } + 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); From 5e581186a47de8d2d562b83106436c597fb37310 Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Thu, 14 Apr 2005 17:22:18 -0700 Subject: [PATCH 3/7] Fix mysql.server.sh to use shell functions as replacement for LSB init functions when they aren't available. (Bug #9852) --- support-files/mysql.server.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh index 376d9051b10..f9015824e6b 100644 --- a/support-files/mysql.server.sh +++ b/support-files/mysql.server.sh @@ -61,8 +61,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 From e889d234cb57c27e254b511c09da978816b6ee5a Mon Sep 17 00:00:00 2001 From: "mskold@mysql.com" <> Date: Fri, 15 Apr 2005 15:52:07 +0200 Subject: [PATCH 4/7] Bug #9839 Column with AUTOINC contains -1 Value on node stop --- sql/ha_ndbcluster.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 6dc9c8df64a..242bdec75cb 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -47,6 +47,7 @@ static const char *ha_ndb_ext=".ndb"; #define NDB_HIDDEN_PRIMARY_KEY_LENGTH 8 +#define NDB_FAILED_AUTO_INCREMENT ~(Uint64)0 #define ERR_PRINT(err) \ DBUG_PRINT("error", ("%d message: %s", err.code, err.message)) @@ -1839,6 +1840,8 @@ 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); + if (auto_value == NDB_FAILED_AUTO_INCREMENT) + ERR_RETURN(ndb->getNdbError()); if (set_hidden_key(op, table->fields, (const byte*)&auto_value)) ERR_RETURN(op->getNdbError()); } @@ -3975,6 +3978,8 @@ longlong ha_ndbcluster::get_auto_increment() (m_skip_auto_increment) ? ndb->readAutoIncrementValue((const NDBTAB *) m_table) : ndb->getAutoIncrementValue((const NDBTAB *) m_table, cache_size); + if (auto_value == NDB_FAILED_AUTO_INCREMENT) + ERR_RETURN(ndb->getNdbError()); DBUG_RETURN((longlong)auto_value); } From 40a0548a1bc3f7a2dddd2adb9274edc9f8b944da Mon Sep 17 00:00:00 2001 From: "mskold@mysql.com" <> Date: Fri, 15 Apr 2005 16:14:08 +0200 Subject: [PATCH 5/7] Bug #9839 Column with AUTOINC contains -1 Value on node stop, post review fix --- sql/ha_ndbcluster.cc | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 242bdec75cb..d14d5f6f5c3 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -48,6 +48,7 @@ static const char *ha_ndb_ext=".ndb"; #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)) @@ -1839,7 +1840,13 @@ 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->fields, (const byte*)&auto_value)) @@ -3974,10 +3981,16 @@ longlong ha_ndbcluster::get_auto_increment() : (m_rows_to_insert > m_autoincrement_prefetch) ? m_rows_to_insert : m_autoincrement_prefetch; - Uint64 auto_value= - (m_skip_auto_increment) ? - ndb->readAutoIncrementValue((const NDBTAB *) m_table) - : ndb->getAutoIncrementValue((const NDBTAB *) m_table, cache_size); + Uint64 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); From 8d919770c71178cc430fd515eaed3859e65792da Mon Sep 17 00:00:00 2001 From: "monty@mishka.local" <> Date: Sat, 16 Apr 2005 03:40:33 +0300 Subject: [PATCH 6/7] Fixed core dump with long timezone names Don't abort on bootstrap if a wrong --default-storage-engine is specified --- sql/handler.cc | 9 ++------- sql/mysqld.cc | 26 +++++++++++++++++--------- sql/set_var.cc | 4 ++-- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index 7d8fc5d8110..7c369a72392 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -163,13 +163,8 @@ my_bool ha_storage_engine_is_enabled(enum db_type database_type) enum db_type ha_checktype(enum db_type database_type) { - show_table_type_st *types; - for (types= sys_table_types; types->type; types++) - { - if ((database_type == types->db_type) && - (*types->value == SHOW_OPTION_YES)) - return database_type; - } + if (ha_storage_engine_is_enabled(database_type)) + return database_type; switch (database_type) { #ifndef NO_HASH diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b13851df479..056c2a7ad7f 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2426,8 +2426,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 @@ -3081,7 +3083,8 @@ we force server id to 2, but this MySQL server will not act as a slave."); if (opt_bootstrap) { - int error=bootstrap(stdin); + select_thread_in_use= 0; // Allow 'kill' to work + int error= bootstrap(stdin); end_thr_alarm(1); // Don't allow alarms unireg_abort(error ? 1 : 0); } @@ -6184,9 +6187,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; @@ -6442,10 +6446,14 @@ static void get_options(int argc,char **argv) if (!ha_storage_engine_is_enabled((enum db_type) global_system_variables.table_type)) { - sql_print_error("Default storage engine (%s) is not available", - ha_get_storage_engine((enum db_type) - global_system_variables.table_type)); - exit(1); + 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) diff --git a/sql/set_var.cc b/sql/set_var.cc index 9cf3dcac047..9f63188c28a 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -2985,8 +2985,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; From 2b322f36d8e458927845e81e6585a61e8dfff038 Mon Sep 17 00:00:00 2001 From: "monty@mishka.local" <> Date: Sat, 16 Apr 2005 04:12:30 +0300 Subject: [PATCH 7/7] Ensure that all privilege tables are created in MyISAM --- scripts/mysql_create_system_tables.sh | 1 + scripts/mysql_fix_privilege_tables.sql | 2 ++ 2 files changed, 3 insertions(+) diff --git a/scripts/mysql_create_system_tables.sh b/scripts/mysql_create_system_tables.sh index 993efcb0fda..4c642423879 100644 --- a/scripts/mysql_create_system_tables.sh +++ b/scripts/mysql_create_system_tables.sh @@ -629,6 +629,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 8f398689bd9..0d7d32fd6a9 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,