From 3bde13932ee53ee765a858e4413bc6c6af296d4b Mon Sep 17 00:00:00 2001 From: Monty Date: Sun, 3 Aug 2014 15:12:10 +0300 Subject: [PATCH] Minor cleanups, fix compiler warnings --- extra/my_print_defaults.c | 11 ++++++++--- sql/events.cc | 4 +++- sql/handler.cc | 5 ++--- sql/sql_class.cc | 4 ++-- storage/innobase/include/dict0dict.ic | 6 +++--- storage/innobase/include/dict0pagecompress.ic | 2 +- storage/innobase/include/fsp0fsp.ic | 2 +- storage/xtradb/include/dict0dict.ic | 6 +++--- storage/xtradb/include/dict0pagecompress.ic | 2 +- storage/xtradb/include/fsp0fsp.ic | 2 +- 10 files changed, 25 insertions(+), 19 deletions(-) diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c index e91163dde1c..bfd0c3c635a 100644 --- a/extra/my_print_defaults.c +++ b/extra/my_print_defaults.c @@ -98,6 +98,11 @@ static struct my_option my_long_options[] = {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; +void cleanup_and_exit(int exit_code) +{ + my_end(0); + exit(exit_code); +} static void usage(my_bool version) { @@ -112,7 +117,7 @@ static void usage(my_bool version) my_print_default_files(config_file); my_print_variables(my_long_options); printf("\nExample usage:\n%s --defaults-file=example.cnf client client-server mysql\n", my_progname); - exit(0); + cleanup_and_exit(0); } @@ -125,7 +130,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), opt_defaults_file_used= 1; break; case 'n': - exit(0); + cleanup_and_exit(0); case 'I': case '?': usage(0); @@ -174,7 +179,7 @@ int main(int argc, char **argv) /* Check out the args */ if (get_options(&argc,&argv)) - exit(1); + cleanup_and_exit(1); nargs= argc + 1; if (opt_mysqld) diff --git a/sql/events.cc b/sql/events.cc index 63627b21777..a81447396d4 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -270,6 +270,7 @@ common_1_lev_code: static int create_query_string(THD *thd, String *buf) { + buf->length(0); /* Append the "CREATE" part of the query */ if (buf->append(STRING_WITH_LEN("CREATE "))) return 1; @@ -380,7 +381,8 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, { /* Binlog the create event. */ DBUG_ASSERT(thd->query() && thd->query_length()); - String log_query; + char buffer[1024]; + String log_query(buffer, sizeof(buffer), &my_charset_bin); if (create_query_string(thd, &log_query)) { sql_print_error("Event Error: An error occurred while creating query " diff --git a/sql/handler.cc b/sql/handler.cc index 56e7da6430d..cc8fa528251 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1414,11 +1414,10 @@ int ha_commit_trans(THD *thd, bool all) err= ht->prepare(ht, thd, all); status_var_increment(thd->status_var.ha_prepare_count); if (err) + { my_error(ER_ERROR_DURING_COMMIT, MYF(0), err); - - if (err) goto err; - + } need_prepare_ordered|= (ht->prepare_ordered != NULL); need_commit_ordered|= (ht->commit_ordered != NULL); } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 8d6ddc0bb08..b0760b1615c 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1355,8 +1355,8 @@ void THD::init(void) mysql_mutex_lock(&LOCK_global_system_variables); plugin_thdvar_init(this); /* - variables= global_system_variables above has reset - variables.pseudo_thread_id to 0. We need to correct it here to + plugin_thd_var_init() sets variables= global_system_variables, which + has reset variables.pseudo_thread_id to 0. We need to correct it here to avoid temporary tables replication failure. */ variables.pseudo_thread_id= thread_id; diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic index 497a3bd86e6..84d5c57f720 100644 --- a/storage/innobase/include/dict0dict.ic +++ b/storage/innobase/include/dict0dict.ic @@ -647,7 +647,7 @@ dict_tf_is_valid( if (atomic_writes) { - if(atomic_writes < 0 || atomic_writes > ATOMIC_WRITES_OFF) { + if(atomic_writes > ATOMIC_WRITES_OFF) { fprintf(stderr, "InnoDB: Error: table flags are %ld in the data dictionary and are corrupted\n" @@ -689,7 +689,7 @@ dict_sys_tables_type_validate( ulint page_compression_level = DICT_TF_GET_PAGE_COMPRESSION_LEVEL(type); ulint atomic_writes = DICT_TF_GET_ATOMIC_WRITES(type); - ut_a(atomic_writes >= 0 && atomic_writes <= ATOMIC_WRITES_OFF); + ut_a(atomic_writes <= ATOMIC_WRITES_OFF); /* The low order bit of SYS_TABLES.TYPE is always set to 1. If the format is UNIV_FORMAT_B or higher, this field is the same @@ -768,7 +768,7 @@ dict_sys_tables_type_validate( } /* Validate that the atomic writes number is within allowed range. */ - if (atomic_writes < 0 || atomic_writes > ATOMIC_WRITES_OFF) { + if (atomic_writes > ATOMIC_WRITES_OFF) { fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=%lu, atomic_writes %lu\n", type, atomic_writes); return(ULINT_UNDEFINED); diff --git a/storage/innobase/include/dict0pagecompress.ic b/storage/innobase/include/dict0pagecompress.ic index ea3c7546850..811976434a8 100644 --- a/storage/innobase/include/dict0pagecompress.ic +++ b/storage/innobase/include/dict0pagecompress.ic @@ -122,7 +122,7 @@ dict_tf_get_page_compression_level( { ulint page_compression_level = DICT_TF_GET_PAGE_COMPRESSION_LEVEL(flags); - ut_ad(page_compression_level >= 0 && page_compression_level <= 9); + ut_ad(page_compression_level <= 9); return(page_compression_level); } diff --git a/storage/innobase/include/fsp0fsp.ic b/storage/innobase/include/fsp0fsp.ic index fb253370b6e..3a3eb21a61a 100644 --- a/storage/innobase/include/fsp0fsp.ic +++ b/storage/innobase/include/fsp0fsp.ic @@ -131,7 +131,7 @@ fsp_flags_is_valid( } } - if (atomic_writes < 0 || atomic_writes > ATOMIC_WRITES_OFF) { + if (atomic_writes > ATOMIC_WRITES_OFF) { fprintf(stderr, "InnoDB: Error: Tablespace flags %lu corrupted atomic_writes %lu\n", flags, atomic_writes); return (false); diff --git a/storage/xtradb/include/dict0dict.ic b/storage/xtradb/include/dict0dict.ic index 435b244ec3d..2b698dd7218 100644 --- a/storage/xtradb/include/dict0dict.ic +++ b/storage/xtradb/include/dict0dict.ic @@ -651,7 +651,7 @@ dict_tf_is_valid( if (atomic_writes) { - if(atomic_writes < 0 || atomic_writes > ATOMIC_WRITES_OFF) { + if(atomic_writes > ATOMIC_WRITES_OFF) { fprintf(stderr, "InnoDB: Error: table flags are %ld in the data dictionary and are corrupted\n" @@ -693,7 +693,7 @@ dict_sys_tables_type_validate( ulint page_compression_level = DICT_TF_GET_PAGE_COMPRESSION_LEVEL(type); ulint atomic_writes = DICT_TF_GET_ATOMIC_WRITES(type); - ut_a(atomic_writes >= 0 && atomic_writes <= ATOMIC_WRITES_OFF); + ut_a(atomic_writes <= ATOMIC_WRITES_OFF); /* The low order bit of SYS_TABLES.TYPE is always set to 1. If the format is UNIV_FORMAT_B or higher, this field is the same @@ -772,7 +772,7 @@ dict_sys_tables_type_validate( } /* Validate that the atomic writes number is within allowed range. */ - if (atomic_writes < 0 || atomic_writes > ATOMIC_WRITES_OFF) { + if (atomic_writes > ATOMIC_WRITES_OFF) { fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=%lu, atomic_writes %lu\n", type, atomic_writes); return(ULINT_UNDEFINED); diff --git a/storage/xtradb/include/dict0pagecompress.ic b/storage/xtradb/include/dict0pagecompress.ic index ea3c7546850..811976434a8 100644 --- a/storage/xtradb/include/dict0pagecompress.ic +++ b/storage/xtradb/include/dict0pagecompress.ic @@ -122,7 +122,7 @@ dict_tf_get_page_compression_level( { ulint page_compression_level = DICT_TF_GET_PAGE_COMPRESSION_LEVEL(flags); - ut_ad(page_compression_level >= 0 && page_compression_level <= 9); + ut_ad(page_compression_level <= 9); return(page_compression_level); } diff --git a/storage/xtradb/include/fsp0fsp.ic b/storage/xtradb/include/fsp0fsp.ic index 3563f5ef372..ddcb87b0e57 100644 --- a/storage/xtradb/include/fsp0fsp.ic +++ b/storage/xtradb/include/fsp0fsp.ic @@ -135,7 +135,7 @@ fsp_flags_is_valid( } } - if (atomic_writes < 0 || atomic_writes > ATOMIC_WRITES_OFF) { + if (atomic_writes > ATOMIC_WRITES_OFF) { fprintf(stderr, "InnoDB: Error: Tablespace flags %lu corrupted atomic_writes %lu\n", flags, atomic_writes); return (false);