5.5 merge

This commit is contained in:
Sergei Golubchik 2013-04-14 10:04:07 +02:00
commit f57ecb7786
56 changed files with 767 additions and 177 deletions

View file

@ -5940,15 +5940,12 @@ void Item_func_match::init_search(bool no_order)
{
DBUG_ENTER("Item_func_match::init_search");
if (!table->file->get_table()) // the handler isn't opened yet
DBUG_VOID_RETURN;
/* Check if init_search() has been called before */
if (ft_handler)
{
/*
We should reset ft_handler as it is cleaned up
on destruction of FT_SELECT object
(necessary in case of re-execution of subquery).
TODO: FT_SELECT should not clean up ft_handler.
*/
if (join_key)
table->file->ft_handler= ft_handler;
DBUG_VOID_RETURN;
@ -5957,10 +5954,10 @@ void Item_func_match::init_search(bool no_order)
if (key == NO_SUCH_KEY)
{
List<Item> fields;
fields.push_back(new Item_string(" ",1, cmp_collation.collation));
for (uint i=1; i < arg_count; i++)
fields.push_back(new Item_string(" ", 1, cmp_collation.collation));
for (uint i= 1; i < arg_count; i++)
fields.push_back(args[i]);
concat_ws=new Item_func_concat_ws(fields);
concat_ws= new Item_func_concat_ws(fields);
/*
Above function used only to get value and do not need fix_fields for it:
Item_string - basic constant
@ -5972,10 +5969,10 @@ void Item_func_match::init_search(bool no_order)
if (master)
{
join_key=master->join_key=join_key|master->join_key;
join_key= master->join_key= join_key | master->join_key;
master->init_search(no_order);
ft_handler=master->ft_handler;
join_key=master->join_key;
ft_handler= master->ft_handler;
join_key= master->join_key;
DBUG_VOID_RETURN;
}
@ -5985,7 +5982,7 @@ void Item_func_match::init_search(bool no_order)
if (!(ft_tmp=key_item()->val_str(&value)))
{
ft_tmp= &value;
value.set("",0,cmp_collation.collation);
value.set("", 0, cmp_collation.collation);
}
if (ft_tmp->charset() != cmp_collation.collation)
@ -5998,7 +5995,11 @@ void Item_func_match::init_search(bool no_order)
if (join_key && !no_order)
flags|=FT_SORTED;
ft_handler=table->file->ft_init_ext(flags, key, ft_tmp);
if (key != NO_SUCH_KEY)
thd_proc_info(table->in_use, "FULLTEXT initialization");
ft_handler= table->file->ft_init_ext(flags, key, ft_tmp);
if (join_key)
table->file->ft_handler=ft_handler;

View file

@ -2288,7 +2288,7 @@ static int find_uniq_filename(char *name)
my_dirend(dir_info);
/* check if reached the maximum possible extension number */
if ((max_found == MAX_LOG_UNIQUE_FN_EXT))
if (max_found == MAX_LOG_UNIQUE_FN_EXT)
{
sql_print_error("Log filename extension number exhausted: %06lu. \
Please fix this by archiving old logs and \

View file

@ -1370,7 +1370,7 @@ failed my_b_read"));
Log_event *res= 0;
#ifndef max_allowed_packet
THD *thd=current_thd;
uint max_allowed_packet= thd ? slave_max_allowed_packet:~(ulong)0;
uint max_allowed_packet= thd ? slave_max_allowed_packet:~(uint)0;
#endif
if (data_len > max_allowed_packet)

View file

@ -1648,7 +1648,7 @@ int DsMrr_impl::dsmrr_explain_info(uint mrr_mode, char *str, size_t size)
uint used_str_len= strlen(used_str);
uint copy_len= min(used_str_len, size);
memcpy(str, used_str, size);
memcpy(str, used_str, copy_len);
return copy_len;
}
return 0;

View file

@ -2184,8 +2184,28 @@ static my_socket activate_tcp_port(uint port)
for (a= ai; a != NULL; a= a->ai_next)
{
ip_sock= socket(a->ai_family, a->ai_socktype, a->ai_protocol);
if (ip_sock != INVALID_SOCKET)
char ip_addr[INET6_ADDRSTRLEN];
if (vio_get_normalized_ip_string(a->ai_addr, a->ai_addrlen,
ip_addr, sizeof (ip_addr)))
{
ip_addr[0]= 0;
}
if (ip_sock == INVALID_SOCKET)
{
sql_print_error("Failed to create a socket for %s '%s': errno: %d.",
(a->ai_family == AF_INET) ? "IPv4" : "IPv6",
(const char *) ip_addr,
(int) socket_errno);
}
else
{
sql_print_information("Server socket created on IP: '%s'.",
(const char *) ip_addr);
break;
}
}
if (ip_sock == INVALID_SOCKET)
@ -7801,28 +7821,6 @@ mysqld_get_one_option(int optid,
case (int) OPT_WANT_CORE:
test_flags |= TEST_CORE_ON_SIGNAL;
break;
case (int) OPT_BIND_ADDRESS:
{
struct addrinfo *res_lst, hints;
bzero(&hints, sizeof(struct addrinfo));
hints.ai_socktype= SOCK_STREAM;
hints.ai_protocol= IPPROTO_TCP;
if (getaddrinfo(argument, NULL, &hints, &res_lst) != 0)
{
sql_print_error("Can't start server: cannot resolve hostname!");
return 1;
}
if (res_lst->ai_next)
{
sql_print_error("Can't start server: bind-address refers to multiple interfaces!");
return 1;
}
freeaddrinfo(res_lst);
}
break;
case OPT_CONSOLE:
if (opt_console)
opt_error_log= 0; // Force logs to stdout

View file

@ -132,7 +132,12 @@
static int sel_cmp(Field *f,uchar *a,uchar *b,uint8 a_flag,uint8 b_flag);
static uchar is_null_string[2]= {1,0};
/*
this should be long enough so that any memcmp with a string that
starts from '\0' won't cross is_null_string boundaries, even
if the memcmp is optimized to compare 4- 8- or 16- bytes at once
*/
static uchar is_null_string[20]= {1,0};
class RANGE_OPT_PARAM;
/*
@ -2000,7 +2005,7 @@ int QUICK_ROR_INTERSECT_SELECT::init()
1 error
*/
int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler)
int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler, MEM_ROOT *alloc)
{
handler *save_file= file, *org_file;
my_bool org_key_read;
@ -2028,7 +2033,7 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler)
DBUG_RETURN(0);
}
if (!(file= head->file->clone(head->s->normalized_path.str, thd->mem_root)))
if (!(file= head->file->clone(head->s->normalized_path.str, alloc)))
{
/*
Manually set the error flag. Note: there seems to be quite a few
@ -2129,7 +2134,8 @@ failure:
0 OK
other error code
*/
int QUICK_ROR_INTERSECT_SELECT::init_ror_merged_scan(bool reuse_handler)
int QUICK_ROR_INTERSECT_SELECT::init_ror_merged_scan(bool reuse_handler,
MEM_ROOT *alloc)
{
List_iterator_fast<QUICK_SELECT_WITH_RECORD> quick_it(quick_selects);
QUICK_SELECT_WITH_RECORD *cur;
@ -2146,7 +2152,7 @@ int QUICK_ROR_INTERSECT_SELECT::init_ror_merged_scan(bool reuse_handler)
There is no use of this->file. Use it for the first of merged range
selects.
*/
int error= quick->init_ror_merged_scan(TRUE);
int error= quick->init_ror_merged_scan(TRUE, alloc);
if (error)
DBUG_RETURN(error);
quick->file->extra(HA_EXTRA_KEYREAD_PRESERVE_FIELDS);
@ -2158,7 +2164,7 @@ int QUICK_ROR_INTERSECT_SELECT::init_ror_merged_scan(bool reuse_handler)
const MY_BITMAP * const save_read_set= quick->head->read_set;
const MY_BITMAP * const save_write_set= quick->head->write_set;
#endif
if (quick->init_ror_merged_scan(FALSE))
if (quick->init_ror_merged_scan(FALSE, alloc))
DBUG_RETURN(1);
quick->file->extra(HA_EXTRA_KEYREAD_PRESERVE_FIELDS);
@ -2192,7 +2198,7 @@ int QUICK_ROR_INTERSECT_SELECT::init_ror_merged_scan(bool reuse_handler)
int QUICK_ROR_INTERSECT_SELECT::reset()
{
DBUG_ENTER("QUICK_ROR_INTERSECT_SELECT::reset");
if (!scans_inited && init_ror_merged_scan(TRUE))
if (!scans_inited && init_ror_merged_scan(TRUE, &alloc))
DBUG_RETURN(1);
scans_inited= TRUE;
List_iterator_fast<QUICK_SELECT_WITH_RECORD> it(quick_selects);
@ -2329,7 +2335,7 @@ int QUICK_ROR_UNION_SELECT::reset()
List_iterator_fast<QUICK_SELECT_I> it(quick_selects);
while ((quick= it++))
{
if (quick->init_ror_merged_scan(FALSE))
if (quick->init_ror_merged_scan(FALSE, &alloc))
DBUG_RETURN(1);
}
scans_inited= TRUE;
@ -7373,8 +7379,10 @@ static SEL_TREE *get_mm_tree(RANGE_OPT_PARAM *param,COND *cond)
DBUG_RETURN(tree);
}
/* Here when simple cond */
if (cond->const_item() && !cond->is_expensive())
if (cond->const_item())
{
if (cond->is_expensive())
DBUG_RETURN(0);
/*
During the cond->val_int() evaluation we can come across a subselect
item which may allocate memory on the thd->mem_root and assumes

View file

@ -323,7 +323,7 @@ public:
0 Ok
other Error
*/
virtual int init_ror_merged_scan(bool reuse_handler)
virtual int init_ror_merged_scan(bool reuse_handler, MEM_ROOT *alloc)
{ DBUG_ASSERT(0); return 1; }
/*
@ -473,7 +473,7 @@ public:
uchar *cur_prefix);
bool reverse_sorted() { return 0; }
bool unique_key_range();
int init_ror_merged_scan(bool reuse_handler);
int init_ror_merged_scan(bool reuse_handler, MEM_ROOT *alloc);
void save_last_pos()
{ file->position(record); }
int get_type() { return QS_TYPE_RANGE; }
@ -722,7 +722,7 @@ public:
#ifndef DBUG_OFF
void dbug_dump(int indent, bool verbose);
#endif
int init_ror_merged_scan(bool reuse_handler);
int init_ror_merged_scan(bool reuse_handler, MEM_ROOT *alloc);
bool push_quick_back(MEM_ROOT *alloc, QUICK_RANGE_SELECT *quick_sel_range);
class QUICK_SELECT_WITH_RECORD : public Sql_alloc

View file

@ -1513,6 +1513,9 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
*/
parent_lex->leaf_tables.concat(&subq_lex->leaf_tables);
if (subq_lex->options & OPTION_SCHEMA_TABLE)
parent_lex->options |= OPTION_SCHEMA_TABLE;
/*
Same as above for next_local chain
(a theory: a next_local chain always starts with ::leaf_tables
@ -1730,6 +1733,9 @@ static bool convert_subq_to_jtbm(JOIN *parent_join,
*/
parent_lex->leaf_tables.push_back(jtbm);
if (subq_pred->unit->first_select()->options & OPTION_SCHEMA_TABLE)
parent_lex->options |= OPTION_SCHEMA_TABLE;
/*
Same as above for TABLE_LIST::next_local chain
(a theory: a next_local chain always starts with ::leaf_tables

View file

@ -84,7 +84,7 @@ static ulonglong get_exact_record_count(List<TABLE_LIST> &tables)
while ((tl= ti++))
{
ha_rows tmp= tl->table->file->records();
if ((tmp == HA_POS_ERROR))
if (tmp == HA_POS_ERROR)
return ULONGLONG_MAX;
count*= tmp;
}

View file

@ -9343,7 +9343,6 @@ int init_ftfuncs(THD *thd, SELECT_LEX *select_lex, bool no_order)
List_iterator<Item_func_match> li(*(select_lex->ftfunc_list));
Item_func_match *ifm;
DBUG_PRINT("info",("Performing FULLTEXT search"));
thd_proc_info(thd, "FULLTEXT initialization");
while ((ifm=li++))
ifm->init_search(no_order);

View file

@ -3848,6 +3848,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
DBUG_RETURN(TRUE);
join->join_tab=stat;
join->top_join_tab_count= table_count;
join->map2table=stat_ref;
join->table= table_vector;
join->const_tables=const_count;
@ -3895,6 +3896,8 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
if (join->choose_subquery_plan(all_table_map & ~join->const_table_map))
goto error;
DEBUG_SYNC(join->thd, "inside_make_join_statistics");
/* Generate an execution plan from the found optimal join order. */
DBUG_RETURN(join->thd->check_killed() || get_best_combination(join));
@ -10587,6 +10590,10 @@ bool JOIN_TAB::preread_init()
dbug_serve_apcs(join->thd, 1);
);
/* init ftfuns for just initialized derived table */
if (table->fulltext_searched)
init_ftfuncs(join->thd, join->select_lex, test(join->order));
return FALSE;
}

View file

@ -7451,20 +7451,20 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
break;
case MYSQL_TYPE_DATE:
if (!(item=new Item_return_date_time(fields_info->field_name,
MAX_DATE_WIDTH,
strlen(fields_info->field_name),
fields_info->field_type)))
DBUG_RETURN(0);
break;
case MYSQL_TYPE_TIME:
if (!(item=new Item_return_date_time(fields_info->field_name,
MAX_TIME_FULL_WIDTH,
strlen(fields_info->field_name),
fields_info->field_type)))
DBUG_RETURN(0);
break;
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_DATETIME:
if (!(item=new Item_return_date_time(fields_info->field_name,
MAX_DATETIME_WIDTH,
strlen(fields_info->field_name),
fields_info->field_type)))
DBUG_RETURN(0);
break;

View file

@ -1092,7 +1092,7 @@ static Sys_var_ulonglong Sys_max_binlog_cache_size(
"Sets the total size of the transactional cache",
GLOBAL_VAR(max_binlog_cache_size), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(IO_SIZE, ULONGLONG_MAX),
DEFAULT((UINT_MAX/IO_SIZE)*IO_SIZE),
DEFAULT((ULONGLONG_MAX/IO_SIZE)*IO_SIZE),
BLOCK_SIZE(IO_SIZE));
static Sys_var_ulonglong Sys_max_binlog_stmt_cache_size(
@ -1100,7 +1100,7 @@ static Sys_var_ulonglong Sys_max_binlog_stmt_cache_size(
"Sets the total size of the statement cache",
GLOBAL_VAR(max_binlog_stmt_cache_size), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(IO_SIZE, ULONGLONG_MAX),
DEFAULT((UINT_MAX/IO_SIZE)*IO_SIZE),
DEFAULT((ULONGLONG_MAX/IO_SIZE)*IO_SIZE),
BLOCK_SIZE(IO_SIZE));
static bool fix_max_binlog_size(sys_var *self, THD *thd, enum_var_type type)

View file

@ -3454,9 +3454,9 @@ bool check_column_name(const char *name)
}
#else
last_char_is_space= *name==' ';
#endif
if (*name == NAMES_SEP_CHAR)
if (*name == '\377')
return 1;
#endif
name++;
name_length++;
}