Commit 1913b715 authored by Alexander Nozdrin's avatar Alexander Nozdrin

Manual merge from mysql-trunk-merge.

Conflicts:
  - sql/share/Makefile.am
parents bf875901 031657c6
......@@ -138,12 +138,12 @@ uninstall-local:
# mtr - a shortcut for executing mysql-test-run.pl
mtr:
$(RM) -f mtr
$(LN_S) mysql-test-run.pl mtr
$(LN_S) $(srcdir)/mysql-test-run.pl mtr
# mysql-test-run - a shortcut for executing mysql-test-run.pl
mysql-test-run:
$(RM) -f mysql-test-run
$(LN_S) mysql-test-run.pl mysql-test-run
$(LN_S) $(srcdir)/mysql-test-run.pl mysql-test-run
# Don't update the files from bitkeeper
%::SCCS/s.%
......@@ -404,3 +404,37 @@ describe t1;
Field Type Null Key Default Extra
bi decimal(19,0) NO 0
drop table t1;
#
# Bug #45360: wrong results
#
CREATE TABLE t1 (id INT AUTO_INCREMENT PRIMARY KEY,
a BIGINT(20) UNSIGNED,
b VARCHAR(20));
INSERT INTO t1 (a) VALUES
(0),
(CAST(0x7FFFFFFFFFFFFFFF AS UNSIGNED)),
(CAST(0x8000000000000000 AS UNSIGNED)),
(CAST(0xFFFFFFFFFFFFFFFF AS UNSIGNED));
UPDATE t1 SET b = a;
# FFFFFFFFFFFFFFFF
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE a = 18446744073709551615 AND TRIM(a) = b;
SHOW WARNINGS;
Level Code Message
Note 1003 select 1 AS `1` from `test`.`t1` where ((`test`.`t1`.`a` = 18446744073709551615) and ('18446744073709551615' = `test`.`t1`.`b`))
# 8000000000000000
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE a = 9223372036854775808 AND TRIM(a) = b;
SHOW WARNINGS;
Level Code Message
Note 1003 select 1 AS `1` from `test`.`t1` where ((`test`.`t1`.`a` = 9223372036854775808) and ('9223372036854775808' = `test`.`t1`.`b`))
# 7FFFFFFFFFFFFFFF
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE a = 9223372036854775807 AND TRIM(a) = b;
SHOW WARNINGS;
Level Code Message
Note 1003 select 1 AS `1` from `test`.`t1` where ((`test`.`t1`.`a` = 9223372036854775807) and ('9223372036854775807' = `test`.`t1`.`b`))
# 0
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE a = 0 AND TRIM(a) = b;
SHOW WARNINGS;
Level Code Message
Note 1003 select 1 AS `1` from `test`.`t1` where ((`test`.`t1`.`a` = 0) and ('0' = `test`.`t1`.`b`))
DROP TABLE t1;
# End of 5.1 tests
......@@ -278,6 +278,18 @@ DELETE FROM t1 ORDER BY (f1(10)) LIMIT 1;
ERROR 42000: Incorrect number of arguments for FUNCTION test.f1; expected 0, got 1
DROP TABLE t1;
DROP FUNCTION f1;
#
# Bug #49552 : sql_buffer_result cause crash + not found records
# in multitable delete/subquery
#
CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES (1),(2),(3);
SET SESSION SQL_BUFFER_RESULT=1;
DELETE t1 FROM (SELECT SUM(a) a FROM t1) x,t1;
SET SESSION SQL_BUFFER_RESULT=DEFAULT;
SELECT * FROM t1;
a
DROP TABLE t1;
End of 5.0 tests
DROP DATABASE IF EXISTS db1;
DROP DATABASE IF EXISTS db2;
......@@ -478,16 +490,4 @@ END |
DELETE IGNORE FROM t1;
ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
DROP TABLE t1;
#
# Bug #49552 : sql_buffer_result cause crash + not found records
# in multitable delete/subquery
#
CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES (1),(2),(3);
SET SESSION SQL_BUFFER_RESULT=1;
DELETE t1 FROM (SELECT SUM(a) a FROM t1) x,t1;
SET SESSION SQL_BUFFER_RESULT=DEFAULT;
SELECT * FROM t1;
a
DROP TABLE t1;
End of 5.1 tests
......@@ -430,4 +430,24 @@ SELECT b, COUNT(DISTINCT a) FROM t1 GROUP BY b HAVING b is NULL;
b COUNT(DISTINCT a)
NULL 1
DROP TABLE t1;
#
# Bug#50995 Having clause on subquery result produces incorrect results.
#
CREATE TABLE t1
(
id1 INT,
id2 INT NOT NULL,
INDEX id1(id2)
);
INSERT INTO t1 SET id1=1, id2=1;
INSERT INTO t1 SET id1=2, id2=1;
INSERT INTO t1 SET id1=3, id2=1;
SELECT t1.id1,
(SELECT 0 FROM DUAL
WHERE t1.id1=t1.id1) AS amount FROM t1
WHERE t1.id2 = 1
HAVING amount > 0
ORDER BY t1.id1;
id1 amount
DROP TABLE t1;
End of 5.0 tests
......@@ -2284,6 +2284,20 @@ CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb ;
SELECT 1 FROM t1 JOIN t1 a USING(a) GROUP BY t1.a,t1.a;
1
DROP TABLE t1;
#
# Bug#50843: Filesort used instead of clustered index led to
# performance degradation.
#
create table t1(f1 int not null primary key, f2 int) engine=innodb;
create table t2(f1 int not null, key (f1)) engine=innodb;
insert into t1 values (1,1),(2,2),(3,3);
insert into t2 values (1),(2),(3);
explain select t1.* from t1 left join t2 using(f1) group by t1.f1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 3
1 SIMPLE t2 ref f1 f1 4 test.t1.f1 1 Using index
drop table t1,t2;
#
End of 5.1 tests
#
# Test for bug #39932 "create table fails if column for FK is in different
......
......@@ -1145,3 +1145,14 @@ NULL
NULL
1
DROP TABLE t1, t2, mm1;
#
# Bug #50335: Assertion `!(order->used & map)' in eq_ref_table
#
CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY (a,b));
INSERT INTO t1 VALUES (0,0), (1,1);
SELECT * FROM t1 STRAIGHT_JOIN t1 t2 ON t1.a=t2.a AND t1.a=t2.b ORDER BY t2.a, t1.a;
a b a b
0 0 0 0
1 1 1 1
DROP TABLE t1;
End of 5.1 tests
......@@ -327,3 +327,38 @@ drop table t1;
create table t1 select -9223372036854775809 bi;
describe t1;
drop table t1;
--echo #
--echo # Bug #45360: wrong results
--echo #
CREATE TABLE t1 (id INT AUTO_INCREMENT PRIMARY KEY,
a BIGINT(20) UNSIGNED,
b VARCHAR(20));
INSERT INTO t1 (a) VALUES
(0),
(CAST(0x7FFFFFFFFFFFFFFF AS UNSIGNED)),
(CAST(0x8000000000000000 AS UNSIGNED)),
(CAST(0xFFFFFFFFFFFFFFFF AS UNSIGNED));
UPDATE t1 SET b = a;
let $n = `SELECT MAX(id) FROM t1`;
while($n) {
let $x = `SELECT a FROM t1 WHERE id = $n`;
dec $n;
let $hex = `SELECT HEX($x)`;
echo # $hex;
--disable_result_log
eval EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE a = $x AND TRIM(a) = b;
--enable_result_log
SHOW WARNINGS;
}
DROP TABLE t1;
--echo # End of 5.1 tests
......@@ -291,6 +291,21 @@ DELETE FROM t1 ORDER BY (f1(10)) LIMIT 1;
DROP TABLE t1;
DROP FUNCTION f1;
--echo #
--echo # Bug #49552 : sql_buffer_result cause crash + not found records
--echo # in multitable delete/subquery
--echo #
CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES (1),(2),(3);
SET SESSION SQL_BUFFER_RESULT=1;
DELETE t1 FROM (SELECT SUM(a) a FROM t1) x,t1;
SET SESSION SQL_BUFFER_RESULT=DEFAULT;
SELECT * FROM t1;
DROP TABLE t1;
--echo End of 5.0 tests
#
......@@ -513,18 +528,4 @@ DELETE IGNORE FROM t1;
DROP TABLE t1;
--echo #
--echo # Bug #49552 : sql_buffer_result cause crash + not found records
--echo # in multitable delete/subquery
--echo #
CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES (1),(2),(3);
SET SESSION SQL_BUFFER_RESULT=1;
DELETE t1 FROM (SELECT SUM(a) a FROM t1) x,t1;
SET SESSION SQL_BUFFER_RESULT=DEFAULT;
SELECT * FROM t1;
DROP TABLE t1;
--echo End of 5.1 tests
......@@ -442,4 +442,30 @@ INSERT INTO t1 VALUES (1, 1), (2,2), (3, NULL);
SELECT b, COUNT(DISTINCT a) FROM t1 GROUP BY b HAVING b is NULL;
DROP TABLE t1;
--echo #
--echo # Bug#50995 Having clause on subquery result produces incorrect results.
--echo #
CREATE TABLE t1
(
id1 INT,
id2 INT NOT NULL,
INDEX id1(id2)
);
INSERT INTO t1 SET id1=1, id2=1;
INSERT INTO t1 SET id1=2, id2=1;
INSERT INTO t1 SET id1=3, id2=1;
SELECT t1.id1,
(SELECT 0 FROM DUAL
WHERE t1.id1=t1.id1) AS amount FROM t1
WHERE t1.id2 = 1
HAVING amount > 0
ORDER BY t1.id1;
DROP TABLE t1;
--echo End of 5.0 tests
......@@ -545,6 +545,18 @@ CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb ;
SELECT 1 FROM t1 JOIN t1 a USING(a) GROUP BY t1.a,t1.a;
DROP TABLE t1;
--echo #
--echo # Bug#50843: Filesort used instead of clustered index led to
--echo # performance degradation.
--echo #
create table t1(f1 int not null primary key, f2 int) engine=innodb;
create table t2(f1 int not null, key (f1)) engine=innodb;
insert into t1 values (1,1),(2,2),(3,3);
insert into t2 values (1),(2),(3);
explain select t1.* from t1 left join t2 using(f1) group by t1.f1;
drop table t1,t2;
--echo #
--echo End of 5.1 tests
......
......@@ -816,3 +816,16 @@ CREATE TABLE mm1(a CHAR(9),b INT,KEY(b),KEY(a))
ENGINE=MERGE UNION=(t1,t2);
SELECT t1.a FROM mm1,t1;
DROP TABLE t1, t2, mm1;
--echo #
--echo # Bug #50335: Assertion `!(order->used & map)' in eq_ref_table
--echo #
CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY (a,b));
INSERT INTO t1 VALUES (0,0), (1,1);
SELECT * FROM t1 STRAIGHT_JOIN t1 t2 ON t1.a=t2.a AND t1.a=t2.b ORDER BY t2.a, t1.a;
DROP TABLE t1;
--echo End of 5.1 tests
......@@ -112,7 +112,8 @@ mysqlbug: ${top_builddir}/config.status mysqlbug.sh
mysql_fix_privilege_tables.sql: mysql_system_tables.sql \
mysql_system_tables_fix.sql
@echo "Building $@";
@cat $(srcdir)/mysql_system_tables.sql $(srcdir)/mysql_system_tables_fix.sql > $@
@cat $(srcdir)/mysql_system_tables.sql \
$(srcdir)/mysql_system_tables_fix.sql > $@
#
# Build mysql_fix_privilege_tables_sql.c from
......
......@@ -2210,14 +2210,14 @@ String *Item_int::val_str(String *str)
{
// following assert is redundant, because fixed=1 assigned in constructor
DBUG_ASSERT(fixed == 1);
str->set(value, &my_charset_bin);
str->set_int(value, unsigned_flag, &my_charset_bin);
return str;
}
void Item_int::print(String *str, enum_query_type query_type)
{
// my_charset_bin is good enough for numbers
str_value.set(value, &my_charset_bin);
str_value.set_int(value, unsigned_flag, &my_charset_bin);
str->append(str_value);
}
......
......@@ -1477,9 +1477,21 @@ class Item_cond :public Item_bool_func
Item_cond(THD *thd, Item_cond *item);
Item_cond(List<Item> &nlist)
:Item_bool_func(), list(nlist), abort_on_null(0) {}
bool add(Item *item) { return list.push_back(item); }
bool add_at_head(Item *item) { return list.push_front(item); }
void add_at_head(List<Item> *nlist) { list.prepand(nlist); }
bool add(Item *item)
{
DBUG_ASSERT(item);
return list.push_back(item);
}
bool add_at_head(Item *item)
{
DBUG_ASSERT(item);
return list.push_front(item);
}
void add_at_head(List<Item> *nlist)
{
DBUG_ASSERT(nlist->elements);
list.prepand(nlist);
}
bool fix_fields(THD *, Item **ref);
enum Type type() const { return COND_ITEM; }
......
......@@ -23,7 +23,7 @@ dist-hook:
test -d $(distdir)/$$dir || mkdir $(distdir)/$$dir; \
$(INSTALL_DATA) $(srcdir)/$$dir/*.* $(distdir)/$$dir; \
done; \
sleep 1 ; touch $(srcdir)/*/errmsg.sys
sleep 1 ; touch $(builddir)/*/errmsg.sys
$(INSTALL_DATA) $(srcdir)/charsets/README $(distdir)/charsets
$(INSTALL_DATA) $(srcdir)/charsets/Index.xml $(distdir)/charsets
......@@ -40,11 +40,11 @@ install-data-local:
for lang in @AVAILABLE_LANGUAGES@; \
do \
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/$$lang; \
$(INSTALL_DATA) $(srcdir)/$$lang/errmsg.sys \
$(INSTALL_DATA) $(builddir)/$$lang/errmsg.sys \
$(DESTDIR)$(pkgdatadir)/$$lang/errmsg.sys; \
done
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/charsets
$(INSTALL_DATA) $(srcdir)/errmsg-utf8.txt \
$(INSTALL_DATA) $(builddir)/errmsg-utf8.txt \
$(DESTDIR)$(pkgdatadir)/errmsg-utf8.txt; \
$(INSTALL_DATA) $(srcdir)/charsets/README $(DESTDIR)$(pkgdatadir)/charsets/README
$(INSTALL_DATA) $(srcdir)/charsets/*.xml $(DESTDIR)$(pkgdatadir)/charsets
......@@ -54,7 +54,7 @@ uninstall-local:
@RM@ -f -r $(DESTDIR)$(pkgdatadir)
distclean-local:
@RM@ -f */errmsg.sys
@RM@ -f $(builddir)/*/errmsg.sys
# Do nothing
link_sources:
......
......@@ -7128,10 +7128,12 @@ eq_ref_table(JOIN *join, ORDER *start_order, JOIN_TAB *tab)
break;
}
if (order)
{
if (!(order->used & map))
{
found++;
DBUG_ASSERT(!(order->used & map));
order->used|=map;
order->used|= map;
}
continue; // Used in ORDER BY
}
if (!only_eq_ref_tables(join,start_order, (*ref_item)->used_tables()))
......@@ -8299,6 +8301,7 @@ static Item *eliminate_item_equal(COND *cond, COND_EQUAL *upper_levels,
else
{
DBUG_ASSERT(cond->type() == Item::COND_ITEM);
if (eq_list.elements)
((Item_cond *) cond)->add_at_head(&eq_list);
}
......@@ -13490,12 +13493,6 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
*/
if (select_limit >= table_records)
{
/*
filesort() and join cache are usually faster than reading in
index order and not using join cache
*/
if (tab->type == JT_ALL && tab->join->tables > tab->join->const_tables + 1)
DBUG_RETURN(0);
keys= *table->file->keys_to_use_for_scanning();
keys.merge(table->covering_keys);
......@@ -13645,6 +13642,19 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
}
}
}
/*
filesort() and join cache are usually faster than reading in
index order and not using join cache, except in case that chosen
index is clustered primary key.
*/
if ((select_limit >= table_records) &&
(tab->type == JT_ALL &&
tab->join->tables > tab->join->const_tables + 1) &&
((unsigned) best_key != table->s->primary_key ||
!table->file->primary_key_is_clustered()))
DBUG_RETURN(0);
if (best_key >= 0)
{
bool quick_created= FALSE;
......@@ -15855,7 +15865,7 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab)
Item_cond_and *cond=new Item_cond_and();
TABLE *table=join_tab->table;
int error;
int error= 0;
if (!cond)
DBUG_RETURN(TRUE);
......@@ -15873,6 +15883,7 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab)
cond->fix_fields(thd, (Item**)&cond);
if (join_tab->select)
{
if (join_tab->select->cond)
error=(int) cond->add(join_tab->select->cond);
join_tab->select_cond=join_tab->select->cond=cond;
}
......
......@@ -37,7 +37,7 @@ testBitmask_LDFLAGS = @ndb_bin_am_ldflags@ \
testBitmask.cpp : Bitmask.cpp
rm -f testBitmask.cpp
@LN_CP_F@ Bitmask.cpp testBitmask.cpp
@LN_CP_F@ $(srcdir)/Bitmask.cpp testBitmask.cpp
testBitmask.o: $(testBitmask_SOURCES)
$(CXXCOMPILE) -c $(INCLUDES) -D__TEST_BITMASK__ $<
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment