Commit 557d0ca4 authored by unknown's avatar unknown

Information schema fix for WL#2787


mysql-test/r/information_schema.result:
  new fields in I_S
sql/sql_show.cc:
  added niew firlds to view information schema
parent b34d5bd2
...@@ -360,12 +360,12 @@ latin1_spanish_ci ...@@ -360,12 +360,12 @@ latin1_spanish_ci
show keys from v4; show keys from v4;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
select * from information_schema.views where TABLE_NAME like "v%"; select * from information_schema.views where TABLE_NAME like "v%";
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE
NULL test v0 select sql_no_cache `schemata`.`SCHEMA_NAME` AS `c` from `information_schema`.`schemata` NONE NO NULL test v0 select sql_no_cache `schemata`.`SCHEMA_NAME` AS `c` from `information_schema`.`schemata` NONE NO root@localhos DEFINER
NULL test v1 select sql_no_cache `tables`.`TABLE_NAME` AS `c` from `information_schema`.`tables` where (`tables`.`TABLE_NAME` = _utf8'v1') NONE NO NULL test v1 select sql_no_cache `tables`.`TABLE_NAME` AS `c` from `information_schema`.`tables` where (`tables`.`TABLE_NAME` = _utf8'v1') NONE NO root@localhos DEFINER
NULL test v2 select sql_no_cache `columns`.`COLUMN_NAME` AS `c` from `information_schema`.`columns` where (`columns`.`TABLE_NAME` = _utf8'v2') NONE NO NULL test v2 select sql_no_cache `columns`.`COLUMN_NAME` AS `c` from `information_schema`.`columns` where (`columns`.`TABLE_NAME` = _utf8'v2') NONE NO root@localhos DEFINER
NULL test v3 select sql_no_cache `character_sets`.`CHARACTER_SET_NAME` AS `c` from `information_schema`.`character_sets` where (`character_sets`.`CHARACTER_SET_NAME` like _utf8'latin1%') NONE NO NULL test v3 select sql_no_cache `character_sets`.`CHARACTER_SET_NAME` AS `c` from `information_schema`.`character_sets` where (`character_sets`.`CHARACTER_SET_NAME` like _utf8'latin1%') NONE NO root@localhos DEFINER
NULL test v4 select sql_no_cache `collations`.`COLLATION_NAME` AS `c` from `information_schema`.`collations` where (`collations`.`COLLATION_NAME` like _utf8'latin1%') NONE NO NULL test v4 select sql_no_cache `collations`.`COLLATION_NAME` AS `c` from `information_schema`.`collations` where (`collations`.`COLLATION_NAME` like _utf8'latin1%') NONE NO root@localhos DEFINER
drop view v0, v1, v2, v3, v4; drop view v0, v1, v2, v3, v4;
create table t1 (a int); create table t1 (a int);
grant select,update,insert on t1 to mysqltest_1@localhost; grant select,update,insert on t1 to mysqltest_1@localhost;
...@@ -455,10 +455,10 @@ create view v1 (c) as select a from t1 with check option; ...@@ -455,10 +455,10 @@ create view v1 (c) as select a from t1 with check option;
create view v2 (c) as select a from t1 WITH LOCAL CHECK OPTION; create view v2 (c) as select a from t1 WITH LOCAL CHECK OPTION;
create view v3 (c) as select a from t1 WITH CASCADED CHECK OPTION; create view v3 (c) as select a from t1 WITH CASCADED CHECK OPTION;
select * from information_schema.views; select * from information_schema.views;
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE
NULL test v1 select `test`.`t1`.`a` AS `c` from `test`.`t1` CASCADED YES NULL test v1 select `test`.`t1`.`a` AS `c` from `test`.`t1` CASCADED YES root@localhos DEFINER
NULL test v2 select `test`.`t1`.`a` AS `c` from `test`.`t1` LOCAL YES NULL test v2 select `test`.`t1`.`a` AS `c` from `test`.`t1` LOCAL YES root@localhos DEFINER
NULL test v3 select `test`.`t1`.`a` AS `c` from `test`.`t1` CASCADED YES NULL test v3 select `test`.`t1`.`a` AS `c` from `test`.`t1` CASCADED YES root@localhos DEFINER
grant select (a) on test.t1 to joe@localhost with grant option; grant select (a) on test.t1 to joe@localhost with grant option;
select * from INFORMATION_SCHEMA.COLUMN_PRIVILEGES; select * from INFORMATION_SCHEMA.COLUMN_PRIVILEGES;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
......
...@@ -2947,6 +2947,8 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables, ...@@ -2947,6 +2947,8 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables,
{ {
CHARSET_INFO *cs= system_charset_info; CHARSET_INFO *cs= system_charset_info;
DBUG_ENTER("get_schema_views_record"); DBUG_ENTER("get_schema_views_record");
char definer[HOSTNAME_LENGTH + USERNAME_LENGTH + 2];
uint defiler_len;
if (!res) if (!res)
{ {
if (tables->view) if (tables->view)
...@@ -2960,17 +2962,24 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables, ...@@ -2960,17 +2962,24 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables,
if (tables->with_check != VIEW_CHECK_NONE) if (tables->with_check != VIEW_CHECK_NONE)
{ {
if (tables->with_check == VIEW_CHECK_LOCAL) if (tables->with_check == VIEW_CHECK_LOCAL)
table->field[4]->store("LOCAL", 5, cs); table->field[4]->store(STRING_WITH_LEN("LOCAL"), cs);
else else
table->field[4]->store("CASCADED", 8, cs); table->field[4]->store(STRING_WITH_LEN("CASCADED"), cs);
} }
else else
table->field[4]->store("NONE", 4, cs); table->field[4]->store(STRING_WITH_LEN("NONE"), cs);
if (tables->updatable_view) if (tables->updatable_view)
table->field[5]->store("YES", 3, cs); table->field[5]->store(STRING_WITH_LEN("YES"), cs);
else else
table->field[5]->store("NO", 2, cs); table->field[5]->store(STRING_WITH_LEN("NO"), cs);
defiler_len= (strxmov(definer, tables->definer.user.str, "@",
tables->definer.host.str, NullS) - definer) - 1;
table->field[6]->store(definer, defiler_len, cs);
if (tables->view_suid)
table->field[7]->store(STRING_WITH_LEN("DEFINER"), cs);
else
table->field[7]->store(STRING_WITH_LEN("INVOKER"), cs);
DBUG_RETURN(schema_table_store_record(thd, table)); DBUG_RETURN(schema_table_store_record(thd, table));
} }
} }
...@@ -3911,6 +3920,8 @@ ST_FIELD_INFO view_fields_info[]= ...@@ -3911,6 +3920,8 @@ ST_FIELD_INFO view_fields_info[]=
{"VIEW_DEFINITION", 65535, MYSQL_TYPE_STRING, 0, 0, 0}, {"VIEW_DEFINITION", 65535, MYSQL_TYPE_STRING, 0, 0, 0},
{"CHECK_OPTION", 8, MYSQL_TYPE_STRING, 0, 0, 0}, {"CHECK_OPTION", 8, MYSQL_TYPE_STRING, 0, 0, 0},
{"IS_UPDATABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0}, {"IS_UPDATABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0},
{"DEFINER", 77, MYSQL_TYPE_STRING, 0, 0, 0},
{"SECURITY_TYPE", 7, MYSQL_TYPE_STRING, 0, 0, 0},
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0} {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
}; };
......
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