From af19fa462856d517d3a35737389f432fe071a4f6 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 14 Sep 2001 19:50:56 +0300 Subject: Fixed bug in UNION Fixed replication bug in load_master_data BitKeeper/deleted/.del-global.h~e80d28157acfdcb5: Delete: include/global.h Docs/manual.texi: Cleaned up "Things to do in 4.0" mysql-test/r/union.result: New test mysql-test/t/union.test: New test mysys/my_lib.c: Cleanup sql/mysql_priv.h: Fixed replication bug load_master_data sql/sql_base.cc: Fixed bug in UNION sql/sql_db.cc: Fixed replication bug load_master_data sql/sql_parse.cc: Fixed replication bug load_master_data sql/sql_repl.cc: Fixed replication bug load_master_data sql/sql_union.cc: Fixed bug in UNION tools/mysqlmanager.c: Portability fix --- sql/mysql_priv.h | 4 ++-- sql/sql_base.cc | 35 ++++++++++++++++++------------- sql/sql_db.cc | 64 ++++++++++++++++++++++++++++---------------------------- sql/sql_parse.cc | 8 +++---- sql/sql_repl.cc | 7 +++---- sql/sql_union.cc | 5 +++-- 6 files changed, 65 insertions(+), 58 deletions(-) (limited to 'sql') diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 74bb3411773..7151f43904f 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -237,7 +237,8 @@ inline THD *_current_thd(void) #include "opt_range.h" -int mysql_create_db(THD *thd, char *db, uint create_info); +int mysql_create_db(THD *thd, char *db, uint create_info, bool silent); +int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent); void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags); int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists); int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, @@ -262,7 +263,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd, char* packet, uint packet_length); bool check_stack_overrun(THD *thd,char *dummy); bool reload_acl_and_cache(THD *thd, uint options, TABLE_LIST *tables); -int mysql_rm_db(THD *thd,char *db,bool if_exists); void table_cache_init(void); void table_cache_free(void); uint cached_tables(void); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 9ba5277a92c..425c81964bc 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1780,27 +1780,34 @@ bool setup_tables(TABLE_LIST *tables) { DBUG_ENTER("setup_tables"); uint tablenr=0; - for (TABLE_LIST *table=tables ; table ; table=table->next,tablenr++) - { - table->table->tablenr=tablenr; - table->table->map= (table_map) 1 << tablenr; - if ((table->table->outer_join=table->outer_join)) - table->table->maybe_null=1; // LEFT OUTER JOIN ... - if (table->use_index) + for (TABLE_LIST *table_list=tables ; table_list ; + table_list=table_list->next,tablenr++) + { + TABLE *table=table_list->table; + + table->used_fields=0; + table->const_table=0; + table->outer_join=table->null_row=0; + table->status=STATUS_NO_RECORD; + table->keys_in_use_for_query=table->used_keys= table->keys_in_use; + table->maybe_null=test(table->outer_join=table_list->outer_join); + table->tablenr=tablenr; + table->map= (table_map) 1 << tablenr; + if (table_list->use_index) { - key_map map= get_key_map_from_key_list(table->table, - table->use_index); + key_map map= get_key_map_from_key_list(table, + table_list->use_index); if (map == ~(key_map) 0) DBUG_RETURN(1); - table->table->keys_in_use_for_query=map; + table->keys_in_use_for_query=map; } - if (table->ignore_index) + if (table_list->ignore_index) { - key_map map= get_key_map_from_key_list(table->table, - table->ignore_index); + key_map map= get_key_map_from_key_list(table, + table_list->ignore_index); if (map == ~(key_map) 0) DBUG_RETURN(1); - table->table->keys_in_use_for_query &= ~map; + table->keys_in_use_for_query &= ~map; } } if (tablenr > MAX_TABLES) diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 520c6c7e94d..2100b3f8318 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -31,7 +31,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, /* db-name is already validated when we come here */ -int mysql_create_db(THD *thd, char *db, uint create_options) +int mysql_create_db(THD *thd, char *db, uint create_options, bool silent) { char path[FN_REFLEN+16]; MY_DIR *dirp; @@ -56,9 +56,8 @@ int mysql_create_db(THD *thd, char *db, uint create_options) my_dirend(dirp); if (!(create_options & HA_LEX_CREATE_IF_NOT_EXISTS)) { - if (thd) - net_printf(&thd->net,ER_DB_CREATE_EXISTS,db); - error = 1; + my_error(ER_DB_CREATE_EXISTS,MYF(0),db); + error = -1; goto exit; } result = 0; @@ -68,14 +67,13 @@ int mysql_create_db(THD *thd, char *db, uint create_options) strend(path)[-1]=0; // Remove last '/' from path if (my_mkdir(path,0777,MYF(0)) < 0) { - if (thd) - net_printf(&thd->net,ER_CANT_CREATE_DB,db,my_errno); - error = 1; + my_error(ER_CANT_CREATE_DB,MYF(0),db,my_errno); + error = -1; goto exit; } } - if (thd) + if (!silent) { if (!thd->query) { @@ -124,7 +122,7 @@ static TYPELIB known_extentions= */ -int mysql_rm_db(THD *thd,char *db,bool if_exists) +int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) { long deleted=0; int error = 0; @@ -144,16 +142,15 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists) (void) sprintf(path,"%s/%s",mysql_data_home,db); unpack_dirname(path,path); // Convert if not unix /* See if the directory exists */ - if (!(dirp = my_dir(path,MYF(MY_WME | MY_DONT_SORT)))) + if (!(dirp = my_dir(path,MYF(MY_DONT_SORT)))) { - if (thd) + if (!if_exists) { - if (!if_exists) - net_printf(&thd->net,ER_DB_DROP_EXISTS,db); - else - send_ok(&thd->net,0); + error= -1; + my_error(ER_DB_DROP_EXISTS,MYF(0),db); } - error = !if_exists; + else if (!silent) + send_ok(&thd->net,0); goto exit; } remove_db_from_cache(db); @@ -161,24 +158,27 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists) error = -1; if ((deleted=mysql_rm_known_files(thd, dirp, db, path,0)) >= 0 && thd) { - if (!thd->query) - { - thd->query = path; - thd->query_length = (uint) (strxmov(path,"drop database ", db, NullS)- - path); - } - mysql_update_log.write(thd, thd->query, thd->query_length); - if (mysql_bin_log.is_open()) + if (!silent) { - Query_log_event qinfo(thd, thd->query); - mysql_bin_log.write(&qinfo); - } - if (thd->query == path) - { - thd->query = 0; // just in case - thd->query_length = 0; + if (!thd->query) + { + thd->query = path; + thd->query_length = (uint) (strxmov(path,"drop database ", db, NullS)- + path); + } + mysql_update_log.write(thd, thd->query, thd->query_length); + if (mysql_bin_log.is_open()) + { + Query_log_event qinfo(thd, thd->query); + mysql_bin_log.write(&qinfo); + } + if (thd->query == path) + { + thd->query = 0; // just in case + thd->query_length = 0; + } + send_ok(&thd->net,(ulong) deleted); } - send_ok(&thd->net,(ulong) deleted); error = 0; } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index a41ad1ba9ab..251906cf0c5 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -903,7 +903,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, if (check_access(thd,CREATE_ACL,db,0,1)) break; mysql_log.write(thd,command,packet); - mysql_create_db(thd,db,0); + mysql_create_db(thd,db,0,0); break; } case COM_DROP_DB: // QQ: To be removed @@ -921,7 +921,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, break; } mysql_log.write(thd,command,db); - mysql_rm_db(thd,db,0); + mysql_rm_db(thd,db,0,0); break; } case COM_BINLOG_DUMP: @@ -1974,7 +1974,7 @@ mysql_execute_command(void) } if (check_access(thd,CREATE_ACL,lex->name,0,1)) break; - res=mysql_create_db(thd,lex->name,lex->create_info.options); + res=mysql_create_db(thd,lex->name,lex->create_info.options,0); break; } case SQLCOM_DROP_DB: @@ -1991,7 +1991,7 @@ mysql_execute_command(void) send_error(&thd->net,ER_LOCK_OR_ACTIVE_TRANSACTION); goto error; } - res=mysql_rm_db(thd,lex->name,lex->drop_if_exists); + res=mysql_rm_db(thd,lex->name,lex->drop_if_exists,0); break; } case SQLCOM_CREATE_FUNCTION: diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index ff1cb125ef8..1bd84c11c56 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1531,11 +1531,10 @@ int load_master_data(THD* thd) continue; } - if ((drop_error = mysql_rm_db(0, db, 1)) || - mysql_create_db(0, db, 0)) + if (mysql_rm_db(thd, db, 1,1) || + mysql_create_db(thd, db, 0, 1)) { - error = (drop_error) ? ER_DB_DROP_DELETE : ER_CANT_CREATE_DB; - net_printf(&thd->net, error, db, my_error); + send_error(&thd->net, 0, 0); cleanup_mysql_results(db_res, cur_table_res - 1, table_res); goto err; } diff --git a/sql/sql_union.cc b/sql/sql_union.cc index a0a6704b631..8d0c2e6b1e6 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -73,10 +73,11 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) (ORDER*) sl->group_list.first, sl->having, (ORDER*) NULL, - sl->options | thd->options | SELECT_NO_UNLOCK | SELECT_DESCRIBE, + (sl->options | thd->options | SELECT_NO_UNLOCK | + SELECT_DESCRIBE), result); } - return 0; + DBUG_RETURN(0); } order = (ORDER *) last_sl->order_list.first; -- cgit v1.2.1