From d689f2fa702efd1fb5bbde47d16873cd3a8f0283 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Wed, 3 May 2006 19:40:52 +0300 Subject: [PATCH] Cleanups after review of WL#602 Fixed warnings from test suite Some fixes in mysql-test-run script to catch more warnings --- mysql-test/lib/mtr_report.pl | 4 +++- mysql-test/mysql-test-run.sh | 2 +- mysql-test/t/mysqldump.test | 2 +- mysys/errors.c | 4 ++-- sql/handler.cc | 2 +- sql/log.cc | 3 ++- sql/sql_class.h | 6 +++--- sql/sql_lex.h | 2 +- sql/sql_table.cc | 34 +++++++++++++++++++++------------- sql/sql_yacc.yy | 22 +++++++++++----------- 10 files changed, 46 insertions(+), 35 deletions(-) diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl index 4587c8bc385..007cdcdbfd8 100644 --- a/mysql-test/lib/mtr_report.pl +++ b/mysql-test/lib/mtr_report.pl @@ -217,7 +217,9 @@ sub mtr_report_stats ($) { my $found_problems= 0; # Some warnings are errors... # We report different types of problems in order - foreach my $pattern ( "^Warning:", "^Error:", "^==.* at 0x" ) + foreach my $pattern ( "^Warning:", "^Error:", "^==.* at 0x", + "InnoDB: Warning", "missing DBUG_RETURN", + "mysqld: Warning") { foreach my $errlog ( sort glob("$::opt_vardir/log/*.err") ) { diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 7e1ae58a406..7a71c15ae48 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -1079,7 +1079,7 @@ report_stats () { found_error=0 # Find errors - for i in "^Warning:" "^Error:" "^==.* at 0x" "InnoDB: Warning" "missing DBUG_RETURN" + for i in "^Warning:" "^Error:" "^==.* at 0x" "InnoDB: Warning" "missing DBUG_RETURN" "mysqld: Warning" do if $GREP "$i" $MY_LOG_DIR/warnings.tmp >> $MY_LOG_DIR/warnings then diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 5ba7838bb81..d9a73f9056d 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -11,7 +11,7 @@ drop view if exists v1, v2, v3; # XML output -CREATE TABLE t1(a int); +CREATE TABLE t1(a int, key (a)) key_block_size=1024; INSERT INTO t1 VALUES (1), (2); --exec $MYSQL_DUMP --skip-create --skip-comments -X test t1 DROP TABLE t1; diff --git a/mysys/errors.c b/mysys/errors.c index 4472b7173fa..630e4511124 100644 --- a/mysys/errors.c +++ b/mysys/errors.c @@ -39,7 +39,7 @@ const char * NEAR globerrs[GLOBERRS]= "Can't get working dirctory (Errcode: %d)", "Can't change dir to '%s' (Errcode: %d)", "Warning: '%s' had %d links", - "%d files and %d streams is left open\n", + "Warning: %d files and %d streams is left open\n", "Disk is full writing '%s' (Errcode: %d). Waiting for someone to free space... Retry in %d secs", "Can't create directory '%s' (Errcode: %d)", "Character set '%s' is not a compiled character set and is not specified in the '%s' file", @@ -78,7 +78,7 @@ void init_glob_errs() EE(EE_GETWD) = "Can't get working dirctory (Errcode: %d)"; EE(EE_SETWD) = "Can't change dir to '%s' (Errcode: %d)"; EE(EE_LINK_WARNING) = "Warning: '%s' had %d links"; - EE(EE_OPEN_WARNING) = "%d files and %d streams is left open\n"; + EE(EE_OPEN_WARNING) = "Warning: %d files and %d streams is left open\n"; EE(EE_DISK_FULL) = "Disk is full writing '%s'. Waiting for someone to free space..."; EE(EE_CANT_MKDIR) ="Can't create directory '%s' (Errcode: %d)"; EE(EE_UNKNOWN_CHARSET)= "Character set '%s' is not a compiled character set and is not specified in the %s file"; diff --git a/sql/handler.cc b/sql/handler.cc index 5de25b969a8..984d880f4d7 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -47,7 +47,7 @@ extern handlerton *sys_table_types[]; #define BITMAP_STACKBUF_SIZE (128/8) -KEY_CREATE_INFO default_key_create_info= { HA_KEY_ALG_UNDEF, 0 }; +KEY_CREATE_INFO default_key_create_info= { HA_KEY_ALG_UNDEF, 0, {NullS,0} }; /* static functions defined in this file */ diff --git a/sql/log.cc b/sql/log.cc index 818abe89e02..223ceccf5d8 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1084,7 +1084,7 @@ binlog_end_trans(THD *thd, binlog_trx_data *trx_data, Log_event *end_ev) were, we would have to ensure that we're not ending a statement inside a stored function. */ - thd->binlog_flush_pending_rows_event(true); + thd->binlog_flush_pending_rows_event(TRUE); error= mysql_bin_log.write(thd, trans_log, end_ev); } else @@ -1480,6 +1480,7 @@ const char *MYSQL_LOG::generate_name(const char *log_name, return log_name; } + bool MYSQL_LOG::open_index_file(const char *index_file_name_arg, const char *log_name) { diff --git a/sql/sql_class.h b/sql/sql_class.h index 937457abc64..54f256997d0 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -112,7 +112,7 @@ class Key :public Sql_alloc { public: enum Keytype { PRIMARY, UNIQUE, MULTIPLE, FULLTEXT, SPATIAL, FOREIGN_KEY}; enum Keytype type; - KEY_CREATE_INFO key_info; + KEY_CREATE_INFO key_create_info; List columns; const char *name; bool generated; @@ -120,8 +120,8 @@ public: Key(enum Keytype type_par, const char *name_arg, KEY_CREATE_INFO *key_info_arg, bool generated_arg, List &cols) - :type(type_par), key_info(*key_info_arg), columns(cols), name(name_arg), - generated(generated_arg) + :type(type_par), key_create_info(*key_info_arg), columns(cols), + name(name_arg), generated(generated_arg) {} ~Key() {} /* Equality comparison of keys (ignoring name) */ diff --git a/sql/sql_lex.h b/sql/sql_lex.h index a7f9aa8ac5e..f0bd85367d0 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -840,7 +840,7 @@ typedef struct st_lex udf_func udf; HA_CHECK_OPT check_opt; // check/repair options HA_CREATE_INFO create_info; - KEY_CREATE_INFO key_info; + KEY_CREATE_INFO key_create_info; LEX_MASTER_INFO mi; // used by CHANGE MASTER USER_RESOURCES mqh; ulong type; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 6225cda3e1c..1782dc5a226 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -231,7 +231,7 @@ static int mysql_copy_key_list(List *orig_key, } } if (!(temp_key= new Key(prep_key->type, prep_key->name, - &prep_key->key_info, + &prep_key->key_create_info, prep_key->generated, prep_columns))) { @@ -507,12 +507,14 @@ bool read_ddl_log_entry(uint read_entry, DDL_LOG_ENTRY *ddl_log_entry) Initialise ddl log SYNOPSIS init_ddl_log() - RETURN VALUES - TRUE Error - FALSE Success + DESCRIPTION Write the header of the ddl log file and length of names. Also set number of entries to zero. + + RETURN VALUES + TRUE Error + FALSE Success */ static bool init_ddl_log() @@ -522,9 +524,8 @@ static bool init_ddl_log() DBUG_ENTER("init_ddl_log"); if (global_ddl_log.inited) - { - DBUG_RETURN(FALSE); - } + goto end; + global_ddl_log.io_size= IO_SIZE; create_ddl_log_file_name(file_name); if ((global_ddl_log.file_id= my_create(file_name, @@ -539,9 +540,12 @@ static bool init_ddl_log() global_ddl_log.inited= TRUE; if (write_ddl_log_header()) { + VOID(my_close(global_ddl_log.file_id, MYF(MY_WME))); global_ddl_log.inited= FALSE; DBUG_RETURN(TRUE); } + +end: DBUG_RETURN(FALSE); } @@ -1129,7 +1133,11 @@ void release_ddl_log() my_free((char*)free_list, MYF(0)); free_list= tmp; } - VOID(my_close(global_ddl_log.file_id, MYF(0))); + if (global_ddl_log.inited) + { + global_ddl_log.inited= 0; + VOID(my_close(global_ddl_log.file_id, MYF(MY_WME))); + } pthread_mutex_unlock(&LOCK_gdl); VOID(pthread_mutex_destroy(&LOCK_gdl)); DBUG_VOID_RETURN; @@ -2500,7 +2508,7 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, break; case Key::FULLTEXT: key_info->flags= HA_FULLTEXT; - if ((key_info->parser_name= &key->key_info.parser_name)->str) + if ((key_info->parser_name= &key->key_create_info.parser_name)->str) key_info->flags|= HA_USES_PARSER; else key_info->parser_name= 0; @@ -2527,7 +2535,7 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, key_info->key_parts=(uint8) key->columns.elements; key_info->key_part=key_part_info; key_info->usable_key_parts= key_number; - key_info->algorithm= key->key_info.algorithm; + key_info->algorithm= key->key_create_info.algorithm; if (key->type == Key::FULLTEXT) { @@ -2578,8 +2586,8 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, TODO: Add warning if block size changes. We can't do it here, as this may depend on the size of the key */ - key_info->block_size= (key->key_info.block_size ? - key->key_info.block_size : + key_info->block_size= (key->key_create_info.block_size ? + key->key_create_info.block_size : create_info->key_block_size); if (key_info->block_size) @@ -5476,7 +5484,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, while ((prep_col= prep_col_it++)) prep_columns.push_back(new key_part_spec(*prep_col)); prepared_key_list.push_back(new Key(prep_key->type, prep_key->name, - &prep_key->key_info, + &prep_key->key_create_info, prep_key->generated, prep_columns)); } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 75a588a2bc4..5bca2fbf2b7 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1239,12 +1239,12 @@ create: '(' key_list ')' key_options { LEX *lex=Lex; - if ($2 != Key::FULLTEXT && lex->key_info.parser_name.str) + if ($2 != Key::FULLTEXT && lex->key_create_info.parser_name.str) { yyerror(ER(ER_SYNTAX_ERROR)); YYABORT; } - lex->key_list.push_back(new Key($2, $4.str, &lex->key_info, 0, + lex->key_list.push_back(new Key($2, $4.str, &lex->key_create_info, 0, lex->col_list)); lex->col_list.empty(); } @@ -3996,12 +3996,12 @@ key_def: key_type opt_ident key_alg '(' key_list ')' key_options { LEX *lex=Lex; - if ($1 != Key::FULLTEXT && lex->key_info.parser_name.str) + if ($1 != Key::FULLTEXT && lex->key_create_info.parser_name.str) { yyerror(ER(ER_SYNTAX_ERROR)); YYABORT; } - lex->key_list.push_back(new Key($1,$2, &lex->key_info, 0, + lex->key_list.push_back(new Key($1,$2, &lex->key_create_info, 0, lex->col_list)); lex->col_list.empty(); /* Alloced by sql_alloc */ } @@ -4010,7 +4010,7 @@ key_def: { LEX *lex=Lex; const char *key_name= $3 ? $3 : $1; - lex->key_list.push_back(new Key($2, key_name, &lex->key_info, 0, + lex->key_list.push_back(new Key($2, key_name, &lex->key_create_info, 0, lex->col_list)); lex->col_list.empty(); /* Alloced by sql_alloc */ } @@ -4516,12 +4516,12 @@ opt_unique_or_fulltext: init_key_options: { - Lex->key_info= default_key_create_info; + Lex->key_create_info= default_key_create_info; } ; /* - For now, key_alg initializies lex->key_info. + For now, key_alg initializies lex->key_create_info. In the future, when all key options are after key definition, we can remove key_alg and move init_key_options to key_options */ @@ -4542,14 +4542,14 @@ key_opts: ; key_opt: - USING opt_btree_or_rtree { Lex->key_info.algorithm= $2; } - | TYPE_SYM opt_btree_or_rtree { Lex->key_info.algorithm= $2; } + USING opt_btree_or_rtree { Lex->key_create_info.algorithm= $2; } + | TYPE_SYM opt_btree_or_rtree { Lex->key_create_info.algorithm= $2; } | KEY_BLOCK_SIZE opt_equal ulong_num - { Lex->key_info.block_size= $3; } + { Lex->key_create_info.block_size= $3; } | WITH PARSER_SYM IDENT_sys { if (plugin_is_ready(&$3, MYSQL_FTPARSER_PLUGIN)) - Lex->key_info.parser_name= $3; + Lex->key_create_info.parser_name= $3; else { my_error(ER_FUNCTION_NOT_DEFINED, MYF(0), $3.str);