summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-07-16 19:09:54 +0200
committerSergei Golubchik <sergii@pisem.net>2013-07-16 19:09:54 +0200
commit005c7e54214546584c8dc67a746e215f8dbe4b58 (patch)
treedea50cd7b32808413e058d43d20cf230d1cc7477 /sql
parentb9f220b45afaae9b61af29129a8c8ec5f9a7759b (diff)
parent4f5c10e6b565bc2761b9d083e25c6a36141552a0 (diff)
downloadmariadb-git-005c7e54214546584c8dc67a746e215f8dbe4b58.tar.gz
mysql-5.5.32 merge
Diffstat (limited to 'sql')
-rw-r--r--sql/custom_conf.h2
-rw-r--r--sql/filesort.cc2
-rw-r--r--sql/ha_ndbcluster_cond.cc2
-rw-r--r--sql/ha_ndbcluster_cond.h2
-rw-r--r--sql/ha_ndbcluster_tables.h2
-rw-r--r--sql/hostname.cc2
-rw-r--r--sql/innodb_priv.h2
-rw-r--r--sql/item.cc4
-rw-r--r--sql/item.h2
-rw-r--r--sql/item_cmpfunc.cc2
-rw-r--r--sql/item_cmpfunc.h2
-rw-r--r--sql/item_func.cc7
-rw-r--r--sql/item_func.h2
-rw-r--r--sql/item_geofunc.h4
-rw-r--r--sql/item_strfunc.h2
-rw-r--r--sql/item_sum.cc104
-rw-r--r--sql/item_sum.h6
-rw-r--r--sql/item_timefunc.h2
-rw-r--r--sql/lex_symbol.h2
-rw-r--r--sql/log.cc2
-rw-r--r--sql/log_event.cc14
-rw-r--r--sql/log_event.h7
-rw-r--r--sql/log_event_old.h2
-rw-r--r--sql/mem_root_array.h2
-rw-r--r--sql/my_decimal.h2
-rw-r--r--sql/mysqld.cc2
-rw-r--r--sql/net_serv.cc2
-rw-r--r--sql/opt_range.cc83
-rw-r--r--sql/rpl_filter.cc13
-rw-r--r--sql/set_var.h2
-rw-r--r--sql/share/charsets/Index.xml2
-rw-r--r--sql/share/charsets/armscii8.xml2
-rw-r--r--sql/share/charsets/ascii.xml2
-rw-r--r--sql/share/charsets/cp1250.xml2
-rw-r--r--sql/share/charsets/cp1256.xml2
-rw-r--r--sql/share/charsets/cp1257.xml2
-rw-r--r--sql/share/charsets/cp850.xml2
-rw-r--r--sql/share/charsets/cp852.xml2
-rw-r--r--sql/share/charsets/cp866.xml2
-rw-r--r--sql/share/charsets/dec8.xml2
-rw-r--r--sql/share/charsets/geostd8.xml2
-rw-r--r--sql/share/charsets/greek.xml2
-rw-r--r--sql/share/charsets/hebrew.xml2
-rw-r--r--sql/share/charsets/hp8.xml2
-rw-r--r--sql/share/charsets/keybcs2.xml2
-rw-r--r--sql/share/charsets/koi8r.xml2
-rw-r--r--sql/share/charsets/koi8u.xml2
-rw-r--r--sql/share/charsets/languages.html2
-rw-r--r--sql/share/charsets/latin1.xml2
-rw-r--r--sql/share/charsets/latin2.xml2
-rw-r--r--sql/share/charsets/latin5.xml2
-rw-r--r--sql/share/charsets/latin7.xml2
-rw-r--r--sql/share/charsets/macce.xml2
-rw-r--r--sql/share/charsets/macroman.xml2
-rw-r--r--sql/share/charsets/swe7.xml2
-rw-r--r--sql/slave.cc46
-rw-r--r--sql/spatial.cc9
-rw-r--r--sql/spatial.h33
-rw-r--r--sql/sql_acl.cc2
-rw-r--r--sql/sql_analyse.cc2
-rw-r--r--sql/sql_base.cc2
-rw-r--r--sql/sql_class.cc45
-rw-r--r--sql/sql_class.h7
-rw-r--r--sql/sql_cursor.cc2
-rw-r--r--sql/sql_db.cc2
-rw-r--r--sql/sql_error.cc2
-rw-r--r--sql/sql_error.h2
-rw-r--r--sql/sql_handler.cc2
-rw-r--r--sql/sql_help.cc2
-rw-r--r--sql/sql_hset.h2
-rw-r--r--sql/sql_insert.cc94
-rw-r--r--sql/sql_lex.cc45
-rw-r--r--sql/sql_lex.h7
-rw-r--r--sql/sql_parse.cc5
-rw-r--r--sql/sql_partition.cc2
-rw-r--r--sql/sql_repl.cc2
-rw-r--r--sql/sql_select.cc17
-rw-r--r--sql/sql_show.cc8
-rw-r--r--sql/sql_state.c2
-rw-r--r--sql/sql_string.h5
-rw-r--r--sql/sql_table.cc55
-rw-r--r--sql/sql_trigger.cc2
-rw-r--r--sql/sql_update.cc25
-rw-r--r--sql/sql_view.cc2
-rw-r--r--sql/sql_yacc.yy88
-rw-r--r--sql/strfunc.cc2
-rw-r--r--sql/table.cc2
-rw-r--r--sql/transaction.cc2
-rw-r--r--sql/unireg.h2
89 files changed, 569 insertions, 292 deletions
diff --git a/sql/custom_conf.h b/sql/custom_conf.h
index 137b7e9eef2..afef0219857 100644
--- a/sql/custom_conf.h
+++ b/sql/custom_conf.h
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#ifndef __MYSQL_CUSTOM_BUILD_CONFIG__
#define __MYSQL_CUSTOM_BUILD_CONFIG__
diff --git a/sql/filesort.cc b/sql/filesort.cc
index be350037adc..1ee50ba134b 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/**
diff --git a/sql/ha_ndbcluster_cond.cc b/sql/ha_ndbcluster_cond.cc
index 9ab7fb6208d..f8b2ed8429a 100644
--- a/sql/ha_ndbcluster_cond.cc
+++ b/sql/ha_ndbcluster_cond.cc
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/*
diff --git a/sql/ha_ndbcluster_cond.h b/sql/ha_ndbcluster_cond.h
index 442eac2fafd..27675588ed7 100644
--- a/sql/ha_ndbcluster_cond.h
+++ b/sql/ha_ndbcluster_cond.h
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/*
This file defines the data structures used by engine condition pushdown in
diff --git a/sql/ha_ndbcluster_tables.h b/sql/ha_ndbcluster_tables.h
index ba2e8ec251b..6ed46123738 100644
--- a/sql/ha_ndbcluster_tables.h
+++ b/sql/ha_ndbcluster_tables.h
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define NDB_REP_DB "mysql"
diff --git a/sql/hostname.cc b/sql/hostname.cc
index ee30d071602..3540dd8c8ab 100644
--- a/sql/hostname.cc
+++ b/sql/hostname.cc
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/**
diff --git a/sql/innodb_priv.h b/sql/innodb_priv.h
index 24ee848bed1..33ba7b0f5b3 100644
--- a/sql/innodb_priv.h
+++ b/sql/innodb_priv.h
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#ifndef INNODB_PRIV_INCLUDED
#define INNODB_PRIV_INCLUDED
diff --git a/sql/item.cc b/sql/item.cc
index dc0c977acdd..9862db4e597 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -3673,7 +3673,9 @@ bool Item_param::convert_str_value(THD *thd)
/* Here str_value is guaranteed to be in final_character_set_of_str_value */
max_length= str_value.numchars() * str_value.charset()->mbmaxlen;
- decimals= 0;
+
+ /* For the strings converted to numeric form within some functions */
+ decimals= NOT_FIXED_DEC;
/*
str_value_ptr is returned from val_str(). It must be not alloced
to prevent it's modification by val_str() invoker.
diff --git a/sql/item.h b/sql/item.h
index b04e879ed4f..884d1694292 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#ifdef USE_PRAGMA_INTERFACE
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 5b0a2520fbc..51b31d8e17f 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/**
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 1f490d3b5fc..0be9730c63e 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/* compare and test functions */
diff --git a/sql/item_func.cc b/sql/item_func.cc
index b047258818b..2fa9b35db9e 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -6130,6 +6130,13 @@ bool Item_func_match::fix_index()
uint ft_to_key[MAX_KEY], ft_cnt[MAX_KEY], fts=0, keynr;
uint max_cnt=0, mkeys=0, i;
+ /*
+ We will skip execution if the item is not fixed
+ with fix_field
+ */
+ if (!fixed)
+ return false;
+
if (key == NO_SUCH_KEY)
return 0;
diff --git a/sql/item_func.h b/sql/item_func.h
index e43393abf28..499d1796d5d 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/* Function items used by mysql */
diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h
index ee61f921adb..4d5911324ac 100644
--- a/sql/item_geofunc.h
+++ b/sql/item_geofunc.h
@@ -14,8 +14,8 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/* This file defines all spatial functions */
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 77179195283..b601491060c 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/* This file defines all string functions */
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 4f4d8588a3a..7c2eea6258b 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
Copyright (c) 2008, 2013 Monty Program Ab
This program is free software; you can redistribute it and/or modify
@@ -2953,9 +2953,9 @@ int group_concat_key_cmp_with_distinct(void* arg, const void* key1,
for (uint i= 0; i < item_func->arg_count_field; i++)
{
Item *item= item_func->args[i];
- /*
- If field_item is a const item then either get_tmp_table_field returns 0
- or it is an item over a const table.
+ /*
+ If item is a const item then either get_tmp_table_field returns 0
+ or it is an item over a const table.
*/
if (item->const_item())
continue;
@@ -2965,10 +2965,14 @@ int group_concat_key_cmp_with_distinct(void* arg, const void* key1,
the temporary table, not the original field
*/
Field *field= item->get_tmp_table_field();
- int res;
+
+ if (!field)
+ continue;
+
uint offset= (field->offset(field->table->record[0]) -
field->table->s->null_bytes);
- if((res= field->cmp((uchar*)key1 + offset, (uchar*)key2 + offset)))
+ int res= field->cmp((uchar*)key1 + offset, (uchar*)key2 + offset);
+ if (res)
return res;
}
return 0;
@@ -2998,27 +3002,29 @@ int group_concat_key_cmp_with_order(void* arg, const void* key1,
if (item->const_item())
continue;
/*
+ If item is a const item then either get_tmp_table_field returns 0
+ or it is an item over a const table.
+ */
+ if (item->const_item())
+ continue;
+ /*
We have to use get_tmp_table_field() instead of
real_item()->get_tmp_table_field() because we want the field in
the temporary table, not the original field
Note that for the case of ROLLUP, field may point to another table
- tham grp_item->table. This is howver ok as the table definitions are
+ tham grp_item->table. This is however ok as the table definitions are
the same.
*/
Field *field= item->get_tmp_table_field();
- /*
- If item is a const item then either get_tmp_table_field returns 0
- or it is an item over a const table.
- */
- if (field)
- {
- int res;
- uint offset= (field->offset(field->table->record[0]) -
- field->table->s->null_bytes);
- if ((res= field->cmp((uchar*)key1 + offset, (uchar*)key2 + offset)))
- return (*order_item)->asc ? res : -res;
- }
+ if (!field)
+ continue;
+
+ uint offset= (field->offset(field->table->record[0]) -
+ field->table->s->null_bytes);
+ int res= field->cmp((uchar*)key1 + offset, (uchar*)key2 + offset);
+ if (res)
+ return (*order_item)->asc ? res : -res;
}
/*
We can't return 0 because in that case the tree class would remove this
@@ -3058,23 +3064,28 @@ int dump_leaf_key(void* key_arg, element_count count __attribute__((unused)),
for (; arg < arg_end; arg++)
{
String *res;
- if (! (*arg)->const_item())
+ /*
+ We have to use get_tmp_table_field() instead of
+ real_item()->get_tmp_table_field() because we want the field in
+ the temporary table, not the original field
+ We also can't use table->field array to access the fields
+ because it contains both order and arg list fields.
+ */
+ if ((*arg)->const_item())
+ res= (*arg)->val_str(&tmp);
+ else
{
- /*
- We have to use get_tmp_table_field() instead of
- real_item()->get_tmp_table_field() because we want the field in
- the temporary table, not the original field
- We also can't use table->field array to access the fields
- because it contains both order and arg list fields.
- */
Field *field= (*arg)->get_tmp_table_field();
- uint offset= (field->offset(field->table->record[0]) -
- table->s->null_bytes);
- DBUG_ASSERT(offset < table->s->reclength);
- res= field->val_str(&tmp, key + offset);
+ if (field)
+ {
+ uint offset= (field->offset(field->table->record[0]) -
+ table->s->null_bytes);
+ DBUG_ASSERT(offset < table->s->reclength);
+ res= field->val_str(&tmp, key + offset);
+ }
+ else
+ res= (*arg)->val_str(&tmp);
}
- else
- res= (*arg)->val_str(&tmp);
if (res)
result->append(*res);
}
@@ -3122,11 +3133,12 @@ int dump_leaf_key(void* key_arg, element_count count __attribute__((unused)),
Item_func_group_concat::
Item_func_group_concat(Name_resolution_context *context_arg,
bool distinct_arg, List<Item> *select_list,
- SQL_I_List<ORDER> *order_list, String *separator_arg)
+ const SQL_I_List<ORDER> &order_list,
+ String *separator_arg)
:tmp_table_param(0), separator(separator_arg), tree(0),
unique_filter(NULL), table(0),
order(0), context(context_arg),
- arg_count_order(order_list ? order_list->elements : 0),
+ arg_count_order(order_list.elements),
arg_count_field(select_list->elements),
row_count(0),
distinct(distinct_arg),
@@ -3166,7 +3178,7 @@ Item_func_group_concat(Name_resolution_context *context_arg,
if (arg_count_order)
{
ORDER **order_ptr= order;
- for (ORDER *order_item= order_list->first;
+ for (ORDER *order_item= order_list.first;
order_item != NULL;
order_item= order_item->next)
{
@@ -3214,8 +3226,14 @@ Item_func_group_concat::Item_func_group_concat(THD *thd,
order= (ORDER **)(tmp + arg_count_order);
for (uint i= 0; i < arg_count_order; i++, tmp++)
{
- memcpy(tmp, item->order[i], sizeof(ORDER));
- tmp->next= i == arg_count_order-1 ? 0 : tmp+1;
+ /*
+ Compiler generated copy constructor is used to
+ to copy all the members of ORDER struct.
+ It's also necessary to update ORDER::next pointer
+ so that it points to new ORDER element.
+ */
+ new (tmp) st_order(*(item->order[i]));
+ tmp->next= (i + 1 == arg_count_order) ? NULL : (tmp + 1);
order[i]= tmp;
}
}
@@ -3305,12 +3323,12 @@ bool Item_func_group_concat::add()
for (uint i= 0; i < arg_count_field; i++)
{
Item *show_item= args[i];
- if (!show_item->const_item())
- {
- Field *f= show_item->get_tmp_table_field();
- if (f->is_null_in_record((const uchar*) table->record[0]))
+ if (show_item->const_item())
+ continue;
+
+ Field *field= show_item->get_tmp_table_field();
+ if (field && field->is_null_in_record((const uchar*) table->record[0]))
return 0; // Skip row if it contains null
- }
}
null_value= FALSE;
diff --git a/sql/item_sum.h b/sql/item_sum.h
index a954b0f65c1..27748d214dd 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -1,7 +1,7 @@
#ifndef ITEM_SUM_INCLUDED
#define ITEM_SUM_INCLUDED
-/* Copyright (c) 2000, 2011 Oracle and/or its affiliates.
- Copyright (c) 2008-2011 Monty Program Ab
+/* Copyright (c) 2000, 2013 Oracle and/or its affiliates.
+ Copyright (c) 2008, 2013 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
@@ -1428,7 +1428,7 @@ class Item_func_group_concat : public Item_sum
public:
Item_func_group_concat(Name_resolution_context *context_arg,
bool is_distinct, List<Item> *is_select,
- SQL_I_List<ORDER> *is_order, String *is_separator);
+ const SQL_I_List<ORDER> &is_order, String *is_separator);
Item_func_group_concat(THD *thd, Item_func_group_concat *item);
~Item_func_group_concat();
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index 9b2db9e816e..8bea068357b 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/* Function items used by mysql */
diff --git a/sql/lex_symbol.h b/sql/lex_symbol.h
index 000c0709071..5f3c70a50a4 100644
--- a/sql/lex_symbol.h
+++ b/sql/lex_symbol.h
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/* This struct includes all reserved words and functions */
diff --git a/sql/log.cc b/sql/log.cc
index 932840e7d2f..881eeafcb97 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/**
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 46a1879e890..e29e0cd688e 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -6325,7 +6325,7 @@ User_var_log_event(const char* buf, uint event_len,
const Format_description_log_event* description_event)
:Log_event(buf, description_event)
#ifndef MYSQL_CLIENT
- , deferred(false)
+ , deferred(false), query_id(0)
#endif
{
bool error= false;
@@ -6609,12 +6609,18 @@ int User_var_log_event::do_apply_event(Relay_log_info const *rli)
Item *it= 0;
CHARSET_INFO *charset;
DBUG_ENTER("User_var_log_event::do_apply_event");
+ query_id_t sav_query_id= 0; /* memorize orig id when deferred applying */
if (rli->deferred_events_collecting)
{
- set_deferred();
+ set_deferred(current_thd->query_id);
DBUG_RETURN(rli->deferred_events->add(this));
}
+ else if (is_deferred())
+ {
+ sav_query_id= current_thd->query_id;
+ current_thd->query_id= query_id; /* recreating original time context */
+ }
if (!(charset= get_charset(charset_number, MYF(MY_WME))))
DBUG_RETURN(1);
@@ -6688,6 +6694,8 @@ int User_var_log_event::do_apply_event(Relay_log_info const *rli)
(flags & User_var_log_event::UNSIGNED_F));
if (!is_deferred())
free_root(thd->mem_root, 0);
+ else
+ current_thd->query_id= sav_query_id; /* restore current query's context */
DBUG_RETURN(0);
}
@@ -10111,6 +10119,8 @@ Write_rows_log_event::do_exec_row(const Relay_log_info *const rli)
#ifdef MYSQL_CLIENT
void Write_rows_log_event::print(FILE *file, PRINT_EVENT_INFO* print_event_info)
{
+ DBUG_EXECUTE_IF("simulate_cache_read_error",
+ {DBUG_SET("+d,simulate_my_b_fill_error");});
Rows_log_event::print_helper(file, print_event_info, "Write_rows");
}
#endif
diff --git a/sql/log_event.h b/sql/log_event.h
index 6f5e64eb8f3..11fff7a8af6 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -2716,6 +2716,7 @@ public:
uchar flags;
#ifdef MYSQL_SERVER
bool deferred;
+ query_id_t query_id;
User_var_log_event(THD* thd_arg, char *name_arg, uint name_len_arg,
char *val_arg, ulong val_len_arg, Item_result type_arg,
uint charset_number_arg, uchar flags_arg,
@@ -2746,7 +2747,11 @@ public:
and which case the applier adjusts execution path.
*/
bool is_deferred() { return deferred; }
- void set_deferred() { deferred= true; }
+ /*
+ In case of the deffered applying the variable instance is flagged
+ and the parsing time query id is stored to be used at applying time.
+ */
+ void set_deferred(query_id_t qid) { deferred= true; query_id= qid; }
#endif
bool is_valid() const { return name != 0; }
diff --git a/sql/log_event_old.h b/sql/log_event_old.h
index 3e1efd8e2c0..0034bb9d142 100644
--- a/sql/log_event_old.h
+++ b/sql/log_event_old.h
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#ifndef LOG_EVENT_OLD_H
#define LOG_EVENT_OLD_H
diff --git a/sql/mem_root_array.h b/sql/mem_root_array.h
index 5ce4dcb584d..9dc9638c13f 100644
--- a/sql/mem_root_array.h
+++ b/sql/mem_root_array.h
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#ifndef MEM_ROOT_ARRAY_INCLUDED
diff --git a/sql/my_decimal.h b/sql/my_decimal.h
index bd03782cb18..4b1c7f647b1 100644
--- a/sql/my_decimal.h
+++ b/sql/my_decimal.h
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/**
@file
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index bbdd6971f71..e79106bca2d 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#include "my_global.h" /* NO_EMBEDDED_ACCESS_CHECKS */
#include "sql_priv.h"
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index 08ac93f3091..e0a0d5b75cf 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/**
@file
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 239d4411188..821c5d3b7b8 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
- Copyright (c) 2008-2011 Monty Program Ab
+/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2008, 2013, 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
@@ -843,8 +843,17 @@ public:
/* Number of SEL_ARG objects allocated by SEL_ARG::clone_tree operations */
uint alloced_sel_args;
+
bool force_default_mrr;
KEY_PART *key[MAX_KEY]; /* First key parts of keys used in the query */
+
+ bool statement_should_be_aborted() const
+ {
+ return
+ thd->is_fatal_error ||
+ thd->is_error() ||
+ alloced_sel_args > SEL_ARG::MAX_SEL_ARGS;
+ }
};
class PARAM : public RANGE_OPT_PARAM
@@ -7124,6 +7133,34 @@ static SEL_TREE *get_func_mm_tree(RANGE_OPT_PARAM *param, Item_func *cond_func,
{
new_interval->min_value= last_val->max_value;
new_interval->min_flag= NEAR_MIN;
+
+ /*
+ If the interval is over a partial keypart, the
+ interval must be "c_{i-1} <= X < c_i" instead of
+ "c_{i-1} < X < c_i". Reason:
+
+ Consider a table with a column "my_col VARCHAR(3)",
+ and an index with definition
+ "INDEX my_idx my_col(1)". If the table contains rows
+ with my_col values "f" and "foo", the index will not
+ distinguish the two rows.
+
+ Note that tree_or() below will effectively merge
+ this range with the range created for c_{i-1} and
+ we'll eventually end up with only one range:
+ "NULL < X".
+
+ Partitioning indexes are never partial.
+ */
+ if (param->using_real_indexes)
+ {
+ const KEY key=
+ param->table->key_info[param->real_keynr[idx]];
+ const KEY_PART_INFO *kpi= key.key_part + new_interval->part;
+
+ if (kpi->key_part_flag & HA_PART_KEY_SEG)
+ new_interval->min_flag= 0;
+ }
}
}
/*
@@ -7336,34 +7373,35 @@ static SEL_TREE *get_mm_tree(RANGE_OPT_PARAM *param,COND *cond)
if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC)
{
- tree=0;
+ tree= NULL;
Item *item;
while ((item=li++))
{
- SEL_TREE *new_tree=get_mm_tree(param,item);
- if (param->thd->is_fatal_error ||
- param->alloced_sel_args > SEL_ARG::MAX_SEL_ARGS)
- DBUG_RETURN(0); // out of memory
- tree=tree_and(param,tree,new_tree);
- if (tree && tree->type == SEL_TREE::IMPOSSIBLE)
- break;
+ SEL_TREE *new_tree= get_mm_tree(param,item);
+ if (param->statement_should_be_aborted())
+ DBUG_RETURN(NULL);
+ tree= tree_and(param,tree,new_tree);
+ if (tree && tree->type == SEL_TREE::IMPOSSIBLE)
+ break;
}
}
else
- { // COND OR
- tree=get_mm_tree(param,li++);
+ { // COND OR
+ tree= get_mm_tree(param,li++);
+ if (param->statement_should_be_aborted())
+ DBUG_RETURN(NULL);
if (tree)
{
- Item *item;
- while ((item=li++))
- {
- SEL_TREE *new_tree=get_mm_tree(param,item);
- if (!new_tree)
- DBUG_RETURN(0); // out of memory
- tree=tree_or(param,tree,new_tree);
- if (!tree || tree->type == SEL_TREE::ALWAYS)
- break;
- }
+ Item *item;
+ while ((item=li++))
+ {
+ SEL_TREE *new_tree=get_mm_tree(param,item);
+ if (new_tree == NULL || param->statement_should_be_aborted())
+ DBUG_RETURN(NULL);
+ tree= tree_or(param,tree,new_tree);
+ if (tree == NULL || tree->type == SEL_TREE::ALWAYS)
+ break;
+ }
}
}
DBUG_RETURN(tree);
@@ -7617,6 +7655,7 @@ get_mm_leaf(RANGE_OPT_PARAM *param, COND *conf_func, Field *field,
if (key_part->image_type == Field::itMBR)
{
+ // @todo: use is_spatial_operator() instead?
switch (type) {
case Item_func::SP_EQUALS_FUNC:
case Item_func::SP_DISJOINT_FUNC:
diff --git a/sql/rpl_filter.cc b/sql/rpl_filter.cc
index 0380bc323a3..9edbfc05677 100644
--- a/sql/rpl_filter.cc
+++ b/sql/rpl_filter.cc
@@ -156,14 +156,15 @@ Rpl_filter::db_ok(const char* db)
DBUG_RETURN(1); // Ok to replicate if the user puts no constraints
/*
- If the user has specified restrictions on which databases to replicate
- and db was not selected, do not replicate.
+ Previous behaviour "if the user has specified restrictions on which
+ databases to replicate and db was not selected, do not replicate" has
+ been replaced with "do replicate".
+ Since the filtering criteria is not equal to "NULL" the statement should
+ be logged into binlog.
*/
if (!db)
- {
- DBUG_PRINT("exit", ("Don't replicate"));
- DBUG_RETURN(0);
- }
+ DBUG_RETURN(1);
+
if (!do_db.is_empty()) // if the do's are not empty
{
I_List_iterator<i_string> it(do_db);
diff --git a/sql/set_var.h b/sql/set_var.h
index 9a36cdb6f70..205812e8822 100644
--- a/sql/set_var.h
+++ b/sql/set_var.h
@@ -13,7 +13,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/**
@file
diff --git a/sql/share/charsets/Index.xml b/sql/share/charsets/Index.xml
index f32d8bf6127..e82ffc85ea6 100644
--- a/sql/share/charsets/Index.xml
+++ b/sql/share/charsets/Index.xml
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
</copyright>
<description>
diff --git a/sql/share/charsets/armscii8.xml b/sql/share/charsets/armscii8.xml
index 714e57bb12e..52382c83af0 100644
--- a/sql/share/charsets/armscii8.xml
+++ b/sql/share/charsets/armscii8.xml
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
</copyright>
<charset name="armscii8">
diff --git a/sql/share/charsets/ascii.xml b/sql/share/charsets/ascii.xml
index f4fb79ac632..bec34ad525e 100644
--- a/sql/share/charsets/ascii.xml
+++ b/sql/share/charsets/ascii.xml
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
</copyright>
<charset name="ascii">
diff --git a/sql/share/charsets/cp1250.xml b/sql/share/charsets/cp1250.xml
index bd0d7d3f3c0..58e55de9bdc 100644
--- a/sql/share/charsets/cp1250.xml
+++ b/sql/share/charsets/cp1250.xml
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
</copyright>
<charset name="cp1250">
diff --git a/sql/share/charsets/cp1256.xml b/sql/share/charsets/cp1256.xml
index 64cb253145c..806fef961f7 100644
--- a/sql/share/charsets/cp1256.xml
+++ b/sql/share/charsets/cp1256.xml
@@ -18,7 +18,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
</copyright>
<charset name="cp1256">
diff --git a/sql/share/charsets/cp1257.xml b/sql/share/charsets/cp1257.xml
index 0c2688c264e..8ae73fdf25a 100644
--- a/sql/share/charsets/cp1257.xml
+++ b/sql/share/charsets/cp1257.xml
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
</copyright>
<charset name="cp1257">
diff --git a/sql/share/charsets/cp850.xml b/sql/share/charsets/cp850.xml
index 4076a5f6a56..198b336daef 100644
--- a/sql/share/charsets/cp850.xml
+++ b/sql/share/charsets/cp850.xml
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
</copyright>
<charset name="cp850">
diff --git a/sql/share/charsets/cp852.xml b/sql/share/charsets/cp852.xml
index 25b622d2a4b..7608296d5b7 100644
--- a/sql/share/charsets/cp852.xml
+++ b/sql/share/charsets/cp852.xml
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
</copyright>
<charset name="cp852">
diff --git a/sql/share/charsets/cp866.xml b/sql/share/charsets/cp866.xml
index fa2e1865de6..d35f3d68b05 100644
--- a/sql/share/charsets/cp866.xml
+++ b/sql/share/charsets/cp866.xml
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
</copyright>
<charset name="cp866">
diff --git a/sql/share/charsets/dec8.xml b/sql/share/charsets/dec8.xml
index 2cd52de464a..66bb421b674 100644
--- a/sql/share/charsets/dec8.xml
+++ b/sql/share/charsets/dec8.xml
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
</copyright>
<charset name="dec8">
diff --git a/sql/share/charsets/geostd8.xml b/sql/share/charsets/geostd8.xml
index 5e3816975d6..a789d07e6d8 100644
--- a/sql/share/charsets/geostd8.xml
+++ b/sql/share/charsets/geostd8.xml
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
</copyright>
<charset name="geostd8">
diff --git a/sql/share/charsets/greek.xml b/sql/share/charsets/greek.xml
index 000019a8ce0..5b66a7ab442 100644
--- a/sql/share/charsets/greek.xml
+++ b/sql/share/charsets/greek.xml
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
</copyright>
<charset name="greek">
diff --git a/sql/share/charsets/hebrew.xml b/sql/share/charsets/hebrew.xml
index 20d68487301..e7f896a3e12 100644
--- a/sql/share/charsets/hebrew.xml
+++ b/sql/share/charsets/hebrew.xml
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
</copyright>
<charset name="hebrew">
diff --git a/sql/share/charsets/hp8.xml b/sql/share/charsets/hp8.xml
index 3ab383ef386..83a076237f7 100644
--- a/sql/share/charsets/hp8.xml
+++ b/sql/share/charsets/hp8.xml
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
</copyright>
<charset name="hp8">
diff --git a/sql/share/charsets/keybcs2.xml b/sql/share/charsets/keybcs2.xml
index 7335a0f428d..a9f305deab8 100644
--- a/sql/share/charsets/keybcs2.xml
+++ b/sql/share/charsets/keybcs2.xml
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
</copyright>
<charset name="keybcs2">
diff --git a/sql/share/charsets/koi8r.xml b/sql/share/charsets/koi8r.xml
index 2d8473f6440..21ebf78b79e 100644
--- a/sql/share/charsets/koi8r.xml
+++ b/sql/share/charsets/koi8r.xml
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
</copyright>
<charset name="koi8r">
diff --git a/sql/share/charsets/koi8u.xml b/sql/share/charsets/koi8u.xml
index 16177627ffe..65145c97593 100644
--- a/sql/share/charsets/koi8u.xml
+++ b/sql/share/charsets/koi8u.xml
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
</copyright>
<charset name="koi8u">
diff --git a/sql/share/charsets/languages.html b/sql/share/charsets/languages.html
index 76af973113e..2b1c44421bf 100644
--- a/sql/share/charsets/languages.html
+++ b/sql/share/charsets/languages.html
@@ -13,7 +13,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#<pre>
(
diff --git a/sql/share/charsets/latin1.xml b/sql/share/charsets/latin1.xml
index 88ceff440d5..8963c3481d3 100644
--- a/sql/share/charsets/latin1.xml
+++ b/sql/share/charsets/latin1.xml
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
</copyright>
<charset name="latin1">
diff --git a/sql/share/charsets/latin2.xml b/sql/share/charsets/latin2.xml
index 6b887b927a4..183da7b6cd3 100644
--- a/sql/share/charsets/latin2.xml
+++ b/sql/share/charsets/latin2.xml
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
</copyright>
<charset name="latin2">
diff --git a/sql/share/charsets/latin5.xml b/sql/share/charsets/latin5.xml
index 9c23200a46d..489299564f1 100644
--- a/sql/share/charsets/latin5.xml
+++ b/sql/share/charsets/latin5.xml
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
</copyright>
<charset name="latin5">
diff --git a/sql/share/charsets/latin7.xml b/sql/share/charsets/latin7.xml
index 02d3ff8b17e..fb384b3a5ff 100644
--- a/sql/share/charsets/latin7.xml
+++ b/sql/share/charsets/latin7.xml
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
</copyright>
<charset name="latin7">
diff --git a/sql/share/charsets/macce.xml b/sql/share/charsets/macce.xml
index 21e303609cf..d7242f26297 100644
--- a/sql/share/charsets/macce.xml
+++ b/sql/share/charsets/macce.xml
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
</copyright>
<charset name="macce">
diff --git a/sql/share/charsets/macroman.xml b/sql/share/charsets/macroman.xml
index 2b43fe73b07..a2485cf9379 100644
--- a/sql/share/charsets/macroman.xml
+++ b/sql/share/charsets/macroman.xml
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
</copyright>
<charset name="macroman">
diff --git a/sql/share/charsets/swe7.xml b/sql/share/charsets/swe7.xml
index 17fa6b7d9bc..f12a2238718 100644
--- a/sql/share/charsets/swe7.xml
+++ b/sql/share/charsets/swe7.xml
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
</copyright>
<charset name="swe7">
diff --git a/sql/slave.cc b/sql/slave.cc
index 02ab69af0e8..19c84174cc2 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -159,6 +159,37 @@ static int terminate_slave_thread(THD *thd,
volatile uint *slave_running,
bool skip_lock);
static bool check_io_slave_killed(THD *thd, Master_info *mi, const char *info);
+/*
+ Function to set the slave's max_allowed_packet based on the value
+ of slave_max_allowed_packet.
+
+ @in_param thd Thread handler for slave
+ @in_param mysql MySQL connection handle
+*/
+
+static void set_slave_max_allowed_packet(THD *thd, MYSQL *mysql)
+{
+ DBUG_ENTER("set_slave_max_allowed_packet");
+ // thd and mysql must be valid
+ DBUG_ASSERT(thd && mysql);
+
+ thd->variables.max_allowed_packet= slave_max_allowed_packet;
+ thd->net.max_packet_size= slave_max_allowed_packet;
+ /*
+ Adding MAX_LOG_EVENT_HEADER_LEN to the max_packet_size on the I/O
+ thread and the mysql->option max_allowed_packet, since a
+ replication event can become this much larger than
+ the corresponding packet (query) sent from client to master.
+ */
+ thd->net.max_packet_size+= MAX_LOG_EVENT_HEADER;
+ /*
+ Skipping the setting of mysql->net.max_packet size to slave
+ max_allowed_packet since this is done during mysql_real_connect.
+ */
+ mysql->options.max_allowed_packet=
+ slave_max_allowed_packet+MAX_LOG_EVENT_HEADER;
+ DBUG_VOID_RETURN;
+}
/*
Find out which replications threads are running
@@ -2278,12 +2309,6 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type)
SYSTEM_THREAD_SLAVE_SQL : SYSTEM_THREAD_SLAVE_IO;
thd->security_ctx->skip_grants();
my_net_init(&thd->net, 0);
-/*
- Adding MAX_LOG_EVENT_HEADER_LEN to the max_allowed_packet on all
- slave threads, since a replication event can become this much larger
- than the corresponding packet (query) sent from client to master.
-*/
- thd->variables.max_allowed_packet= slave_max_allowed_packet;
thd->slave_thread = 1;
thd->enable_slow_log= opt_log_slow_slave_statements;
thd->variables.log_slow_filter= global_system_variables.log_slow_filter;
@@ -3067,13 +3092,6 @@ pthread_handler_t handle_slave_io(void *arg)
mi->user, mi->host, mi->port,
IO_RPL_LOG_NAME,
llstr(mi->master_log_pos,llbuff));
- /*
- Adding MAX_LOG_EVENT_HEADER_LEN to the max_packet_size on the I/O
- thread, since a replication event can become this much larger than
- the corresponding packet (query) sent from client to master.
- */
- thd->net.max_packet_size= slave_max_allowed_packet;
- mysql->net.max_packet_size= thd->net.max_packet_size+= MAX_LOG_EVENT_HEADER;
}
else
{
@@ -4638,7 +4656,7 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi,
ulong err_count=0;
char llbuff[22];
DBUG_ENTER("connect_to_master");
-
+ set_slave_max_allowed_packet(thd, mysql);
#ifndef DBUG_OFF
mi->events_till_disconnect = disconnect_slave_event_count;
#endif
diff --git a/sql/spatial.cc b/sql/spatial.cc
index 2359f4fa271..a01d2c59a49 100644
--- a/sql/spatial.cc
+++ b/sql/spatial.cc
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2002, 2012, Oracle and/or its affiliates.
- Copyright (c) 2011, 2012, Monty Program Ab
+ Copyright (c) 2002, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2011, 2013, 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
@@ -818,7 +818,6 @@ int Gis_line_string::store_shapes(Gcalc_shape_transporter *trn) const
return trn->complete_line();
}
-
const Geometry::Class_info *Gis_line_string::get_class_info() const
{
return &linestring_class;
@@ -939,7 +938,9 @@ uint Gis_polygon::init_from_wkb(const char *wkb, uint len, wkbByteOrder bo,
if (len < 4)
return 0;
- n_linear_rings= wkb_get_uint(wkb, bo);
+ if (!(n_linear_rings= wkb_get_uint(wkb, bo)))
+ return 0;
+
if (res->reserve(4, 512))
return 0;
wkb+= 4;
diff --git a/sql/spatial.h b/sql/spatial.h
index 9aaedfe8a20..6df6e37e9b8 100644
--- a/sql/spatial.h
+++ b/sql/spatial.h
@@ -1,5 +1,6 @@
/*
- Copyright (c) 2002, 2010, Oracle and/or its affiliates.
+ Copyright (c) 2002, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2013, 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
@@ -28,7 +29,7 @@ class Gis_read_stream;
const uint SRID_SIZE= 4;
const uint SIZEOF_STORED_DOUBLE= 8;
-const uint POINT_DATA_SIZE= SIZEOF_STORED_DOUBLE*2;
+const uint POINT_DATA_SIZE= (SIZEOF_STORED_DOUBLE * 2);
const uint WKB_HEADER_SIZE= 1+4;
const uint32 GET_SIZE_ERROR= ((uint32) -1);
@@ -334,10 +335,36 @@ protected:
const char *get_mbr_for_points(MBR *mbr, const char *data, uint offset)
const;
- inline bool no_data(const char *cur_data, uint32 data_amount) const
+ /**
+ Check if there're enough data remaining as requested
+
+ @arg cur_data pointer to the position in the binary form
+ @arg data_amount number of points expected
+ @return true if not enough data
+ */
+ inline bool no_data(const char *cur_data, size_t data_amount) const
{
return (cur_data + data_amount > m_data_end);
}
+
+ /**
+ Check if there're enough points remaining as requested
+
+ Need to perform the calculation in logical units, since multiplication
+ can overflow the size data type.
+
+ @arg data pointer to the begining of the points array
+ @arg expected_points number of points expected
+ @arg extra_point_space extra space for each point element in the array
+ @return true if there are not enough points
+ */
+ inline bool not_enough_points(const char *data, uint32 expected_points,
+ uint32 extra_point_space = 0) const
+ {
+ return (m_data_end < data ||
+ (expected_points > ((m_data_end - data) /
+ (POINT_DATA_SIZE + extra_point_space))));
+ }
const char *m_data;
const char *m_data_end;
};
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 1af275f9c7f..91b283f168c 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/*
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc
index 31e13882515..f287bf47e81 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/* Analyse database */
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 56c2a613b1e..b2b1b01f1b9 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/* Basic functions needed by many modules */
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 2d3d0930500..8b0006431a2 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2000, 2012, Oracle and/or its affiliates.
- Copyright (c) 2008, 2012, Monty Program Ab
+ Copyright (c) 2000, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2008, 2013, 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
@@ -1451,7 +1451,6 @@ THD::~THD()
DBUG_ENTER("~THD()");
/* Ensure that no one is using THD */
mysql_mutex_lock(&LOCK_thd_data);
- mysys_var=0; // Safety (shouldn't be needed)
mysql_mutex_unlock(&LOCK_thd_data);
/* Close connection */
@@ -4840,6 +4839,46 @@ int THD::decide_logging_format(TABLE_LIST *tables)
DBUG_PRINT("info", ("decision: logging in %s format",
is_current_stmt_binlog_format_row() ?
"ROW" : "STATEMENT"));
+
+ if (variables.binlog_format == BINLOG_FORMAT_ROW &&
+ (lex->sql_command == SQLCOM_UPDATE ||
+ lex->sql_command == SQLCOM_UPDATE_MULTI ||
+ lex->sql_command == SQLCOM_DELETE ||
+ lex->sql_command == SQLCOM_DELETE_MULTI))
+ {
+ String table_names;
+ /*
+ Generate a warning for UPDATE/DELETE statements that modify a
+ BLACKHOLE table, as row events are not logged in row format.
+ */
+ for (TABLE_LIST *table= tables; table; table= table->next_global)
+ {
+ if (table->placeholder())
+ continue;
+ if (table->table->file->ht->db_type == DB_TYPE_BLACKHOLE_DB &&
+ table->lock_type >= TL_WRITE_ALLOW_WRITE)
+ {
+ table_names.append(table->table_name);
+ table_names.append(",");
+ }
+ }
+ if (!table_names.is_empty())
+ {
+ bool is_update= (lex->sql_command == SQLCOM_UPDATE ||
+ lex->sql_command == SQLCOM_UPDATE_MULTI);
+ /*
+ Replace the last ',' with '.' for table_names
+ */
+ table_names.replace(table_names.length()-1, 1, ".", 1);
+ push_warning_printf(this, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_UNKNOWN_ERROR,
+ "Row events are not logged for %s statements "
+ "that modify BLACKHOLE tables in row format. "
+ "Table(s): '%-.192s'",
+ is_update ? "UPDATE" : "DELETE",
+ table_names.c_ptr());
+ }
+ }
}
#ifndef DBUG_OFF
else
diff --git a/sql/sql_class.h b/sql/sql_class.h
index b11e18777d5..9b6cbcc2e8a 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -13,7 +13,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#ifndef SQL_CLASS_INCLUDED
@@ -4155,6 +4155,11 @@ inline bool add_order_to_list(THD *thd, Item *item, bool asc)
return thd->lex->current_select->add_order_to_list(thd, item, asc);
}
+inline bool add_gorder_to_list(THD *thd, Item *item, bool asc)
+{
+ return thd->lex->current_select->add_gorder_to_list(thd, item, asc);
+}
+
inline bool add_group_to_list(THD *thd, Item *item, bool asc)
{
return thd->lex->current_select->add_group_to_list(thd, item, asc);
diff --git a/sql/sql_cursor.cc b/sql/sql_cursor.cc
index b8b979a282b..3758bf27819 100644
--- a/sql/sql_cursor.cc
+++ b/sql/sql_cursor.cc
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation /* gcc class implementation */
#endif
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index cbe59503058..579c032f332 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -13,7 +13,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/* create and drop of databases */
diff --git a/sql/sql_error.cc b/sql/sql_error.cc
index a4f5b210285..e12723402a8 100644
--- a/sql/sql_error.cc
+++ b/sql/sql_error.cc
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/**********************************************************************
This file contains the implementation of error and warnings related
diff --git a/sql/sql_error.h b/sql/sql_error.h
index 0483e7c65d1..9efd77328ea 100644
--- a/sql/sql_error.h
+++ b/sql/sql_error.h
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#ifndef SQL_ERROR_H
#define SQL_ERROR_H
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index df979c62541..6ff550985fa 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/* HANDLER ... commands - direct access to ISAM */
diff --git a/sql/sql_help.cc b/sql/sql_help.cc
index 458904ebe1d..d3c36e2c5d7 100644
--- a/sql/sql_help.cc
+++ b/sql/sql_help.cc
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#include "sql_priv.h"
#include "unireg.h"
diff --git a/sql/sql_hset.h b/sql/sql_hset.h
index 2ea70b91da8..f3a1467737f 100644
--- a/sql/sql_hset.h
+++ b/sql/sql_hset.h
@@ -13,7 +13,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#include "my_global.h"
#include "hash.h"
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index bda443de3c3..306d5c8d306 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1,5 +1,6 @@
/*
- Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2000, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2010, 2013, 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
@@ -94,15 +95,13 @@ static bool check_view_insertability(THD *thd, TABLE_LIST *view);
/*
Check that insert/update fields are from the same single table of a view.
- SYNOPSIS
- check_view_single_update()
- fields The insert/update fields to be checked.
- values Values to use for update
- view The view for insert.
- map [in/out] The insert table map.
+ @param fields The insert/update fields to be checked.
+ @param values The insert/update values to be checked, NULL if
+ checking is not wanted.
+ @param view The view for insert.
+ @param map [in/out] The insert table map.
- DESCRIPTION
- This function is called in 2 cases:
+ This function is called in 2 cases:
1. to check insert fields. In this case *map will be set to 0.
Insert fields are checked to be all from the same single underlying
table of the given view. Otherwise the error is thrown. Found table
@@ -112,9 +111,7 @@ static bool check_view_insertability(THD *thd, TABLE_LIST *view);
the function to check insert fields. Update fields are checked to be
from the same table as the insert fields.
- RETURN
- 0 OK
- 1 Error
+ @returns false if success.
*/
bool check_view_single_update(List<Item> &fields, List<Item> *values,
@@ -179,26 +176,20 @@ error:
/*
Check if insert fields are correct.
- SYNOPSIS
- check_insert_fields()
- thd The current thread.
- table The table for insert.
- fields The insert fields.
- values The insert values.
- check_unique If duplicate values should be rejected.
- fields_and_values_from_different_maps
- Set to 1 if fields and values are using
- different table maps, like on select ... insert
- map Store here table map for used fields
-
+ @param thd The current thread.
+ @param table_list The table we are inserting into (may be view)
+ @param fields The insert fields.
+ @param values The insert values.
+ @param check_unique If duplicate values should be rejected.
+ @param fields_and_values_from_different_maps If 'values' are allowed to
+ refer to other tables than those of 'fields'
+ @param map See check_view_single_update
NOTE
Clears TIMESTAMP_AUTO_SET_ON_INSERT from table->timestamp_field_type
or leaves it as is, depending on if timestamp should be updated or
not.
-
- RETURN
- 0 OK
- -1 Error
+
+ @returns 0 if success, -1 if error
*/
static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
@@ -328,31 +319,29 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
}
-/*
- Check update fields for the timestamp and auto_increment fields.
+/**
+ Check if update fields are correct.
- SYNOPSIS
- check_update_fields()
- thd The current thread.
- insert_table_list The insert table list.
- table The table for update.
- update_fields The update fields.
+ @param thd The current thread.
+ @param insert_table_list The table we are inserting into (may be view)
+ @param update_fields The update fields.
+ @param update_values The update values.
+ @param fields_and_values_from_different_maps If 'update_values' are allowed to
+ refer to other tables than those of 'update_fields'
+ @param map See check_view_single_update
NOTE
If the update fields include the timestamp field,
remove TIMESTAMP_AUTO_SET_ON_UPDATE from table->timestamp_field_type.
- If the update fields include an autoinc field, set the
- table->next_number_field_updated flag.
-
- RETURN
- 0 OK
- -1 Error
+ @returns 0 if success, -1 if error
*/
static int check_update_fields(THD *thd, TABLE_LIST *insert_table_list,
List<Item> &update_fields,
- List<Item> &update_values, table_map *map)
+ List<Item> &update_values,
+ bool fields_and_values_from_different_maps,
+ table_map *map)
{
TABLE *table= insert_table_list->table;
my_bool timestamp_mark;
@@ -389,7 +378,9 @@ static int check_update_fields(THD *thd, TABLE_LIST *insert_table_list,
if (insert_table_list->is_view() &&
insert_table_list->is_merged_derived() &&
- check_view_single_update(update_fields, &update_values,
+ check_view_single_update(update_fields,
+ fields_and_values_from_different_maps ?
+ (List<Item>*) 0 : &update_values,
insert_table_list, map, false))
return -1;
@@ -1483,7 +1474,7 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
{
select_lex->no_wrap_view_item= TRUE;
res= check_update_fields(thd, context->table_list, update_fields,
- update_values, &map);
+ update_values, false, &map);
select_lex->no_wrap_view_item= FALSE;
}
@@ -3388,9 +3379,16 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
context->resolve_in_table_list_only(table_list);
lex->select_lex.no_wrap_view_item= TRUE;
- res= res || check_update_fields(thd, context->table_list,
- *info.update_fields, *info.update_values,
- &map);
+ res= res ||
+ check_update_fields(thd, context->table_list,
+ *info.update_fields, *info.update_values,
+ /*
+ In INSERT SELECT ON DUPLICATE KEY UPDATE col=x
+ 'x' can legally refer to a non-inserted table.
+ 'x' is not even resolved yet.
+ */
+ true,
+ &map);
lex->select_lex.no_wrap_view_item= FALSE;
/*
When we are not using GROUP BY and there are no ungrouped aggregate functions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 14105de9e59..5be56e4d520 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
+/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
Copyright (c) 2009, 2013, Monty Program Ab.
This program is free software; you can redistribute it and/or modify
@@ -1863,8 +1863,10 @@ void st_select_lex::init_query()
cond_count= between_count= with_wild= 0;
max_equal_elems= 0;
ref_pointer_array= 0;
+ ref_pointer_array_size= 0;
select_n_where_fields= 0;
select_n_having_items= 0;
+ n_sum_items= 0;
n_child_sum_items= 0;
subquery_in_having= explicit_limit= 0;
is_item_list_lookup= 0;
@@ -2224,6 +2226,11 @@ bool st_select_lex::add_order_to_list(THD *thd, Item *item, bool asc)
}
+bool st_select_lex::add_gorder_to_list(THD *thd, Item *item, bool asc)
+{
+ return add_to_list(thd, gorder_list, item, asc);
+}
+
bool st_select_lex::add_item_to_list(THD *thd, Item *item)
{
DBUG_ENTER("st_select_lex::add_item_to_list");
@@ -2294,11 +2301,6 @@ ulong st_select_lex::get_table_join_options()
bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num)
{
- DBUG_ENTER("st_select_lex::setup_ref_array");
-
- if (ref_pointer_array)
- DBUG_RETURN(0);
-
// find_order_in_list() may need some extra space, so multiply by two.
order_group_num*= 2;
@@ -2306,13 +2308,30 @@ bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num)
We have to create array in prepared statement memory if it is a
prepared statement
*/
- ref_pointer_array=
- (Item **)thd->stmt_arena->alloc(sizeof(Item*) * (n_child_sum_items +
- item_list.elements +
- select_n_having_items +
- select_n_where_fields +
- order_group_num)*5);
- DBUG_RETURN(ref_pointer_array == 0);
+ Query_arena *arena= thd->stmt_arena;
+ const uint n_elems= (n_sum_items +
+ n_child_sum_items +
+ item_list.elements +
+ select_n_having_items +
+ select_n_where_fields +
+ order_group_num) * 5;
+ if (ref_pointer_array != NULL)
+ {
+ /*
+ We need to take 'n_sum_items' into account when allocating the array,
+ and this may actually increase during the optimization phase due to
+ MIN/MAX rewrite in Item_in_subselect::single_value_transformer.
+ In the usual case we can reuse the array from the prepare phase.
+ If we need a bigger array, we must allocate a new one.
+ */
+ if (ref_pointer_array_size >= n_elems)
+ return false;
+ }
+ ref_pointer_array= static_cast<Item**>(arena->alloc(sizeof(Item*) * n_elems));
+ if (ref_pointer_array != NULL)
+ ref_pointer_array_size= n_elems;
+
+ return ref_pointer_array == NULL;
}
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 2af1ddbf39c..ca85dcfd57e 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -1,4 +1,5 @@
-/* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
+/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2010, 2013, 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
@@ -787,10 +788,11 @@ public:
const char *type; /* type of select for EXPLAIN */
SQL_I_List<ORDER> order_list; /* ORDER clause */
- SQL_I_List<ORDER> *gorder_list;
+ SQL_I_List<ORDER> gorder_list;
Item *select_limit, *offset_limit; /* LIMIT clause parameters */
// Arrays of pointers to top elements of all_fields list
Item **ref_pointer_array;
+ size_t ref_pointer_array_size; // Number of elements in array.
/*
number of items in select_list and HAVING clause used to get number
@@ -923,6 +925,7 @@ public:
bool add_group_to_list(THD *thd, Item *item, bool asc);
bool add_ftfunc_to_list(Item_func_match *func);
bool add_order_to_list(THD *thd, Item *item, bool asc);
+ bool add_gorder_to_list(THD *thd, Item *item, bool asc);
TABLE_LIST* add_table_to_list(THD *thd, Table_ident *table,
LEX_STRING *alias,
ulong table_options,
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 6db3a8eff3f..c3e6e276c42 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1086,6 +1086,11 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
thd->update_server_status();
thd->protocol->end_statement();
query_cache_end_of_result(thd);
+
+ mysql_audit_general(thd, MYSQL_AUDIT_GENERAL_STATUS,
+ thd->stmt_da->is_error() ? thd->stmt_da->sql_errno()
+ : 0, command_name[command].str);
+
ulong length= (ulong)(packet_end - beginning_of_next_stmt);
log_slow_statement(thd);
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 72061f90e67..a3054ecfb15 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/*
This file is a container for general functionality related
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 5a031ef795c..124af78ed61 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -2213,6 +2213,8 @@ bool show_binlogs(THD* thd)
if (protocol->write())
goto err;
}
+ if(index_file->error == -1)
+ goto err;
mysql_bin_log.unlock_index();
my_eof(thd);
DBUG_RETURN(FALSE);
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index e517c05c161..cacaea44d12 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/**
@file
@@ -8133,6 +8133,7 @@ JOIN::make_simple_join(JOIN *parent, TABLE *temp_table)
join_tab->ref.key = -1;
join_tab->read_first_record= join_init_read_record;
join_tab->join= this;
+ join_tab->ref.key_parts= 0;
bzero((char*) &join_tab->read_record,sizeof(join_tab->read_record));
temp_table->status=0;
temp_table->null_row=0;
@@ -14015,7 +14016,7 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
if (new_field)
new_field->init(table);
- if (copy_func && item->is_result_field())
+ if (copy_func && item->real_item()->is_result_field())
*((*copy_func)++) = item; // Save for copy_funcs
if (modify_item)
item->set_result_field(new_field);
@@ -19307,7 +19308,17 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
tablesort_result_cache= table->sort.io_cache;
table->sort.io_cache= NULL;
- // select->cleanup(); // filesort did select
+ if (select->quick &&
+ select->quick->get_type() == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX)
+ {
+ tab->filesort_used_loose_index_scan= true;
+
+ QUICK_GROUP_MIN_MAX_SELECT *minmax_quick=
+ static_cast<QUICK_GROUP_MIN_MAX_SELECT*>(select->quick);
+ if (minmax_quick->is_agg_distinct())
+ tab->filesort_used_loose_index_scan_agg_distinct= true;
+ }
+
/*
If a quick object was created outside of create_sort_index()
that might be reused, then do not call select->cleanup() since
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 223a9d30b5a..6c382a57eff 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -2724,6 +2724,14 @@ static bool show_status_array(THD *thd, const char *wild,
{
if (!(pos= *(char**) value))
pos= "";
+
+ DBUG_EXECUTE_IF("alter_server_version_str",
+ if (!my_strcasecmp(system_charset_info,
+ variables->name,
+ "version")) {
+ pos= "some-other-version";
+ });
+
end= strend(pos);
break;
}
diff --git a/sql/sql_state.c b/sql/sql_state.c
index 5acf97f16cc..c733d4b37c0 100644
--- a/sql/sql_state.c
+++ b/sql/sql_state.c
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/* Functions to map mysqld errno to sql_state */
diff --git a/sql/sql_string.h b/sql/sql_string.h
index 7a2f27da998..020628100cb 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -2,8 +2,8 @@
#define SQL_STRING_INCLUDED
/*
- Copyright (c) 2000, 2012, Oracle and/or its affiliates.
- Copyright (c) 2008, 2011, Monty Program Ab
+ Copyright (c) 2000, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2008, 2013, 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
@@ -311,6 +311,7 @@ public:
DBUG_ASSERT(!s.uses_buffer_owned_by(this));
free();
Ptr=s.Ptr ; str_length=s.str_length ; Alloced_length=s.Alloced_length;
+ str_charset=s.str_charset;
}
return *this;
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 47b1627f8e4..9d0b7b709c9 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -198,7 +198,6 @@ uint explain_filename(THD* thd,
uint to_length,
enum_explain_filename_mode explain_mode)
{
- uint res= 0;
char *to_p= to;
char *end_p= to_p + to_length;
const char *db_name= NULL;
@@ -209,7 +208,8 @@ uint explain_filename(THD* thd,
int part_name_len= 0;
const char *subpart_name= NULL;
int subpart_name_len= 0;
- uint name_variant= NORMAL_PART_NAME;
+ uint part_type= NORMAL_PART_NAME;
+
const char *tmp_p;
DBUG_ENTER("explain_filename");
DBUG_PRINT("enter", ("from '%s'", from));
@@ -228,17 +228,18 @@ uint explain_filename(THD* thd,
table_name= tmp_p;
}
tmp_p= table_name;
- while (!res && (tmp_p= strchr(tmp_p, '#')))
+ /* Look if there are partition tokens in the table name. */
+ while ((tmp_p= strchr(tmp_p, '#')))
{
tmp_p++;
switch (tmp_p[0]) {
case 'P':
case 'p':
if (tmp_p[1] == '#')
+ {
part_name= tmp_p + 2;
- else
- res= 1;
- tmp_p+= 2;
+ tmp_p+= 2;
+ }
break;
case 'S':
case 's':
@@ -248,48 +249,32 @@ uint explain_filename(THD* thd,
subpart_name= tmp_p + 3;
tmp_p+= 3;
}
- else if ((tmp_p[1] == 'Q' || tmp_p[1] == 'q') &&
- (tmp_p[2] == 'L' || tmp_p[2] == 'l') &&
- tmp_p[3] == '-')
- {
- tmp_p+= 4; /* sql- prefix found */
- }
- else
- res= 2;
break;
case 'T':
case 't':
if ((tmp_p[1] == 'M' || tmp_p[1] == 'm') &&
(tmp_p[2] == 'P' || tmp_p[2] == 'p') &&
tmp_p[3] == '#' && !tmp_p[4])
- name_variant= TEMP_PART_NAME;
- else
- res= 3;
- tmp_p+= 4;
+ {
+ part_type= TEMP_PART_NAME;
+ tmp_p+= 4;
+ }
break;
case 'R':
case 'r':
if ((tmp_p[1] == 'E' || tmp_p[1] == 'e') &&
(tmp_p[2] == 'N' || tmp_p[2] == 'n') &&
tmp_p[3] == '#' && !tmp_p[4])
- name_variant= RENAMED_PART_NAME;
- else
- res= 4;
- tmp_p+= 4;
+ {
+ part_type= RENAMED_PART_NAME;
+ tmp_p+= 4;
+ }
break;
default:
- res= 5;
+ /* Not partition name part. */
+ ;
}
}
- if (res)
- {
- /* Better to give something back if we fail parsing, than nothing at all */
- DBUG_PRINT("info", ("Error in explain_filename: %u", res));
- sql_print_warning("Invalid (old?) table or database name '%s'", from);
- DBUG_RETURN(my_snprintf(to, to_length,
- "<result %u when explaining filename '%s'>",
- res, from));
- }
if (part_name)
{
table_name_len= part_name - table_name - 3;
@@ -297,7 +282,7 @@ uint explain_filename(THD* thd,
subpart_name_len= strlen(subpart_name);
else
part_name_len= strlen(part_name);
- if (name_variant != NORMAL_PART_NAME)
+ if (part_type != NORMAL_PART_NAME)
{
if (subpart_name)
subpart_name_len-= 5;
@@ -339,9 +324,9 @@ uint explain_filename(THD* thd,
to_p= strnmov(to_p, " ", end_p - to_p);
else
to_p= strnmov(to_p, ", ", end_p - to_p);
- if (name_variant != NORMAL_PART_NAME)
+ if (part_type != NORMAL_PART_NAME)
{
- if (name_variant == TEMP_PART_NAME)
+ if (part_type == TEMP_PART_NAME)
to_p= strnmov(to_p, ER_THD_OR_DEFAULT(thd, ER_TEMPORARY_NAME),
end_p - to_p);
else
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index 11f2007f0bc..dd1c92af6f4 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#define MYSQL_LEX 1
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 42e12f4cb76..0cedf50e4a2 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
- Copyright (c) 2011 Monty Program Ab
+/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2011, 2013, 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
@@ -535,7 +535,10 @@ int mysql_update(THD *thd,
/* If quick select is used, initialize it before retrieving rows. */
if (select && select->quick && select->quick->reset())
+ {
+ close_cached_file(&tempfile);
goto err;
+ }
table->file->try_semi_consistent_read(1);
/*
@@ -587,13 +590,18 @@ int mysql_update(THD *thd,
}
else
{
- table->file->unlock_row();
+ /*
+ Don't try unlocking the row if skip_record reported an error since in
+ this case the transaction might have been rolled back already.
+ */
if (error < 0)
{
/* Fatal error from select->skip_record() */
error= 1;
break;
}
+ else
+ table->file->unlock_row();
}
}
if (thd->killed && !error)
@@ -832,8 +840,17 @@ int mysql_update(THD *thd,
}
}
}
- else
+ /*
+ Don't try unlocking the row if skip_record reported an error since in
+ this case the transaction might have been rolled back already.
+ */
+ else if (!thd->is_error())
table->file->unlock_row();
+ else
+ {
+ error= 1;
+ break;
+ }
thd->warning_info->inc_current_row_for_warning();
if (thd->is_error())
{
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 0e22db11eb8..17287b27154 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define MYSQL_LEX 1
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 08972afbf9a..53dd524ac65 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -780,6 +780,7 @@ static bool add_create_index (LEX *lex, Key::Keytype type,
Diag_condition_item_name diag_condition_item_name;
DYNCALL_CREATE_DEF *dyncol_def;
List<DYNCALL_CREATE_DEF> *dyncol_def_list;
+ bool is_not_empty;
}
%{
@@ -1675,6 +1676,9 @@ END_OF_INPUT
'-' '+' '*' '/' '%' '(' ')'
',' '!' '{' '}' '&' '|' AND_SYM OR_SYM OR_OR_SYM BETWEEN_SYM CASE_SYM
THEN_SYM WHEN_SYM DIV_SYM MOD_SYM OR2_SYM AND_AND_SYM DELETE_SYM
+
+%type <is_not_empty> opt_union_order_or_limit
+
%%
/*
@@ -9387,6 +9391,7 @@ sum_expr:
if ($$ == NULL)
MYSQL_YYABORT;
$5->empty();
+ sel->gorder_list.empty();
}
;
@@ -9456,18 +9461,27 @@ opt_gconcat_separator:
opt_gorder_clause:
/* empty */
+ | ORDER_SYM BY
{
- Select->gorder_list = NULL;
- }
- | order_clause
- {
- SELECT_LEX *select= Select;
- select->gorder_list= new (YYTHD->mem_root)
- SQL_I_List<ORDER>(select->order_list);
- if (select->gorder_list == NULL)
+ LEX *lex= Lex;
+ SELECT_LEX *sel= lex->current_select;
+ if (sel->linkage != GLOBAL_OPTIONS_TYPE &&
+ sel->olap != UNSPECIFIED_OLAP_TYPE &&
+ (sel->linkage != UNION_TYPE || sel->braces))
+ {
+ my_error(ER_WRONG_USAGE, MYF(0),
+ "CUBE/ROLLUP", "ORDER BY");
MYSQL_YYABORT;
- select->order_list.empty();
+ }
}
+ gorder_list;
+ ;
+
+gorder_list:
+ gorder_list ',' order_ident order_dir
+ { if (add_gorder_to_list(YYTHD, $3,(bool) $4)) MYSQL_YYABORT; }
+ | order_ident order_dir
+ { if (add_gorder_to_list(YYTHD, $1,(bool) $2)) MYSQL_YYABORT; }
;
in_sum_expr:
@@ -9874,12 +9888,16 @@ table_factor:
lex->pop_context();
lex->nest_level--;
}
- else if (($3->select_lex &&
+ /*else if (($3->select_lex &&
$3->select_lex->master_unit()->is_union() &&
($3->select_lex->master_unit()->first_select() ==
- $3->select_lex || !$3->lifted)) || $5)
+ $3->select_lex || !$3->lifted)) || $5)*/
+ else if ($5 != NULL)
{
- /* simple nested joins cannot have aliases or unions */
+ /*
+ Tables with or without joins within parentheses cannot
+ have aliases, and we ruled out derived tables above.
+ */
my_parse_error(ER(ER_SYNTAX_ERROR));
MYSQL_YYABORT;
}
@@ -9892,8 +9910,34 @@ table_factor:
}
;
+/*
+ This rule accepts just about anything. The reason is that we have
+ empty-producing rules in the beginning of rules, in this case
+ subselect_start. This forces bison to take a decision which rules to
+ reduce by long before it has seen any tokens. This approach ties us
+ to a very limited class of parseable languages, and unfortunately
+ SQL is not one of them. The chosen 'solution' was this rule, which
+ produces just about anything, even complete bogus statements, for
+ instance ( table UNION SELECT 1 ).
+ Fortunately, we know that the semantic value returned by
+ select_derived is NULL if it contained a derived table, and a pointer to
+ the base table's TABLE_LIST if it was a base table. So in the rule
+ regarding union's, we throw a parse error manually and pretend it
+ was bison that did it.
+
+ Also worth noting is that this rule concerns query expressions in
+ the from clause only. Top level select statements and other types of
+ subqueries have their own union rules.
+*/
select_derived_union:
select_derived opt_union_order_or_limit
+ {
+ if ($1 && $2)
+ {
+ my_parse_error(ER(ER_SYNTAX_ERROR));
+ MYSQL_YYABORT;
+ }
+ }
| select_derived_union
UNION_SYM
union_option
@@ -9910,6 +9954,13 @@ select_derived_union:
Lex->pop_context();
}
opt_union_order_or_limit
+ {
+ if ($1 != NULL)
+ {
+ my_parse_error(ER(ER_SYNTAX_ERROR));
+ MYSQL_YYABORT;
+ }
+ }
;
/* The equivalent of select_init2 for nested queries. */
@@ -11374,7 +11425,9 @@ show:
bzero((char*) &lex->create_info,sizeof(lex->create_info));
}
show_param
- {}
+ {
+ Select->parsing_place= NO_MATTER;
+ }
;
show_param:
@@ -11752,7 +11805,10 @@ describe:
if (prepare_schema_table(YYTHD, lex, $2, SCH_COLUMNS))
MYSQL_YYABORT;
}
- opt_describe_column {}
+ opt_describe_column
+ {
+ Select->parsing_place= NO_MATTER;
+ }
| describe_command opt_extended_describe
{ Lex->describe|= DESCRIBE_NORMAL; }
select
@@ -14505,8 +14561,8 @@ union_opt:
;
opt_union_order_or_limit:
- /* Empty */
- | union_order_or_limit
+ /* Empty */{ $$= false; }
+ | union_order_or_limit { $$= true; }
;
union_order_or_limit:
diff --git a/sql/strfunc.cc b/sql/strfunc.cc
index f39901a6ca5..2b3df48cf74 100644
--- a/sql/strfunc.cc
+++ b/sql/strfunc.cc
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/* Some useful string utility functions used by the MySQL server */
diff --git a/sql/table.cc b/sql/table.cc
index 9eaa214dfb0..7635e03ad6b 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -13,7 +13,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/* Some general useful functions */
diff --git a/sql/transaction.cc b/sql/transaction.cc
index 1623cd57d77..3b0af4db710 100644
--- a/sql/transaction.cc
+++ b/sql/transaction.cc
@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#ifdef USE_PRAGMA_IMPLEMENTATION
diff --git a/sql/unireg.h b/sql/unireg.h
index da510bb4e6d..a35c25f92ee 100644
--- a/sql/unireg.h
+++ b/sql/unireg.h
@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#include "my_global.h" /* ulonglong */