From: Date: June 9 2007 1:52pm Subject: bk commit into 5.0 tree (gluh:1.2525) BUG#28266 List-Archive: http://lists.mysql.com/commits/28456 X-Bug: 28266 Message-Id: <20070609115241.5C52224A0079@eagle.localdomain> Below is the list of changes that have just been committed into a local 5.0 repository of gluh. When gluh does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2007-06-09 16:52:37+05:00, gluh@stripped +5 -0 Bug#28266 IS_UPDATABLE field on VIEWS table in I_S database is wrong IS_UPDATABLE flag is set to 'yes' when the view has at least one updatable column and the algorithm is not 'temporary'. mysql-test/r/information_schema.result@stripped, 2007-06-09 16:52:36+05:00, gluh@stripped +11 -0 test result mysql-test/r/view.result@stripped, 2007-06-09 16:52:36+05:00, gluh@stripped +13 -0 test result mysql-test/t/information_schema.test@stripped, 2007-06-09 16:52:36+05:00, gluh@stripped +15 -0 test case mysql-test/t/view.test@stripped, 2007-06-09 16:52:36+05:00, gluh@stripped +4 -0 test case sql/sql_show.cc@stripped, 2007-06-09 16:52:36+05:00, gluh@stripped +29 -1 IS_UPDATABLE flag is set to 'yes' when the view has at least one updatable column and the algorithm is not 'temporary'. # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: gluh # Host: eagle.(none) # Root: /home/gluh/MySQL/Merge/5.0-opt --- 1.348/sql/sql_show.cc 2007-05-16 13:44:42 +05:00 +++ 1.349/sql/sql_show.cc 2007-06-09 16:52:36 +05:00 @@ -3158,6 +3158,7 @@ static int get_schema_views_record(THD * DBUG_ENTER("get_schema_views_record"); char definer[USER_HOST_BUFF_SIZE]; uint definer_len; + bool updatable_view; if (tables->view) { @@ -3195,7 +3196,34 @@ static int get_schema_views_record(THD * else table->field[4]->store(STRING_WITH_LEN("NONE"), cs); - if (tables->updatable_view) + updatable_view= 0; + if (tables->algorithm != VIEW_ALGORITHM_TMPTABLE) + { + /* + We should use tables->view->select_lex.item_list here and + can not use Field_iterator_view because the view always uses + temporary algorithm during opening for I_S and + TABLE_LIST fields 'field_translation' & 'field_translation_end' + are uninitialized is this case. + */ + List *fields= &tables->view->select_lex.item_list; + List_iterator it(*fields); + Item *item; + Item_field *field; + /* + chech that at least one coulmn in view is updatable + */ + while ((item= it++)) + { + if ((field= item->filed_for_view_update()) && field->field && + !field->field->table->pos_in_table_list->schema_table) + { + updatable_view= 1; + break; + } + } + } + if (updatable_view) table->field[5]->store(STRING_WITH_LEN("YES"), cs); else table->field[5]->store(STRING_WITH_LEN("NO"), cs); --- 1.205/mysql-test/r/view.result 2007-06-01 02:40:46 +05:00 +++ 1.206/mysql-test/r/view.result 2007-06-09 16:52:36 +05:00 @@ -23,6 +23,9 @@ c 5 6 11 +select is_updatable from information_schema.views where table_name='v1'; +is_updatable +NO create temporary table t1 (a int, b int); select * from t1; a b @@ -322,6 +325,12 @@ create table t1 (a int, b int, primary k insert into t1 values (10,2), (20,3), (30,4), (40,5), (50,10); create view v1 (a,c) as select a, b+1 from t1; create algorithm=temptable view v2 (a,c) as select a, b+1 from t1; +select is_updatable from information_schema.views where table_name='v2'; +is_updatable +NO +select is_updatable from information_schema.views where table_name='v1'; +is_updatable +YES update v1 set c=a+c; ERROR HY000: Column 'c' is not updatable update v2 set a=a+c; @@ -604,6 +613,10 @@ insert into t1 values(5,'Hello, world of create view v1 as select * from t1; create view v2 as select * from v1; update v2 set col2='Hello, view world'; +select is_updatable from information_schema.views; +is_updatable +YES +YES select * from t1; col1 col2 5 Hello, view world --- 1.186/mysql-test/t/view.test 2007-06-01 02:40:47 +05:00 +++ 1.187/mysql-test/t/view.test 2007-06-09 16:52:36 +05:00 @@ -32,6 +32,7 @@ create view v1 (c,d) as select a,b from # simple view create view v1 (c) as select b+1 from t1; select c from v1; +select is_updatable from information_schema.views where table_name='v1'; # temporary table should not hide table of view create temporary table t1 (a int, b int); @@ -228,6 +229,8 @@ create table t1 (a int, b int, primary k insert into t1 values (10,2), (20,3), (30,4), (40,5), (50,10); create view v1 (a,c) as select a, b+1 from t1; create algorithm=temptable view v2 (a,c) as select a, b+1 from t1; +select is_updatable from information_schema.views where table_name='v2'; +select is_updatable from information_schema.views where table_name='v1'; # try to update expression -- error 1348 update v1 set c=a+c; @@ -497,6 +500,7 @@ insert into t1 values(5,'Hello, world of create view v1 as select * from t1; create view v2 as select * from v1; update v2 set col2='Hello, view world'; +select is_updatable from information_schema.views; select * from t1; drop view v2, v1; drop table t1; --- 1.121/mysql-test/r/information_schema.result 2007-03-27 21:31:42 +05:00 +++ 1.122/mysql-test/r/information_schema.result 2007-06-09 16:52:36 +05:00 @@ -1315,3 +1315,14 @@ TABLE_PRIVILEGES information_schema.TABL TRIGGERS information_schema.TRIGGERS 1 USER_PRIVILEGES information_schema.USER_PRIVILEGES 1 VIEWS information_schema.VIEWS 1 +create table t1(f1 int); +create view v1 as select f1+1 as a from t1; +create table t2 (f1 int, f2 int); +create view v2 as select f1+1 as a, f2 as b from t2; +select table_name, is_updatable from information_schema.views; +table_name is_updatable +v1 NO +v2 YES +delete from v1; +drop view v1,v2; +drop table t1,t2; --- 1.90/mysql-test/t/information_schema.test 2007-02-12 16:06:12 +04:00 +++ 1.91/mysql-test/t/information_schema.test 2007-06-09 16:52:36 +05:00 @@ -1023,4 +1023,19 @@ where t.table_schema = 'information_sche group by c2.column_type order by num limit 1) group by t.table_name order by num1, t.table_name; +# +# Bug#28266 IS_UPDATABLE field on VIEWS table in I_S database is wrong +# +create table t1(f1 int); +create view v1 as select f1+1 as a from t1; +create table t2 (f1 int, f2 int); +create view v2 as select f1+1 as a, f2 as b from t2; +select table_name, is_updatable from information_schema.views; +# +# Note: we can perform 'delete' for non updatable view. +# +delete from v1; +drop view v1,v2; +drop table t1,t2; + # End of 5.0 tests.