Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
392292a4
Commit
392292a4
authored
Sep 29, 2004
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
post review changes:
CHECK OPTION moved to one function view name added to error messages
parent
f7e92479
Changes
30
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
154 additions
and
146 deletions
+154
-146
mysql-test/r/view.result
mysql-test/r/view.result
+14
-14
sql/share/czech/errmsg.txt
sql/share/czech/errmsg.txt
+2
-2
sql/share/danish/errmsg.txt
sql/share/danish/errmsg.txt
+2
-2
sql/share/dutch/errmsg.txt
sql/share/dutch/errmsg.txt
+2
-2
sql/share/english/errmsg.txt
sql/share/english/errmsg.txt
+2
-2
sql/share/estonian/errmsg.txt
sql/share/estonian/errmsg.txt
+2
-2
sql/share/french/errmsg.txt
sql/share/french/errmsg.txt
+2
-2
sql/share/german/errmsg.txt
sql/share/german/errmsg.txt
+2
-2
sql/share/greek/errmsg.txt
sql/share/greek/errmsg.txt
+2
-2
sql/share/hungarian/errmsg.txt
sql/share/hungarian/errmsg.txt
+2
-2
sql/share/italian/errmsg.txt
sql/share/italian/errmsg.txt
+2
-2
sql/share/japanese/errmsg.txt
sql/share/japanese/errmsg.txt
+2
-2
sql/share/korean/errmsg.txt
sql/share/korean/errmsg.txt
+2
-2
sql/share/norwegian-ny/errmsg.txt
sql/share/norwegian-ny/errmsg.txt
+2
-2
sql/share/norwegian/errmsg.txt
sql/share/norwegian/errmsg.txt
+2
-2
sql/share/polish/errmsg.txt
sql/share/polish/errmsg.txt
+2
-2
sql/share/portuguese/errmsg.txt
sql/share/portuguese/errmsg.txt
+2
-2
sql/share/romanian/errmsg.txt
sql/share/romanian/errmsg.txt
+2
-2
sql/share/russian/errmsg.txt
sql/share/russian/errmsg.txt
+2
-2
sql/share/serbian/errmsg.txt
sql/share/serbian/errmsg.txt
+2
-2
sql/share/slovak/errmsg.txt
sql/share/slovak/errmsg.txt
+2
-2
sql/share/spanish/errmsg.txt
sql/share/spanish/errmsg.txt
+2
-2
sql/share/swedish/errmsg.txt
sql/share/swedish/errmsg.txt
+2
-2
sql/share/ukrainian/errmsg.txt
sql/share/ukrainian/errmsg.txt
+2
-2
sql/sql_class.h
sql/sql_class.h
+1
-1
sql/sql_insert.cc
sql/sql_insert.cc
+23
-46
sql/sql_update.cc
sql/sql_update.cc
+26
-36
sql/sql_view.cc
sql/sql_view.cc
+3
-3
sql/table.cc
sql/table.cc
+34
-0
sql/table.h
sql/table.h
+7
-0
No files found.
mysql-test/r/view.result
View file @
392292a4
...
...
@@ -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
...
...
sql/share/czech/errmsg.txt
View file @
392292a4
...
...
@@ -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'
"
sql/share/danish/errmsg.txt
View file @
392292a4
...
...
@@ -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'
"
sql/share/dutch/errmsg.txt
View file @
392292a4
...
...
@@ -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'
"
sql/share/english/errmsg.txt
View file @
392292a4
...
...
@@ -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'
"
sql/share/estonian/errmsg.txt
View file @
392292a4
...
...
@@ -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'
"
sql/share/french/errmsg.txt
View file @
392292a4
...
...
@@ -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'
"
sql/share/german/errmsg.txt
View file @
392292a4
...
...
@@ -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'
"
sql/share/greek/errmsg.txt
View file @
392292a4
...
...
@@ -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'
"
sql/share/hungarian/errmsg.txt
View file @
392292a4
...
...
@@ -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'
"
sql/share/italian/errmsg.txt
View file @
392292a4
...
...
@@ -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'
"
sql/share/japanese/errmsg.txt
View file @
392292a4
...
...
@@ -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'
"
sql/share/korean/errmsg.txt
View file @
392292a4
...
...
@@ -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'
"
sql/share/norwegian-ny/errmsg.txt
View file @
392292a4
...
...
@@ -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'
"
sql/share/norwegian/errmsg.txt
View file @
392292a4
...
...
@@ -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'
"
sql/share/polish/errmsg.txt
View file @
392292a4
...
...
@@ -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'
"
sql/share/portuguese/errmsg.txt
View file @
392292a4
...
...
@@ -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'
"
sql/share/romanian/errmsg.txt
View file @
392292a4
...
...
@@ -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'
"
sql/share/russian/errmsg.txt
View file @
392292a4
...
...
@@ -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'
"
sql/share/serbian/errmsg.txt
View file @
392292a4
...
...
@@ -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'
"
sql/share/slovak/errmsg.txt
View file @
392292a4
...
...
@@ -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'
"
sql/share/spanish/errmsg.txt
View file @
392292a4
...
...
@@ -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'
"
sql/share/swedish/errmsg.txt
View file @
392292a4
...
...
@@ -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'
"
sql/share/ukrainian/errmsg.txt
View file @
392292a4
...
...
@@ -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'
"
sql/sql_class.h
View file @
392292a4
...
...
@@ -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
;
...
...
sql/sql_insert.cc
View file @
392292a4
...
...
@@ -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,20 +305,13 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
break
;
}
}
if
(
check
&&
table_list
->
check_option
->
val_int
()
==
0
)
if
((
res
=
table_list
->
view_check_option
(
thd
,
ignore_err
))
==
VIEW_CHECK_SKIP
)
continue
;
else
if
(
res
==
VIEW_CHECK_ERROR
)
{
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
));
error
=
1
;
break
;
}
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
));
break
;
}
else
{
my_error
(
ER_VIEW_CHECK_FAILED
,
MYF
(
0
));
goto
err
;
}
}
if
(
info
->
view
&&
(
res
=
info
->
view
->
view_check_option
(
current_thd
,
info
->
ignore
))
==
VIEW_CHECK_SKIP
)
break
;
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,19 +1695,13 @@ 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
));
DBUG_RETURN
(
0
);
}
else
{
my_error
(
ER_VIEW_CHECK_FAILED
,
MYF
(
0
));
DBUG_RETURN
(
1
);
}
case
VIEW_CHECK_SKIP
:
DBUG_RETURN
(
0
);
case
VIEW_CHECK_ERROR
:
DBUG_RETURN
(
1
);
}
if
(
thd
->
net
.
report_error
||
write_record
(
table
,
&
info
))
DBUG_RETURN
(
1
);
...
...
sql/sql_update.cc
View file @
392292a4
...
...
@@ -94,11 +94,12 @@ int mysql_update(THD *thd,
ha_rows
limit
,
enum
enum_duplicates
handle_duplicates
)
{
bool
using_limit
=
limit
!=
HA_POS_ERROR
;
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
)
{
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
));
error
=
1
;
break
;
}
}
found
++
;
if
(
compare_record
(
table
,
query_id
))
{
if
((
res
=
table_list
->
view_check_option
(
thd
,
ignore_err
))
!=
VIEW_CHECK_OK
)
{
found
--
;
if
(
res
==
VIEW_CHECK_SKIP
)
continue
;
else
if
(
res
==
VIEW_CHECK_ERROR
)
{
error
=
1
;
break
;
}
}
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
>
&
not_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
++
)
{
/*
...
...
sql/sql_view.cc
View file @
392292a4
...
...
@@ -398,7 +398,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
char
path_buff
[
FN_REFLEN
];
LEX_STRING
path
;
File_parser
*
parser
;
path
.
str
=
path_buff
;
fn_format
(
path_buff
,
file
.
str
,
dir
.
str
,
0
,
MY_UNPACK_FILENAME
);
path
.
length
=
strlen
(
path_buff
);
...
...
@@ -424,7 +424,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
/*
read revision number
TODO: read dependense list, too, to process cascade/restrict
TODO: special cascade/restrict procedure for alter?
*/
...
...
@@ -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
);
}
...
...
sql/table.cc
View file @
392292a4
...
...
@@ -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
;
...
...
sql/table.h
View file @
392292a4
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment