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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
52d4103c
Commit
52d4103c
authored
Feb 03, 2012
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed DELETE issues of view over view over table.
parent
b9616d81
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
2 deletions
+35
-2
mysql-test/r/view.result
mysql-test/r/view.result
+18
-0
mysql-test/t/view.test
mysql-test/t/view.test
+14
-0
sql/sql_delete.cc
sql/sql_delete.cc
+3
-2
No files found.
mysql-test/r/view.result
View file @
52d4103c
...
...
@@ -3943,12 +3943,20 @@ REPLACE v1 SET a = 10;
ERROR HY000: The target table v1 of the INSERT is not insertable-into
INSERT into v1 values (20);
ERROR HY000: The target table v1 of the INSERT is not insertable-into
DELETE from v1;
ERROR HY000: The target table v1 of the DELETE is not updatable
UPDATE v3 SET b= 10;
ERROR HY000: The target table v2 of the UPDATE is not updatable
REPLACE v3 SET b= 10;
ERROR HY000: The target table v3 of the INSERT is not insertable-into
INSERT into v3(b) values (20);
ERROR HY000: The target table v3 of the INSERT is not insertable-into
DELETE from v3 where b=20;
ERROR HY000: Can not delete from join view 'test.v3'
DELETE from v3 where a=20;
ERROR HY000: Can not delete from join view 'test.v3'
DELETE v1 from v1,t1 where v1.a=t1.a;
ERROR HY000: The target table v1 of the DELETE is not updatable
UPDATE v3 SET a = 10;
REPLACE v3 SET a = 11;
INSERT INTO v3(a) values (20);
...
...
@@ -3960,6 +3968,16 @@ a
10
11
20
CREATE OR REPLACE ALGORITHM = MERGE VIEW v2 AS SELECT * FROM t2;
DELETE from v1 where a=11;
DELETE v1 from v1,t1 where v1.a=t1.a;
select * from t1;
a
1
select * from t2;
a
10
20
DROP VIEW v1,v2,v3;
DROP TABLE t1,t2;
# -----------------------------------------------------------------
...
...
mysql-test/t/view.test
View file @
52d4103c
...
...
@@ -3998,11 +3998,19 @@ REPLACE v1 SET a = 10;
--
error
ER_NON_INSERTABLE_TABLE
INSERT
into
v1
values
(
20
);
--
error
ER_NON_UPDATABLE_TABLE
DELETE
from
v1
;
--
error
ER_NON_UPDATABLE_TABLE
UPDATE
v3
SET
b
=
10
;
--
error
ER_NON_INSERTABLE_TABLE
REPLACE
v3
SET
b
=
10
;
--
error
ER_NON_INSERTABLE_TABLE
INSERT
into
v3
(
b
)
values
(
20
);
--
error
ER_VIEW_DELETE_MERGE_VIEW
DELETE
from
v3
where
b
=
20
;
--
error
ER_VIEW_DELETE_MERGE_VIEW
DELETE
from
v3
where
a
=
20
;
--
error
ER_NON_UPDATABLE_TABLE
DELETE
v1
from
v1
,
t1
where
v1
.
a
=
t1
.
a
;
UPDATE
v3
SET
a
=
10
;
REPLACE
v3
SET
a
=
11
;
INSERT
INTO
v3
(
a
)
values
(
20
);
...
...
@@ -4010,6 +4018,12 @@ INSERT INTO v3(a) values (20);
select
*
from
t1
;
select
*
from
t2
;
CREATE
OR
REPLACE
ALGORITHM
=
MERGE
VIEW
v2
AS
SELECT
*
FROM
t2
;
DELETE
from
v1
where
a
=
11
;
DELETE
v1
from
v1
,
t1
where
v1
.
a
=
t1
.
a
;
select
*
from
t1
;
select
*
from
t2
;
DROP
VIEW
v1
,
v2
,
v3
;
DROP
TABLE
t1
,
t2
;
...
...
sql/sql_delete.cc
View file @
52d4103c
...
...
@@ -508,7 +508,8 @@ int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds)
setup_conds
(
thd
,
table_list
,
select_lex
->
leaf_tables
,
conds
)
||
setup_ftfuncs
(
select_lex
))
DBUG_RETURN
(
TRUE
);
if
(
!
table_list
->
updatable
||
check_key_in_view
(
thd
,
table_list
))
if
(
!
table_list
->
single_table_updatable
()
||
check_key_in_view
(
thd
,
table_list
))
{
my_error
(
ER_NON_UPDATABLE_TABLE
,
MYF
(
0
),
table_list
->
alias
,
"DELETE"
);
DBUG_RETURN
(
TRUE
);
...
...
@@ -598,7 +599,7 @@ int mysql_multi_delete_prepare(THD *thd)
DBUG_RETURN
(
TRUE
);
}
if
(
!
target_tbl
->
correspondent_table
->
updatable
||
if
(
!
target_tbl
->
correspondent_table
->
single_table_updatable
()
||
check_key_in_view
(
thd
,
target_tbl
->
correspondent_table
))
{
my_error
(
ER_NON_UPDATABLE_TABLE
,
MYF
(
0
),
...
...
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