Commit 7725eb31 authored by igor@igor-inspiron.creware.com's avatar igor@igor-inspiron.creware.com

Merge ibabaev@bk-internal.mysql.com:/home/bk/mysql-5.0

into igor-inspiron.creware.com:/home/igor/mysql-5.0
parents a0f594a8 83b84bc3
...@@ -2837,3 +2837,9 @@ WHERE select_id = 0 OR select_id = 1); ...@@ -2837,3 +2837,9 @@ WHERE select_id = 0 OR select_id = 1);
values_id values_id
1 1
DROP TABLE t1, t2; DROP TABLE t1, t2;
create table t1 (fld enum('0','1'));
insert into t1 values ('1');
select * from (select max(fld) from t1) as foo;
max(fld)
1
drop table t1;
...@@ -1923,6 +1923,14 @@ ERROR HY000: Field of view 'test.v2' underlying table doesn't have a default val ...@@ -1923,6 +1923,14 @@ ERROR HY000: Field of view 'test.v2' underlying table doesn't have a default val
set sql_mode=default; set sql_mode=default;
drop view v2,v1; drop view v2,v1;
drop table t1; drop table t1;
create table t1 (f1 int);
insert into t1 values (1);
create view v1 as select f1 from t1;
select f1 as alias from v1;
alias
1
drop view v1;
drop table t1;
CREATE TABLE t1 (s1 int, s2 int); CREATE TABLE t1 (s1 int, s2 int);
INSERT INTO t1 VALUES (1,2); INSERT INTO t1 VALUES (1,2);
CREATE VIEW v1 AS SELECT s2 AS s1, s1 AS s2 FROM t1; CREATE VIEW v1 AS SELECT s2 AS s1, s1 AS s2 FROM t1;
......
...@@ -1859,3 +1859,11 @@ WHERE values_id IN (SELECT values_id FROM t2 ...@@ -1859,3 +1859,11 @@ WHERE values_id IN (SELECT values_id FROM t2
WHERE select_id = 0 OR select_id = 1); WHERE select_id = 0 OR select_id = 1);
DROP TABLE t1, t2; DROP TABLE t1, t2;
# BUG#11821 : Select from subselect using aggregate function on an enum
# segfaults:
create table t1 (fld enum('0','1'));
insert into t1 values ('1');
select * from (select max(fld) from t1) as foo;
drop table t1;
...@@ -1762,6 +1762,16 @@ set sql_mode=default; ...@@ -1762,6 +1762,16 @@ set sql_mode=default;
drop view v2,v1; drop view v2,v1;
drop table t1; drop table t1;
#
# Bug#11399 Use an alias in a select statement on a view
#
create table t1 (f1 int);
insert into t1 values (1);
create view v1 as select f1 from t1;
select f1 as alias from v1;
drop view v1;
drop table t1;
# #
# Test for bug #6120: SP cache to be invalidated when altering a view # Test for bug #6120: SP cache to be invalidated when altering a view
# #
......
...@@ -5421,9 +5421,13 @@ void Item_type_holder::get_full_info(Item *item) ...@@ -5421,9 +5421,13 @@ void Item_type_holder::get_full_info(Item *item)
if (fld_type == MYSQL_TYPE_ENUM || if (fld_type == MYSQL_TYPE_ENUM ||
fld_type == MYSQL_TYPE_SET) fld_type == MYSQL_TYPE_SET)
{ {
if (item->type() == Item::SUM_FUNC_ITEM &&
(((Item_sum*)item)->sum_func() == Item_sum::MAX_FUNC ||
((Item_sum*)item)->sum_func() == Item_sum::MIN_FUNC))
item = ((Item_sum*)item)->args[0];
/* /*
We can have enum/set type after merging only if we have one enum/set We can have enum/set type after merging only if we have one enum|set
field and number of NULL fields field (or MIN|MAX(enum|set field)) and number of NULL fields
*/ */
DBUG_ASSERT((enum_set_typelib && DBUG_ASSERT((enum_set_typelib &&
get_real_type(item) == MYSQL_TYPE_NULL) || get_real_type(item) == MYSQL_TYPE_NULL) ||
......
...@@ -2400,9 +2400,11 @@ Field *view_ref_found= (Field*) 0x2; ...@@ -2400,9 +2400,11 @@ Field *view_ref_found= (Field*) 0x2;
name name of field name name of field
item_name name of item if it will be created (VIEW) item_name name of item if it will be created (VIEW)
length length of name length length of name
ref expression substituted in VIEW should be ref [in/out] expression substituted in VIEW should be
passed using this reference (return passed using this reference (return
view_ref_found) view_ref_found)
(*ref != NULL) only if *ref contains
the item that we need to replace.
check_grants_table do check columns grants for table? check_grants_table do check columns grants for table?
check_grants_view do check columns grants for view? check_grants_view do check columns grants for view?
allow_rowid do allow finding of "_rowid" field? allow_rowid do allow finding of "_rowid" field?
...@@ -2440,11 +2442,6 @@ find_field_in_table(THD *thd, TABLE_LIST *table_list, ...@@ -2440,11 +2442,6 @@ find_field_in_table(THD *thd, TABLE_LIST *table_list,
{ {
if (!my_strcasecmp(system_charset_info, field_it.name(), name)) if (!my_strcasecmp(system_charset_info, field_it.name(), name))
{ {
Item *item= field_it.create_item(thd);
if (!item)
{
DBUG_RETURN(0);
}
if (table_list->schema_table_reformed) if (table_list->schema_table_reformed)
{ {
/* /*
...@@ -2463,6 +2460,19 @@ find_field_in_table(THD *thd, TABLE_LIST *table_list, ...@@ -2463,6 +2460,19 @@ find_field_in_table(THD *thd, TABLE_LIST *table_list,
name, length)) name, length))
DBUG_RETURN(WRONG_GRANT); DBUG_RETURN(WRONG_GRANT);
#endif #endif
Item *item= field_it.create_item(thd);
if (!item)
{
DBUG_RETURN(0);
}
/*
*ref != NULL means that *ref contains the item that we need to
replace. If the item was aliased by the user, set the alias to
the replacing item.
*/
if (*ref && !(*ref)->is_autogenerated_name)
item->set_name((*ref)->name, (*ref)->name_length,
system_charset_info);
if (register_tree_change) if (register_tree_change)
thd->change_item_tree(ref, item); thd->change_item_tree(ref, item);
else else
......
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