summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2005-10-12 00:59:52 +0300
committerunknown <monty@mysql.com>2005-10-12 00:59:52 +0300
commit706157f025c8bfe01faa3783a54eecb8884b0d3f (patch)
tree7613691c50c9b918d5dbcb5683e2672e06db2a71 /sql/sql_parse.cc
parent4857e205a3fbe7d533af70028adf7ee8868a174e (diff)
parent0ce12f70ed2eee1b92e2af27e7dda30db544f492 (diff)
downloadmariadb-git-706157f025c8bfe01faa3783a54eecb8884b0d3f.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/my/mysql-5.0 mysql-test/r/view.result: Auto merged mysql-test/t/view.test: Auto merged server-tools/instance-manager/instance.cc: Auto merged sql/ha_ndbcluster.cc: Auto merged sql/handler.cc: Auto merged sql/item.cc: Auto merged sql/slave.cc: Auto merged sql/sp_head.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_manager.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_show.cc: Auto merged sql/table.cc: Auto merged sql/unireg.cc: Auto merged
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc41
1 files changed, 22 insertions, 19 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 88718f6c8c9..3c8920429c7 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -4524,7 +4524,8 @@ end_with_restore_list:
command[thd->lex->create_view_mode].length);
view_store_options(thd, first_table, &buff);
buff.append("VIEW ", 5);
- if (!first_table->current_db_used)
+ /* Test if user supplied a db (ie: we did not use thd->db) */
+ if (first_table->db != thd->db && first_table->db[0])
{
append_identifier(thd, &buff, first_table->db,
first_table->db_length);
@@ -4842,7 +4843,6 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
bool db_is_pattern= test(want_access & GRANT_ACL);
#endif
ulong dummy;
- const char *db_name;
DBUG_ENTER("check_access");
DBUG_PRINT("enter",("db: %s want_access: %lu master_access: %lu",
db ? db : "", want_access, sctx->master_access));
@@ -4860,15 +4860,16 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
DBUG_RETURN(TRUE); /* purecov: tested */
}
- db_name= db ? db : thd->db;
if (schema_db)
{
if (want_access & ~(SELECT_ACL | EXTRA_ACL))
{
if (!no_errors)
+ {
+ const char *db_name= db ? db : thd->db;
my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
- sctx->priv_user,
- sctx->priv_host, db_name);
+ sctx->priv_user, sctx->priv_host, db_name);
+ }
DBUG_RETURN(TRUE);
}
else
@@ -5043,11 +5044,16 @@ check_routine_access(THD *thd, ulong want_access,char *db, char *name,
tables->db= db;
tables->table_name= tables->alias= name;
- if ((thd->security_ctx->master_access & want_access) == want_access &&
- !thd->db)
+ /*
+ The following test is just a shortcut for check_access() (to avoid
+ calculating db_access) under the assumption that it's common to
+ give persons global right to execute all stored SP (but not
+ necessary to create them).
+ */
+ if ((thd->security_ctx->master_access & want_access) == want_access)
tables->grant.privilege= want_access;
else if (check_access(thd,want_access,db,&tables->grant.privilege,
- 0, no_errors, test(tables->schema_table)))
+ 0, no_errors, 0))
return TRUE;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
@@ -6134,14 +6140,12 @@ 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);
@@ -7390,9 +7394,9 @@ Item *negate_expression(THD *thd, Item *expr)
Assign as view definer current user
SYNOPSIS
- default_definer()
- Secytity_context current decurity context
- definer structure where it should be assigned
+ default_view_definer()
+ sctx current security context
+ definer structure where it should be assigned
RETURN
FALSE OK
@@ -7403,15 +7407,14 @@ bool default_view_definer(Security_context *sctx, st_lex_user *definer)
{
definer->user.str= sctx->priv_user;
definer->user.length= strlen(sctx->priv_user);
- if (*sctx->priv_host != 0)
- {
- definer->host.str= sctx->priv_host;
- definer->host.length= strlen(sctx->priv_host);
- }
- else
+
+ if (!*sctx->priv_host)
{
my_error(ER_NO_VIEW_USER, MYF(0));
return TRUE;
}
+
+ definer->host.str= sctx->priv_host;
+ definer->host.length= strlen(sctx->priv_host);
return FALSE;
}