summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <jani@a88-113-38-195.elisa-laajakaista.fi>2008-03-13 23:35:52 +0200
committerunknown <jani@a88-113-38-195.elisa-laajakaista.fi>2008-03-13 23:35:52 +0200
commit6ef32fd0a91148b9758acaa1e2ebde3110e96781 (patch)
tree45d9abbd3b89bec4d4880130013f666463dccb90 /sql
parentabf07615394340cf8100afdb192b37d518cf3910 (diff)
parent269ebe54211cf96c4e64fa7268a1414588ca1de8 (diff)
downloadmariadb-git-6ef32fd0a91148b9758acaa1e2ebde3110e96781.tar.gz
Merge a88-113-38-195.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-main
into a88-113-38-195.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-marvel client/mysqldump.c: Auto merged include/my_global.h: Auto merged mysql-test/lib/mtr_report.pl: Auto merged sql/handler.cc: Auto merged sql/item_func.cc: Auto merged sql/log.cc: Auto merged sql/mysql_priv.h: Auto merged sql/mysqld.cc: Auto merged sql/set_var.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_plugin.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.h: Auto merged mysys/my_create.c: SCCS merged
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc84
-rw-r--r--sql/field.h2
-rw-r--r--sql/filesort.cc3
-rw-r--r--sql/ha_ndbcluster_cond.cc9
-rw-r--r--sql/ha_ndbcluster_cond.h1
-rw-r--r--sql/handler.cc11
-rw-r--r--sql/item.cc126
-rw-r--r--sql/item.h39
-rw-r--r--sql/item_cmpfunc.cc5
-rw-r--r--sql/item_func.cc42
-rw-r--r--sql/item_func.h24
-rw-r--r--sql/item_sum.cc3
-rw-r--r--sql/log.cc10
-rw-r--r--sql/matherr.c42
-rw-r--r--sql/mysql_priv.h4
-rw-r--r--sql/mysqld.cc12
-rw-r--r--sql/partition_info.cc56
-rw-r--r--sql/partition_info.h1
-rw-r--r--sql/rpl_mi.cc4
-rw-r--r--sql/rpl_rli.cc6
-rw-r--r--sql/set_var.cc41
-rw-r--r--sql/share/errmsg.txt6
-rw-r--r--sql/sp.cc6
-rw-r--r--sql/sql_acl.cc19
-rw-r--r--sql/sql_base.cc8
-rw-r--r--sql/sql_parse.cc77
-rw-r--r--sql/sql_plugin.cc38
-rw-r--r--sql/sql_select.cc43
-rw-r--r--sql/sql_show.cc8
-rw-r--r--sql/sql_yacc.yy29
-rw-r--r--sql/table.h24
-rw-r--r--sql/unireg.h1
32 files changed, 546 insertions, 238 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 7c4f6c9ff5f..4b07da2c1c1 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -2261,13 +2261,11 @@ int Field_decimal::store(double nr)
return 1;
}
-#ifdef HAVE_FINITE
- if (!finite(nr)) // Handle infinity as special case
+ if (!isfinite(nr)) // Handle infinity as special case
{
overflow(nr < 0.0);
return 1;
}
-#endif
reg4 uint i;
size_t length;
@@ -6323,26 +6321,41 @@ check_string_copy_error(Field_str *field,
}
-
/*
- Send a truncation warning or a truncation error
- after storing a too long character string info a field.
+ Check if we lost any important data and send a truncation error/warning
SYNOPSIS
- report_data_too_long()
- field - Field
+ Field_longstr::report_if_important_data()
+ ptr - Truncated rest of string
+ end - End of truncated string
- RETURN
- N/A
+ RETURN VALUES
+ 0 - None was truncated (or we don't count cut fields)
+ 2 - Some bytes was truncated
+
+ NOTE
+ Check if we lost any important data (anything in a binary string,
+ or any non-space in others). If only trailing spaces was lost,
+ send a truncation note, otherwise send a truncation error.
*/
-inline void
-report_data_too_long(Field_str *field)
+int
+Field_longstr::report_if_important_data(const char *ptr, const char *end)
{
- if (field->table->in_use->abort_on_warning)
- field->set_warning(MYSQL_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1);
- else
- field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
+ if ((ptr < end) && table->in_use->count_cuted_fields)
+ {
+ if (test_if_important_data(field_charset, ptr, end))
+ {
+ if (table->in_use->abort_on_warning)
+ set_warning(MYSQL_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1);
+ else
+ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
+ }
+ else /* If we lost only spaces then produce a NOTE, not a WARNING */
+ set_warning(MYSQL_ERROR::WARN_LEVEL_NOTE, WARN_DATA_TRUNCATED, 1);
+ return 2;
+ }
+ return 0;
}
@@ -6377,19 +6390,7 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
cannot_convert_error_pos, from + length, cs))
return 2;
- /*
- Check if we lost any important data (anything in a binary string,
- or any non-space in others).
- */
- if ((from_end_pos < from + length) && table->in_use->count_cuted_fields)
- {
- if (test_if_important_data(field_charset, from_end_pos, from + length))
- {
- report_data_too_long(this);
- return 2;
- }
- }
- return 0;
+ return report_if_important_data(from_end_pos, from + length);
}
@@ -6964,16 +6965,7 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
cannot_convert_error_pos, from + length, cs))
return 2;
- // Check if we lost something other than just trailing spaces
- if ((from_end_pos < from + length) && table->in_use->count_cuted_fields)
- {
- if (test_if_important_data(field_charset, from_end_pos, from + length))
- report_data_too_long(this);
- else /* If we lost only spaces then produce a NOTE, not a WARNING */
- set_warning(MYSQL_ERROR::WARN_LEVEL_NOTE, WARN_DATA_TRUNCATED, 1);
- return 2;
- }
- return 0;
+ return report_if_important_data(from_end_pos, from + length);
}
@@ -7665,13 +7657,7 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs)
cannot_convert_error_pos, from + length, cs))
return 2;
- if (from_end_pos < from + length)
- {
- report_data_too_long(this);
- return 2;
- }
-
- return 0;
+ return report_if_important_data(from_end_pos, from + length);
oom_error:
/* Fatal OOM error */
@@ -8619,10 +8605,10 @@ int Field_set::store(longlong nr, bool unsigned_val)
{
ASSERT_COLUMN_MARKED_FOR_WRITE;
int error= 0;
- if ((ulonglong) nr > (ulonglong) (((longlong) 1 << typelib->count) -
- (longlong) 1))
+ ulonglong max_nr= set_bits(ulonglong, typelib->count);
+ if ((ulonglong) nr > max_nr)
{
- nr&= (longlong) (((longlong) 1 << typelib->count) - (longlong) 1);
+ nr&= max_nr;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
error=1;
}
diff --git a/sql/field.h b/sql/field.h
index a6a1d8bfabc..9855ec563d5 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -593,6 +593,8 @@ public:
class Field_longstr :public Field_str
{
+protected:
+ int report_if_important_data(const char *ptr, const char *end);
public:
Field_longstr(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg,
diff --git a/sql/filesort.cc b/sql/filesort.cc
index ac731616218..90e0fe386d5 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -230,8 +230,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
sort_keys= table_sort.sort_keys;
if (memavl < min_sort_memory)
{
- my_error(ER_OUTOFMEMORY,MYF(ME_ERROR+ME_WAITTANG),
- thd->variables.sortbuff_size);
+ my_error(ER_OUT_OF_SORTMEMORY,MYF(ME_ERROR+ME_WAITTANG));
goto err;
}
if (open_cached_file(&buffpek_pointers,mysql_tmpdir,TEMP_PREFIX,
diff --git a/sql/ha_ndbcluster_cond.cc b/sql/ha_ndbcluster_cond.cc
index d8dff3c7e2f..bb35211944b 100644
--- a/sql/ha_ndbcluster_cond.cc
+++ b/sql/ha_ndbcluster_cond.cc
@@ -117,7 +117,8 @@ void ndb_serialize_cond(const Item *item, void *arg)
if (item->type() == Item::FUNC_ITEM)
{
Item_func *func_item= (Item_func *) item;
- if (func_item->functype() == Item_func::UNKNOWN_FUNC &&
+ if ((func_item->functype() == Item_func::UNKNOWN_FUNC ||
+ func_item->functype() == Item_func::NEG_FUNC) &&
func_item->const_item())
{
// Skip any arguments since we will evaluate function instead
@@ -369,8 +370,9 @@ void ndb_serialize_cond(const Item *item, void *arg)
{
Item_func *func_item= (Item_func *) item;
// Check that we expect a function or functional expression here
- if (context->expecting(Item::FUNC_ITEM) ||
- func_item->functype() == Item_func::UNKNOWN_FUNC)
+ if (context->expecting(Item::FUNC_ITEM) ||
+ func_item->functype() == Item_func::UNKNOWN_FUNC ||
+ func_item->functype() == Item_func::NEG_FUNC)
context->expect_nothing();
else
{
@@ -584,6 +586,7 @@ void ndb_serialize_cond(const Item *item, void *arg)
context->expect(Item::FUNC_ITEM);
break;
}
+ case Item_func::NEG_FUNC:
case Item_func::UNKNOWN_FUNC:
{
DBUG_PRINT("info", ("UNKNOWN_FUNC %s",
diff --git a/sql/ha_ndbcluster_cond.h b/sql/ha_ndbcluster_cond.h
index 4d1d2ef9f92..4401a93c9e1 100644
--- a/sql/ha_ndbcluster_cond.h
+++ b/sql/ha_ndbcluster_cond.h
@@ -233,6 +233,7 @@ public:
case (Item_func::ISNOTNULL_FUNC): { return NDB_ISNOTNULL_FUNC; }
case (Item_func::LIKE_FUNC): { return NDB_LIKE_FUNC; }
case (Item_func::NOT_FUNC): { return NDB_NOT_FUNC; }
+ case (Item_func::NEG_FUNC): { return NDB_UNKNOWN_FUNC; }
case (Item_func::UNKNOWN_FUNC): { return NDB_UNKNOWN_FUNC; }
case (Item_func::COND_AND_FUNC): { return NDB_COND_AND_FUNC; }
case (Item_func::COND_OR_FUNC): { return NDB_COND_OR_FUNC; }
diff --git a/sql/handler.cc b/sql/handler.cc
index 8dee27b509d..69302d4253a 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -1922,6 +1922,13 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path,
handler *handler::clone(MEM_ROOT *mem_root)
{
handler *new_handler= get_new_handler(table->s, mem_root, table->s->db_type());
+ /*
+ Allocate handler->ref here because otherwise ha_open will allocate it
+ on this->table->mem_root and we will not be able to reclaim that memory
+ when the clone handler object is destroyed.
+ */
+ if (!(new_handler->ref= (uchar*) alloc_root(mem_root, ALIGN_SIZE(ref_length)*2)))
+ return NULL;
if (new_handler && !new_handler->ha_open(table,
table->s->normalized_path.str,
table->db_stat,
@@ -1990,7 +1997,9 @@ int handler::ha_open(TABLE *table_arg, const char *name, int mode,
table->db_stat|=HA_READ_ONLY;
(void) extra(HA_EXTRA_NO_READCHECK); // Not needed in SQL
- if (!(ref= (uchar*) alloc_root(&table->mem_root, ALIGN_SIZE(ref_length)*2)))
+ /* ref is already allocated for us if we're called from handler::clone() */
+ if (!ref && !(ref= (uchar*) alloc_root(&table->mem_root,
+ ALIGN_SIZE(ref_length)*2)))
{
close();
error=HA_ERR_OUT_OF_MEM;
diff --git a/sql/item.cc b/sql/item.cc
index d2b071a1dfd..cfb8f336a91 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -18,6 +18,7 @@
#pragma implementation // gcc: Class implementation
#endif
#include "mysql_priv.h"
+#include <mysql.h>
#include <m_ctype.h>
#include "my_dir.h"
#include "sp_rcontext.h"
@@ -1237,6 +1238,22 @@ bool Item_name_const::is_null()
return value_item->is_null();
}
+
+Item_name_const::Item_name_const(Item *name_arg, Item *val):
+ value_item(val), name_item(name_arg)
+{
+ if (!(valid_args= name_item->basic_const_item() &&
+ (value_item->basic_const_item() ||
+ ((value_item->type() == FUNC_ITEM) &&
+ (((Item_func *) value_item)->functype() ==
+ Item_func::NEG_FUNC) &&
+ (((Item_func *) value_item)->key_item()->type() !=
+ FUNC_ITEM)))))
+ my_error(ER_WRONG_ARGUMENTS, MYF(0), "NAME_CONST");
+ Item::maybe_null= TRUE;
+}
+
+
Item::Type Item_name_const::type() const
{
/*
@@ -1248,8 +1265,17 @@ Item::Type Item_name_const::type() const
if (item->type() == FIELD_ITEM)
((Item_field *) item)->...
we return NULL_ITEM in the case to avoid wrong casting.
+
+ valid_args guarantees value_item->basic_const_item(); if type is
+ FUNC_ITEM, then we have a fudged item_func_neg() on our hands
+ and return the underlying type.
*/
- return valid_args ? value_item->type() : NULL_ITEM;
+ return valid_args ?
+ (((value_item->type() == FUNC_ITEM) &&
+ (((Item_func *) value_item)->functype() == Item_func::NEG_FUNC)) ?
+ ((Item_func *) value_item)->key_item()->type() :
+ value_item->type()) :
+ NULL_ITEM;
}
@@ -3983,6 +4009,18 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
else if (!from_field)
goto error;
+ if (!outer_fixed && cached_table && cached_table->select_lex &&
+ context->select_lex &&
+ cached_table->select_lex != context->select_lex)
+ {
+ int ret;
+ if ((ret= fix_outer_field(thd, &from_field, reference)) < 0)
+ goto error;
+ if (!ret)
+ return FALSE;
+ outer_fixed= 1;
+ }
+
/*
if it is not expression from merged VIEW we will set this field.
@@ -3998,18 +4036,6 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
if (from_field == view_ref_found)
return FALSE;
- if (!outer_fixed && cached_table && cached_table->select_lex &&
- context->select_lex &&
- cached_table->select_lex != context->select_lex)
- {
- int ret;
- if ((ret= fix_outer_field(thd, &from_field, reference)) < 0)
- goto error;
- if (!ret)
- return FALSE;
- outer_fixed= 1;
- }
-
set_field(from_field);
if (thd->lex->in_sum_func &&
thd->lex->in_sum_func->nest_level ==
@@ -4181,6 +4207,30 @@ bool Item_field::subst_argument_checker(uchar **arg)
/**
+ Convert a numeric value to a zero-filled string
+
+ @param[in,out] item the item to operate on
+ @param field The field that this value is equated to
+
+ This function converts a numeric value to a string. In this conversion
+ the zero-fill flag of the field is taken into account.
+ This is required so the resulting string value can be used instead of
+ the field reference when propagating equalities.
+*/
+
+static void convert_zerofill_number_to_string(Item **item, Field_num *field)
+{
+ char buff[MAX_FIELD_WIDTH],*pos;
+ String tmp(buff,sizeof(buff), field->charset()), *res;
+
+ res= (*item)->val_str(&tmp);
+ field->prepend_zeros(res);
+ pos= (char *) sql_strmake (res->ptr(), res->length());
+ *item= new Item_string(pos, res->length(), field->charset());
+}
+
+
+/**
Set a pointer to the multiple equality the field reference belongs to
(if any).
@@ -4226,6 +4276,13 @@ Item *Item_field::equal_fields_propagator(uchar *arg)
if (!item ||
(cmp_context != (Item_result)-1 && item->cmp_context != cmp_context))
item= this;
+ else if (field && (field->flags & ZEROFILL_FLAG) && IS_NUM(field->type()))
+ {
+ if (item && cmp_context != INT_RESULT)
+ convert_zerofill_number_to_string(&item, (Field_num *)field);
+ else
+ item= this;
+ }
return item;
}
@@ -4402,6 +4459,49 @@ String *Item::check_well_formed_result(String *str, bool send_error)
return str;
}
+/*
+ Compare two items using a given collation
+
+ SYNOPSIS
+ eq_by_collation()
+ item item to compare with
+ binary_cmp TRUE <-> compare as binaries
+ cs collation to use when comparing strings
+
+ DESCRIPTION
+ This method works exactly as Item::eq if the collation cs coincides with
+ the collation of the compared objects. Otherwise, first the collations that
+ differ from cs are replaced for cs and then the items are compared by
+ Item::eq. After the comparison the original collations of items are
+ restored.
+
+ RETURN
+ 1 compared items has been detected as equal
+ 0 otherwise
+*/
+
+bool Item::eq_by_collation(Item *item, bool binary_cmp, CHARSET_INFO *cs)
+{
+ CHARSET_INFO *save_cs= 0;
+ CHARSET_INFO *save_item_cs= 0;
+ if (collation.collation != cs)
+ {
+ save_cs= collation.collation;
+ collation.collation= cs;
+ }
+ if (item->collation.collation != cs)
+ {
+ save_item_cs= item->collation.collation;
+ item->collation.collation= cs;
+ }
+ bool res= eq(item, binary_cmp);
+ if (save_cs)
+ collation.collation= save_cs;
+ if (save_item_cs)
+ item->collation.collation= save_item_cs;
+ return res;
+}
+
/**
Create a field to hold a string value from an item.
diff --git a/sql/item.h b/sql/item.h
index 7cf0bafa9d9..cd8bb4faccb 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -1007,6 +1007,7 @@ public:
virtual Field::geometry_type get_geometry_type() const
{ return Field::GEOM_GEOMETRY; };
String *check_well_formed_result(String *str, bool send_error= 0);
+ bool eq_by_collation(Item *item, bool binary_cmp, CHARSET_INFO *cs);
};
@@ -1264,14 +1265,7 @@ class Item_name_const : public Item
Item *name_item;
bool valid_args;
public:
- Item_name_const(Item *name_arg, Item *val):
- value_item(val), name_item(name_arg)
- {
- if (!(valid_args= name_item->basic_const_item() &
- value_item->basic_const_item()))
- my_error(ER_WRONG_ARGUMENTS, MYF(0), "NAME_CONST");
- Item::maybe_null= TRUE;
- }
+ Item_name_const(Item *name_arg, Item *val);
bool fix_fields(THD *, Item **);
@@ -2219,6 +2213,35 @@ public:
Item_field *filed_for_view_update()
{ return (*ref)->filed_for_view_update(); }
virtual Ref_Type ref_type() { return REF; }
+
+ // Row emulation: forwarding of ROW-related calls to ref
+ uint cols()
+ {
+ return ref && result_type() == ROW_RESULT ? (*ref)->cols() : 1;
+ }
+ Item* element_index(uint i)
+ {
+ return ref && result_type() == ROW_RESULT ? (*ref)->element_index(i) : this;
+ }
+ Item** addr(uint i)
+ {
+ return ref && result_type() == ROW_RESULT ? (*ref)->addr(i) : 0;
+ }
+ bool check_cols(uint c)
+ {
+ return ref && result_type() == ROW_RESULT ? (*ref)->check_cols(c)
+ : Item::check_cols(c);
+ }
+ bool null_inside()
+ {
+ return ref && result_type() == ROW_RESULT ? (*ref)->null_inside() : 0;
+ }
+ void bring_value()
+ {
+ if (ref && result_type() == ROW_RESULT)
+ (*ref)->bring_value();
+ }
+
};
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index ae7ea95707c..f267ad39984 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -3059,7 +3059,10 @@ void in_string::set(uint pos,Item *item)
{
if (res->uses_buffer_owned_by(str))
res->copy();
- *str= *res;
+ if (item->type() == Item::FUNC_ITEM)
+ str->copy(*res);
+ else
+ *str= *res;
}
if (!str->charset())
{
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 5a95e8ffa08..f5bae5f07d8 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -1094,7 +1094,7 @@ double Item_func_plus::real_op()
double value= args[0]->val_real() + args[1]->val_real();
if ((null_value=args[0]->null_value || args[1]->null_value))
return 0.0;
- return value;
+ return fix_result(value);
}
@@ -1172,7 +1172,7 @@ double Item_func_minus::real_op()
double value= args[0]->val_real() - args[1]->val_real();
if ((null_value=args[0]->null_value || args[1]->null_value))
return 0.0;
- return value;
+ return fix_result(value);
}
@@ -1212,7 +1212,7 @@ double Item_func_mul::real_op()
double value= args[0]->val_real() * args[1]->val_real();
if ((null_value=args[0]->null_value || args[1]->null_value))
return 0.0;
- return value;
+ return fix_result(value);
}
@@ -1270,7 +1270,7 @@ double Item_func_div::real_op()
signal_divide_by_null();
return 0.0;
}
- return value/val2;
+ return fix_result(value/val2);
}
@@ -1644,7 +1644,7 @@ double Item_func_exp::val_real()
double value= args[0]->val_real();
if ((null_value=args[0]->null_value))
return 0.0; /* purecov: inspected */
- return exp(value);
+ return fix_result(exp(value));
}
double Item_func_sqrt::val_real()
@@ -1663,7 +1663,7 @@ double Item_func_pow::val_real()
double val2= args[1]->val_real();
if ((null_value=(args[0]->null_value || args[1]->null_value)))
return 0.0; /* purecov: inspected */
- return pow(value,val2);
+ return fix_result(pow(value,val2));
}
// Trigonometric functions
@@ -1675,7 +1675,7 @@ double Item_func_acos::val_real()
volatile double value= args[0]->val_real();
if ((null_value=(args[0]->null_value || (value < -1.0 || value > 1.0))))
return 0.0;
- return fix_result(acos(value));
+ return acos(value);
}
double Item_func_asin::val_real()
@@ -1685,7 +1685,7 @@ double Item_func_asin::val_real()
volatile double value= args[0]->val_real();
if ((null_value=(args[0]->null_value || (value < -1.0 || value > 1.0))))
return 0.0;
- return fix_result(asin(value));
+ return asin(value);
}
double Item_func_atan::val_real()
@@ -1701,7 +1701,7 @@ double Item_func_atan::val_real()
return 0.0;
return fix_result(atan2(value,val2));
}
- return fix_result(atan(value));
+ return atan(value);
}
double Item_func_cos::val_real()
@@ -1710,7 +1710,7 @@ double Item_func_cos::val_real()
double value= args[0]->val_real();
if ((null_value=args[0]->null_value))
return 0.0;
- return fix_result(cos(value));
+ return cos(value);
}
double Item_func_sin::val_real()
@@ -1719,7 +1719,7 @@ double Item_func_sin::val_real()
double value= args[0]->val_real();
if ((null_value=args[0]->null_value))
return 0.0;
- return fix_result(sin(value));
+ return sin(value);
}
double Item_func_tan::val_real()
@@ -3647,18 +3647,28 @@ longlong Item_func_benchmark::val_int()
String tmp(buff,sizeof(buff), &my_charset_bin);
my_decimal tmp_decimal;
THD *thd=current_thd;
- ulong loop_count;
+ ulonglong loop_count;
- loop_count= (ulong) args[0]->val_int();
+ loop_count= (ulonglong) args[0]->val_int();
- if (args[0]->null_value)
+ if (args[0]->null_value ||
+ (!args[0]->unsigned_flag && (((longlong) loop_count) < 0)))
{
+ if (!args[0]->null_value)
+ {
+ char buff[22];
+ llstr(((longlong) loop_count), buff);
+ push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+ ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
+ "count", buff, "benchmark");
+ }
+
null_value= 1;
return 0;
}
null_value=0;
- for (ulong loop=0 ; loop < loop_count && !thd->killed; loop++)
+ for (ulonglong loop=0 ; loop < loop_count && !thd->killed; loop++)
{
switch (args[1]->result_type()) {
case REAL_RESULT:
@@ -5491,6 +5501,8 @@ Item_func_sp::make_field(Send_field *tmp_field)
DBUG_ENTER("Item_func_sp::make_field");
DBUG_ASSERT(sp_result_field);
sp_result_field->make_field(tmp_field);
+ if (name)
+ tmp_field->col_name= name;
DBUG_VOID_RETURN;
}
diff --git a/sql/item_func.h b/sql/item_func.h
index f8eb7ff6200..9affa3a1b54 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -54,7 +54,8 @@ public:
NOT_FUNC, NOT_ALL_FUNC,
NOW_FUNC, TRIG_COND_FUNC,
SUSERVAR_FUNC, GUSERVAR_FUNC, COLLATE_FUNC,
- EXTRACT_FUNC, CHAR_TYPECAST_FUNC, FUNC_SP, UDF_FUNC };
+ EXTRACT_FUNC, CHAR_TYPECAST_FUNC, FUNC_SP, UDF_FUNC,
+ NEG_FUNC };
enum optimize_type { OPTIMIZE_NONE,OPTIMIZE_KEY,OPTIMIZE_OP, OPTIMIZE_NULL,
OPTIMIZE_EQUAL };
enum Type type() const { return FUNC_ITEM; }
@@ -192,6 +193,13 @@ public:
void * arg, traverse_order order);
bool is_expensive_processor(uchar *arg);
virtual bool is_expensive() { return 0; }
+ inline double fix_result(double value)
+ {
+ if (isfinite(value))
+ return value;
+ null_value=1;
+ return 0.0;
+ }
};
@@ -477,7 +485,7 @@ public:
longlong int_op();
my_decimal *decimal_op(my_decimal *);
const char *func_name() const { return "-"; }
- virtual bool basic_const_item() const { return args[0]->basic_const_item(); }
+ enum Functype functype() const { return NEG_FUNC; }
void fix_length_and_dec();
void fix_num_length_and_dec();
uint decimal_precision() const { return args[0]->decimal_precision(); }
@@ -509,18 +517,6 @@ class Item_dec_func :public Item_real_func
decimals=NOT_FIXED_DEC; max_length=float_length(decimals);
maybe_null=1;
}
- inline double fix_result(double value)
- {
-#ifndef HAVE_FINITE
- return value;
-#else
- /* The following should be safe, even if we compare doubles */
- if (finite(value) && value != POSTFIX_ERROR)
- return value;
- null_value=1;
- return 0.0;
-#endif
- }
};
class Item_func_exp :public Item_dec_func
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index f5a3956c1e4..4a4ee5fa73c 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -600,6 +600,7 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref)
result_field=0;
null_value=1;
fix_length_and_dec();
+ item= item->real_item();
if (item->type() == Item::FIELD_ITEM)
hybrid_field_type= ((Item_field*) item)->field->type();
else
@@ -3493,6 +3494,6 @@ void Item_func_group_concat::print(String *str, enum_query_type query_type)
Item_func_group_concat::~Item_func_group_concat()
{
- if (unique_filter)
+ if (!original && unique_filter)
delete unique_filter;
}
diff --git a/sql/log.cc b/sql/log.cc
index 9e7a4d05f3f..e26ce6e619d 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -4453,15 +4453,7 @@ static void print_buffer_to_nt_eventlog(enum loglevel level, char *buff,
return an error (e.g. logging to the log tables)
*/
-#ifdef EMBEDDED_LIBRARY
-int vprint_msg_to_log(enum loglevel level __attribute__((unused)),
- const char *format __attribute__((unused)),
- va_list argsi __attribute__((unused)))
-{
- DBUG_ENTER("vprint_msg_to_log");
- DBUG_RETURN(0);
-}
-#else /*!EMBEDDED_LIBRARY*/
+#ifndef EMBEDDED_LIBRARY
static void print_buffer_to_file(enum loglevel level, const char *buffer)
{
time_t skr;
diff --git a/sql/matherr.c b/sql/matherr.c
deleted file mode 100644
index 4998d8b4961..00000000000
--- a/sql/matherr.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Copyright (C) 2000-2001 MySQL 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
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- 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, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-/* Fix that we got POSTFIX_ERROR when doing unreasonable math (not core) */
-
-#include <my_global.h>
-#include <errno.h>
-
- /* Fix that we gets POSTFIX_ERROR when error in math */
-
-#if defined(HAVE_MATHERR)
-int matherr(struct exception *x)
-{
- if (x->type != PLOSS)
- x->retval=POSTFIX_ERROR;
- switch (x->type) {
- case DOMAIN:
- case SING:
- my_errno=EDOM;
- break;
- case OVERFLOW:
- case UNDERFLOW:
- my_errno=ERANGE;
- break;
- default:
- break;
- }
- return(1); /* Take no other action */
-}
-#endif
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index bfb077e92bc..6bd0895aeb1 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -761,6 +761,7 @@ bool check_string_byte_length(LEX_STRING *str, const char *err_msg,
bool check_string_char_length(LEX_STRING *str, const char *err_msg,
uint max_char_length, CHARSET_INFO *cs,
bool no_error);
+bool test_if_data_home_dir(const char *dir);
bool parse_sql(THD *thd,
class Lex_input_stream *lip,
@@ -1805,7 +1806,8 @@ extern time_t server_start_time, flush_status_time;
#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
extern uint mysql_data_home_len;
extern char *mysql_data_home,server_version[SERVER_VERSION_LENGTH],
- mysql_real_data_home[];
+ mysql_real_data_home[], mysql_unpacked_real_data_home[];
+extern CHARSET_INFO *character_set_filesystem;
#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
#ifdef MYSQL_SERVER
extern char *opt_mysql_tmpdir, mysql_charsets_dir[],
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index aa928def49d..fd57be234aa 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -519,6 +519,7 @@ char mysql_real_data_home[FN_REFLEN],
language[FN_REFLEN], reg_ext[FN_EXTLEN], mysql_charsets_dir[FN_REFLEN],
*opt_init_file, *opt_tc_log_file,
def_ft_boolean_syntax[sizeof(ft_boolean_syntax)];
+char mysql_unpacked_real_data_home[FN_REFLEN];
uint reg_ext_length;
const key_map key_map_empty(0);
key_map key_map_full(0); // Will be initialized later
@@ -2513,10 +2514,6 @@ static void init_signals(void)
struct sigaction sa;
DBUG_ENTER("init_signals");
- if (test_flags & TEST_SIGINT)
- {
- my_sigset(thr_kill_signal, end_thread_signal);
- }
my_sigset(THR_SERVER_ALARM,print_signal_warning); // Should never be called!
if (!(test_flags & TEST_NO_STACKTRACE) || (test_flags & TEST_CORE_ON_SIGNAL))
@@ -2553,7 +2550,6 @@ static void init_signals(void)
(void) sigemptyset(&set);
my_sigset(SIGPIPE,SIG_IGN);
sigaddset(&set,SIGPIPE);
- sigaddset(&set,SIGINT);
#ifndef IGNORE_SIGHUP_SIGQUIT
sigaddset(&set,SIGQUIT);
sigaddset(&set,SIGHUP);
@@ -2575,9 +2571,12 @@ static void init_signals(void)
sigaddset(&set,THR_SERVER_ALARM);
if (test_flags & TEST_SIGINT)
{
+ my_sigset(thr_kill_signal, end_thread_signal);
// May be SIGINT
sigdelset(&set, thr_kill_signal);
}
+ else
+ sigaddset(&set,SIGINT);
sigprocmask(SIG_SETMASK,&set,NULL);
pthread_sigmask(SIG_SETMASK,&set,NULL);
DBUG_VOID_RETURN;
@@ -8310,6 +8309,9 @@ static void fix_paths(void)
pos[1]= 0;
}
convert_dirname(mysql_real_data_home,mysql_real_data_home,NullS);
+ (void) fn_format(buff, mysql_real_data_home, "", "",
+ (MY_RETURN_REAL_PATH|MY_RESOLVE_SYMLINKS));
+ (void) unpack_dirname(mysql_unpacked_real_data_home, buff);
convert_dirname(language,language,NullS);
(void) my_load_path(mysql_home,mysql_home,""); // Resolve current dir
(void) my_load_path(mysql_real_data_home,mysql_real_data_home,mysql_home);
diff --git a/sql/partition_info.cc b/sql/partition_info.cc
index 3b580422da1..3130f84bd73 100644
--- a/sql/partition_info.cc
+++ b/sql/partition_info.cc
@@ -1047,4 +1047,60 @@ error:
mem_alloc_error(size);
DBUG_RETURN(TRUE);
}
+
+
+/*
+ Check if path does not contain mysql data home directory
+ for partition elements with data directory and index directory
+
+ SYNOPSIS
+ check_partition_dirs()
+ part_info partition_info struct
+
+ RETURN VALUES
+ 0 ok
+ 1 error
+*/
+
+bool check_partition_dirs(partition_info *part_info)
+{
+ if (!part_info)
+ return 0;
+
+ partition_element *part_elem;
+ List_iterator<partition_element> part_it(part_info->partitions);
+ while ((part_elem= part_it++))
+ {
+ if (part_elem->subpartitions.elements)
+ {
+ List_iterator<partition_element> sub_it(part_elem->subpartitions);
+ partition_element *subpart_elem;
+ while ((subpart_elem= sub_it++))
+ {
+ if (test_if_data_home_dir(subpart_elem->data_file_name))
+ goto dd_err;
+ if (test_if_data_home_dir(subpart_elem->index_file_name))
+ goto id_err;
+ }
+ }
+ else
+ {
+ if (test_if_data_home_dir(part_elem->data_file_name))
+ goto dd_err;
+ if (test_if_data_home_dir(part_elem->index_file_name))
+ goto id_err;
+ }
+ }
+ return 0;
+
+dd_err:
+ my_error(ER_WRONG_ARGUMENTS,MYF(0),"DATA DIRECORY");
+ return 1;
+
+id_err:
+ my_error(ER_WRONG_ARGUMENTS,MYF(0),"INDEX DIRECORY");
+ return 1;
+}
+
+
#endif /* WITH_PARTITION_STORAGE_ENGINE */
diff --git a/sql/partition_info.h b/sql/partition_info.h
index b7d13e188f3..2859aaec3be 100644
--- a/sql/partition_info.h
+++ b/sql/partition_info.h
@@ -290,6 +290,7 @@ private:
};
uint32 get_next_partition_id_range(struct st_partition_iter* part_iter);
+bool check_partition_dirs(partition_info *part_info);
/* Initialize the iterator to return a single partition with given part_id */
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc
index 1165164fd88..5e46837e948 100644
--- a/sql/rpl_mi.cc
+++ b/sql/rpl_mi.cc
@@ -29,9 +29,9 @@ int init_strvar_from_file(char *var, int max_size, IO_CACHE *f,
Master_info::Master_info()
:Slave_reporting_capability("I/O"),
- ssl(0), fd(-1), io_thd(0), inited(0),
+ ssl(0), ssl_verify_server_cert(0), fd(-1), io_thd(0), inited(0),
abort_slave(0),slave_running(0),
- ssl_verify_server_cert(0), slave_run_id(0)
+ slave_run_id(0)
{
host[0] = 0; user[0] = 0; password[0] = 0;
ssl_ca[0]= 0; ssl_capath[0]= 0; ssl_cert[0]= 0;
diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc
index 03f790b934f..52656fe9973 100644
--- a/sql/rpl_rli.cc
+++ b/sql/rpl_rli.cc
@@ -33,12 +33,12 @@ Relay_log_info::Relay_log_info()
:Slave_reporting_capability("SQL"),
no_storage(FALSE), replicate_same_server_id(::replicate_same_server_id),
info_fd(-1), cur_log_fd(-1), save_temporary_tables(0),
- group_relay_log_pos(0), event_relay_log_pos(0),
#if HAVE_purify
is_fake(FALSE),
#endif
- cur_log_old_open_count(0), group_master_log_pos(0), log_space_total(0),
- ignore_log_space_limit(0), last_master_timestamp(0), slave_skip_counter(0),
+ cur_log_old_open_count(0), group_relay_log_pos(0), event_relay_log_pos(0),
+ group_master_log_pos(0), log_space_total(0), ignore_log_space_limit(0),
+ last_master_timestamp(0), slave_skip_counter(0),
abort_pos_wait(0), slave_run_id(0), sql_thd(0),
inited(0), abort_slave(0), slave_running(0), until_condition(UNTIL_NONE),
until_log_pos(0), retried_trans(0),
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 7ff73148b02..7f43f6c564f 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -137,7 +137,8 @@ static void fix_trans_mem_root(THD *thd, enum_var_type type);
static void fix_server_id(THD *thd, enum_var_type type);
static ulonglong fix_unsigned(THD *, ulonglong, const struct my_option *);
static bool get_unsigned(THD *thd, set_var *var);
-static void throw_bounds_warning(THD *thd, const char *name, ulonglong num);
+bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
+ const char *name, longlong val);
static KEY_CACHE *create_key_cache(const char *name, uint length);
void fix_sql_mode_var(THD *thd, enum_var_type type);
static uchar *get_error_count(THD *thd);
@@ -1207,13 +1208,29 @@ static void fix_server_id(THD *thd, enum_var_type type)
}
-static void throw_bounds_warning(THD *thd, const char *name, ulonglong num)
+bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
+ const char *name, longlong val)
{
- char buf[22];
- push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_TRUNCATED_WRONG_VALUE,
- ER(ER_TRUNCATED_WRONG_VALUE), name,
- ullstr(num, buf));
+ if (fixed)
+ {
+ char buf[22];
+
+ if (unsignd)
+ ullstr((ulonglong) val, buf);
+ else
+ llstr(val, buf);
+
+ if (thd->variables.sql_mode & MODE_STRICT_ALL_TABLES)
+ {
+ my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, buf);
+ return TRUE;
+ }
+
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_TRUNCATED_WRONG_VALUE,
+ ER(ER_TRUNCATED_WRONG_VALUE), name, buf);
+ }
+ return FALSE;
}
static ulonglong fix_unsigned(THD *thd, ulonglong num,
@@ -1222,8 +1239,7 @@ static ulonglong fix_unsigned(THD *thd, ulonglong num,
my_bool fixed= FALSE;
ulonglong out= getopt_ull_limit_value(num, option_limits, &fixed);
- if (fixed)
- throw_bounds_warning(thd, option_limits->name, num);
+ throw_bounds_warning(thd, fixed, TRUE, option_limits->name, (longlong) num);
return out;
}
@@ -1266,7 +1282,8 @@ bool sys_var_long_ptr_global::update(THD *thd, set_var *var)
if (tmp > ULONG_MAX)
{
tmp= ULONG_MAX;
- throw_bounds_warning(thd, name, var->save_result.ulonglong_value);
+ throw_bounds_warning(thd, TRUE, TRUE, name,
+ (longlong) var->save_result.ulonglong_value);
}
#endif
*value= (ulong) tmp;
@@ -1355,7 +1372,7 @@ bool sys_var_thd_ulong::update(THD *thd, set_var *var)
/* Don't use bigger value than given with --maximum-variable-name=.. */
if ((ulong) tmp > max_system_variables.*offset)
{
- throw_bounds_warning(thd, name, tmp);
+ throw_bounds_warning(thd, TRUE, TRUE, name, (longlong) tmp);
tmp= max_system_variables.*offset;
}
@@ -1365,7 +1382,7 @@ bool sys_var_thd_ulong::update(THD *thd, set_var *var)
else if (tmp > ULONG_MAX)
{
tmp= ULONG_MAX;
- throw_bounds_warning(thd, name, var->save_result.ulonglong_value);
+ throw_bounds_warning(thd, TRUE, TRUE, name, (longlong) var->save_result.ulonglong_value);
}
#endif
diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt
index ee3a7e6080a..693140e642a 100644
--- a/sql/share/errmsg.txt
+++ b/sql/share/errmsg.txt
@@ -2146,14 +2146,14 @@ ER_WRONG_SUB_KEY
cze "Chybn-Bá podèást klíèe -- není to øetìzec nebo je del¹í ne¾ délka èásti klíèe"
dan "Forkert indeksdel. Den anvendte nøgledel er ikke en streng eller længden er større end nøglelængden"
nla "Foutief sub-gedeelte van de zoeksleutel. De gebruikte zoeksleutel is geen onderdeel van een string of of de gebruikte lengte is langer dan de zoeksleutel"
- eng "Incorrect sub part key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique sub keys"
+ eng "Incorrect prefix key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique prefix keys"
est "Vigane võtme osa. Kasutatud võtmeosa ei ole string tüüpi, määratud pikkus on pikem kui võtmeosa või tabelihandler ei toeta seda tüüpi võtmeid"
fre "Mauvaise sous-clef. Ce n'est pas un 'string' ou la longueur dépasse celle définie dans la clef"
ger "Falscher Unterteilschlüssel. Der verwendete Schlüsselteil ist entweder kein String, die verwendete Länge ist länger als der Teilschlüssel oder die Speicher-Engine unterstützt keine Unterteilschlüssel"
greek "ÅóöáëìÝíï sub part key. Ôï ÷ñçóéìïðïéïýìåíï key part äåí åßíáé string Þ ôï ìÞêïò ôïõ åßíáé ìåãáëýôåñï"
hun "Rossz alkulcs. A hasznalt kulcsresz nem karaktersorozat vagy hosszabb, mint a kulcsresz"
ita "Sotto-parte della chiave errata. La parte di chiave utilizzata non e` una stringa o la lunghezza e` maggiore della parte di chiave."
- jpn "Incorrect sub part key; the used key part isn't a string or the used length is longer than the key part"
+ jpn "Incorrect prefix key; the used key part isn't a string or the used length is longer than the key part"
kor "ºÎÁ¤È®ÇÑ ¼­¹ö ÆÄÆ® Å°. »ç¿ëµÈ Å° ÆÄÆ®°¡ ½ºÆ®¸µÀÌ ¾Æ´Ï°Å³ª Å° ÆÄÆ®ÀÇ ±æÀÌ°¡ ³Ê¹« ±é´Ï´Ù."
nor "Feil delnøkkel. Den brukte delnøkkelen er ikke en streng eller den oppgitte lengde er lengre enn nøkkel lengden"
norwegian-ny "Feil delnykkel. Den brukte delnykkelen er ikkje ein streng eller den oppgitte lengda er lengre enn nykkellengden"
@@ -2162,7 +2162,7 @@ ER_WRONG_SUB_KEY
rum "Componentul cheii este incorrect. Componentul folosit al cheii nu este un sir sau lungimea folosita este mai lunga decit lungimea cheii"
rus "îÅËÏÒÒÅËÔÎÁÑ ÞÁÓÔØ ËÌÀÞÁ. éÓÐÏÌØÚÕÅÍÁÑ ÞÁÓÔØ ËÌÀÞÁ ÎÅ Ñ×ÌÑÅÔÓÑ ÓÔÒÏËÏÊ, ÕËÁÚÁÎÎÁÑ ÄÌÉÎÁ ÂÏÌØÛÅ, ÞÅÍ ÄÌÉÎÁ ÞÁÓÔÉ ËÌÀÞÁ, ÉÌÉ ÏÂÒÁÂÏÔÞÉË ÔÁÂÌÉÃÙ ÎÅ ÐÏÄÄÅÒÖÉ×ÁÅÔ ÕÎÉËÁÌØÎÙÅ ÞÁÓÔÉ ËÌÀÞÁ"
serbian "Pogrešan pod-kljuè dela kljuèa. Upotrebljeni deo kljuèa nije string, upotrebljena dužina je veæa od dela kljuèa ili handler tabela ne podržava jedinstvene pod-kljuèeve"
- slo "Incorrect sub part key; the used key part isn't a string or the used length is longer than the key part"
+ slo "Incorrect prefix key; the used key part isn't a string or the used length is longer than the key part"
spa "Parte de la clave es erronea. Una parte de la clave no es una cadena o la longitud usada es tan grande como la parte de la clave"
swe "Felaktig delnyckel. Nyckeldelen är inte en sträng eller den angivna längden är längre än kolumnlängden"
ukr "îÅצÒÎÁ ÞÁÓÔÉÎÁ ËÌÀÞÁ. ÷ÉËÏÒÉÓÔÁÎÁ ÞÁÓÔÉÎÁ ËÌÀÞÁ ÎÅ ¤ ÓÔÒÏËÏÀ, ÚÁÄÏ×ÇÁ ÁÂÏ ×ËÁÚ¦×ÎÉË ÔÁÂÌÉæ ΊЦÄÔÒÉÍÕ¤ ÕΦËÁÌØÎÉÈ ÞÁÓÔÉÎ ËÌÀÞÅÊ"
diff --git a/sql/sp.cc b/sql/sp.cc
index b486e58883a..69eae8de207 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -388,6 +388,7 @@ db_find_routine(THD *thd, int type, sp_name *name, sp_head **sphp)
uint length;
char buff[65];
String str(buff, sizeof(buff), &my_charset_bin);
+ bool saved_time_zone_used= thd->time_zone_used;
ulong sql_mode, saved_mode= thd->variables.sql_mode;
Open_tables_state open_tables_state_backup;
Stored_program_creation_ctx *creation_ctx;
@@ -504,6 +505,11 @@ db_find_routine(THD *thd, int type, sp_name *name, sp_head **sphp)
sql_mode, params, returns, body, chistics,
definer, created, modified, creation_ctx);
done:
+ /*
+ Restore the time zone flag as the timezone usage in proc table
+ does not affect replication.
+ */
+ thd->time_zone_used= saved_time_zone_used;
if (table)
close_system_tables(thd, &open_tables_state_backup);
thd->variables.sql_mode= saved_mode;
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 3805d9fa8b6..9d38efb6464 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -192,7 +192,7 @@ static void update_hostname(acl_host_and_ip *host, const char *hostname);
static bool compare_hostname(const acl_host_and_ip *host,const char *hostname,
const char *ip);
static my_bool acl_load(THD *thd, TABLE_LIST *tables);
-static my_bool grant_load(TABLE_LIST *tables);
+static my_bool grant_load(THD *thd, TABLE_LIST *tables);
/*
Convert scrambled password to binary form, according to scramble type,
@@ -314,8 +314,11 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE;
char tmp_name[NAME_LEN+1];
int password_length;
+ ulong old_sql_mode= thd->variables.sql_mode;
DBUG_ENTER("acl_load");
+ thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH;
+
grant_version++; /* Privileges updated */
acl_cache->clear(1); // Clear locked hostname cache
@@ -622,6 +625,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
return_val=0;
end:
+ thd->variables.sql_mode= old_sql_mode;
DBUG_RETURN(return_val);
}
@@ -801,7 +805,9 @@ static ulong get_sort(uint count,...)
{
for (; *str ; str++)
{
- if (*str == wild_many || *str == wild_one || *str == wild_prefix)
+ if (*str == wild_prefix && str[1])
+ str++;
+ else if (*str == wild_many || *str == wild_one)
{
wild_pos= (uint) (str - start) + 1;
break;
@@ -3618,7 +3624,7 @@ end_unlock:
@retval TRUE Error
*/
-static my_bool grant_load(TABLE_LIST *tables)
+static my_bool grant_load(THD *thd, TABLE_LIST *tables)
{
MEM_ROOT *memex_ptr;
my_bool return_val= 1;
@@ -3626,7 +3632,11 @@ static my_bool grant_load(TABLE_LIST *tables)
bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE;
MEM_ROOT **save_mem_root_ptr= my_pthread_getspecific_ptr(MEM_ROOT**,
THR_MALLOC);
+ ulong old_sql_mode= thd->variables.sql_mode;
DBUG_ENTER("grant_load");
+
+ thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH;
+
(void) hash_init(&column_priv_hash,system_charset_info,
0,0,0, (hash_get_key) get_grant_table,
(hash_free_key) free_grant_table,0);
@@ -3678,6 +3688,7 @@ static my_bool grant_load(TABLE_LIST *tables)
return_val=0; // Return ok
end_unlock:
+ thd->variables.sql_mode= old_sql_mode;
t_table->file->ha_index_end();
my_pthread_setspecific_ptr(THR_MALLOC, save_mem_root_ptr);
DBUG_RETURN(return_val);
@@ -3791,7 +3802,7 @@ my_bool grant_reload(THD *thd)
old_mem= memex;
init_sql_alloc(&memex, ACL_ALLOC_BLOCK_SIZE, 0);
- if ((return_val= grant_load(tables)))
+ if ((return_val= grant_load(thd, tables)))
{ // Error. Revert to old hash
DBUG_PRINT("error",("Reverting to old privileges"));
grant_free(); /* purecov: deadcode */
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 4a417dc05b1..01e0009ad0d 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -4599,8 +4599,12 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags)
}
if (tables->lock_type != TL_UNLOCK && ! thd->locked_tables)
- tables->table->reginfo.lock_type= tables->lock_type == TL_WRITE_DEFAULT ?
- thd->update_lock_default : tables->lock_type;
+ {
+ if (tables->lock_type == TL_WRITE_DEFAULT)
+ tables->table->reginfo.lock_type= thd->update_lock_default;
+ else if (tables->table->s->tmp_table == NO_TMP_TABLE)
+ tables->table->reginfo.lock_type= tables->lock_type;
+ }
tables->table->grant= tables->grant;
/* Attach MERGE children if not locked already. */
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 41db1a27637..67f29b0444a 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2360,6 +2360,28 @@ mysql_execute_command(THD *thd)
"INDEX DIRECTORY option ignored");
create_info.data_file_name= create_info.index_file_name= NULL;
#else
+
+ if (test_if_data_home_dir(lex->create_info.data_file_name))
+ {
+ my_error(ER_WRONG_ARGUMENTS,MYF(0),"DATA DIRECORY");
+ res= -1;
+ break;
+ }
+ if (test_if_data_home_dir(lex->create_info.index_file_name))
+ {
+ my_error(ER_WRONG_ARGUMENTS,MYF(0),"INDEX DIRECORY");
+ res= -1;
+ break;
+ }
+
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ if (check_partition_dirs(thd->lex->part_info))
+ {
+ res= -1;
+ break;
+ }
+#endif
+
/* Fix names if symlinked tables */
if (append_file_to_dir(thd, &create_info.data_file_name,
create_table->table_name) ||
@@ -3249,6 +3271,18 @@ end_with_restore_list:
thd->one_shot_set|= lex->one_shot_set;
my_ok(thd);
}
+ else
+ {
+ /*
+ We encountered some sort of error, but no message was sent.
+ Send something semi-generic here since we don't know which
+ assignment in the list caused the error.
+ */
+ if (!thd->is_error())
+ my_error(ER_WRONG_ARGUMENTS,MYF(0),"SET");
+ goto error;
+ }
+
break;
}
@@ -7340,6 +7374,49 @@ bool check_string_char_length(LEX_STRING *str, const char *err_msg,
}
+/*
+ Check if path does not contain mysql data home directory
+ SYNOPSIS
+ test_if_data_home_dir()
+ dir directory
+ conv_home_dir converted data home directory
+ home_dir_len converted data home directory length
+
+ RETURN VALUES
+ 0 ok
+ 1 error
+*/
+
+bool test_if_data_home_dir(const char *dir)
+{
+ char path[FN_REFLEN], conv_path[FN_REFLEN];
+ uint dir_len, home_dir_len= strlen(mysql_unpacked_real_data_home);
+ DBUG_ENTER("test_if_data_home_dir");
+
+ if (!dir)
+ DBUG_RETURN(0);
+
+ (void) fn_format(path, dir, "", "",
+ (MY_RETURN_REAL_PATH|MY_RESOLVE_SYMLINKS));
+ dir_len= unpack_dirname(conv_path, dir);
+
+ if (home_dir_len < dir_len)
+ {
+ if (lower_case_file_system)
+ {
+ if (!my_strnncoll(character_set_filesystem,
+ (const uchar*) conv_path, home_dir_len,
+ (const uchar*) mysql_unpacked_real_data_home,
+ home_dir_len))
+ DBUG_RETURN(1);
+ }
+ else if (!memcmp(conv_path, mysql_unpacked_real_data_home, home_dir_len))
+ DBUG_RETURN(1);
+ }
+ DBUG_RETURN(0);
+}
+
+
extern int MYSQLparse(void *thd); // from sql_yacc.cc
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index df408d0e61f..ddaf7bccbc1 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -210,6 +210,8 @@ static void reap_plugins(void);
/* declared in set_var.cc */
extern sys_var *intern_find_sys_var(const char *str, uint length, bool no_error);
+extern bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
+ const char *name, longlong val);
#ifdef EMBEDDED_LIBRARY
/* declared in sql_base.cc */
@@ -1891,16 +1893,8 @@ static int check_func_int(THD *thd, struct st_mysql_sys_var *var,
else
*(int *)save= (int) getopt_ll_limit_value(tmp, &options, &fixed);
- if (fixed)
- {
- char buf[22];
- push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_TRUNCATED_WRONG_VALUE,
- ER(ER_TRUNCATED_WRONG_VALUE), var->name,
- ullstr(tmp, buf));
- }
- return (thd->variables.sql_mode & MODE_STRICT_ALL_TABLES) &&
- (*(int *)save != (int) tmp);
+ return throw_bounds_warning(thd, fixed, var->flags & PLUGIN_VAR_UNSIGNED,
+ var->name, (longlong) tmp);
}
@@ -1919,16 +1913,8 @@ static int check_func_long(THD *thd, struct st_mysql_sys_var *var,
else
*(long *)save= (long) getopt_ll_limit_value(tmp, &options, &fixed);
- if (fixed)
- {
- char buf[22];
- push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_TRUNCATED_WRONG_VALUE,
- ER(ER_TRUNCATED_WRONG_VALUE), var->name,
- ullstr(tmp, buf));
- }
- return (thd->variables.sql_mode & MODE_STRICT_ALL_TABLES) &&
- (*(long *)save != (long) tmp);
+ return throw_bounds_warning(thd, fixed, var->flags & PLUGIN_VAR_UNSIGNED,
+ var->name, (longlong) tmp);
}
@@ -1947,16 +1933,8 @@ static int check_func_longlong(THD *thd, struct st_mysql_sys_var *var,
else
*(longlong *)save= getopt_ll_limit_value(tmp, &options, &fixed);
- if (fixed)
- {
- char buf[22];
- push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_TRUNCATED_WRONG_VALUE,
- ER(ER_TRUNCATED_WRONG_VALUE), var->name,
- ullstr(tmp, buf));
- }
- return (thd->variables.sql_mode & MODE_STRICT_ALL_TABLES) &&
- (*(long long *)save != tmp);
+ return throw_bounds_warning(thd, fixed, var->flags & PLUGIN_VAR_UNSIGNED,
+ var->name, (longlong) tmp);
}
static int check_func_str(THD *thd, struct st_mysql_sys_var *var,
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 587120eb141..8b6d0fcb0a4 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -372,10 +372,10 @@ fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select,
}
}
new_ref= direct_ref ?
- new Item_direct_ref(ref->context, item_ref, ref->field_name,
- ref->table_name, ref->alias_name_used) :
- new Item_ref(ref->context, item_ref, ref->field_name,
- ref->table_name, ref->alias_name_used);
+ new Item_direct_ref(ref->context, item_ref, ref->table_name,
+ ref->field_name, ref->alias_name_used) :
+ new Item_ref(ref->context, item_ref, ref->table_name,
+ ref->field_name, ref->alias_name_used);
if (!new_ref)
return TRUE;
ref->outer_ref= new_ref;
@@ -2990,7 +2990,9 @@ merge_key_fields(KEY_FIELD *start,KEY_FIELD *new_fields,KEY_FIELD *end,
}
}
else if (old->eq_func && new_fields->eq_func &&
- old->val->eq(new_fields->val, old->field->binary()))
+ old->val->eq_by_collation(new_fields->val,
+ old->field->binary(),
+ old->field->charset()))
{
old->level= and_level;
@@ -11184,7 +11186,7 @@ evaluate_join_record(JOIN *join, JOIN_TAB *join_tab,
we found a row, as no new rows can be added to the result.
*/
if (not_used_in_distinct && found_records != join->found_records)
- return NESTED_LOOP_OK;
+ return NESTED_LOOP_NO_MORE_ROWS;
}
else
join_tab->read_record.file->unlock_row();
@@ -11569,21 +11571,42 @@ join_read_key(JOIN_TAB *tab)
}
+/*
+ ref access method implementation: "read_first" function
+
+ SYNOPSIS
+ join_read_always_key()
+ tab JOIN_TAB of the accessed table
+
+ DESCRIPTION
+ This is "read_fist" function for the "ref" access method.
+
+ The functon must leave the index initialized when it returns.
+ ref_or_null access implementation depends on that.
+
+ RETURN
+ 0 - Ok
+ -1 - Row not found
+ 1 - Error
+*/
+
static int
join_read_always_key(JOIN_TAB *tab)
{
int error;
TABLE *table= tab->table;
+ /* Initialize the index first */
+ if (!table->file->inited)
+ table->file->ha_index_init(tab->ref.key, tab->sorted);
+
+ /* Perform "Late NULLs Filtering" (see internals manual for explanations) */
for (uint i= 0 ; i < tab->ref.key_parts ; i++)
{
if ((tab->ref.null_rejecting & 1 << i) && tab->ref.items[i]->is_null())
return -1;
- }
- if (!table->file->inited)
- {
- table->file->ha_index_init(tab->ref.key, tab->sorted);
}
+
if (cp_buffer_from_ref(tab->join->thd, table, &tab->ref))
return -1;
if ((error=table->file->index_read_map(table->record[0],
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 72e18ed7725..24f7817aa73 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -5402,8 +5402,9 @@ ST_SCHEMA_TABLE *get_schema_table(enum enum_schema_tables schema_table_idx)
@param
thd thread handler
- @param
- schema_table pointer to 'shema_tables' element
+
+ @param table_list Used to pass I_S table information(fields info, tables
+ parameters etc) and table name.
@retval \# Pointer to created table
@retval NULL Can't create table
@@ -5454,6 +5455,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
DBUG_RETURN(NULL);
break;
case MYSQL_TYPE_DECIMAL:
+ case MYSQL_TYPE_NEWDECIMAL:
if (!(item= new Item_decimal((longlong) fields_info->value, false)))
{
DBUG_RETURN(0);
@@ -5803,7 +5805,7 @@ int make_schema_select(THD *thd, SELECT_LEX *sel,
{
ST_SCHEMA_TABLE *schema_table= get_schema_table(schema_table_idx);
LEX_STRING db, table;
- DBUG_ENTER("mysql_schema_select");
+ DBUG_ENTER("make_schema_select");
DBUG_PRINT("enter", ("mysql_schema_select: %s", schema_table->table_name));
/*
We have to make non const db_name & table_name
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 133ee9fd549..2ab5966c799 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1217,6 +1217,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <interval_time_st> interval_time_st
+%type <interval_time_st> interval_time_stamp
+
%type <db_type> storage_engines known_storage_engines
%type <row_type> row_types
@@ -7007,9 +7009,9 @@ function_call_nonkeyword:
$$= new (YYTHD->mem_root) Item_func_now_local($3);
Lex->safe_to_cache_query=0;
}
- | TIMESTAMP_ADD '(' interval_time_st ',' expr ',' expr ')'
+ | TIMESTAMP_ADD '(' interval_time_stamp ',' expr ',' expr ')'
{ $$= new (YYTHD->mem_root) Item_date_add_interval($7,$5,$3,0); }
- | TIMESTAMP_DIFF '(' interval_time_st ',' expr ',' expr ')'
+ | TIMESTAMP_DIFF '(' interval_time_stamp ',' expr ',' expr ')'
{ $$= new (YYTHD->mem_root) Item_func_timestamp_diff($5,$7,$3); }
| UTC_DATE_SYM optional_braces
{
@@ -7974,22 +7976,41 @@ interval:
| HOUR_MICROSECOND_SYM { $$=INTERVAL_HOUR_MICROSECOND; }
| HOUR_MINUTE_SYM { $$=INTERVAL_HOUR_MINUTE; }
| HOUR_SECOND_SYM { $$=INTERVAL_HOUR_SECOND; }
- | MICROSECOND_SYM { $$=INTERVAL_MICROSECOND; }
| MINUTE_MICROSECOND_SYM { $$=INTERVAL_MINUTE_MICROSECOND; }
| MINUTE_SECOND_SYM { $$=INTERVAL_MINUTE_SECOND; }
| SECOND_MICROSECOND_SYM { $$=INTERVAL_SECOND_MICROSECOND; }
| YEAR_MONTH_SYM { $$=INTERVAL_YEAR_MONTH; }
;
+interval_time_stamp:
+ interval_time_st {}
+ | FRAC_SECOND_SYM {
+ $$=INTERVAL_MICROSECOND;
+ /*
+ FRAC_SECOND was mistakenly implemented with
+ a wrong resolution. According to the ODBC
+ standard it should be nanoseconds, not
+ microseconds. Changing it to nanoseconds
+ in MySQL would mean making TIMESTAMPDIFF
+ and TIMESTAMPADD to return DECIMAL, since
+ the return value would be too big for BIGINT
+ Hence we just deprecate the incorrect
+ implementation without changing its
+ resolution.
+ */
+ WARN_DEPRECATED(yythd, "6.2", "FRAC_SECOND", "MICROSECOND");
+ }
+ ;
+
interval_time_st:
DAY_SYM { $$=INTERVAL_DAY; }
| WEEK_SYM { $$=INTERVAL_WEEK; }
| HOUR_SYM { $$=INTERVAL_HOUR; }
- | FRAC_SECOND_SYM { $$=INTERVAL_MICROSECOND; }
| MINUTE_SYM { $$=INTERVAL_MINUTE; }
| MONTH_SYM { $$=INTERVAL_MONTH; }
| QUARTER_SYM { $$=INTERVAL_QUARTER; }
| SECOND_SYM { $$=INTERVAL_SECOND; }
+ | MICROSECOND_SYM { $$=INTERVAL_MICROSECOND; }
| YEAR_SYM { $$=INTERVAL_YEAR; }
;
diff --git a/sql/table.h b/sql/table.h
index 3ecc3274b09..0e0a35b022d 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -760,12 +760,36 @@ enum enum_schema_tables
typedef struct st_field_info
{
+ /**
+ This is used as column name.
+ */
const char* field_name;
+ /**
+ For string-type columns, this is the maximum number of
+ characters. Otherwise, it is the 'display-length' for the column.
+ */
uint field_length;
+ /**
+ This denotes data type for the column. For the most part, there seems to
+ be one entry in the enum for each SQL data type, although there seem to
+ be a number of additional entries in the enum.
+ */
enum enum_field_types field_type;
int value;
+ /**
+ This is used to set column attributes. By default, columns are @c NOT
+ @c NULL and @c SIGNED, and you can deviate from the default
+ by setting the appopriate flags. You can use either one of the flags
+ @c MY_I_S_MAYBE_NULL and @cMY_I_S_UNSIGNED or
+ combine them using the bitwise or operator @c |. Both flags are
+ defined in table.h.
+ */
uint field_flags; // Field atributes(maybe_null, signed, unsigned etc.)
const char* old_name;
+ /**
+ This should be one of @c SKIP_OPEN_TABLE,
+ @c OPEN_FRM_ONLY or @c OPEN_FULL_TABLE.
+ */
uint open_method;
} ST_FIELD_INFO;
diff --git a/sql/unireg.h b/sql/unireg.h
index 2e0172ce31d..8731a0ac98a 100644
--- a/sql/unireg.h
+++ b/sql/unireg.h
@@ -108,7 +108,6 @@
#define READ_RECORD_BUFFER (uint) (IO_SIZE*8) /* Pointer_buffer_size */
#define DISK_BUFFER_SIZE (uint) (IO_SIZE*16) /* Size of diskbuffer */
-#define POSTFIX_ERROR DBL_MAX
#define ME_INFO (ME_HOLDTANG+ME_OLDWIN+ME_NOREFRESH)
#define ME_ERROR (ME_BELL+ME_OLDWIN+ME_NOREFRESH)