summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2005-09-14 11:07:04 +0300
committerunknown <bell@sanja.is.com.ua>2005-09-14 11:07:04 +0300
commitd0a78e6fa6f7ac5cbe16fa7680aa532af3d80e8e (patch)
treefce4b18c473720fa7cbd61bd4bf4ac04214f27be /sql/sql_parse.cc
parenta8d4bfd168ab0e4d2fe545f1719e063e64196fcf (diff)
parentf7aeb6f9fd473d856585ffa068064067f02cbd94 (diff)
downloadmariadb-git-d0a78e6fa6f7ac5cbe16fa7680aa532af3d80e8e.tar.gz
Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-5.0
into sanja.is.com.ua:/home/bell/mysql/bk/work-owner2-5.0 sql/sql_acl.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.h: Auto merged mysql-test/r/func_in.result: merge mysql-test/r/lowercase_view.result: merge mysql-test/r/mysqldump.result: merge mysql-test/r/sql_mode.result: merge mysql-test/r/temp_table.result: merge mysql-test/r/view.result: merge mysql-test/t/view.test: merge
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc56
1 files changed, 55 insertions, 1 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index b7428939e6f..c6bd9649774 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -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);
@@ -7297,3 +7320,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;
+}