summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2006-06-20 23:49:33 +0400
committerunknown <evgen@moonbone.local>2006-06-20 23:49:33 +0400
commit3db65ca83a5721073c0bba4f66c1c16bda968ca2 (patch)
tree7a4a1c029b51a17919d4fcee4f88c113de3a3233
parentb5cbe5ce73ab5045ff410583dafa0a09193e2cb1 (diff)
parent503d20239f94b1baf556b12cf69837d03c3b0885 (diff)
downloadmariadb-git-3db65ca83a5721073c0bba4f66c1c16bda968ca2.tar.gz
Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-4.1
into moonbone.local:/work/tmp_merge-4.1-opt-mysql
-rw-r--r--mysql-test/r/insert_select.result4
-rw-r--r--mysql-test/r/select.result6
-rw-r--r--mysql-test/t/insert_select.test13
-rw-r--r--mysql-test/t/select.test19
-rw-r--r--sql/item_cmpfunc.cc3
-rw-r--r--sql/sql_select.cc12
6 files changed, 52 insertions, 5 deletions
diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result
index 028b40ac3b6..1d7aef256e1 100644
--- a/mysql-test/r/insert_select.result
+++ b/mysql-test/r/insert_select.result
@@ -686,3 +686,7 @@ ERROR 42S22: Unknown column 'z' in 'field list'
insert into t1(x,y) select x,z from t2 on duplicate key update x=values(t2.x);
ERROR 42S02: Unknown table 't2' in field list
drop table t1,t2;
+CREATE TABLE t1 (a int PRIMARY KEY);
+INSERT INTO t1 values (1), (2);
+INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1;
+DROP TABLE t1;
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index 7808e787e39..c7df11ab018 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -2738,3 +2738,9 @@ ERROR HY000: Key 'a' doesn't exist in table 't1'
EXPLAIN SELECT * FROM t1 FORCE INDEX (a);
ERROR HY000: Key 'a' doesn't exist in table 't1'
DROP TABLE t1;
+CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
+INSERT INTO t1 VALUES (10);
+SELECT i='1e+01',i=1e+01, i in (1e+01), i in ('1e+01') FROM t1;
+i='1e+01' i=1e+01 i in (1e+01) i in ('1e+01')
+0 1 1 1
+DROP TABLE t1;
diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test
index 48acdf1cbc5..fcea489fcff 100644
--- a/mysql-test/t/insert_select.test
+++ b/mysql-test/t/insert_select.test
@@ -226,4 +226,17 @@ insert into t1(x,y) select x,z from t2 on duplicate key update x=values(z);
insert into t1(x,y) select x,z from t2 on duplicate key update x=values(t2.x);
drop table t1,t2;
+#
+# Bug #9676: INSERT INTO x SELECT .. FROM x LIMIT 1; slows down with big
+# tables
+#
+
+#Note: not an exsaustive test : just a check of the code path.
+CREATE TABLE t1 (a int PRIMARY KEY);
+INSERT INTO t1 values (1), (2);
+
+INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1;
+
+DROP TABLE t1;
+
# End of 4.1 tests
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index f7b5a2fbcb6..4cdfc220350 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -2278,4 +2278,23 @@ EXPLAIN SELECT * FROM t1 FORCE INDEX (a);
DROP TABLE t1;
+#
+# Bug #18759 "Incorrect string to numeric conversion"
+#
+# This test is here so that the behavior will not be changed to 4.1
+# and not to 5.0 either. In 4.1 and 5.0 sending an integer as a string
+# will be converted internally to real (double) value and it is not
+# as accurate as bigint (longlong) for integers. Thus the results may
+# vary. In 5.1 internally it is decimal, which is a string type and
+# will be more accurate. Due to rather big changes needed to fix this
+# in 4.1 or 5.0 it is not desired to do it in the stable versions.
+#
+# This test is here only to make sure that behavior is not changed in
+# 4.1 and 5.0
+#
+CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
+INSERT INTO t1 VALUES (10);
+SELECT i='1e+01',i=1e+01, i in (1e+01), i in ('1e+01') FROM t1;
+DROP TABLE t1;
+
# End of 4.1 tests
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 5055b5f4197..f14efc7187b 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -136,7 +136,8 @@ static void agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems)
}
continue;
}
- if ((res= items[i]->real_item()->type()) == Item::FIELD_ITEM)
+ if ((res= items[i]->real_item()->type()) == Item::FIELD_ITEM &&
+ items[i]->result_type() != INT_RESULT)
{
field= ((Item_field *)items[i]->real_item())->field;
break;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 5a7e9e52aed..709ff9726bb 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -888,8 +888,9 @@ JOIN::optimize()
group_list ? 0 : select_distinct,
group_list && simple_group,
select_options,
- (order == 0 || skip_sort_order) ? select_limit :
- HA_POS_ERROR,
+ (order == 0 || skip_sort_order ||
+ test(select_options & OPTION_BUFFER_RESULT)) ?
+ select_limit : HA_POS_ERROR,
(char *) "")))
DBUG_RETURN(1);
@@ -5530,6 +5531,11 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
keyinfo->key_length+= key_part_info->length;
}
}
+ else
+ {
+ set_if_smaller(table->max_rows, rows_limit);
+ param->end_write_records= rows_limit;
+ }
if (distinct && field_count != param->hidden_field_count)
{
@@ -5544,8 +5550,6 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
null_pack_length-=hidden_null_pack_length;
keyinfo->key_parts= ((field_count-param->hidden_field_count)+
test(null_pack_length));
- set_if_smaller(table->max_rows, rows_limit);
- param->end_write_records= rows_limit;
table->distinct=1;
table->keys=1;
if (blob_count)