summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <evgen@sunlight.local>2006-08-01 06:42:33 +0400
committerunknown <evgen@sunlight.local>2006-08-01 06:42:33 +0400
commitb91f3bace1bd875e4e0ca5220dc0ea1093cbe6f4 (patch)
treed3aa90ab29cf41c357155a0e0def4163110eb01d /sql
parent45871dbfd907cd0f0e68d4c73bbb1e96b4d0eb22 (diff)
parent4acf6de89b0a0aca6137c361e116d5f58e86814e (diff)
downloadmariadb-git-b91f3bace1bd875e4e0ca5220dc0ea1093cbe6f4.tar.gz
Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into sunlight.local:/local_work/tmp_merge-5.0-opt-mysql
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_lex.h2
-rw-r--r--sql/sql_view.cc56
-rw-r--r--sql/sql_yacc.yy6
-rw-r--r--sql/table.h4
4 files changed, 64 insertions, 4 deletions
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index e5b087fc72a..897f6c25190 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -978,7 +978,7 @@ typedef struct st_lex : public Query_tables_list
/*
view created to be run from definer (standard behaviour)
*/
- bool create_view_suid;
+ uint8 create_view_suid;
/* Characterstics of trigger being created */
st_trg_chistics trg_chistics;
/*
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 1561ade78af..8aa93a7bbeb 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -155,6 +155,54 @@ err:
DBUG_RETURN(TRUE);
}
+/*
+ Fill defined view parts
+
+ SYNOPSIS
+ fill_defined_view_parts()
+ thd current thread.
+ view view to operate on
+
+ DESCRIPTION
+ This function will initialize the parts of the view
+ definition that are not specified in ALTER VIEW
+ to their values from CREATE VIEW.
+ The view must be opened to get its definition.
+ We use a copy of the view when opening because we want
+ to preserve the original view instance.
+
+ RETURN VALUE
+ TRUE can't open table
+ FALSE success
+*/
+static bool
+fill_defined_view_parts (THD *thd, TABLE_LIST *view)
+{
+ LEX *lex= thd->lex;
+ bool not_used;
+ TABLE_LIST decoy;
+
+ memcpy (&decoy, view, sizeof (TABLE_LIST));
+ if (!open_table(thd, &decoy, thd->mem_root, &not_used, 0) &&
+ !decoy.view)
+ {
+ return TRUE;
+ }
+ if (!lex->definer)
+ {
+ view->definer.host= decoy.definer.host;
+ view->definer.user= decoy.definer.user;
+ lex->definer= &view->definer;
+ }
+ if (lex->create_view_algorithm == VIEW_ALGORITHM_UNDEFINED)
+ lex->create_view_algorithm= decoy.algorithm;
+ if (lex->create_view_suid == VIEW_SUID_DEFAULT)
+ lex->create_view_suid= decoy.view_suid ?
+ VIEW_SUID_DEFINER : VIEW_SUID_INVOKER;
+
+ return FALSE;
+}
+
/*
Creating/altering VIEW procedure
@@ -207,7 +255,15 @@ bool mysql_create_view(THD *thd,
}
if (mode != VIEW_CREATE_NEW)
+ {
+ if (mode == VIEW_ALTER &&
+ fill_defined_view_parts(thd, view))
+ {
+ res= TRUE;
+ goto err;
+ }
sp_cache_invalidate();
+ }
if (!lex->definer)
{
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 425945f525e..677c327be3e 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -8997,11 +8997,11 @@ view_algorithm_opt:
view_suid:
/* empty */
- { Lex->create_view_suid= TRUE; }
+ { Lex->create_view_suid= VIEW_SUID_DEFAULT; }
| SQL_SYM SECURITY_SYM DEFINER_SYM
- { Lex->create_view_suid= TRUE; }
+ { Lex->create_view_suid= VIEW_SUID_DEFINER; }
| SQL_SYM SECURITY_SYM INVOKER_SYM
- { Lex->create_view_suid= FALSE; }
+ { Lex->create_view_suid= VIEW_SUID_INVOKER; }
;
view_tail:
diff --git a/sql/table.h b/sql/table.h
index eb34867c390..675439e3662 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -360,6 +360,10 @@ typedef struct st_schema_table
#define VIEW_ALGORITHM_TMPTABLE 1
#define VIEW_ALGORITHM_MERGE 2
+#define VIEW_SUID_INVOKER 0
+#define VIEW_SUID_DEFINER 1
+#define VIEW_SUID_DEFAULT 2
+
/* view WITH CHECK OPTION parameter options */
#define VIEW_CHECK_NONE 0
#define VIEW_CHECK_LOCAL 1