summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2004-10-28 11:02:48 +0300
committerunknown <bell@sanja.is.com.ua>2004-10-28 11:02:48 +0300
commit46ce3d00921491398d2e9a00c2b03e67540dee23 (patch)
tree70b19d638c9beac263179291143f76c5af8757f4 /sql
parent93678f6bd9be1d320a63ae3fcf24493dae065ae7 (diff)
parentf41bba8c6156a7adf4c67dfa75e16112767a5d3c (diff)
downloadmariadb-git-46ce3d00921491398d2e9a00c2b03e67540dee23.tar.gz
merge
mysql-test/r/sp-security.result: Auto merged mysql-test/r/sp.result: Auto merged mysql-test/t/sp-security.test: Auto merged mysql-test/t/sp.test: Auto merged sql/log_event.cc: Auto merged sql/set_var.cc: Auto merged sql/sp.cc: Auto merged sql/sp_rcontext.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_load.cc: Auto merged sql/sql_yacc.yy: Auto merged
Diffstat (limited to 'sql')
-rw-r--r--sql/handler.cc10
-rw-r--r--sql/item_cmpfunc.h2
-rw-r--r--sql/item_strfunc.h2
-rw-r--r--sql/log_event.cc2
-rw-r--r--sql/mysql_priv.h7
-rw-r--r--sql/opt_range.cc4
-rw-r--r--sql/set_var.cc2
-rw-r--r--sql/share/czech/errmsg.txt1
-rw-r--r--sql/share/danish/errmsg.txt1
-rw-r--r--sql/share/dutch/errmsg.txt1
-rw-r--r--sql/share/english/errmsg.txt1
-rw-r--r--sql/share/estonian/errmsg.txt1
-rw-r--r--sql/share/french/errmsg.txt1
-rw-r--r--sql/share/german/errmsg.txt1
-rw-r--r--sql/share/greek/errmsg.txt1
-rw-r--r--sql/share/hungarian/errmsg.txt1
-rw-r--r--sql/share/italian/errmsg.txt1
-rw-r--r--sql/share/japanese/errmsg.txt1
-rw-r--r--sql/share/korean/errmsg.txt1
-rw-r--r--sql/share/norwegian-ny/errmsg.txt1
-rw-r--r--sql/share/norwegian/errmsg.txt1
-rw-r--r--sql/share/polish/errmsg.txt1
-rw-r--r--sql/share/portuguese/errmsg.txt1
-rw-r--r--sql/share/romanian/errmsg.txt1
-rw-r--r--sql/share/russian/errmsg.txt1
-rw-r--r--sql/share/serbian/errmsg.txt1
-rw-r--r--sql/share/slovak/errmsg.txt1
-rw-r--r--sql/share/spanish/errmsg.txt1
-rw-r--r--sql/share/swedish/errmsg.txt1
-rw-r--r--sql/share/ukrainian/errmsg.txt1
-rw-r--r--sql/sp.cc24
-rw-r--r--sql/sp.h8
-rw-r--r--sql/sp_rcontext.cc39
-rw-r--r--sql/sp_rcontext.h2
-rw-r--r--sql/sql_base.cc4
-rw-r--r--sql/sql_insert.cc19
-rw-r--r--sql/sql_lex.cc1
-rw-r--r--sql/sql_load.cc65
-rw-r--r--sql/sql_parse.cc111
-rw-r--r--sql/sql_yacc.yy20
-rw-r--r--sql/table.cc29
-rw-r--r--sql/table.h2
42 files changed, 242 insertions, 134 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index e74103489eb..5185e7f8921 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -1004,12 +1004,12 @@ next_insert_id(ulonglong nr,struct system_variables *variables)
The next row will be given the id
next_insert_id(next_insert_id)
- The idea is the generated auto_increment values are predicatable and
+ The idea is that generated auto_increment values are predictable and
independent of the column values in the table. This is needed to be
- able to replicate into a table that alread has rows with a higher
+ able to replicate into a table that already has rows with a higher
auto-increment value than the one that is inserted.
- After we have already generated an auto-increment number and the users
+ After we have already generated an auto-increment number and the user
inserts a column with a higher value than the last used one, we will
start counting from the inserted value.
@@ -1035,7 +1035,7 @@ void handler::update_auto_increment()
{
/* Clear flag for next row */
table->auto_increment_field_not_null= FALSE;
- /* Mark that we didn't generated a new value **/
+ /* Mark that we didn't generate a new value **/
auto_increment_column_changed=0;
/* Update next_insert_id if we have already generated a value */
@@ -1076,7 +1076,7 @@ void handler::update_auto_increment()
/*
We can't set next_insert_id if the auto-increment key is not the
- first key part, as there is no gurantee that the first parts will be in
+ first key part, as there is no guarantee that the first parts will be in
sequence
*/
if (!table->next_number_key_offset)
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index a8382df20f5..8d52459c0e5 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -1081,7 +1081,7 @@ public:
{ return fields.head()->collation.collation; }
};
-class COND_EQUAL
+class COND_EQUAL: public Sql_alloc
{
public:
uint max_members; /* max number of members the current level
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 357ce0af45a..49429a55cac 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -218,7 +218,7 @@ public:
Item_func_substr_index(Item *a,Item *b,Item *c) :Item_str_func(a,b,c) {}
String *val_str(String *);
void fix_length_and_dec();
- const char *func_name() const { return "substr_index"; }
+ const char *func_name() const { return "substring_index"; }
};
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 9c9e600edf0..6ac08ffb347 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -2548,7 +2548,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
thd->net.pkt_nr = net->pkt_nr;
}
if (mysql_load(thd, &ex, &tables, field_list, handle_dup, net != 0,
- TL_WRITE))
+ TL_WRITE, 0))
thd->query_error = 1;
if (thd->cuted_fields)
{
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 0031f6989b0..a8ca32f3d7e 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -838,9 +838,10 @@ inline TABLE_LIST *find_table_in_local_list(TABLE_LIST *table,
bool eval_const_cond(COND *cond);
/* sql_load.cc */
-bool mysql_load(THD *thd,sql_exchange *ex, TABLE_LIST *table_list,
- List<Item> &fields, enum enum_duplicates handle_duplicates,
- bool local_file,thr_lock_type lock_type);
+bool mysql_load(THD *thd, sql_exchange *ex, TABLE_LIST *table_list,
+ List<Item> &fields, enum enum_duplicates handle_duplicates,
+ bool local_file, thr_lock_type lock_type,
+ bool ignore_check_option_errors);
int write_record(THD *thd, TABLE *table, COPY_INFO *info);
/* sql_manager.cc */
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index a4b4944eab6..683bf1bdc13 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -7564,6 +7564,8 @@ int QUICK_GROUP_MIN_MAX_SELECT::init()
else
max_functions_it= NULL;
}
+ else
+ min_max_ranges.elements= 0;
return 0;
}
@@ -7656,7 +7658,7 @@ void QUICK_GROUP_MIN_MAX_SELECT::update_key_stat()
max_used_key_length= real_prefix_len;
if (min_max_ranges.elements > 0)
{
- QUICK_RANGE *cur_range;
+ QUICK_RANGE *cur_range= 0;
if (have_min)
{ /* Check if the right-most range has a lower boundary. */
get_dynamic(&min_max_ranges, (gptr)&cur_range,
diff --git a/sql/set_var.cc b/sql/set_var.cc
index e08a65c793a..8195792419e 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -632,7 +632,7 @@ sys_var *sys_variables[]=
*/
struct show_var_st init_vars[]= {
- {"auto_incrememt_increment", (char*) &sys_auto_increment_increment, SHOW_SYS},
+ {"auto_increment_increment", (char*) &sys_auto_increment_increment, SHOW_SYS},
{"auto_increment_offset", (char*) &sys_auto_increment_offset, SHOW_SYS},
{"back_log", (char*) &back_log, SHOW_LONG},
{"basedir", mysql_home, SHOW_CHAR},
diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt
index 3f5814df575..68816534d3a 100644
--- a/sql/share/czech/errmsg.txt
+++ b/sql/share/czech/errmsg.txt
@@ -398,6 +398,7 @@ character-set=latin2
"Illegal %s '%-.64s' value found during parsing",
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
+"Access denied; you are not the procedure/function definer of '%s'"
"Failed purging old relay logs: %s"
"Password hash should be a %d-digit hexadecimal number"
"Target log not found in binlog index"
diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt
index fa5d8f8a8c7..f475c9cd371 100644
--- a/sql/share/danish/errmsg.txt
+++ b/sql/share/danish/errmsg.txt
@@ -389,6 +389,7 @@ character-set=latin1
"Illegal %s '%-.64s' value found during parsing",
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
+"Access denied; you are not the procedure/function definer of '%s'"
"Failed purging old relay logs: %s"
"Password hash should be a %d-digit hexadecimal number"
"Target log not found in binlog index"
diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt
index 7dbd32c9db4..471997e8a22 100644
--- a/sql/share/dutch/errmsg.txt
+++ b/sql/share/dutch/errmsg.txt
@@ -398,6 +398,7 @@ character-set=latin1
"Illegal %s '%-.64s' value found during parsing",
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
+"Access denied; you are not the procedure/function definer of '%s'"
"Failed purging old relay logs: %s"
"Password hash should be a %d-digit hexadecimal number"
"Target log not found in binlog index"
diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt
index 8fe08ddc7a7..293227e64b9 100644
--- a/sql/share/english/errmsg.txt
+++ b/sql/share/english/errmsg.txt
@@ -386,6 +386,7 @@ character-set=latin1
"Illegal %s '%-.64s' value found during parsing",
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
+"Access denied; you are not the procedure/function definer of '%s'"
"Failed purging old relay logs: %s"
"Password hash should be a %d-digit hexadecimal number"
"Target log not found in binlog index"
diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt
index b52aa6154ec..59e55207946 100644
--- a/sql/share/estonian/errmsg.txt
+++ b/sql/share/estonian/errmsg.txt
@@ -391,6 +391,7 @@ character-set=latin7
"Illegal %s '%-.64s' value found during parsing",
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
+"Access denied; you are not the procedure/function definer of '%s'"
"Failed purging old relay logs: %s"
"Password hash should be a %d-digit hexadecimal number"
"Target log not found in binlog index"
diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt
index 43a77fdec42..be6c440b509 100644
--- a/sql/share/french/errmsg.txt
+++ b/sql/share/french/errmsg.txt
@@ -386,6 +386,7 @@ character-set=latin1
"Illegal %s '%-.64s' value found during parsing",
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
+"Access denied; you are not the procedure/function definer of '%s'"
"Failed purging old relay logs: %s"
"Password hash should be a %d-digit hexadecimal number"
"Target log not found in binlog index"
diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt
index 1b3a916c777..3afdd3ab496 100644
--- a/sql/share/german/errmsg.txt
+++ b/sql/share/german/errmsg.txt
@@ -399,6 +399,7 @@ character-set=latin1
"Illegal %s '%-.64s' value found during parsing",
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
+"Access denied; you are not the procedure/function definer of '%s'"
"Failed purging old relay logs: %s"
"Password hash should be a %d-digit hexadecimal number"
"Target log not found in binlog index"
diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt
index baf88d7fead..b0b158f5851 100644
--- a/sql/share/greek/errmsg.txt
+++ b/sql/share/greek/errmsg.txt
@@ -386,6 +386,7 @@ character-set=greek
"Illegal %s '%-.64s' value found during parsing",
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
+"Access denied; you are not the procedure/function definer of '%s'"
"Failed purging old relay logs: %s"
"Password hash should be a %d-digit hexadecimal number"
"Target log not found in binlog index"
diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt
index 2c1efa97e30..ba5f662a196 100644
--- a/sql/share/hungarian/errmsg.txt
+++ b/sql/share/hungarian/errmsg.txt
@@ -391,6 +391,7 @@ character-set=latin2
"Illegal %s '%-.64s' value found during parsing",
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
+"Access denied; you are not the procedure/function definer of '%s'"
"Failed purging old relay logs: %s"
"Password hash should be a %d-digit hexadecimal number"
"Target log not found in binlog index"
diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt
index 5859e5380ef..d7ce95f8ed3 100644
--- a/sql/share/italian/errmsg.txt
+++ b/sql/share/italian/errmsg.txt
@@ -386,6 +386,7 @@ character-set=latin1
"Illegal %s '%-.64s' value found during parsing",
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
+"Access denied; you are not the procedure/function definer of '%s'"
"Failed purging old relay logs: %s"
"Password hash should be a %d-digit hexadecimal number"
"Target log not found in binlog index"
diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt
index c58acde49cd..56df55f3db4 100644
--- a/sql/share/japanese/errmsg.txt
+++ b/sql/share/japanese/errmsg.txt
@@ -390,6 +390,7 @@ character-set=ujis
"Illegal %s '%-.64s' value found during parsing",
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
+"Access denied; you are not the procedure/function definer of '%s'"
"Failed purging old relay logs: %s"
"Password hash should be a %d-digit hexadecimal number"
"Target log not found in binlog index"
diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt
index 74e42b09fc7..1672dcb7dc6 100644
--- a/sql/share/korean/errmsg.txt
+++ b/sql/share/korean/errmsg.txt
@@ -386,6 +386,7 @@ character-set=euckr
"Illegal %s '%-.64s' value found during parsing",
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
+"Access denied; you are not the procedure/function definer of '%s'"
"Failed purging old relay logs: %s"
"Password hash should be a %d-digit hexadecimal number"
"Target log not found in binlog index"
diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt
index 1bce2767784..187bab28cf1 100644
--- a/sql/share/norwegian-ny/errmsg.txt
+++ b/sql/share/norwegian-ny/errmsg.txt
@@ -388,6 +388,7 @@ character-set=latin1
"Illegal %s '%-.64s' value found during parsing",
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
+"Access denied; you are not the procedure/function definer of '%s'"
"Failed purging old relay logs: %s"
"Password hash should be a %d-digit hexadecimal number"
"Target log not found in binlog index"
diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt
index c09aa257ead..ba1d11aa158 100644
--- a/sql/share/norwegian/errmsg.txt
+++ b/sql/share/norwegian/errmsg.txt
@@ -388,6 +388,7 @@ character-set=latin1
"Illegal %s '%-.64s' value found during parsing",
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
+"Access denied; you are not the procedure/function definer of '%s'"
"Failed purging old relay logs: %s"
"Password hash should be a %d-digit hexadecimal number"
"Target log not found in binlog index"
diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt
index 96985de759d..9d9940ca69d 100644
--- a/sql/share/polish/errmsg.txt
+++ b/sql/share/polish/errmsg.txt
@@ -391,6 +391,7 @@ character-set=latin2
"Illegal %s '%-.64s' value found during parsing",
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
+"Access denied; you are not the procedure/function definer of '%s'"
"Failed purging old relay logs: %s"
"Password hash should be a %d-digit hexadecimal number"
"Target log not found in binlog index"
diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt
index c9dac302f5e..214b4753f1c 100644
--- a/sql/share/portuguese/errmsg.txt
+++ b/sql/share/portuguese/errmsg.txt
@@ -388,6 +388,7 @@ character-set=latin1
"Illegal %s '%-.64s' value found during parsing",
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
+"Access denied; you are not the procedure/function definer of '%s'"
"Failed purging old relay logs: %s"
"Password hash should be a %d-digit hexadecimal number"
"Target log not found in binlog index"
diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt
index 25c06397d7c..2019bcc98f5 100644
--- a/sql/share/romanian/errmsg.txt
+++ b/sql/share/romanian/errmsg.txt
@@ -391,6 +391,7 @@ character-set=latin2
"Illegal %s '%-.64s' value found during parsing",
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
+"Access denied; you are not the procedure/function definer of '%s'"
"Failed purging old relay logs: %s"
"Password hash should be a %d-digit hexadecimal number"
"Target log not found in binlog index"
diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt
index 71b21268dba..3354d6a7ee5 100644
--- a/sql/share/russian/errmsg.txt
+++ b/sql/share/russian/errmsg.txt
@@ -391,6 +391,7 @@ character-set=koi8r
"Illegal %s '%-.64s' value found during parsing",
"CHECK OPTION ��� �������������� VIEW '%-.64s.%-.64s'"
"�������� CHECK OPTION ��� VIEW '%-.64s.%-.64s' �����������"
+"Access denied; you are not the procedure/function definer of '%s'"
"Failed purging old relay logs: %s"
"Password hash should be a %d-digit hexadecimal number"
"Target log not found in binlog index"
diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt
index 4228f3a3a4e..385f6f2044c 100644
--- a/sql/share/serbian/errmsg.txt
+++ b/sql/share/serbian/errmsg.txt
@@ -379,6 +379,7 @@ character-set=cp1250
"Illegal %s '%-.64s' value found during parsing",
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
+"Access denied; you are not the procedure/function definer of '%s'"
"Failed purging old relay logs: %s"
"Password hash should be a %d-digit hexadecimal number"
"Target log not found in binlog index"
diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt
index 9b9508eeca9..8ee06be1128 100644
--- a/sql/share/slovak/errmsg.txt
+++ b/sql/share/slovak/errmsg.txt
@@ -394,6 +394,7 @@ character-set=latin2
"Illegal %s '%-.64s' value found during parsing",
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
+"Access denied; you are not the procedure/function definer of '%s'"
"Failed purging old relay logs: %s"
"Password hash should be a %d-digit hexadecimal number"
"Target log not found in binlog index"
diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt
index 5af6d647fd3..2215da6d57e 100644
--- a/sql/share/spanish/errmsg.txt
+++ b/sql/share/spanish/errmsg.txt
@@ -390,6 +390,7 @@ character-set=latin1
"Illegal %s '%-.64s' value found during parsing",
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
+"Access denied; you are not the procedure/function definer of '%s'"
"Failed purging old relay logs: %s"
"Password hash should be a %d-digit hexadecimal number"
"Target log not found in binlog index"
diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt
index 85866007367..92ef9e1659b 100644
--- a/sql/share/swedish/errmsg.txt
+++ b/sql/share/swedish/errmsg.txt
@@ -386,6 +386,7 @@ character-set=latin1
"Illegal %s '%-.64s' value found during parsing",
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
+"Access denied; you are not the procedure/function definer of '%s'"
"Failed purging old relay logs: %s"
"Password hash should be a %d-digit hexadecimal number"
"Target log not found in binlog index"
diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt
index 4bb3a6a1aab..c1f86886870 100644
--- a/sql/share/ukrainian/errmsg.txt
+++ b/sql/share/ukrainian/errmsg.txt
@@ -392,6 +392,7 @@ character-set=koi8u
"Illegal %s '%-.64s' value found during parsing",
"CHECK OPTION ��� VIEW '%-.64s.%-.64s' �� �� ���� ���� ����������"
"����צ��� CHECK OPTION ��� VIEW '%-.64s.%-.64s' �� �������"
+"Access denied; you are not the procedure/function definer of '%s'"
"Failed purging old relay logs: %s"
"Password hash should be a %d-digit hexadecimal number"
"Target log not found in binlog index"
diff --git a/sql/sp.cc b/sql/sp.cc
index 52d8b33bd9c..db03900f44a 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -442,9 +442,7 @@ db_drop_routine(THD *thd, int type, sp_name *name)
static int
-db_update_routine(THD *thd, int type, sp_name *name,
- char *newname, uint newnamelen,
- st_sp_chistics *chistics)
+db_update_routine(THD *thd, int type, sp_name *name, st_sp_chistics *chistics)
{
TABLE *table;
int ret;
@@ -462,10 +460,6 @@ db_update_routine(THD *thd, int type, sp_name *name,
if (chistics->suid != SP_IS_DEFAULT_SUID)
table->field[MYSQL_PROC_FIELD_SECURITY_TYPE]->
store((longlong)chistics->suid);
- if (newname)
- table->field[MYSQL_PROC_FIELD_NAME]->store(newname,
- newnamelen,
- system_charset_info);
if (chistics->daccess != SP_DEFAULT_ACCESS)
table->field[MYSQL_PROC_FIELD_ACCESS]->
store((longlong)chistics->daccess);
@@ -772,9 +766,7 @@ sp_drop_procedure(THD *thd, sp_name *name)
int
-sp_update_procedure(THD *thd, sp_name *name,
- char *newname, uint newnamelen,
- st_sp_chistics *chistics)
+sp_update_procedure(THD *thd, sp_name *name, st_sp_chistics *chistics)
{
int ret;
bool found;
@@ -782,8 +774,7 @@ sp_update_procedure(THD *thd, sp_name *name,
DBUG_PRINT("enter", ("name: %*s", name->m_name.length, name->m_name.str));
found= sp_cache_remove(&thd->sp_proc_cache, name);
- ret= db_update_routine(thd, TYPE_ENUM_PROCEDURE, name,
- newname, newnamelen, chistics);
+ ret= db_update_routine(thd, TYPE_ENUM_PROCEDURE, name, chistics);
if (!found && !ret)
sp_cache_invalidate();
DBUG_RETURN(ret);
@@ -870,9 +861,7 @@ sp_drop_function(THD *thd, sp_name *name)
int
-sp_update_function(THD *thd, sp_name *name,
- char *newname, uint newnamelen,
- st_sp_chistics *chistics)
+sp_update_function(THD *thd, sp_name *name, st_sp_chistics *chistics)
{
int ret;
bool found;
@@ -880,8 +869,7 @@ sp_update_function(THD *thd, sp_name *name,
DBUG_PRINT("enter", ("name: %*s", name->m_name.length, name->m_name.str));
found= sp_cache_remove(&thd->sp_func_cache, name);
- ret= db_update_routine(thd, TYPE_ENUM_FUNCTION, name,
- newname, newnamelen, chistics);
+ ret= db_update_routine(thd, TYPE_ENUM_FUNCTION, name, chistics);
if (!found && !ret)
sp_cache_invalidate();
DBUG_RETURN(ret);
@@ -1002,12 +990,12 @@ sp_cache_functions(THD *thd, LEX *lex)
if (db_find_routine(thd, TYPE_ENUM_FUNCTION, &name, &sp)
== SP_OK)
{
+ sp_cache_insert(&thd->sp_func_cache, sp);
ret= sp_cache_functions(thd, newlex);
delete newlex;
thd->lex= oldlex;
if (ret)
break;
- sp_cache_insert(&thd->sp_func_cache, sp);
}
else
{
diff --git a/sql/sp.h b/sql/sp.h
index 783de2fe7ee..acdfe824b97 100644
--- a/sql/sp.h
+++ b/sql/sp.h
@@ -44,9 +44,7 @@ sp_drop_procedure(THD *thd, sp_name *name);
int
-sp_update_procedure(THD *thd, sp_name *name,
- char *newname, uint newnamelen,
- st_sp_chistics *chistics);
+sp_update_procedure(THD *thd, sp_name *name, st_sp_chistics *chistics);
int
sp_show_create_procedure(THD *thd, sp_name *name);
@@ -64,9 +62,7 @@ int
sp_drop_function(THD *thd, sp_name *name);
int
-sp_update_function(THD *thd, sp_name *name,
- char *newname, uint newnamelen,
- st_sp_chistics *chistics);
+sp_update_function(THD *thd, sp_name *name, st_sp_chistics *chistics);
int
sp_show_create_function(THD *thd, sp_name *name);
diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc
index 3f9ab39e358..db298974c45 100644
--- a/sql/sp_rcontext.cc
+++ b/sql/sp_rcontext.cc
@@ -56,7 +56,7 @@ sp_rcontext::set_item_eval(uint idx, Item *i, enum_field_types type)
}
}
-int
+bool
sp_rcontext::find_handler(uint sql_errno,
MYSQL_ERROR::enum_warning_level level)
{
@@ -66,9 +66,9 @@ sp_rcontext::find_handler(uint sql_errno,
return 1; // Already got one
const char *sqlstate= mysql_errno_to_sqlstate(sql_errno);
- int i= m_hcount, found= 0;
+ int i= m_hcount, found= -1;
- while (!found && i--)
+ while (i--)
{
sp_cond_type_t *cond= m_handler[i].cond;
@@ -76,31 +76,36 @@ sp_rcontext::find_handler(uint sql_errno,
{
case sp_cond_type_t::number:
if (sql_errno == cond->mysqlerr)
- found= 1;
+ found= i; // Always the most specific
break;
case sp_cond_type_t::state:
- if (strcmp(sqlstate, cond->sqlstate) == 0)
- found= 1;
+ if (strcmp(sqlstate, cond->sqlstate) == 0 &&
+ (found < 0 || m_handler[found].cond->type > sp_cond_type_t::number))
+ found= i;
break;
case sp_cond_type_t::warning:
- if (sqlstate[0] == '0' && sqlstate[1] == '1' ||
- level == MYSQL_ERROR::WARN_LEVEL_WARN)
- found= 1;
+ if ((sqlstate[0] == '0' && sqlstate[1] == '1' ||
+ level == MYSQL_ERROR::WARN_LEVEL_WARN) &&
+ (found < 0 || m_handler[found].cond->type > sp_cond_type_t::state))
+ found= i;
break;
case sp_cond_type_t::notfound:
- if (sqlstate[0] == '0' && sqlstate[1] == '2')
- found= 1;
+ if (sqlstate[0] == '0' && sqlstate[1] == '2' &&
+ (found < 0 || m_handler[found].cond->type > sp_cond_type_t::state))
+ found= i;
break;
case sp_cond_type_t::exception:
- if (sqlstate[0] != '0' || sqlstate[1] > '2' ||
- level == MYSQL_ERROR::WARN_LEVEL_ERROR)
- found= 1;
+ if ((sqlstate[0] != '0' || sqlstate[1] > '2' ||
+ level == MYSQL_ERROR::WARN_LEVEL_ERROR) &&
+ (found < 0 || m_handler[found].cond->type > sp_cond_type_t::state))
+ found= i;
break;
}
}
- if (found)
- m_hfound= i;
- return found;
+ if (found < 0)
+ return FALSE;
+ m_hfound= found;
+ return TRUE;
}
void
diff --git a/sql/sp_rcontext.h b/sql/sp_rcontext.h
index fff10ff3d0a..8e818ab76d1 100644
--- a/sql/sp_rcontext.h
+++ b/sql/sp_rcontext.h
@@ -122,7 +122,7 @@ class sp_rcontext : public Sql_alloc
}
// Returns 1 if a handler was found, 0 otherwise.
- int
+ bool
find_handler(uint sql_errno,MYSQL_ERROR::enum_warning_level level);
// Returns handler type and sets *ip to location if one was found
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 9a45660c45b..1f52c532737 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -2696,7 +2696,9 @@ bool setup_tables(THD *thd, TABLE_LIST *tables, Item **conds)
table->keys_in_use_for_query.subtract(map);
}
table->used_keys.intersect(table->keys_in_use_for_query);
- if (table_list->ancestor && table_list->setup_ancestor(thd, conds))
+ if (table_list->ancestor &&
+ table_list->setup_ancestor(thd, conds,
+ table_list->effective_with_check))
DBUG_RETURN(1);
}
if (tablenr > MAX_TABLES)
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 44a66095059..81f80378763 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -331,14 +331,6 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
break;
}
}
- if ((res= table_list->view_check_option(thd, ignore_err)) ==
- VIEW_CHECK_SKIP)
- continue;
- else if (res == VIEW_CHECK_ERROR)
- {
- error= 1;
- break;
- }
/*
FIXME: Actually we should do this before
@@ -348,6 +340,17 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
table->triggers->process_triggers(thd, TRG_EVENT_INSERT,
TRG_ACTION_BEFORE);
+ if ((res= table_list->view_check_option(thd,
+ (values_list.elements == 1 ?
+ 0 :
+ ignore_err))) ==
+ VIEW_CHECK_SKIP)
+ continue;
+ else if (res == VIEW_CHECK_ERROR)
+ {
+ error= 1;
+ break;
+ }
#ifndef EMBEDDED_LIBRARY
if (lock_type == TL_WRITE_DELAYED)
{
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 59dc1a7ee8b..73f99d0dd68 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1616,6 +1616,7 @@ bool st_lex::can_use_merged()
case SQLCOM_INSERT_SELECT:
case SQLCOM_REPLACE:
case SQLCOM_REPLACE_SELECT:
+ case SQLCOM_LOAD:
return TRUE;
default:
return FALSE;
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 353a3b2c83c..0be4d9ecdc1 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -71,16 +71,19 @@ public:
void set_io_cache_arg(void* arg) { cache.arg = arg; }
};
-static int read_fixed_length(THD *thd,COPY_INFO &info,TABLE *table,
+static int read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
List<Item> &fields, READ_INFO &read_info,
- ulong skip_lines);
-static int read_sep_field(THD *thd,COPY_INFO &info,TABLE *table,
+ ulong skip_lines,
+ bool ignore_check_option_errors);
+static int read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
List<Item> &fields, READ_INFO &read_info,
- String &enclosed, ulong skip_lines);
+ String &enclosed, ulong skip_lines,
+ bool ignore_check_option_errors);
bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
List<Item> &fields, enum enum_duplicates handle_duplicates,
- bool read_file_from_client,thr_lock_type lock_type)
+ bool read_file_from_client,thr_lock_type lock_type,
+ bool ignore_check_option_errors)
{
char name[FN_REFLEN];
File file;
@@ -88,6 +91,7 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
int error;
String *field_term=ex->field_term,*escaped=ex->escaped;
String *enclosed=ex->enclosed;
+ Item *unused_conds;
bool is_fifo=0;
#ifndef EMBEDDED_LIBRARY
LOAD_FILE_INFO lf_info;
@@ -117,8 +121,9 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
table_list->lock_type= lock_type;
if (open_and_lock_tables(thd, table_list))
DBUG_RETURN(TRUE);
- /* TODO: add key check when we will support VIEWs in LOAD */
- if (!table_list->updatable)
+ if (setup_tables(thd, table_list, &unused_conds))
+ DBUG_RETURN(-1);
+ if (!table_list->updatable || check_key_in_view(thd, table_list))
{
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "LOAD");
DBUG_RETURN(TRUE);
@@ -294,11 +299,12 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
MODE_STRICT_ALL_TABLES)));
if (!field_term->length() && !enclosed->length())
- error=read_fixed_length(thd,info,table,fields,read_info,
- skip_lines);
+ error= read_fixed_length(thd, info, table_list, fields,read_info,
+ skip_lines, ignore_check_option_errors);
else
- error=read_sep_field(thd,info,table,fields,read_info,*enclosed,
- skip_lines);
+ error= read_sep_field(thd, info, table_list, fields, read_info,
+ *enclosed, skip_lines,
+ ignore_check_option_errors);
if (table->file->end_bulk_insert())
error=1; /* purecov: inspected */
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
@@ -401,11 +407,13 @@ err:
****************************************************************************/
static int
-read_fixed_length(THD *thd,COPY_INFO &info,TABLE *table,List<Item> &fields,
- READ_INFO &read_info, ulong skip_lines)
+read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
+ List<Item> &fields, READ_INFO &read_info, ulong skip_lines,
+ bool ignore_check_option_errors)
{
List_iterator_fast<Item> it(fields);
Item_field *sql_field;
+ TABLE *table= table_list->table;
ulonglong id;
bool no_trans_update;
DBUG_ENTER("read_fixed_length");
@@ -472,6 +480,17 @@ read_fixed_length(THD *thd,COPY_INFO &info,TABLE *table,List<Item> &fields,
ER_WARN_TOO_MANY_RECORDS,
ER(ER_WARN_TOO_MANY_RECORDS), thd->row_count);
}
+
+ switch(table_list->view_check_option(thd,
+ ignore_check_option_errors))
+ {
+ case VIEW_CHECK_SKIP:
+ read_info.next_line();
+ goto continue_loop;
+ case VIEW_CHECK_ERROR:
+ DBUG_RETURN(-1);
+ }
+
if (thd->killed || write_record(thd,table,&info))
DBUG_RETURN(1);
thd->no_trans_update= no_trans_update;
@@ -496,6 +515,7 @@ read_fixed_length(THD *thd,COPY_INFO &info,TABLE *table,List<Item> &fields,
ER(ER_WARN_TOO_MANY_RECORDS), thd->row_count);
}
thd->row_count++;
+continue_loop:;
}
if (id && !read_info.error)
thd->insert_id(id); // For binary/update log
@@ -505,12 +525,14 @@ read_fixed_length(THD *thd,COPY_INFO &info,TABLE *table,List<Item> &fields,
static int
-read_sep_field(THD *thd,COPY_INFO &info,TABLE *table,
+read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
List<Item> &fields, READ_INFO &read_info,
- String &enclosed, ulong skip_lines)
+ String &enclosed, ulong skip_lines,
+ bool ignore_check_option_errors)
{
List_iterator_fast<Item> it(fields);
Item_field *sql_field;
+ TABLE *table= table_list->table;
uint enclosed_length;
ulonglong id;
bool no_trans_update;
@@ -580,6 +602,18 @@ read_sep_field(THD *thd,COPY_INFO &info,TABLE *table,
ER(ER_WARN_TOO_FEW_RECORDS), thd->row_count);
}
}
+
+ switch(table_list->view_check_option(thd,
+ ignore_check_option_errors))
+ {
+ case VIEW_CHECK_SKIP:
+ read_info.next_line();
+ goto continue_loop;
+ case VIEW_CHECK_ERROR:
+ DBUG_RETURN(-1);
+ }
+
+
if (thd->killed || write_record(thd, table, &info))
DBUG_RETURN(1);
/*
@@ -605,6 +639,7 @@ read_sep_field(THD *thd,COPY_INFO &info,TABLE *table,
DBUG_RETURN(1);
}
thd->row_count++;
+continue_loop:;
}
if (id && !read_info.error)
thd->insert_id(id); // For binary/update log
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index ed174162db8..316f5ebdf60 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -69,6 +69,7 @@ static void remove_escape(char *name);
static void refresh_status(void);
static bool append_file_to_dir(THD *thd, const char **filename_ptr,
const char *table_name);
+static bool check_sp_definer_access(THD *thd, sp_head *sp);
const char *any_db="*any*"; // Special symbol for check_access
@@ -3110,7 +3111,8 @@ create_error:
goto error;
}
res= mysql_load(thd, lex->exchange, first_table, lex->field_list,
- lex->duplicates, (bool) lex->local_file, lex->lock_option);
+ lex->duplicates, (bool) lex->local_file,
+ lex->lock_option, lex->duplicates == DUP_IGNORE);
break;
}
@@ -3722,21 +3724,27 @@ create_error:
case SQLCOM_ALTER_FUNCTION:
{
int result;
- uint newname_len= 0;
- if (lex->name)
- newname_len= strlen(lex->name);
- if (newname_len > NAME_LEN)
- {
- my_error(ER_TOO_LONG_IDENT, MYF(0), lex->name);
- goto error;
- }
+ sp_head *sp;
+ st_sp_chistics chistics;
+
+ memcpy(&chistics, &lex->sp_chistics, sizeof(chistics));
if (lex->sql_command == SQLCOM_ALTER_PROCEDURE)
- result= sp_update_procedure(thd, lex->spname,
- lex->name, newname_len, &lex->sp_chistics);
+ sp= sp_find_procedure(thd, lex->spname);
else
- result= sp_update_function(thd, lex->spname,
- lex->name, newname_len, &lex->sp_chistics);
- res= result;
+ sp= sp_find_function(thd, lex->spname);
+ mysql_reset_errors(thd);
+ if (! sp)
+ result= SP_KEY_NOT_FOUND;
+ else
+ {
+ if (check_sp_definer_access(thd, sp))
+ goto error;
+ memcpy(&lex->sp_chistics, &chistics, sizeof(lex->sp_chistics));
+ if (lex->sql_command == SQLCOM_ALTER_PROCEDURE)
+ result= sp_update_procedure(thd, lex->spname, &lex->sp_chistics);
+ else
+ result= sp_update_function(thd, lex->spname, &lex->sp_chistics);
+ }
switch (result)
{
case SP_OK:
@@ -3756,29 +3764,43 @@ create_error:
case SQLCOM_DROP_PROCEDURE:
case SQLCOM_DROP_FUNCTION:
{
+ sp_head *sp;
int result;
+
if (lex->sql_command == SQLCOM_DROP_PROCEDURE)
- result= sp_drop_procedure(thd, lex->spname);
+ sp= sp_find_procedure(thd, lex->spname);
+ else
+ sp= sp_find_function(thd, lex->spname);
+ mysql_reset_errors(thd);
+ if (! sp)
+ result= SP_KEY_NOT_FOUND;
else
{
- result= sp_drop_function(thd, lex->spname);
-#ifdef HAVE_DLOPEN
- if (result == SP_KEY_NOT_FOUND)
+ if (check_sp_definer_access(thd, sp))
+ goto error;
+ if (lex->sql_command == SQLCOM_DROP_PROCEDURE)
+ result= sp_drop_procedure(thd, lex->spname);
+ else
{
- udf_func *udf = find_udf(lex->spname->m_name.str,
- lex->spname->m_name.length);
- if (udf)
+ result= sp_drop_function(thd, lex->spname);
+#ifdef HAVE_DLOPEN
+ if (result == SP_KEY_NOT_FOUND)
{
- if (check_access(thd, DELETE_ACL, "mysql", 0, 1, 0))
- goto error;
- if (!(result = mysql_drop_function(thd,&lex->spname->m_name)))
+ udf_func *udf = find_udf(lex->spname->m_name.str,
+ lex->spname->m_name.length);
+ if (udf)
{
- send_ok(thd);
- break;
+ if (check_access(thd, DELETE_ACL, "mysql", 0, 1, 0))
+ goto error;
+ if (!(res = mysql_drop_function(thd,&lex->spname->m_name)))
+ {
+ send_ok(thd);
+ break;
+ }
}
}
- }
#endif
+ }
}
res= result;
switch (result)
@@ -4220,6 +4242,41 @@ static bool check_db_used(THD *thd,TABLE_LIST *tables)
return FALSE;
}
+
+/*
+ Check if the given SP is owned by thd->priv_user/host, or priv_user is root.
+ QQ This is not quite complete, but it will do as a basic security check
+ for now. The question is exactly which rights should 'root' have?
+ Should root have access regardless of host for instance?
+
+ SYNOPSIS
+ check_sp_definer_access()
+ thd Thread handler
+ sp The SP pointer
+
+ RETURN
+ 0 ok
+ 1 error Error message has been sent
+*/
+
+static bool
+check_sp_definer_access(THD *thd, sp_head *sp)
+{
+ LEX_STRING *usr, *hst;
+
+ if (strcmp("root", thd->priv_user) == 0)
+ return FALSE; /* QQ Any root is ok now */
+ usr= &sp->m_definer_user;
+ hst= &sp->m_definer_host;
+ if (strncmp(thd->priv_user, usr->str, usr->length) == 0 &&
+ strncmp(thd->priv_host, hst->str, hst->length) == 0)
+ return FALSE; /* Both user and host must match */
+
+ my_error(ER_SP_ACCESS_DENIED_ERROR, MYF(0), sp->m_qname.str);
+ return TRUE; /* Not definer or root */
+}
+
+
/****************************************************************************
Check stack size; Send error if there isn't enough stack to continue
****************************************************************************/
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 4509bb60aaa..bdeb5a7d98d 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -789,7 +789,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
opt_extended_describe
prepare prepare_src execute deallocate
statement sp_suid opt_view_list view_list or_replace algorithm
- sp_c_chistics sp_a_chistics sp_chistic sp_c_chistic sp_a_chistic
+ sp_c_chistics sp_a_chistics sp_chistic sp_c_chistic
END_OF_INPUT
%type <NONE> call sp_proc_stmts sp_proc_stmt
@@ -1371,7 +1371,7 @@ create_function_tail:
sp_a_chistics:
/* Empty */ {}
- | sp_a_chistics sp_a_chistic {}
+ | sp_a_chistics sp_chistic {}
;
sp_c_chistics:
@@ -1397,12 +1397,6 @@ sp_chistic:
{ }
;
-/* Alter characteristics */
-sp_a_chistic:
- sp_chistic { }
- | NAME_SYM ident { Lex->name= $2.str; }
- ;
-
/* Create characteristics */
sp_c_chistic:
sp_chistic { }
@@ -3197,7 +3191,6 @@ alter:
LEX *lex= Lex;
bzero((char *)&lex->sp_chistics, sizeof(st_sp_chistics));
- lex->name= 0;
}
sp_a_chistics
{
@@ -3212,7 +3205,6 @@ alter:
LEX *lex= Lex;
bzero((char *)&lex->sp_chistics, sizeof(st_sp_chistics));
- lex->name= 0;
}
sp_a_chistics
{
@@ -6500,12 +6492,6 @@ simple_ident:
if (spc && (spv = spc->find_pvar(&$1)))
{ /* We're compiling a stored procedure and found a variable */
- if (lex->sql_command != SQLCOM_CALL && ! spv->isset)
- {
- push_warning_printf(YYTHD, MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_SP_UNINIT_VAR, ER(ER_SP_UNINIT_VAR),
- $1.str);
- }
$$ = (Item*) new Item_splocal($1, spv->offset);
lex->variables_used= 1;
lex->safe_to_cache_query=0;
@@ -7917,7 +7903,7 @@ check_option:
/* empty */
{ Lex->create_view_check= VIEW_CHECK_NONE; }
| WITH CHECK_SYM OPTION
- { Lex->create_view_check= VIEW_CHECK_LOCAL; }
+ { Lex->create_view_check= VIEW_CHECK_CASCADED; }
| WITH CASCADED CHECK_SYM OPTION
{ Lex->create_view_check= VIEW_CHECK_CASCADED; }
| WITH LOCAL_SYM CHECK_SYM OPTION
diff --git a/sql/table.cc b/sql/table.cc
index bfe5395c3db..e372de57177 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1497,8 +1497,10 @@ void st_table_list::set_ancestor()
SYNOPSIS
st_table_list::setup_ancestor()
- thd - thread handler
- conds - condition of this JOIN
+ thd - thread handler
+ conds - condition of this JOIN
+ check_opt_type - WHITH CHECK OPTION type (VIEW_CHECK_NONE,
+ VIEW_CHECK_LOCAL, VIEW_CHECK_CASCADED)
DESCRIPTION
It is:
@@ -1513,7 +1515,8 @@ void st_table_list::set_ancestor()
1 - error
*/
-bool st_table_list::setup_ancestor(THD *thd, Item **conds)
+bool st_table_list::setup_ancestor(THD *thd, Item **conds,
+ uint8 check_opt_type)
{
Item **transl;
SELECT_LEX *select= &view->select_lex;
@@ -1527,7 +1530,10 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds)
DBUG_ENTER("st_table_list::setup_ancestor");
if (ancestor->ancestor &&
- ancestor->setup_ancestor(thd, conds))
+ ancestor->setup_ancestor(thd, conds,
+ (check_opt_type == VIEW_CHECK_CASCADED ?
+ VIEW_CHECK_CASCADED :
+ VIEW_CHECK_NONE)))
DBUG_RETURN(1);
if (field_translation)
@@ -1586,23 +1592,26 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds)
field_translation= transl;
/* TODO: sort this list? Use hash for big number of fields */
- if (where)
+ if (where ||
+ (check_opt_type == VIEW_CHECK_CASCADED &&
+ ancestor->check_option))
{
Item_arena *arena= thd->current_arena, backup;
TABLE_LIST *tbl= this;
if (arena->is_conventional())
arena= 0; // For easier test
- if (!where->fixed && where->fix_fields(thd, ancestor, &where))
+ if (where && !where->fixed && where->fix_fields(thd, ancestor, &where))
goto err;
if (arena)
thd->set_n_backup_item_arena(arena, &backup);
- if (effective_with_check)
+ if (check_opt_type)
{
- check_option= where->copy_andor_structure(thd);
- if (effective_with_check == VIEW_CHECK_CASCADED)
+ if (where)
+ check_option= where->copy_andor_structure(thd);
+ if (check_opt_type == VIEW_CHECK_CASCADED)
{
check_option= and_conds(check_option, ancestor->check_option);
}
@@ -1612,7 +1621,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds)
check that it is not VIEW in which we insert with INSERT SELECT
(in this case we can't add view WHERE condition to main SELECT_LEX)
*/
- if (!no_where_clause)
+ if (where && !no_where_clause)
{
/* Go up to join tree and try to find left join */
for (; tbl; tbl= tbl->embedding)
diff --git a/sql/table.h b/sql/table.h
index 605cd516d9c..3e2a61d5a21 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -283,7 +283,7 @@ typedef struct st_table_list
void calc_md5(char *buffer);
void set_ancestor();
int view_check_option(THD *thd, bool ignore_failure);
- bool setup_ancestor(THD *thd, Item **conds);
+ bool setup_ancestor(THD *thd, Item **conds, uint8 check_option);
bool placeholder() {return derived || view; }
void print(THD *thd, String *str);
inline st_table_list *next_independent()