summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-01-28 09:12:23 +0100
committerSergei Golubchik <sergii@pisem.net>2013-01-28 09:12:23 +0100
commit34e84c227f1cb76771eabf229b4cf1b5292eef25 (patch)
treee811e54db5452bbe05647d16fa4991c0332121d7
parent0791692bdc311f39181b9df236981a2cb439638e (diff)
parent5138bf4238d4a8850ee364a3adf10dc2687af67c (diff)
downloadmariadb-git-34e84c227f1cb76771eabf229b4cf1b5292eef25.tar.gz
5.2 merge
-rw-r--r--mysql-test/r/func_str.result18
-rw-r--r--mysql-test/r/group_min_max.result7
-rw-r--r--mysql-test/t/func_str.test11
-rw-r--r--mysql-test/t/group_min_max.test9
-rw-r--r--sql/item_strfunc.cc20
-rw-r--r--sql/opt_range.cc8
-rw-r--r--sql/sql_insert.cc2
7 files changed, 65 insertions, 10 deletions
diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result
index a239a74acb1..b77ccdae82c 100644
--- a/mysql-test/r/func_str.result
+++ b/mysql-test/r/func_str.result
@@ -2631,4 +2631,22 @@ SELECT * FROM t1;
a
aaaaaaaaaaaaaa
DROP TABLE t1;
+SELECT SUBSTRING('1', DAY(FROM_UNIXTIME(-1)));
+SUBSTRING('1', DAY(FROM_UNIXTIME(-1)))
+NULL
+SELECT LEFT('1', DAY(FROM_UNIXTIME(-1)));
+LEFT('1', DAY(FROM_UNIXTIME(-1)))
+NULL
+SELECT RIGHT('1', DAY(FROM_UNIXTIME(-1)));
+RIGHT('1', DAY(FROM_UNIXTIME(-1)))
+NULL
+SELECT REPEAT('1', DAY(FROM_UNIXTIME(-1)));
+REPEAT('1', DAY(FROM_UNIXTIME(-1)))
+NULL
+SELECT RPAD('hi', DAY(FROM_UNIXTIME(-1)),'?');
+RPAD('hi', DAY(FROM_UNIXTIME(-1)),'?')
+NULL
+SELECT LPAD('hi', DAY(FROM_UNIXTIME(-1)),'?');
+LPAD('hi', DAY(FROM_UNIXTIME(-1)),'?')
+NULL
End of 5.1 tests
diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result
index 3d0502e163c..bc740cc48ed 100644
--- a/mysql-test/r/group_min_max.result
+++ b/mysql-test/r/group_min_max.result
@@ -2933,6 +2933,13 @@ ORDER BY min_a;
min_a
NULL
DROP TABLE t1;
+create table t1 (a int, b varchar(1), key(b,a)) engine=myisam;
+insert t1 values (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'f'),(7,'g'),(8,'h'),(null,'i');
+select min(a), b from t1 where a=7 or b='z' group by b;
+min(a) b
+7 g
+flush tables;
+drop table t1;
#
# LP BUG#888456 Wrong result with DISTINCT , ANY , subquery_cache=off , NOT NULL
#
diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test
index 4302bf5e7eb..406411eb704 100644
--- a/mysql-test/t/func_str.test
+++ b/mysql-test/t/func_str.test
@@ -1384,4 +1384,15 @@ LOAD DATA INFILE 'bug58165.txt' INTO TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
+#
+# MDEV-759 lp:998340 - Valgrind complains on simple selects containing expression DAY(FROM_UNIXTIME(-1))
+#
+SELECT SUBSTRING('1', DAY(FROM_UNIXTIME(-1)));
+SELECT LEFT('1', DAY(FROM_UNIXTIME(-1)));
+SELECT RIGHT('1', DAY(FROM_UNIXTIME(-1)));
+SELECT REPEAT('1', DAY(FROM_UNIXTIME(-1)));
+SELECT RPAD('hi', DAY(FROM_UNIXTIME(-1)),'?');
+SELECT LPAD('hi', DAY(FROM_UNIXTIME(-1)),'?');
+
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test
index c3fc1f4eab7..d445c867f2a 100644
--- a/mysql-test/t/group_min_max.test
+++ b/mysql-test/t/group_min_max.test
@@ -1155,6 +1155,15 @@ ORDER BY min_a;
DROP TABLE t1;
+#
+# MDEV-729 lp:998028 - Server crashes on normal shutdown in closefrm after executing a query from MyISAM table
+#
+create table t1 (a int, b varchar(1), key(b,a)) engine=myisam;
+insert t1 values (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'f'),(7,'g'),(8,'h'),(null,'i');
+select min(a), b from t1 where a=7 or b='z' group by b;
+flush tables;
+drop table t1;
+
--echo #
--echo # LP BUG#888456 Wrong result with DISTINCT , ANY , subquery_cache=off , NOT NULL
--echo #
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index d0b284a363d..71526c433ed 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1167,7 +1167,7 @@ void Item_str_func::left_right_max_length()
if (args[1]->const_item())
{
int length=(int) args[1]->val_int()*collation.collation->mbmaxlen;
- if (length <= 0)
+ if (args[1]->null_value || length <= 0)
max_length=0;
else
set_if_smaller(max_length,(uint) length);
@@ -1270,7 +1270,9 @@ void Item_func_substr::fix_length_and_dec()
if (args[1]->const_item())
{
int32 start= (int32) args[1]->val_int();
- if (start < 0)
+ if (args[1]->null_value)
+ max_length= 0;
+ else if (start < 0)
max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start);
else
max_length-= min((uint)(start - 1), max_length);
@@ -1278,7 +1280,7 @@ void Item_func_substr::fix_length_and_dec()
if (arg_count == 3 && args[2]->const_item())
{
int32 length= (int32) args[2]->val_int();
- if (length <= 0)
+ if (args[2]->null_value || length <= 0)
max_length=0; /* purecov: inspected */
else
set_if_smaller(max_length,(uint) length);
@@ -2412,7 +2414,9 @@ void Item_func_repeat::fix_length_and_dec()
/* Assumes that the maximum length of a String is < INT_MAX32. */
/* Set here so that rest of code sees out-of-bound value as such. */
- if (count > INT_MAX32)
+ if (args[1]->null_value)
+ count= 0;
+ else if (count > INT_MAX32)
count= INT_MAX32;
ulonglong max_result_length= (ulonglong) args[0]->max_length * count;
@@ -2500,7 +2504,9 @@ void Item_func_rpad::fix_length_and_dec()
/* Assumes that the maximum length of a String is < INT_MAX32. */
/* Set here so that rest of code sees out-of-bound value as such. */
- if (temp > INT_MAX32)
+ if (args[1]->null_value)
+ temp= 0;
+ else if (temp > INT_MAX32)
temp = INT_MAX32;
length= temp * collation.collation->mbmaxlen;
@@ -2617,7 +2623,9 @@ void Item_func_lpad::fix_length_and_dec()
/* Assumes that the maximum length of a String is < INT_MAX32. */
/* Set here so that rest of code sees out-of-bound value as such. */
- if (temp > INT_MAX32)
+ if (args[1]->null_value)
+ temp= 0;
+ else if (temp > INT_MAX32)
temp= INT_MAX32;
length= temp * collation.collation->mbmaxlen;
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 3cad647ba1c..0d1aa83b5e6 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -13160,9 +13160,10 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_min()
*/
if (min_max_arg_part && min_max_arg_part->field->is_null())
{
+ uchar *tmp_key_buff= (uchar*)my_alloca(max_used_key_length);
/* Find the first subsequent record without NULL in the MIN/MAX field. */
- key_copy(tmp_record, record, index_info, max_used_key_length);
- result= file->ha_index_read_map(record, tmp_record,
+ key_copy(tmp_key_buff, record, index_info, max_used_key_length);
+ result= file->ha_index_read_map(record, tmp_key_buff,
make_keypart_map(real_key_parts),
HA_READ_AFTER_KEY);
/*
@@ -13178,10 +13179,11 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_min()
if (!result)
{
if (key_cmp(index_info->key_part, group_prefix, real_prefix_len))
- key_restore(record, tmp_record, index_info, 0);
+ key_restore(record, tmp_key_buff, index_info, 0);
}
else if (result == HA_ERR_KEY_NOT_FOUND || result == HA_ERR_END_OF_FILE)
result= 0; /* There is a result in any case. */
+ my_afree(tmp_key_buff);
}
}
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index bfd08e83ca2..7ab2ed8e1b6 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -2129,7 +2129,7 @@ TABLE *Delayed_insert::get_local_table(THD* client_thd)
{
my_ptrdiff_t adjust_ptrs;
Field **field,**org_field, *found_next_number_field;
- Field **vfield;
+ Field **UNINIT_VAR(vfield);
TABLE *copy;
TABLE_SHARE *share;
uchar *bitmap;