Commit f19814be authored by lars@mysql.com's avatar lars@mysql.com

Merge mysql.com:/home/bkroot/mysql-5.0

into  mysql.com:/home/bk/mysql-5.0
parents df55465b 4ffd18b4
......@@ -51,13 +51,13 @@ cv_undo(EditLine *el)
{
c_undo_t *vu = &el->el_chared.c_undo;
c_redo_t *r = &el->el_chared.c_redo;
uint size;
int size;
/* Save entire line for undo */
size = el->el_line.lastchar - el->el_line.buffer;
vu->len = size;
vu->cursor = el->el_line.cursor - el->el_line.buffer;
memcpy(vu->buf, el->el_line.buffer, size);
memcpy(vu->buf, el->el_line.buffer, (size_t)size);
/* save command info for redo */
r->count = el->el_state.doingarg ? el->el_state.argument : 0;
......
......@@ -2837,3 +2837,9 @@ WHERE select_id = 0 OR select_id = 1);
values_id
1
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
set sql_mode=default;
drop view v2,v1;
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);
INSERT INTO t1 VALUES (1,2);
CREATE VIEW v1 AS SELECT s2 AS s1, s1 AS s2 FROM t1;
......@@ -1937,6 +1945,25 @@ ALTER VIEW v1 AS SELECT s1 AS s1, s2 AS s2 FROM t1;
CALL p1();
s1 s2
1 2
DROP VIEW v1;
CREATE VIEW v1 AS SELECT s2 AS s1, s1 AS s2 FROM t1;
CALL p1();
s1 s2
2 1
DROP PROCEDURE p1;
DROP VIEW v1;
DROP TABLE t1;
CREATE TABLE t1 (f1 char) ENGINE = innodb;
INSERT INTO t1 VALUES ('A');
CREATE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES('B');
SELECT * FROM v1;
f1
A
B
SELECT * FROM t1;
f1
A
B
DROP VIEW v1;
DROP TABLE t1;
......@@ -1859,3 +1859,11 @@ WHERE values_id IN (SELECT values_id FROM t2
WHERE select_id = 0 OR select_id = 1);
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;
drop view v2,v1;
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
#
......@@ -1774,7 +1784,25 @@ CREATE PROCEDURE p1 () SELECT * FROM v1;
CALL p1();
ALTER VIEW v1 AS SELECT s1 AS s1, s2 AS s2 FROM t1;
CALL p1();
DROP VIEW v1;
CREATE VIEW v1 AS SELECT s2 AS s1, s1 AS s2 FROM t1;
CALL p1();
DROP PROCEDURE p1;
DROP VIEW v1;
DROP TABLE t1;
#
# Test for bug #11771: wrong query_id in SELECT * FROM <view>
#
CREATE TABLE t1 (f1 char) ENGINE = innodb;
INSERT INTO t1 VALUES ('A');
CREATE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES('B');
SELECT * FROM v1;
SELECT * FROM t1;
DROP VIEW v1;
DROP TABLE t1;
......@@ -5421,9 +5421,13 @@ void Item_type_holder::get_full_info(Item *item)
if (fld_type == MYSQL_TYPE_ENUM ||
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
field and number of NULL fields
We can have enum/set type after merging only if we have one enum|set
field (or MIN|MAX(enum|set field)) and number of NULL fields
*/
DBUG_ASSERT((enum_set_typelib &&
get_real_type(item) == MYSQL_TYPE_NULL) ||
......
......@@ -641,6 +641,7 @@ public:
virtual bool cleanup_processor(byte *arg);
virtual bool collect_item_field_processor(byte * arg) { return 0; }
virtual bool change_context_processor(byte *context) { return 0; }
virtual bool reset_query_id_processor(byte *query_id) { return 0; }
virtual Item *equal_fields_propagator(byte * arg) { return this; }
virtual Item *set_no_const_sub(byte *arg) { return this; }
......@@ -895,6 +896,13 @@ public:
bool is_null() { return field->is_null(); }
Item *get_tmp_table_item(THD *thd);
bool collect_item_field_processor(byte * arg);
bool reset_query_id_processor(byte *arg)
{
field->query_id= *((query_id_t *) arg);
if (result_field)
result_field->query_id= field->query_id;
return 0;
}
void cleanup();
Item_equal *find_item_equal(COND_EQUAL *cond_equal);
Item *equal_fields_propagator(byte *arg);
......
......@@ -2400,9 +2400,11 @@ Field *view_ref_found= (Field*) 0x2;
name name of field
item_name name of item if it will be created (VIEW)
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
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_view do check columns grants for view?
allow_rowid do allow finding of "_rowid" field?
......@@ -2440,11 +2442,6 @@ find_field_in_table(THD *thd, TABLE_LIST *table_list,
{
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)
{
/*
......@@ -2463,6 +2460,19 @@ find_field_in_table(THD *thd, TABLE_LIST *table_list,
name, length))
DBUG_RETURN(WRONG_GRANT);
#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)
thd->change_item_tree(ref, item);
else
......@@ -3495,6 +3505,12 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
field->query_id=thd->query_id;
table->used_keys.intersect(field->part_of_key);
}
else
{
Item *item= ((Field_iterator_view *) iterator)->item();
item->walk(&Item::reset_query_id_processor,
(byte *)(&thd->query_id));
}
}
/*
All fields are used in case if usual tables (in case of view used
......
......@@ -1004,6 +1004,7 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode)
if (my_delete(path, MYF(MY_WME)))
goto err;
query_cache_invalidate3(thd, view, 0);
sp_cache_invalidate();
VOID(pthread_mutex_unlock(&LOCK_open));
}
send_ok(thd);
......
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