diff options
author | unknown <lars@mysql.com> | 2005-07-12 19:44:34 +0200 |
---|---|---|
committer | unknown <lars@mysql.com> | 2005-07-12 19:44:34 +0200 |
commit | 1c8ef0cbd025557fc34f02d9a8cc99a392579141 (patch) | |
tree | b42dfe5fdc73c181c8dea9df5114d4bf995c1e30 | |
parent | 56da64cec1fa125a677125027a53adfa5786d4df (diff) | |
parent | 08240bbef3264d16d6084794c1d632a92f1a4e2c (diff) | |
download | mariadb-git-1c8ef0cbd025557fc34f02d9a8cc99a392579141.tar.gz |
Merge mysql.com:/home/bkroot/mysql-5.0
into mysql.com:/home/bk/mysql-5.0
-rw-r--r-- | cmd-line-utils/libedit/chared.c | 4 | ||||
-rw-r--r-- | mysql-test/r/subselect.result | 6 | ||||
-rw-r--r-- | mysql-test/r/view.result | 27 | ||||
-rw-r--r-- | mysql-test/t/subselect.test | 8 | ||||
-rw-r--r-- | mysql-test/t/view.test | 28 | ||||
-rw-r--r-- | sql/item.cc | 8 | ||||
-rw-r--r-- | sql/item.h | 8 | ||||
-rw-r--r-- | sql/sql_base.cc | 28 | ||||
-rw-r--r-- | sql/sql_view.cc | 1 |
9 files changed, 108 insertions, 10 deletions
diff --git a/cmd-line-utils/libedit/chared.c b/cmd-line-utils/libedit/chared.c index 21fc8bc2c1d..4cb6e00d26e 100644 --- a/cmd-line-utils/libedit/chared.c +++ b/cmd-line-utils/libedit/chared.c @@ -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; diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 400a2be01f1..693146c869e 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -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; diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 7bcfaf8bdc3..6d75d934cd9 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -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; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 1e4930d385d..ecb3432753d 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -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; + diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 6b6b3d8a00f..6cb6764b6c0 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -1763,6 +1763,16 @@ 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; diff --git a/sql/item.cc b/sql/item.cc index e53c1ebf734..4679b62643e 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -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) || diff --git a/sql/item.h b/sql/item.h index 560f1124fb4..12acb8dd28d 100644 --- a/sql/item.h +++ b/sql/item.h @@ -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); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 7a7f2292703..c9d50bef82a 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -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 diff --git a/sql/sql_view.cc b/sql/sql_view.cc index d74b96de2cd..a60bf80a6d8 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -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); |