From 0914b0125bec4dd003c0ccd4d8ad0a8ff97b38ee Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Apr 2005 15:43:29 -0700 Subject: [PATCH 1/5] Don't allow the server to start up when an invalid user is specified via --user or in configuration. (Bug #9833) sql/mysqld.cc: Actually die if we an invalid user is specified. --- 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 e687d6beae78b980d984fdbfb518c494295d5200 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Apr 2005 18:25:31 -0700 Subject: [PATCH 2/5] Check that the default storage engine is really available, and refuse to start up if it is not. (Bug #9815) sql/handler.cc: Add ha_storage_engine_is_enabled function. sql/handler.h: Declare ha_storage_engine_is_enabled() sql/mysqld.cc: Abort startup if the specified default storage engine is not available. --- 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 65e4b8ff3b4838814888acdb61d4acdc49812546 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Apr 2005 17:22:18 -0700 Subject: [PATCH 3/5] 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: Use shell function instead of less portable alias command to create replacements for LSB functions, and also use argument in our replacements. --- 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 b112ccb58364631fa2af34dced30fc578d92ed8c Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Apr 2005 15:52:07 +0200 Subject: [PATCH 4/5] 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 6b75a704e8534b54f31abf7ce013d94f6d1c380d Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Apr 2005 16:14:08 +0200 Subject: [PATCH 5/5] 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);