1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

part 1 (ver 2, postreview fix) of WL#2787

view definer information syntax/storage/replication
fixed SOURCE field of .frm


mysql-test/r/func_in.result:
  definer information added to CREATE VIEW
mysql-test/r/lowercase_view.result:
  definer information added to CREATE VIEW
mysql-test/r/mysqldump.result:
  definer information added to CREATE VIEW
mysql-test/r/rpl_view.result:
  check log of queries
mysql-test/r/skip_grants.result:
  --skip-grants do not allow use user information
mysql-test/r/sql_mode.result:
  definer information added to CREATE VIEW
mysql-test/r/temp_table.result:
  definer information added to CREATE VIEW
mysql-test/r/view.result:
  definer information added to CREATE VIEW
  test of storing/restoring definer information
mysql-test/r/view_grant.result:
  test of grant check of definer information
  definer information added to CREATE VIEW
mysql-test/t/rpl_view.test:
  check log of queries
mysql-test/t/skip_grants.test:
  --skip-grants do not allow use user information
mysql-test/t/view.test:
  test of storing/restoring definer information
mysql-test/t/view_grant.test:
  test of grant check of definer information
sql/mysql_priv.h:
  CREATE/ALTER VIEW print support
  set current user as definer procedure
sql/share/errmsg.txt:
  new errors/warnings
sql/sql_acl.cc:
  make find_acl_user public to allow to check user
sql/sql_acl.h:
  make find_acl_user public to allow to check user
sql/sql_lex.h:
  storing definer information
sql/sql_parse.cc:
  send CREATE/ALTER VIEW for replication with full list of options
  set current user as definer procedure
sql/sql_show.cc:
  new CREATE VIEW options printed
sql/sql_view.cc:
  check of definer clause
  changes in .frm file
  definer information storage support
  now we store only original SELECT in SOURCE field of .frm
sql/sql_yacc.yy:
  definer information sintax support
  getting SOURCE field information for .frm
sql/table.h:
  definer information storage
This commit is contained in:
unknown
2005-09-14 10:53:09 +03:00
parent 49be919a89
commit f7aeb6f9fd
23 changed files with 369 additions and 78 deletions

View File

@ -4451,8 +4451,29 @@ end_with_restore_list:
if (!(res= mysql_create_view(thd, thd->lex->create_view_mode)) &&
mysql_bin_log.is_open())
{
String buff;
LEX_STRING command[3]=
{{STRING_WITH_LEN("CREATE ")},
{STRING_WITH_LEN("ALTER ")},
{STRING_WITH_LEN("CREATE OR REPLACE ")}};
thd->clear_error();
Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE);
buff.append(command[thd->lex->create_view_mode].str,
command[thd->lex->create_view_mode].length);
view_store_options(thd, first_table, &buff);
buff.append("VIEW ", 5);
if (!first_table->current_db_used)
{
append_identifier(thd, &buff, first_table->db,
first_table->db_length);
buff.append('.');
}
append_identifier(thd, &buff, first_table->table_name,
first_table->table_name_length);
buff.append(" AS ", 4);
buff.append(first_table->source.str, first_table->source.length);
Query_log_event qinfo(thd, buff.ptr(), buff.length(), 0, FALSE);
mysql_bin_log.write(&qinfo);
}
break;
@ -6009,12 +6030,14 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
{
ptr->db= thd->db;
ptr->db_length= thd->db_length;
ptr->current_db_used= 1;
}
else
{
/* The following can't be "" as we may do 'casedn_str()' on it */
ptr->db= empty_c_string;
ptr->db_length= 0;
ptr->current_db_used= 1;
}
if (thd->stmt_arena->is_stmt_prepare_or_first_sp_execute())
ptr->db= thd->strdup(ptr->db);
@ -7294,3 +7317,34 @@ Item *negate_expression(THD *thd, Item *expr)
return negated;
return new Item_func_not(expr);
}
/*
Assign as view definer current user
SYNOPSIS
default_definer()
thd thread handler
definer structure where it should be assigned
RETURN
FALSE OK
TRUE Error
*/
bool default_view_definer(THD *thd, st_lex_user *definer)
{
definer->user.str= thd->priv_user;
definer->user.length= strlen(thd->priv_user);
if (*thd->priv_host != 0)
{
definer->host.str= thd->priv_host;
definer->host.length= strlen(thd->priv_host);
}
else
{
my_error(ER_NO_VIEW_USER, MYF(0));
return TRUE;
}
return FALSE;
}