post review changes:
CHECK OPTION moved to one function view name added to error messages mysql-test/r/view.result: error messages changed sql/share/czech/errmsg.txt: view name added sql/share/danish/errmsg.txt: view name added sql/share/dutch/errmsg.txt: view name added sql/share/english/errmsg.txt: view name added sql/share/estonian/errmsg.txt: view name added sql/share/french/errmsg.txt: view name added sql/share/german/errmsg.txt: view name added sql/share/greek/errmsg.txt: view name added sql/share/hungarian/errmsg.txt: view name added sql/share/italian/errmsg.txt: view name added sql/share/japanese/errmsg.txt: view name added sql/share/korean/errmsg.txt: view name added sql/share/norwegian-ny/errmsg.txt: view name added sql/share/norwegian/errmsg.txt: view name added sql/share/polish/errmsg.txt: view name added sql/share/portuguese/errmsg.txt: view name added sql/share/romanian/errmsg.txt: view name added sql/share/russian/errmsg.txt: view name added sql/share/serbian/errmsg.txt: view name added sql/share/slovak/errmsg.txt: view name added sql/share/spanish/errmsg.txt: view name added sql/share/swedish/errmsg.txt: view name added sql/share/ukrainian/errmsg.txt: view name added sql/sql_class.h: view reference saved sql/sql_insert.cc: CHECK OPTION moved to one function sql/sql_update.cc: CHECK OPTION moved to one function sql/sql_view.cc: view name added to error message sql/table.cc: CHECK OPTION moved to one function sql/table.h: CHECK OPTION moved to one function
This commit is contained in:
parent
44ca1f80a8
commit
e05e18606b
@ -477,7 +477,7 @@ drop view v1;
|
||||
drop table t1;
|
||||
create table t1 (a int);
|
||||
create view v1 as select distinct a from t1 WITH CHECK OPTION;
|
||||
ERROR HY000: CHECK OPTION on non-updatable view
|
||||
ERROR HY000: CHECK OPTION on non-updatable view 'test.v1'
|
||||
create view v1 as select a from t1 WITH CHECK OPTION;
|
||||
create view v2 as select a from t1 WITH CASCADED CHECK OPTION;
|
||||
create view v3 as select a from t1 WITH LOCAL CHECK OPTION;
|
||||
@ -1276,11 +1276,11 @@ create table t1 (a int);
|
||||
create view v1 as select * from t1 where a < 2 with check option;
|
||||
insert into v1 values(1);
|
||||
insert into v1 values(3);
|
||||
ERROR HY000: CHECK OPTION failed
|
||||
ERROR HY000: CHECK OPTION failed 'test.v1'
|
||||
insert ignore into v1 values (2),(3),(0);
|
||||
Warnings:
|
||||
Error 1359 CHECK OPTION failed
|
||||
Error 1359 CHECK OPTION failed
|
||||
Error 1359 CHECK OPTION failed 'test.v1'
|
||||
Error 1359 CHECK OPTION failed 'test.v1'
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
@ -1288,20 +1288,20 @@ a
|
||||
delete from t1;
|
||||
insert into v1 SELECT 1;
|
||||
insert into v1 SELECT 3;
|
||||
ERROR HY000: CHECK OPTION failed
|
||||
ERROR HY000: CHECK OPTION failed 'test.v1'
|
||||
create table t2 (a int);
|
||||
insert into t2 values (2),(3),(0);
|
||||
insert ignore into v1 SELECT a from t2;
|
||||
Warnings:
|
||||
Error 1359 CHECK OPTION failed
|
||||
Error 1359 CHECK OPTION failed
|
||||
Error 1359 CHECK OPTION failed 'test.v1'
|
||||
Error 1359 CHECK OPTION failed 'test.v1'
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
0
|
||||
update v1 set a=-1 where a=0;
|
||||
update v1 set a=2 where a=1;
|
||||
ERROR HY000: CHECK OPTION failed
|
||||
ERROR HY000: CHECK OPTION failed 'test.v1'
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
@ -1316,7 +1316,7 @@ a
|
||||
update v1 set a=a+1;
|
||||
update ignore v1,t2 set v1.a=v1.a+1 where v1.a=t2.a;
|
||||
Warnings:
|
||||
Error 1359 CHECK OPTION failed
|
||||
Error 1359 CHECK OPTION failed 'test.v1'
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
@ -1330,12 +1330,12 @@ create view v3 as select * from v1 where a > 0 with cascaded check option;
|
||||
insert into v2 values (1);
|
||||
insert into v3 values (1);
|
||||
insert into v2 values (0);
|
||||
ERROR HY000: CHECK OPTION failed
|
||||
ERROR HY000: CHECK OPTION failed 'test.v2'
|
||||
insert into v3 values (0);
|
||||
ERROR HY000: CHECK OPTION failed
|
||||
ERROR HY000: CHECK OPTION failed 'test.v3'
|
||||
insert into v2 values (2);
|
||||
insert into v3 values (2);
|
||||
ERROR HY000: CHECK OPTION failed
|
||||
ERROR HY000: CHECK OPTION failed 'test.v3'
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
@ -1347,10 +1347,10 @@ create table t1 (a int, primary key (a));
|
||||
create view v1 as select * from t1 where a < 2 with check option;
|
||||
insert into v1 values (1) on duplicate key update a=2;
|
||||
insert into v1 values (1) on duplicate key update a=2;
|
||||
ERROR HY000: CHECK OPTION failed
|
||||
ERROR HY000: CHECK OPTION failed 'test.v1'
|
||||
insert ignore into v1 values (1) on duplicate key update a=2;
|
||||
Warnings:
|
||||
Error 1359 CHECK OPTION failed
|
||||
Error 1359 CHECK OPTION failed 'test.v1'
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
|
@ -370,5 +370,5 @@ character-set=latin2
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
"Can't drop a %s from within another stored routine"
|
||||
"GOTO is not allowed in a stored procedure handler"
|
||||
"CHECK OPTION on non-updatable view"
|
||||
"CHECK OPTION failed"
|
||||
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
|
||||
"CHECK OPTION failed '%-.64s.%-.64s'"
|
||||
|
@ -364,5 +364,5 @@ character-set=latin1
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
"Can't drop a %s from within another stored routine"
|
||||
"GOTO is not allowed in a stored procedure handler"
|
||||
"CHECK OPTION on non-updatable view"
|
||||
"CHECK OPTION failed"
|
||||
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
|
||||
"CHECK OPTION failed '%-.64s.%-.64s'"
|
||||
|
@ -372,5 +372,5 @@ character-set=latin1
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
"Can't drop a %s from within another stored routine"
|
||||
"GOTO is not allowed in a stored procedure handler"
|
||||
"CHECK OPTION on non-updatable view"
|
||||
"CHECK OPTION failed"
|
||||
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
|
||||
"CHECK OPTION failed '%-.64s.%-.64s'"
|
||||
|
@ -361,5 +361,5 @@ character-set=latin1
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
"Can't drop a %s from within another stored routine"
|
||||
"GOTO is not allowed in a stored procedure handler"
|
||||
"CHECK OPTION on non-updatable view"
|
||||
"CHECK OPTION failed"
|
||||
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
|
||||
"CHECK OPTION failed '%-.64s.%-.64s'"
|
||||
|
@ -366,5 +366,5 @@ character-set=latin7
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
"Can't drop a %s from within another stored routine"
|
||||
"GOTO is not allowed in a stored procedure handler"
|
||||
"CHECK OPTION on non-updatable view"
|
||||
"CHECK OPTION failed"
|
||||
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
|
||||
"CHECK OPTION failed '%-.64s.%-.64s'"
|
||||
|
@ -361,5 +361,5 @@ character-set=latin1
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
"Can't drop a %s from within another stored routine"
|
||||
"GOTO is not allowed in a stored procedure handler"
|
||||
"CHECK OPTION on non-updatable view"
|
||||
"CHECK OPTION failed"
|
||||
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
|
||||
"CHECK OPTION failed '%-.64s.%-.64s'"
|
||||
|
@ -373,5 +373,5 @@ character-set=latin1
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
"Can't drop a %s from within another stored routine"
|
||||
"GOTO is not allowed in a stored procedure handler"
|
||||
"CHECK OPTION on non-updatable view"
|
||||
"CHECK OPTION failed"
|
||||
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
|
||||
"CHECK OPTION failed '%-.64s.%-.64s'"
|
||||
|
@ -361,5 +361,5 @@ character-set=greek
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
"Can't drop a %s from within another stored routine"
|
||||
"GOTO is not allowed in a stored procedure handler"
|
||||
"CHECK OPTION on non-updatable view"
|
||||
"CHECK OPTION failed"
|
||||
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
|
||||
"CHECK OPTION failed '%-.64s.%-.64s'"
|
||||
|
@ -363,5 +363,5 @@ character-set=latin2
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
"Can't drop a %s from within another stored routine"
|
||||
"GOTO is not allowed in a stored procedure handler"
|
||||
"CHECK OPTION on non-updatable view"
|
||||
"CHECK OPTION failed"
|
||||
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
|
||||
"CHECK OPTION failed '%-.64s.%-.64s'"
|
||||
|
@ -361,5 +361,5 @@ character-set=latin1
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
"Can't drop a %s from within another stored routine"
|
||||
"GOTO is not allowed in a stored procedure handler"
|
||||
"CHECK OPTION on non-updatable view"
|
||||
"CHECK OPTION failed"
|
||||
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
|
||||
"CHECK OPTION failed '%-.64s.%-.64s'"
|
||||
|
@ -363,5 +363,5 @@ character-set=ujis
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
"Can't drop a %s from within another stored routine"
|
||||
"GOTO is not allowed in a stored procedure handler"
|
||||
"CHECK OPTION on non-updatable view"
|
||||
"CHECK OPTION failed"
|
||||
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
|
||||
"CHECK OPTION failed '%-.64s.%-.64s'"
|
||||
|
@ -361,5 +361,5 @@ character-set=euckr
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
"Can't drop a %s from within another stored routine"
|
||||
"GOTO is not allowed in a stored procedure handler"
|
||||
"CHECK OPTION on non-updatable view"
|
||||
"CHECK OPTION failed"
|
||||
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
|
||||
"CHECK OPTION failed '%-.64s.%-.64s'"
|
||||
|
@ -363,5 +363,5 @@ character-set=latin1
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
"Can't drop a %s from within another stored routine"
|
||||
"GOTO is not allowed in a stored procedure handler"
|
||||
"CHECK OPTION on non-updatable view"
|
||||
"CHECK OPTION failed"
|
||||
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
|
||||
"CHECK OPTION failed '%-.64s.%-.64s'"
|
||||
|
@ -363,5 +363,5 @@ character-set=latin1
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
"Can't drop a %s from within another stored routine"
|
||||
"GOTO is not allowed in a stored procedure handler"
|
||||
"CHECK OPTION on non-updatable view"
|
||||
"CHECK OPTION failed"
|
||||
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
|
||||
"CHECK OPTION failed '%-.64s.%-.64s'"
|
||||
|
@ -365,5 +365,5 @@ character-set=latin2
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
"Can't drop a %s from within another stored routine"
|
||||
"GOTO is not allowed in a stored procedure handler"
|
||||
"CHECK OPTION on non-updatable view"
|
||||
"CHECK OPTION failed"
|
||||
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
|
||||
"CHECK OPTION failed '%-.64s.%-.64s'"
|
||||
|
@ -362,5 +362,5 @@ character-set=latin1
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
"Can't drop a %s from within another stored routine"
|
||||
"GOTO is not allowed in a stored procedure handler"
|
||||
"CHECK OPTION on non-updatable view"
|
||||
"CHECK OPTION failed"
|
||||
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
|
||||
"CHECK OPTION failed '%-.64s.%-.64s'"
|
||||
|
@ -365,5 +365,5 @@ character-set=latin2
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
"Can't drop a %s from within another stored routine"
|
||||
"GOTO is not allowed in a stored procedure handler"
|
||||
"CHECK OPTION on non-updatable view"
|
||||
"CHECK OPTION failed"
|
||||
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
|
||||
"CHECK OPTION failed '%-.64s.%-.64s'"
|
||||
|
@ -363,5 +363,5 @@ character-set=koi8r
|
||||
"View '%-.64s.%-.64s' ÓÓÙÌÁÅÔÓÑ ÎÁ ÎÅÓÕÝÅÓÔ×ÕÀÝÉÅ ÔÁÂÌÉÃÙ ÉÌÉ ÓÌÏÌÂÃÙ"
|
||||
"Can't drop a %s from within another stored routine"
|
||||
"GOTO is not allowed in a stored procedure handler"
|
||||
"CHECK OPTION для необновляемого VIEW"
|
||||
"проверка CHECK OPTION провалилась"
|
||||
"CHECK OPTION для необновляемого VIEW '%-.64s.%-.64s'"
|
||||
"проверка CHECK OPTION для VIEW '%-.64s.%-.64s' провалилась"
|
||||
|
@ -367,5 +367,5 @@ character-set=cp1250
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
"Can't drop a %s from within another stored routine"
|
||||
"GOTO is not allowed in a stored procedure handler"
|
||||
"CHECK OPTION on non-updatable view"
|
||||
"CHECK OPTION failed"
|
||||
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
|
||||
"CHECK OPTION failed '%-.64s.%-.64s'"
|
||||
|
@ -369,5 +369,5 @@ character-set=latin2
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
"Can't drop a %s from within another stored routine"
|
||||
"GOTO is not allowed in a stored procedure handler"
|
||||
"CHECK OPTION on non-updatable view"
|
||||
"CHECK OPTION failed"
|
||||
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
|
||||
"CHECK OPTION failed '%-.64s.%-.64s'"
|
||||
|
@ -363,5 +363,5 @@ character-set=latin1
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
"Can't drop a %s from within another stored routine"
|
||||
"GOTO is not allowed in a stored procedure handler"
|
||||
"CHECK OPTION on non-updatable view"
|
||||
"CHECK OPTION failed"
|
||||
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
|
||||
"CHECK OPTION failed '%-.64s.%-.64s'"
|
||||
|
@ -361,5 +361,5 @@ character-set=latin1
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
"Can't drop a %s from within another stored routine"
|
||||
"GOTO is not allowed in a stored procedure handler"
|
||||
"CHECK OPTION on non-updatable view"
|
||||
"CHECK OPTION failed"
|
||||
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
|
||||
"CHECK OPTION failed '%-.64s.%-.64s'"
|
||||
|
@ -366,5 +366,5 @@ character-set=koi8u
|
||||
"View '%-.64s.%-.64s' ÐÏÓÉÌÁ¤ÔÓÑ ÎÁ ÎŦÓÎÕÀÞ¦ ÔÁÂÌÉæ ÁÂÏ ÓÔÏ×Âæ"
|
||||
"Can't drop a %s from within another stored routine"
|
||||
"GOTO is not allowed in a stored procedure handler"
|
||||
"CHECK OPTION ÄÌÑ VIEW ÝÏ ÎÅ ÍÏÖÅ ÂÕÔÉ ÏÎÏ×ÌÅÎÎÉÍ"
|
||||
"ÐÅÒÅצÒËÁ CHECK OPTION ÎÅ ÐÒÏÊÛÌÁ"
|
||||
"CHECK OPTION ÄÌÑ VIEW '%-.64s.%-.64s' ÝÏ ÎÅ ÍÏÖÅ ÂÕÔÉ ÏÎÏ×ÌÅÎÎÉÍ"
|
||||
"ÐÅÒÅצÒËÁ CHECK OPTION ÄÌÑ VIEW '%-.64s.%-.64s' ÎÅ ÐÒÏÊÛÌÁ"
|
||||
|
@ -228,7 +228,7 @@ typedef struct st_copy_info {
|
||||
List<Item> *update_fields;
|
||||
List<Item> *update_values;
|
||||
/* for VIEW ... WITH CHECK OPTION */
|
||||
Item *check_option;
|
||||
TABLE_LIST *view;
|
||||
bool ignore;
|
||||
} COPY_INFO;
|
||||
|
||||
|
@ -128,7 +128,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
|
||||
*/
|
||||
bool log_on= (thd->options & OPTION_BIN_LOG) || (!(thd->master_access & SUPER_ACL));
|
||||
bool transactional_table, log_delayed;
|
||||
bool check;
|
||||
bool ignore_err= (thd->lex->duplicates == DUP_IGNORE);
|
||||
uint value_count;
|
||||
ulong counter = 1;
|
||||
ulonglong id;
|
||||
@ -242,8 +242,8 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
|
||||
info.handle_duplicates=duplic;
|
||||
info.update_fields=&update_fields;
|
||||
info.update_values=&update_values;
|
||||
info.check_option= table_list->check_option;
|
||||
info.ignore= thd->lex->duplicates == DUP_IGNORE;
|
||||
info.view= (table_list->view ? table_list : 0);
|
||||
info.ignore= ignore_err;
|
||||
/*
|
||||
Count warnings for all inserts.
|
||||
For single line insert, generate an error if try to set a NOT NULL field
|
||||
@ -271,8 +271,6 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
|
||||
if (lock_type != TL_WRITE_DELAYED)
|
||||
table->file->start_bulk_insert(values_list.elements);
|
||||
|
||||
check= (table_list->check_option != 0);
|
||||
|
||||
while ((values= its++))
|
||||
{
|
||||
if (fields.elements || !value_count)
|
||||
@ -307,21 +305,14 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (check && table_list->check_option->val_int() == 0)
|
||||
{
|
||||
if (thd->lex->duplicates == DUP_IGNORE)
|
||||
{
|
||||
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
|
||||
ER_VIEW_CHECK_FAILED, ER(ER_VIEW_CHECK_FAILED));
|
||||
if ((res= table_list->view_check_option(thd, ignore_err)) ==
|
||||
VIEW_CHECK_SKIP)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
else if (res == VIEW_CHECK_ERROR)
|
||||
{
|
||||
my_error(ER_VIEW_CHECK_FAILED, MYF(0));
|
||||
error= 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
if (lock_type == TL_WRITE_DELAYED)
|
||||
{
|
||||
@ -708,6 +699,7 @@ int write_record(TABLE *table,COPY_INFO *info)
|
||||
}
|
||||
if (info->handle_duplicates == DUP_UPDATE)
|
||||
{
|
||||
int res= 0;
|
||||
/* we don't check for other UNIQUE keys - the first row
|
||||
that matches, is updated. If update causes a conflict again,
|
||||
an error is returned
|
||||
@ -718,21 +710,12 @@ int write_record(TABLE *table,COPY_INFO *info)
|
||||
goto err;
|
||||
|
||||
/* CHECK OPTION for VIEW ... ON DUPLICATE KEY UPDATE ... */
|
||||
if (info->check_option &&
|
||||
info->check_option->val_int() == 0)
|
||||
{
|
||||
if (info->ignore)
|
||||
{
|
||||
push_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
|
||||
ER_VIEW_CHECK_FAILED, ER(ER_VIEW_CHECK_FAILED));
|
||||
if (info->view &&
|
||||
(res= info->view->view_check_option(current_thd, info->ignore)) ==
|
||||
VIEW_CHECK_SKIP)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
my_error(ER_VIEW_CHECK_FAILED, MYF(0));
|
||||
else if (res == VIEW_CHECK_ERROR)
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
if ((error=table->file->update_row(table->record[1],table->record[0])))
|
||||
goto err;
|
||||
@ -1663,7 +1646,7 @@ select_insert::select_insert(TABLE_LIST *table_list_par, TABLE *table_par,
|
||||
bzero((char*) &info,sizeof(info));
|
||||
info.handle_duplicates=duplic;
|
||||
if (table_list_par)
|
||||
info.check_option= table_list_par->check_option;
|
||||
info.view= (table_list_par->view ? table_list_par : 0);
|
||||
info.ignore= ignore_check_option_errors;
|
||||
}
|
||||
|
||||
@ -1712,20 +1695,14 @@ bool select_insert::send_data(List<Item> &values)
|
||||
fill_record(*fields, values, 1);
|
||||
else
|
||||
fill_record(table->field, values, 1);
|
||||
if (table_list->check_option && table_list->check_option->val_int() == 0)
|
||||
switch (table_list->view_check_option(thd,
|
||||
thd->lex->duplicates == DUP_IGNORE))
|
||||
{
|
||||
if (thd->lex->duplicates == DUP_IGNORE)
|
||||
{
|
||||
push_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
|
||||
ER_VIEW_CHECK_FAILED, ER(ER_VIEW_CHECK_FAILED));
|
||||
case VIEW_CHECK_SKIP:
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
my_error(ER_VIEW_CHECK_FAILED, MYF(0));
|
||||
case VIEW_CHECK_ERROR:
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
}
|
||||
if (thd->net.report_error || write_record(table,&info))
|
||||
DBUG_RETURN(1);
|
||||
if (table->next_number_field) // Clear for next record
|
||||
|
@ -97,8 +97,9 @@ int mysql_update(THD *thd,
|
||||
bool using_limit= limit != HA_POS_ERROR;
|
||||
bool safe_update= thd->options & OPTION_SAFE_UPDATES;
|
||||
bool used_key_is_modified, transactional_table, log_delayed;
|
||||
bool check;
|
||||
bool ignore_err= (thd->lex->duplicates == DUP_IGNORE);
|
||||
int error=0;
|
||||
int res;
|
||||
uint used_index;
|
||||
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
||||
uint want_privilege;
|
||||
@ -150,7 +151,7 @@ int mysql_update(THD *thd,
|
||||
#endif
|
||||
{
|
||||
thd->lex->select_lex.no_wrap_view_item= 1;
|
||||
int res= setup_fields(thd, 0, table_list, fields, 1, 0, 0);
|
||||
res= setup_fields(thd, 0, table_list, fields, 1, 0, 0);
|
||||
thd->lex->select_lex.no_wrap_view_item= 0;
|
||||
if (res)
|
||||
DBUG_RETURN(-1); /* purecov: inspected */
|
||||
@ -345,7 +346,6 @@ int mysql_update(THD *thd,
|
||||
thd->count_cuted_fields= CHECK_FIELD_WARN; /* calc cuted fields */
|
||||
thd->cuted_fields=0L;
|
||||
thd->proc_info="Updating";
|
||||
check= (table_list->check_option != 0);
|
||||
query_id=thd->query_id;
|
||||
|
||||
while (!(error=info.read_record(&info)) && !thd->killed)
|
||||
@ -355,25 +355,21 @@ int mysql_update(THD *thd,
|
||||
store_record(table,record[1]);
|
||||
if (fill_record(fields,values, 0) || thd->net.report_error)
|
||||
break; /* purecov: inspected */
|
||||
if (check && table_list->check_option->val_int() == 0)
|
||||
found++;
|
||||
if (compare_record(table, query_id))
|
||||
{
|
||||
if (thd->lex->duplicates == DUP_IGNORE)
|
||||
if ((res= table_list->view_check_option(thd, ignore_err)) !=
|
||||
VIEW_CHECK_OK)
|
||||
{
|
||||
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
|
||||
ER_VIEW_CHECK_FAILED, ER(ER_VIEW_CHECK_FAILED));
|
||||
found--;
|
||||
if (res == VIEW_CHECK_SKIP)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
else if (res == VIEW_CHECK_ERROR)
|
||||
{
|
||||
my_error(ER_VIEW_CHECK_FAILED, MYF(0));
|
||||
error= 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
found++;
|
||||
if (compare_record(table, query_id))
|
||||
{
|
||||
if (!(error=table->file->update_row((byte*) table->record[1],
|
||||
(byte*) table->record[0])))
|
||||
{
|
||||
@ -974,6 +970,7 @@ multi_update::~multi_update()
|
||||
bool multi_update::send_data(List<Item> ¬_used_values)
|
||||
{
|
||||
TABLE_LIST *cur_table;
|
||||
bool ignore_err= (thd->lex->duplicates == DUP_IGNORE);
|
||||
DBUG_ENTER("multi_update::send_data");
|
||||
|
||||
for (cur_table= update_tables; cur_table; cur_table= cur_table->next_local)
|
||||
@ -1002,26 +999,19 @@ bool multi_update::send_data(List<Item> ¬_used_values)
|
||||
store_record(table,record[1]);
|
||||
if (fill_record(*fields_for_table[offset], *values_for_table[offset], 0))
|
||||
DBUG_RETURN(1);
|
||||
|
||||
if (cur_table->check_option && cur_table->check_option->val_int() == 0)
|
||||
{
|
||||
if (thd->lex->duplicates == DUP_IGNORE)
|
||||
{
|
||||
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
|
||||
ER_VIEW_CHECK_FAILED, ER(ER_VIEW_CHECK_FAILED));
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
my_error(ER_VIEW_CHECK_FAILED, MYF(0));
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
}
|
||||
|
||||
found++;
|
||||
if (compare_record(table, thd->query_id))
|
||||
{
|
||||
int error;
|
||||
if ((error= cur_table->view_check_option(thd, ignore_err)) !=
|
||||
VIEW_CHECK_OK)
|
||||
{
|
||||
found--;
|
||||
if (error == VIEW_CHECK_SKIP)
|
||||
continue;
|
||||
else if (error == VIEW_CHECK_ERROR)
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
if (!updated++)
|
||||
{
|
||||
/*
|
||||
|
@ -481,7 +481,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
|
||||
if (view->with_check != VIEW_CHECK_NONE &&
|
||||
!view->updatable_view)
|
||||
{
|
||||
my_error(ER_VIEW_NONUPD_CHECK, MYF(0));
|
||||
my_error(ER_VIEW_NONUPD_CHECK, MYF(0), view->db, view->real_name);
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
|
||||
|
34
sql/table.cc
34
sql/table.cc
@ -1653,6 +1653,40 @@ err:
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
check CHECK OPTION condition
|
||||
|
||||
SYNOPSIS
|
||||
check_option()
|
||||
ignore_failure ignore check option fail
|
||||
|
||||
RETURN
|
||||
VIEW_CHECK_OK OK
|
||||
VIEW_CHECK_ERROR FAILED
|
||||
VIEW_CHECK_SKIP FAILED, but continue
|
||||
*/
|
||||
|
||||
int st_table_list::view_check_option(THD *thd, bool ignore_failure)
|
||||
{
|
||||
if (check_option && check_option->val_int() == 0)
|
||||
{
|
||||
if (ignore_failure)
|
||||
{
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
|
||||
ER_VIEW_CHECK_FAILED, ER(ER_VIEW_CHECK_FAILED),
|
||||
view_db.str, view_name.str);
|
||||
return(VIEW_CHECK_SKIP);
|
||||
}
|
||||
else
|
||||
{
|
||||
my_error(ER_VIEW_CHECK_FAILED, MYF(0), view_db.str, view_name.str);
|
||||
return(VIEW_CHECK_ERROR);
|
||||
}
|
||||
}
|
||||
return(VIEW_CHECK_OK);
|
||||
}
|
||||
|
||||
|
||||
void Field_iterator_view::set(TABLE_LIST *table)
|
||||
{
|
||||
ptr= table->field_translation;
|
||||
|
@ -185,10 +185,16 @@ struct st_table {
|
||||
#define VIEW_ALGORITHM_TMPTABLE 1
|
||||
#define VIEW_ALGORITHM_MERGE 2
|
||||
|
||||
/* view WITH CHECK OPTION parameter options */
|
||||
#define VIEW_CHECK_NONE 0
|
||||
#define VIEW_CHECK_LOCAL 1
|
||||
#define VIEW_CHECK_CASCADED 2
|
||||
|
||||
/* result of view WITH CHECK OPTION parameter check */
|
||||
#define VIEW_CHECK_OK 0
|
||||
#define VIEW_CHECK_ERROR 1
|
||||
#define VIEW_CHECK_SKIP 2
|
||||
|
||||
struct st_lex;
|
||||
|
||||
typedef struct st_table_list
|
||||
@ -264,6 +270,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 placeholder() {return derived || view; }
|
||||
void print(THD *thd, String *str);
|
||||
|
Loading…
x
Reference in New Issue
Block a user