Commit e06bc9e9 authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/data0/bk/mysql-5.0

into  bk-internal.mysql.com:/data0/bk/mysql-5.0-opt


sql/item_cmpfunc.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_view.cc:
  Auto merged
parents b7d2d38e 69ed5e93
......@@ -1992,4 +1992,73 @@ abc
SELECT INSERT('abc', 6, 3, '1234');
INSERT('abc', 6, 3, '1234')
abc
CREATE TABLE t1 (a INT);
CREATE VIEW v1 AS SELECT CRC32(a) AS C FROM t1;
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
SELECT CRC32(a), COUNT(*) FROM t1 GROUP BY 1;
CRC32(a) COUNT(*)
450215437 1
498629140 1
1790921346 1
1842515611 1
2212294583 1
2226203566 1
2366072709 1
2707236321 1
4088798008 1
4194326291 1
SELECT CRC32(a), COUNT(*) FROM t1 GROUP BY 1 ORDER BY 1;
CRC32(a) COUNT(*)
450215437 1
498629140 1
1790921346 1
1842515611 1
2212294583 1
2226203566 1
2366072709 1
2707236321 1
4088798008 1
4194326291 1
SELECT * FROM (SELECT CRC32(a) FROM t1) t2;
CRC32(a)
2212294583
450215437
1842515611
4088798008
2226203566
498629140
1790921346
4194326291
2366072709
2707236321
CREATE TABLE t2 SELECT CRC32(a) FROM t1;
desc t2;
Field Type Null Key Default Extra
CRC32(a) int(10) unsigned YES NULL
SELECT * FROM v1;
C
2212294583
450215437
1842515611
4088798008
2226203566
498629140
1790921346
4194326291
2366072709
2707236321
SELECT * FROM (SELECT * FROM v1) x;
C
2212294583
450215437
1842515611
4088798008
2226203566
498629140
1790921346
4194326291
2366072709
2707236321
DROP TABLE t1, t2;
DROP VIEW v1;
End of 5.0 tests
......@@ -414,3 +414,44 @@ a int(11) NO PRI
b varchar(20) NO MUL
c varchar(20) NO
drop table t1;
CREATE TABLE t1 (
a INTEGER auto_increment PRIMARY KEY,
b INTEGER NOT NULL,
c INTEGER NOT NULL,
d CHAR(64)
);
CREATE TABLE t2 (
a INTEGER auto_increment PRIMARY KEY,
b INTEGER NOT NULL,
c SMALLINT NOT NULL,
d DATETIME NOT NULL,
e SMALLINT NOT NULL,
f INTEGER NOT NULL,
g INTEGER NOT NULL,
h SMALLINT NOT NULL,
i INTEGER NOT NULL,
j INTEGER NOT NULL,
UNIQUE INDEX (b),
INDEX (b, d, e, f, g, h, i, j, c),
INDEX (c)
);
INSERT INTO t2 VALUES
(NULL, 1, 254, '1000-01-01 00:00:00', 257, 0, 0, 0, 0, 0),
(NULL, 2, 1, '2004-11-30 12:00:00', 1, 0, 0, 0, 0, 0),
(NULL, 3, 1, '2004-11-30 12:00:00', 1, 0, 0, 2, -21600, 0),
(NULL, 4, 1, '2004-11-30 12:00:00', 1, 0, 0, 2, -10800, 0),
(NULL, 5, 1, '2004-11-30 12:00:00', 1, 0, 0, 5, -10800, 0),
(NULL, 6, 1, '2004-11-30 12:00:00', 102, 0, 0, 0, 0, 0),
(NULL, 7, 1, '2004-11-30 12:00:00', 105, 2, 0, 0, 0, 0),
(NULL, 8, 1, '2004-11-30 12:00:00', 105, 10, 0, 0, 0, 0);
INSERT INTO t1 (b, c, d) VALUES
(3388000, -553000, NULL),
(3388000, -553000, NULL);
SELECT *
FROM t2 c JOIN t1 pa ON c.b = pa.a
WHERE c.c = 1
ORDER BY c.b, c.d
;
a b c d e f g h i j a b c d
2 2 1 2004-11-30 12:00:00 1 0 0 0 0 0 2 3388000 -553000 NULL
DROP TABLE t1, t2;
......@@ -193,6 +193,103 @@ SELECT ROW(2,1) IN (ROW(21,2),ROW(ROW(1,1,3),0));
ERROR 21000: Operand should contain 1 column(s)
SELECT ROW(2,1) IN (ROW(ROW(1,1,3),0),ROW(21,2));
ERROR 21000: Operand should contain 1 column(s)
CREATE TABLE t1(a int, b int, c int);
INSERT INTO t1 VALUES (1, 2, 3),
(NULL, 2, 3 ), (1, NULL, 3 ), (1, 2, NULL),
(NULL, 2, 3+1), (1, NULL, 3+1), (1, 2+1, NULL),
(NULL, 2, 3-1), (1, NULL, 3-1), (1, 2-1, NULL);
SELECT (1,2,3) = (1, NULL, 3);
(1,2,3) = (1, NULL, 3)
NULL
SELECT (1,2,3) = (1+1, NULL, 3);
(1,2,3) = (1+1, NULL, 3)
0
SELECT (1,2,3) = (1, NULL, 3+1);
(1,2,3) = (1, NULL, 3+1)
0
SELECT * FROM t1 WHERE (a,b,c) = (1,2,3);
a b c
1 2 3
SELECT (1,2,3) <> (1, NULL, 3);
(1,2,3) <> (1, NULL, 3)
NULL
SELECT (1,2,3) <> (1+1, NULL, 3);
(1,2,3) <> (1+1, NULL, 3)
1
SELECT (1,2,3) <> (1, NULL, 3+1);
(1,2,3) <> (1, NULL, 3+1)
1
SELECT * FROM t1 WHERE (a,b,c) <> (1,2,3);
a b c
NULL 2 4
1 NULL 4
1 3 NULL
NULL 2 2
1 NULL 2
1 1 NULL
SELECT (1,2,3) < (NULL, 2, 3);
(1,2,3) < (NULL, 2, 3)
NULL
SELECT (1,2,3) < (1, NULL, 3);
(1,2,3) < (1, NULL, 3)
NULL
SELECT (1,2,3) < (1-1, NULL, 3);
(1,2,3) < (1-1, NULL, 3)
0
SELECT (1,2,3) < (1+1, NULL, 3);
(1,2,3) < (1+1, NULL, 3)
1
SELECT * FROM t1 WHERE (a,b,c) < (1,2,3);
a b c
1 1 NULL
SELECT (1,2,3) <= (NULL, 2, 3);
(1,2,3) <= (NULL, 2, 3)
NULL
SELECT (1,2,3) <= (1, NULL, 3);
(1,2,3) <= (1, NULL, 3)
NULL
SELECT (1,2,3) <= (1-1, NULL, 3);
(1,2,3) <= (1-1, NULL, 3)
0
SELECT (1,2,3) <= (1+1, NULL, 3);
(1,2,3) <= (1+1, NULL, 3)
1
SELECT * FROM t1 WHERE (a,b,c) <= (1,2,3);
a b c
1 2 3
1 1 NULL
SELECT (1,2,3) > (NULL, 2, 3);
(1,2,3) > (NULL, 2, 3)
NULL
SELECT (1,2,3) > (1, NULL, 3);
(1,2,3) > (1, NULL, 3)
NULL
SELECT (1,2,3) > (1-1, NULL, 3);
(1,2,3) > (1-1, NULL, 3)
1
SELECT (1,2,3) > (1+1, NULL, 3);
(1,2,3) > (1+1, NULL, 3)
0
SELECT * FROM t1 WHERE (a,b,c) > (1,2,3);
a b c
1 3 NULL
SELECT (1,2,3) >= (NULL, 2, 3);
(1,2,3) >= (NULL, 2, 3)
NULL
SELECT (1,2,3) >= (1, NULL, 3);
(1,2,3) >= (1, NULL, 3)
NULL
SELECT (1,2,3) >= (1-1, NULL, 3);
(1,2,3) >= (1-1, NULL, 3)
1
SELECT (1,2,3) >= (1+1, NULL, 3);
(1,2,3) >= (1+1, NULL, 3)
0
SELECT * FROM t1 WHERE (a,b,c) >= (1,2,3);
a b c
1 2 3
1 3 NULL
DROP TABLE t1;
SELECT ROW(1,1,1) = ROW(1,1,1) as `1`, ROW(1,1,1) = ROW(1,2,1) as `0`, ROW(1,NULL,1) = ROW(2,2,1) as `0`, ROW(1,NULL,1) = ROW(1,2,2) as `0`, ROW(1,NULL,1) = ROW(1,2,1) as `null` ;
1 0 0 0 null
1 0 0 0 NULL
......
......@@ -692,3 +692,22 @@ a MAX(b) test
2 3 h
3 4 i
DROP TABLE t1, t2;
CREATE TABLE t1 (a int);
CREATE TABLE t2 (b int, PRIMARY KEY(b));
INSERT INTO t1 VALUES (1), (NULL), (4);
INSERT INTO t2 VALUES (3), (1),(2), (5), (4), (7), (6);
EXPLAIN EXTENDED
SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using index
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (not(<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 AS `Not_used` from `test`.`t1` where ((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`)) having <is_not_null_test>(`test`.`t1`.`a`))))))
SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1));
a
SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1 WHERE a > 4));
a
1
4
DROP TABLE t1,t2;
......@@ -3319,4 +3319,39 @@ lgid clid
2 YES
DROP VIEW v1;
DROP table t1,t2;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2),(3);
CREATE VIEW v1 AS SELECT a FROM t1 ORDER BY a;
SELECT * FROM t1 UNION SELECT * FROM v1;
a
1
2
3
EXPLAIN SELECT * FROM t1 UNION SELECT * FROM v1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
2 UNION t1 ALL NULL NULL NULL NULL 3
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
SELECT * FROM v1 UNION SELECT * FROM t1;
a
1
2
3
EXPLAIN SELECT * FROM v1 UNION SELECT * FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
2 UNION t1 ALL NULL NULL NULL NULL 3
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
SELECT * FROM t1 UNION SELECT * FROM v1 ORDER BY a;
a
1
2
3
EXPLAIN SELECT * FROM t1 UNION SELECT * FROM v1 ORDER BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
2 UNION t1 ALL NULL NULL NULL NULL 3
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL Using filesort
DROP VIEW v1;
DROP TABLE t1;
End of 5.0 tests.
......@@ -1058,4 +1058,22 @@ SELECT INSERT('abc', 4, 3, '1234');
SELECT INSERT('abc', 5, 3, '1234');
SELECT INSERT('abc', 6, 3, '1234');
#
# Bug #27530: Grouping on crc32, or create table select crc32
#
CREATE TABLE t1 (a INT);
CREATE VIEW v1 AS SELECT CRC32(a) AS C FROM t1;
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
SELECT CRC32(a), COUNT(*) FROM t1 GROUP BY 1;
SELECT CRC32(a), COUNT(*) FROM t1 GROUP BY 1 ORDER BY 1;
SELECT * FROM (SELECT CRC32(a) FROM t1) t2;
CREATE TABLE t2 SELECT CRC32(a) FROM t1;
desc t2;
SELECT * FROM v1;
SELECT * FROM (SELECT * FROM v1) x;
DROP TABLE t1, t2;
DROP VIEW v1;
--echo End of 5.0 tests
......@@ -384,3 +384,51 @@ desc t1;
drop table t1;
# End of 4.1 tests
#
# Bug #24778: Innodb: No result when using ORDER BY
#
CREATE TABLE t1 (
a INTEGER auto_increment PRIMARY KEY,
b INTEGER NOT NULL,
c INTEGER NOT NULL,
d CHAR(64)
);
CREATE TABLE t2 (
a INTEGER auto_increment PRIMARY KEY,
b INTEGER NOT NULL,
c SMALLINT NOT NULL,
d DATETIME NOT NULL,
e SMALLINT NOT NULL,
f INTEGER NOT NULL,
g INTEGER NOT NULL,
h SMALLINT NOT NULL,
i INTEGER NOT NULL,
j INTEGER NOT NULL,
UNIQUE INDEX (b),
INDEX (b, d, e, f, g, h, i, j, c),
INDEX (c)
);
INSERT INTO t2 VALUES
(NULL, 1, 254, '1000-01-01 00:00:00', 257, 0, 0, 0, 0, 0),
(NULL, 2, 1, '2004-11-30 12:00:00', 1, 0, 0, 0, 0, 0),
(NULL, 3, 1, '2004-11-30 12:00:00', 1, 0, 0, 2, -21600, 0),
(NULL, 4, 1, '2004-11-30 12:00:00', 1, 0, 0, 2, -10800, 0),
(NULL, 5, 1, '2004-11-30 12:00:00', 1, 0, 0, 5, -10800, 0),
(NULL, 6, 1, '2004-11-30 12:00:00', 102, 0, 0, 0, 0, 0),
(NULL, 7, 1, '2004-11-30 12:00:00', 105, 2, 0, 0, 0, 0),
(NULL, 8, 1, '2004-11-30 12:00:00', 105, 10, 0, 0, 0, 0);
INSERT INTO t1 (b, c, d) VALUES
(3388000, -553000, NULL),
(3388000, -553000, NULL);
SELECT *
FROM t2 c JOIN t1 pa ON c.b = pa.a
WHERE c.c = 1
ORDER BY c.b, c.d
;
DROP TABLE t1, t2;
......@@ -110,6 +110,51 @@ SELECT ROW(2,1) IN (ROW(21,2),ROW(ROW(1,1,3),0));
--error 1241
SELECT ROW(2,1) IN (ROW(ROW(1,1,3),0),ROW(21,2));
#
# Bug#27704: erroneous comparison of rows with NULL components
#
CREATE TABLE t1(a int, b int, c int);
INSERT INTO t1 VALUES (1, 2, 3),
(NULL, 2, 3 ), (1, NULL, 3 ), (1, 2, NULL),
(NULL, 2, 3+1), (1, NULL, 3+1), (1, 2+1, NULL),
(NULL, 2, 3-1), (1, NULL, 3-1), (1, 2-1, NULL);
SELECT (1,2,3) = (1, NULL, 3);
SELECT (1,2,3) = (1+1, NULL, 3);
SELECT (1,2,3) = (1, NULL, 3+1);
SELECT * FROM t1 WHERE (a,b,c) = (1,2,3);
SELECT (1,2,3) <> (1, NULL, 3);
SELECT (1,2,3) <> (1+1, NULL, 3);
SELECT (1,2,3) <> (1, NULL, 3+1);
SELECT * FROM t1 WHERE (a,b,c) <> (1,2,3);
SELECT (1,2,3) < (NULL, 2, 3);
SELECT (1,2,3) < (1, NULL, 3);
SELECT (1,2,3) < (1-1, NULL, 3);
SELECT (1,2,3) < (1+1, NULL, 3);
SELECT * FROM t1 WHERE (a,b,c) < (1,2,3);
SELECT (1,2,3) <= (NULL, 2, 3);
SELECT (1,2,3) <= (1, NULL, 3);
SELECT (1,2,3) <= (1-1, NULL, 3);
SELECT (1,2,3) <= (1+1, NULL, 3);
SELECT * FROM t1 WHERE (a,b,c) <= (1,2,3);
SELECT (1,2,3) > (NULL, 2, 3);
SELECT (1,2,3) > (1, NULL, 3);
SELECT (1,2,3) > (1-1, NULL, 3);
SELECT (1,2,3) > (1+1, NULL, 3);
SELECT * FROM t1 WHERE (a,b,c) > (1,2,3);
SELECT (1,2,3) >= (NULL, 2, 3);
SELECT (1,2,3) >= (1, NULL, 3);
SELECT (1,2,3) >= (1-1, NULL, 3);
SELECT (1,2,3) >= (1+1, NULL, 3);
SELECT * FROM t1 WHERE (a,b,c) >= (1,2,3);
DROP TABLE t1;
# End of 4.1 tests
#
......
......@@ -528,3 +528,21 @@ SELECT a, MAX(b),
DROP TABLE t1, t2;
#
# Bug #27870: crash of an equijoin query with WHERE condition containing
# a subquery predicate of the form <join attr> NOT IN (SELECT ...)
#
CREATE TABLE t1 (a int);
CREATE TABLE t2 (b int, PRIMARY KEY(b));
INSERT INTO t1 VALUES (1), (NULL), (4);
INSERT INTO t2 VALUES (3), (1),(2), (5), (4), (7), (6);
EXPLAIN EXTENDED
SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1));
SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1));
SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1 WHERE a > 4));
DROP TABLE t1,t2;
......@@ -3205,4 +3205,20 @@ SELECT * FROM v1;
DROP VIEW v1;
DROP table t1,t2;
#
# Bug#27786: Inconsistent Operation Performing UNION On View With ORDER BY
#
CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (1),(2),(3);
CREATE VIEW v1 AS SELECT a FROM t1 ORDER BY a;
SELECT * FROM t1 UNION SELECT * FROM v1;
EXPLAIN SELECT * FROM t1 UNION SELECT * FROM v1;
SELECT * FROM v1 UNION SELECT * FROM t1;
EXPLAIN SELECT * FROM v1 UNION SELECT * FROM t1;
SELECT * FROM t1 UNION SELECT * FROM v1 ORDER BY a;
EXPLAIN SELECT * FROM t1 UNION SELECT * FROM v1 ORDER BY a;
DROP VIEW v1;
DROP TABLE t1;
--echo End of 5.0 tests.
......@@ -811,8 +811,18 @@ int Arg_comparator::compare_row()
if (owner->null_value)
{
// NULL was compared
if (owner->abort_on_null)
return -1; // We do not need correct NULL returning
switch (owner->functype()) {
case Item_func::NE_FUNC:
break; // NE never aborts on NULL even if abort_on_null is set
case Item_func::LT_FUNC:
case Item_func::LE_FUNC:
case Item_func::GT_FUNC:
case Item_func::GE_FUNC:
return -1; // <, <=, > and >= always fail on NULL
default: // EQ_FUNC
if (owner->abort_on_null)
return -1; // We do not need correct NULL returning
}
was_null= 1;
owner->null_value= 0;
res= 0; // continue comparison (maybe we will meet explicit difference)
......@@ -823,8 +833,8 @@ int Arg_comparator::compare_row()
if (was_null)
{
/*
There was NULL(s) in comparison in some parts, but there was not
explicit difference in other parts, so we have to return NULL
There was NULL(s) in comparison in some parts, but there was no
explicit difference in other parts, so we have to return NULL.
*/
owner->null_value= 1;
return -1;
......
......@@ -333,7 +333,7 @@ class Item_bool_func2 :public Item_int_func
bool is_bool_func() { return 1; }
CHARSET_INFO *compare_collation() { return cmp.cmp_collation.collation; }
uint decimal_precision() const { return 1; }
void top_level_item() { abort_on_null=1; }
void top_level_item() { abort_on_null= TRUE; }
friend class Arg_comparator;
};
......
......@@ -790,7 +790,7 @@ class Item_func_crc32 :public Item_int_func
{
String value;
public:
Item_func_crc32(Item *a) :Item_int_func(a) {}
Item_func_crc32(Item *a) :Item_int_func(a) { unsigned_flag= 1; }
const char *func_name() const { return "crc32"; }
void fix_length_and_dec() { max_length=10; }
longlong val_int();
......
......@@ -276,7 +276,11 @@ class Item_in_subselect :public Item_exists_subselect
{
return pushed_cond_guards ? pushed_cond_guards + i : NULL;
}
void set_cond_guard_var(int i, bool v) { pushed_cond_guards[i]= v; }
void set_cond_guard_var(int i, bool v)
{
if ( pushed_cond_guards)
pushed_cond_guards[i]= v;
}
bool have_guarded_conds() { return test(pushed_cond_guards); }
Item_func_not_all *upper_item; // point on NOT/NOP before ALL/SOME subquery
......
......@@ -468,6 +468,7 @@ class st_select_lex_unit: public st_select_lex_node {
bool change_result(select_subselect *result, select_subselect *old_result);
void set_limit(st_select_lex *values);
void set_thd(THD *thd_arg) { thd= thd_arg; }
inline bool is_union ();
friend void lex_start(THD *thd, uchar *buf, uint length);
friend int subselect_union_engine::exec();
......@@ -700,6 +701,13 @@ class st_select_lex: public st_select_lex_node
};
typedef class st_select_lex SELECT_LEX;
inline bool st_select_lex_unit::is_union ()
{
return first_select()->next_select() &&
first_select()->next_select()->linkage == UNION_TYPE;
}
#define ALTER_ADD_COLUMN 1
#define ALTER_DROP_COLUMN 2
#define ALTER_CHANGE_COLUMN 4
......
......@@ -5982,10 +5982,7 @@ make_join_readinfo(JOIN *join, ulonglong options)
*/
if (!ordered_set &&
(table == join->sort_by_table &&
(!join->order || join->skip_sort_order ||
test_if_skip_sort_order(tab, join->order, join->select_limit,
1))
) ||
(!join->order || join->skip_sort_order)) ||
(join->sort_by_table == (TABLE *) 1 && i != join->const_tables))
ordered_set= 1;
......
......@@ -2315,18 +2315,32 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
res= open_normal_and_derived_tables(thd, show_table_list,
MYSQL_LOCK_IGNORE_FLUSH);
lex->sql_command= save_sql_command;
/*
We should use show_table_list->alias instead of
show_table_list->table_name because table_name
could be changed during opening of I_S tables. It's safe
to use alias because alias contains original table name
in this case.
/*
They can drop table after table names list creation and
before table opening. We open non existing table and
get ER_NO_SUCH_TABLE error. In this case we do not store
the record into I_S table and clear error.
*/
res= schema_table->process_table(thd, show_table_list, table,
res, orig_base_name,
show_table_list->alias);
close_tables_for_reopen(thd, &show_table_list);
DBUG_ASSERT(!lex->query_tables_own_last);
if (thd->net.last_errno == ER_NO_SUCH_TABLE)
{
res= 0;
thd->clear_error();
}
else
{
/*
We should use show_table_list->alias instead of
show_table_list->table_name because table_name
could be changed during opening of I_S tables. It's safe
to use alias because alias contains original table name
in this case.
*/
res= schema_table->process_table(thd, show_table_list, table,
res, orig_base_name,
show_table_list->alias);
close_tables_for_reopen(thd, &show_table_list);
DBUG_ASSERT(!lex->query_tables_own_last);
}
if (res)
goto err;
}
......
......@@ -1279,13 +1279,18 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
unit->slave= save_slave; // fix include_down initialisation
}
/*
We can safely ignore the VIEW's ORDER BY if we merge into union
branch, as order is not important there.
*/
if (!table->select_lex->master_unit()->is_union())
table->select_lex->order_list.push_back(&lex->select_lex.order_list);
/*
This SELECT_LEX will be linked in global SELECT_LEX list
to make it processed by mysql_handle_derived(),
but it will not be included to SELECT_LEX tree, because it
will not be executed
*/
table->select_lex->order_list.push_back(&lex->select_lex.order_list);
*/
goto ok;
}
......
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