diff options
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r-- | sql/sql_class.cc | 52 |
1 files changed, 45 insertions, 7 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 7a4f3dff845..07c894dc8c1 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -81,7 +81,6 @@ extern "C" void free_user_var(user_var_entry *entry) my_free((char*) entry,MYF(0)); } - bool key_part_spec::operator==(const key_part_spec& other) const { return length == other.length && !strcmp(field_name, other.field_name); @@ -161,8 +160,9 @@ bool foreign_key_prefix(Key *a, Key *b) THD::THD():user_time(0), current_arena(0), is_fatal_error(0), last_insert_id_used(0), - insert_id_used(0), rand_used(0), in_lock_tables(0), - global_read_lock(0), bootstrap(0), spcont(NULL) + insert_id_used(0), rand_used(0), time_zone_used(0), + in_lock_tables(0), global_read_lock(0), bootstrap(0), + spcont(NULL) { host= user= priv_user= db= ip= 0; catalog= (char*)"std"; // the only catalog we have for now @@ -186,6 +186,7 @@ THD::THD():user_time(0), current_arena(0), is_fatal_error(0), current_linfo = 0; slave_thread = 0; variables.pseudo_thread_id= 0; + one_shot_set= 0; file_id = 0; warn_id= 0; db_charset= global_system_variables.collation_database; @@ -762,7 +763,7 @@ bool select_send::send_data(List<Item> &items) } } thd->sent_row_count++; - if (!thd->net.vio) + if (!thd->vio_ok()) DBUG_RETURN(0); if (!thd->net.report_error) DBUG_RETURN(protocol->write()); @@ -1352,7 +1353,9 @@ Statement::Statement(THD *thd) lex(&main_lex), query(0), query_length(0) -{} +{ + name.str= NULL; +} /* This constructor is called when statement is a subobject of THD: @@ -1431,17 +1434,52 @@ static void delete_statement_as_hash_key(void *key) delete (Statement *) key; } +static byte *get_stmt_name_hash_key(Statement *entry, uint *length, + my_bool not_used __attribute__((unused))) +{ + *length=(uint) entry->name.length; + return (byte*) entry->name.str; +} + C_MODE_END Statement_map::Statement_map() : last_found_statement(0) { - enum { START_HASH_SIZE = 16 }; - hash_init(&st_hash, default_charset_info, START_HASH_SIZE, 0, 0, + enum + { + START_STMT_HASH_SIZE = 16, + START_NAME_HASH_SIZE = 16 + }; + hash_init(&st_hash, default_charset_info, START_STMT_HASH_SIZE, 0, 0, get_statement_id_as_hash_key, delete_statement_as_hash_key, MYF(0)); + hash_init(&names_hash, &my_charset_bin, START_NAME_HASH_SIZE, 0, 0, + (hash_get_key) get_stmt_name_hash_key, + NULL,MYF(0)); } +int Statement_map::insert(Statement *statement) +{ + int rc= my_hash_insert(&st_hash, (byte *) statement); + if (rc == 0) + last_found_statement= statement; + if (statement->name.str) + { + /* + If there is a statement with the same name, remove it. It is ok to + remove old and fail to insert new one at the same time. + */ + Statement *old_stmt; + if ((old_stmt= find_by_name(&statement->name))) + erase(old_stmt); + if ((rc= my_hash_insert(&names_hash, (byte*)statement))) + hash_delete(&st_hash, (byte*)statement); + } + return rc; +} + + bool select_dumpvar::send_data(List<Item> &items) { List_iterator_fast<Item_func_set_user_var> li(vars); |