summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-04-27 21:04:06 +0200
committerSergei Golubchik <serg@mariadb.org>2015-04-27 21:04:06 +0200
commit0f12ada6b6a390b8663151f5d8cfae2e6dc9c2bb (patch)
tree5af5b81499f6137f45a37fc77cc518e40fd4ad72 /sql
parente4df6e5799eec20a16e279f7e74e95f18cd475fe (diff)
parente02fe87f00dc9fdb0fb6ab13f2e87485f79f3341 (diff)
downloadmariadb-git-0f12ada6b6a390b8663151f5d8cfae2e6dc9c2bb.tar.gz
Merge remote-tracking branch 'mysql/5.5' into 5.5
Diffstat (limited to 'sql')
-rw-r--r--sql/item.h8
-rw-r--r--sql/mysqld.cc7
-rw-r--r--sql/slave.cc22
-rw-r--r--sql/sp.cc11
-rw-r--r--sql/sql_base.cc6
-rw-r--r--sql/sql_class.cc29
-rw-r--r--sql/sql_class.h9
-rw-r--r--sql/sql_select.cc46
-rw-r--r--sql/sql_table.cc8
-rw-r--r--sql/sql_truncate.cc8
-rw-r--r--sql/sql_yacc.yy11
-rw-r--r--sql/sys_vars.cc8
12 files changed, 125 insertions, 48 deletions
diff --git a/sql/item.h b/sql/item.h
index 2d7236615a8..458db5e0174 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -1,8 +1,8 @@
#ifndef SQL_ITEM_INCLUDED
#define SQL_ITEM_INCLUDED
-/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
- Copyright (c) 2009, 2013 Monty Program Ab.
+/* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2015 Monty Program Ab.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -4103,7 +4103,11 @@ public:
collation.set(item->collation);
unsigned_flag= item->unsigned_flag;
if (item->type() == FIELD_ITEM)
+ {
cached_field= ((Item_field *)item)->field;
+ if (cached_field->table)
+ used_table_map= cached_field->table->map;
+ }
return 0;
};
enum Type type() const { return CACHE_ITEM; }
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 00ddaecd4b7..9d1ba6c66fd 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2014, Oracle and/or its affiliates.
- Copyright (c) 2008, 2014, SkySQL Ab.
+/* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
+ Copyright (c) 2008, 2015, SkySQL Ab.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -3607,6 +3607,9 @@ static int init_common_variables()
return 1;
set_server_version();
+ sql_print_information("%s (mysqld %s) starting as process %lu ...",
+ my_progname, server_version, (ulong) getpid());
+
#ifndef EMBEDDED_LIBRARY
if (opt_abort && !opt_verbose)
unireg_abort(0);
diff --git a/sql/slave.cc b/sql/slave.cc
index f224de2e1ff..a03deb1e793 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
- Copyright (c) 2008, 2014, SkySQL Ab.
+/* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
+ Copyright (c) 2008, 2015, SkySQL Ab.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -4717,7 +4717,23 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi,
}
#endif
- mysql_options(mysql, MYSQL_SET_CHARSET_NAME, default_charset_info->csname);
+ /*
+ If server's default charset is not supported (like utf16, utf32) as client
+ charset, then set client charset to 'latin1' (default client charset).
+ */
+ if (is_supported_parser_charset(default_charset_info))
+ mysql_options(mysql, MYSQL_SET_CHARSET_NAME, default_charset_info->csname);
+ else
+ {
+ sql_print_information("'%s' can not be used as client character set. "
+ "'%s' will be used as default client character set "
+ "while connecting to master.",
+ default_charset_info->csname,
+ default_client_charset_info->csname);
+ mysql_options(mysql, MYSQL_SET_CHARSET_NAME,
+ default_client_charset_info->csname);
+ }
+
/* This one is not strictly needed but we have it here for completeness */
mysql_options(mysql, MYSQL_SET_CHARSET_DIR, (char *) charsets_dir);
diff --git a/sql/sp.cc b/sql/sp.cc
index 13f027493b4..873812c19b3 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -1,5 +1,6 @@
/*
- Copyright (c) 2002, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2002, 2015, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2015, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -1494,6 +1495,14 @@ bool lock_db_routines(THD *thd, char *db)
{
char *sp_name= get_field(thd->mem_root,
table->field[MYSQL_PROC_FIELD_NAME]);
+ if (sp_name == NULL)
+ {
+ table->file->ha_index_end();
+ my_error(ER_SP_WRONG_NAME, MYF(0), "");
+ close_system_tables(thd, &open_tables_state_backup);
+ DBUG_RETURN(true);
+ }
+
longlong sp_type= table->field[MYSQL_PROC_MYSQL_TYPE]->val_int();
MDL_request *mdl_request= new (thd->mem_root) MDL_request;
mdl_request->init(sp_type == TYPE_ENUM_FUNCTION ?
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index ea1eb0aa98e..affccf09513 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
- Copyright (c) 2010, 2013 Monty Program Ab
+/* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
+ Copyright (c) 2010, 2015, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -4106,7 +4106,7 @@ request_backoff_action(enum_open_table_action action_arg,
if (action_arg != OT_REOPEN_TABLES && m_has_locks)
{
my_error(ER_LOCK_DEADLOCK, MYF(0));
- mark_transaction_to_rollback(m_thd, true);
+ m_thd->mark_transaction_to_rollback(true);
return TRUE;
}
/*
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index f5a548064e1..76b2031f553 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2000, 2013, Oracle and/or its affiliates.
- Copyright (c) 2008, 2014, SkySQL Ab.
+ Copyright (c) 2000, 2015, Oracle and/or its affiliates.
+ Copyright (c) 2008, 2015, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -815,7 +815,7 @@ THD::THD()
failed_com_change_user(0),
is_fatal_error(0),
transaction_rollback_request(0),
- is_fatal_sub_stmt_error(0),
+ is_fatal_sub_stmt_error(false),
rand_used(0),
time_zone_used(0),
in_lock_tables(0),
@@ -4045,7 +4045,8 @@ extern "C" int thd_binlog_format(const MYSQL_THD thd)
extern "C" void thd_mark_transaction_to_rollback(MYSQL_THD thd, bool all)
{
- mark_transaction_to_rollback(thd, all);
+ DBUG_ASSERT(thd);
+ thd->mark_transaction_to_rollback(all);
}
extern "C" bool thd_binlog_filter_ok(const MYSQL_THD thd)
@@ -4241,9 +4242,12 @@ void THD::restore_sub_statement_state(Sub_statement_state *backup)
If we've left sub-statement mode, reset the fatal error flag.
Otherwise keep the current value, to propagate it up the sub-statement
stack.
+
+ NOTE: is_fatal_sub_stmt_error can be set only if we've been in the
+ sub-statement mode.
*/
if (!in_sub_stmt)
- is_fatal_sub_stmt_error= FALSE;
+ is_fatal_sub_stmt_error= false;
if ((variables.option_bits & OPTION_BIN_LOG) && is_update_query(lex->sql_command) &&
!is_current_stmt_binlog_format_row())
@@ -4353,17 +4357,18 @@ void THD::get_definer(LEX_USER *definer)
/**
Mark transaction to rollback and mark error as fatal to a sub-statement.
- @param thd Thread handle
@param all TRUE <=> rollback main transaction.
*/
-void mark_transaction_to_rollback(THD *thd, bool all)
+void THD::mark_transaction_to_rollback(bool all)
{
- if (thd)
- {
- thd->is_fatal_sub_stmt_error= TRUE;
- thd->transaction_rollback_request= all;
- }
+ /*
+ There is no point in setting is_fatal_sub_stmt_error unless
+ we are actually in_sub_stmt.
+ */
+ if (in_sub_stmt)
+ is_fatal_sub_stmt_error= true;
+ transaction_rollback_request= all;
}
/***************************************************************************
Handling of XA id cacheing
diff --git a/sql/sql_class.h b/sql/sql_class.h
index c031c265e7e..67db1662f10 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2000, 2013, Oracle and/or its affiliates.
- Copyright (c) 2009, 2013, Monty Program Ab
+ Copyright (c) 2000, 2015, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2014, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -700,8 +700,6 @@ void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var);
void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var,
STATUS_VAR *dec_var);
-void mark_transaction_to_rollback(THD *thd, bool all);
-
#ifdef MYSQL_SERVER
void free_tmp_table(THD *thd, TABLE *entry);
@@ -3121,6 +3119,7 @@ public:
mysql_mutex_unlock(&LOCK_status);
}
+ void mark_transaction_to_rollback(bool all);
private:
/** The current internal error handler for this thread, or NULL. */
@@ -4163,8 +4162,6 @@ public:
*/
#define CF_SKIP_QUESTIONS (1U << 1)
-void mark_transaction_to_rollback(THD *thd, bool all);
-
/* Inline functions */
inline bool add_item_to_list(THD *thd, Item *item)
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 3567c9c2bbd..0373f0baba0 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2014 Oracle and/or its affiliates.
+/* Copyright (c) 2000, 2015 Oracle and/or its affiliates.
Copyright (c) 2009, 2015 MariaDB
This program is free software; you can redistribute it and/or modify
@@ -20309,18 +20309,33 @@ SORT_FIELD *make_unireg_sortorder(ORDER *order, uint *length,
for (;order;order=order->next,pos++)
{
- Item *item= order->item[0]->real_item();
+ Item *const item= order->item[0], *const real_item= item->real_item();
pos->field= 0; pos->item= 0;
- if (item->type() == Item::FIELD_ITEM)
- pos->field= ((Item_field*) item)->field;
- else if (item->type() == Item::SUM_FUNC_ITEM && !item->const_item())
- pos->field= ((Item_sum*) item)->get_tmp_table_field();
- else if (item->type() == Item::COPY_STR_ITEM)
- { // Blob patch
- pos->item= ((Item_copy*) item)->get_item();
+ if (real_item->type() == Item::FIELD_ITEM)
+ {
+ // Could be a field, or Item_direct_view_ref wrapping a field
+ DBUG_ASSERT(item->type() == Item::FIELD_ITEM ||
+ (item->type() == Item::REF_ITEM &&
+ static_cast<Item_ref*>(item)->ref_type() ==
+ Item_ref::VIEW_REF));
+ pos->field= static_cast<Item_field*>(real_item)->field;
+ }
+ else if (real_item->type() == Item::SUM_FUNC_ITEM &&
+ !real_item->const_item())
+ {
+ // Aggregate, or Item_aggregate_ref
+ DBUG_ASSERT(item->type() == Item::SUM_FUNC_ITEM ||
+ (item->type() == Item::REF_ITEM &&
+ static_cast<Item_ref*>(item)->ref_type() ==
+ Item_ref::AGGREGATE_REF));
+ pos->field= item->get_tmp_table_field();
+ }
+ else if (real_item->type() == Item::COPY_STR_ITEM)
+ { // Blob patch
+ pos->item= static_cast<Item_copy*>(real_item)->get_item();
}
else
- pos->item= *order->item;
+ pos->item= item;
pos->reverse=! order->asc;
}
*length=count;
@@ -20562,6 +20577,17 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
uint el= all_fields.elements;
all_fields.push_front(order_item); /* Add new field to field list. */
ref_pointer_array[el]= order_item;
+ /*
+ If the order_item is a SUM_FUNC_ITEM, when fix_fields is called
+ ref_by is set to order->item which is the address of order_item.
+ But this needs to be address of order_item in the all_fields list.
+ As a result, when it gets replaced with Item_aggregate_ref
+ object in Item::split_sum_func2, we will be able to retrieve the
+ newly created object.
+ */
+ if (order_item->type() == Item::SUM_FUNC_ITEM)
+ ((Item_sum *)order_item)->ref_by= all_fields.head_ref();
+
order->item= ref_pointer_array + el;
return FALSE;
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 477ecf4a350..586b542a290 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2000, 2013, Oracle and/or its affiliates.
- Copyright (c) 2010, 2014, SkySQL Ab.
+ Copyright (c) 2000, 2015, Oracle and/or its affiliates.
+ Copyright (c) 2010, 2015, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -5580,6 +5580,10 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
if (!(used_fields & HA_CREATE_USED_TRANSACTIONAL))
create_info->transactional= table->s->transactional;
+ /* Creation of federated table with LIKE clause needs connection string */
+ if (!(used_fields & HA_CREATE_USED_CONNECTION))
+ create_info->connect_string= table->s->connect_string;
+
restore_record(table, s->default_values); // Empty record for DEFAULT
create_info->option_list= merge_engine_table_options(table->s->option_list,
diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc
index 92fc4205656..9b37996f377 100644
--- a/sql/sql_truncate.cc
+++ b/sql/sql_truncate.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -288,6 +288,12 @@ static bool recreate_temporary_table(THD *thd, TABLE *table)
table->file->info(HA_STATUS_AUTO | HA_STATUS_NO_LOCK);
+ /*
+ If LOCK TABLES list is not empty and contains this table
+ then unlock the table and remove it from this list.
+ */
+ mysql_lock_remove(thd, thd->lock, table);
+
/* Don't free share. */
close_temporary_table(thd, table, FALSE, FALSE);
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 257001c80d1..bd0014f4764 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2000, 2014, Oracle and/or its affiliates.
- Copyright (c) 2010, 2014, Monty Program Ab.
+ Copyright (c) 2000, 2015, Oracle and/or its affiliates.
+ Copyright (c) 2010, 2015, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -14597,6 +14597,13 @@ subselect_end:
*/
lex->current_select->select_n_where_fields+=
child->select_n_where_fields;
+
+ /*
+ Aggregate functions in having clause may add fields to an outer
+ select. Count them also.
+ */
+ lex->current_select->select_n_having_items+=
+ child->select_n_having_items;
}
;
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 47bf6baa46b..63d3b388a36 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2002, 2014, Oracle and/or its affiliates.
- Copyright (c) 2012, 2014, SkySQL Ab.
+/* Copyright (c) 2002, 2015, Oracle and/or its affiliates.
+ Copyright (c) 2012, 2015, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -1808,7 +1808,7 @@ static Sys_var_ulong Sys_trans_alloc_block_size(
"transaction_alloc_block_size",
"Allocation block size for transactions to be stored in binary log",
SESSION_VAR(trans_alloc_block_size), CMD_LINE(REQUIRED_ARG),
- VALID_RANGE(1024, UINT_MAX), DEFAULT(QUERY_ALLOC_BLOCK_SIZE),
+ VALID_RANGE(1024, 128 * 1024 * 1024), DEFAULT(QUERY_ALLOC_BLOCK_SIZE),
BLOCK_SIZE(1024), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0),
ON_UPDATE(fix_trans_mem_root));
@@ -1816,7 +1816,7 @@ static Sys_var_ulong Sys_trans_prealloc_size(
"transaction_prealloc_size",
"Persistent buffer for transactions to be stored in binary log",
SESSION_VAR(trans_prealloc_size), CMD_LINE(REQUIRED_ARG),
- VALID_RANGE(1024, UINT_MAX), DEFAULT(TRANS_ALLOC_PREALLOC_SIZE),
+ VALID_RANGE(1024, 128 * 1024 * 1024), DEFAULT(TRANS_ALLOC_PREALLOC_SIZE),
BLOCK_SIZE(1024), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0),
ON_UPDATE(fix_trans_mem_root));