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
9e2dcb5e
Commit
9e2dcb5e
authored
Apr 13, 2007
by
epotemkin@bk-internal.mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal.mysql.com:/data0/bk/mysql-5.0-opt
into bk-internal.mysql.com:/data0/bk/mysql-5.1-opt
parents
51d5c403
2a917850
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
78 additions
and
3 deletions
+78
-3
mysql-test/r/truncate.result
mysql-test/r/truncate.result
+27
-0
mysql-test/r/view.result
mysql-test/r/view.result
+10
-0
mysql-test/t/truncate.test
mysql-test/t/truncate.test
+32
-0
mysql-test/t/view.test
mysql-test/t/view.test
+2
-0
sql/sql_delete.cc
sql/sql_delete.cc
+6
-3
sql/sql_lex.cc
sql/sql_lex.cc
+1
-0
No files found.
mysql-test/r/truncate.result
View file @
9e2dcb5e
...
@@ -53,3 +53,30 @@ a
...
@@ -53,3 +53,30 @@ a
3
3
4
4
drop table t1;
drop table t1;
create table t1 (s1 int);
insert into t1 (s1) values (1), (2), (3), (4), (5);
create view v1 as select * from t1;
truncate table v1;
select count(*) from t1;
count(*)
0
insert into t1 (s1) values (1), (2), (3), (4), (5);
create view v2 as select * from t1 where s1 > 3;
truncate table v2;
select * from t1;
s1
1
2
3
select * from v2;
s1
delete from t1;
create table t2 (s1 int, s2 int);
create view v3 as select a.s1, b.s2 from t1 a join t2 b on a.s1 = b.s1 where a.s1 > 3;
truncate table v3;
ERROR HY000: Can not delete from join view 'test.v3'
create view v4 as select * from t1 limit 1,1;
truncate table v4;
ERROR HY000: The target table v4 of the TRUNCATE is not updatable
drop view v1, v2, v3, v4;
drop table t1, t2;
mysql-test/r/view.result
View file @
9e2dcb5e
...
@@ -2385,6 +2385,16 @@ Table Op Msg_type Msg_text
...
@@ -2385,6 +2385,16 @@ Table Op Msg_type Msg_text
test.v1 optimize error 'test.v1' is not BASE TABLE
test.v1 optimize error 'test.v1' is not BASE TABLE
Warnings:
Warnings:
Error 1347 'test.v1' is not BASE TABLE
Error 1347 'test.v1' is not BASE TABLE
ANALYZE TABLE v1;
Table Op Msg_type Msg_text
test.v1 analyze error 'test.v1' is not BASE TABLE
Warnings:
Error 1347 'test.v1' is not BASE TABLE
REPAIR TABLE v1;
Table Op Msg_type Msg_text
test.v1 repair error 'test.v1' is not BASE TABLE
Warnings:
Error 1347 'test.v1' is not BASE TABLE
DROP VIEW v1;
DROP VIEW v1;
create definer = current_user() sql security invoker view v1 as select 1;
create definer = current_user() sql security invoker view v1 as select 1;
show create view v1;
show create view v1;
...
...
mysql-test/t/truncate.test
View file @
9e2dcb5e
...
@@ -52,3 +52,35 @@ SELECT * from t1;
...
@@ -52,3 +52,35 @@ SELECT * from t1;
drop
table
t1
;
drop
table
t1
;
# End of 4.1 tests
# End of 4.1 tests
# Test for Bug#5507 "TRUNCATE should work with views"
create
table
t1
(
s1
int
);
insert
into
t1
(
s1
)
values
(
1
),
(
2
),
(
3
),
(
4
),
(
5
);
create
view
v1
as
select
*
from
t1
;
truncate
table
v1
;
select
count
(
*
)
from
t1
;
insert
into
t1
(
s1
)
values
(
1
),
(
2
),
(
3
),
(
4
),
(
5
);
create
view
v2
as
select
*
from
t1
where
s1
>
3
;
truncate
table
v2
;
select
*
from
t1
;
select
*
from
v2
;
delete
from
t1
;
# The following should fail
create
table
t2
(
s1
int
,
s2
int
);
create
view
v3
as
select
a
.
s1
,
b
.
s2
from
t1
a
join
t2
b
on
a
.
s1
=
b
.
s1
where
a
.
s1
>
3
;
--
error
1395
truncate
table
v3
;
# The following should fail
create
view
v4
as
select
*
from
t1
limit
1
,
1
;
--
error
1288
truncate
table
v4
;
drop
view
v1
,
v2
,
v3
,
v4
;
drop
table
t1
,
t2
;
# End of 5.0 tests
mysql-test/t/view.test
View file @
9e2dcb5e
...
@@ -2221,6 +2221,8 @@ REPAIR TABLE v1;
...
@@ -2221,6 +2221,8 @@ REPAIR TABLE v1;
DROP
TABLE
t1
;
DROP
TABLE
t1
;
OPTIMIZE
TABLE
v1
;
OPTIMIZE
TABLE
v1
;
ANALYZE
TABLE
v1
;
REPAIR
TABLE
v1
;
DROP
VIEW
v1
;
DROP
VIEW
v1
;
...
...
sql/sql_delete.cc
View file @
9e2dcb5e
...
@@ -394,6 +394,8 @@ bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds)
...
@@ -394,6 +394,8 @@ bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds)
{
{
Item
*
fake_conds
=
0
;
Item
*
fake_conds
=
0
;
SELECT_LEX
*
select_lex
=
&
thd
->
lex
->
select_lex
;
SELECT_LEX
*
select_lex
=
&
thd
->
lex
->
select_lex
;
const
char
*
operation
=
thd
->
lex
->
sql_command
==
SQLCOM_TRUNCATE
?
"TRUNCATE"
:
"DELETE"
;
DBUG_ENTER
(
"mysql_prepare_delete"
);
DBUG_ENTER
(
"mysql_prepare_delete"
);
List
<
Item
>
all_fields
;
List
<
Item
>
all_fields
;
...
@@ -408,14 +410,14 @@ bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds)
...
@@ -408,14 +410,14 @@ bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds)
DBUG_RETURN
(
TRUE
);
DBUG_RETURN
(
TRUE
);
if
(
!
table_list
->
updatable
||
check_key_in_view
(
thd
,
table_list
))
if
(
!
table_list
->
updatable
||
check_key_in_view
(
thd
,
table_list
))
{
{
my_error
(
ER_NON_UPDATABLE_TABLE
,
MYF
(
0
),
table_list
->
alias
,
"DELETE"
);
my_error
(
ER_NON_UPDATABLE_TABLE
,
MYF
(
0
),
table_list
->
alias
,
operation
);
DBUG_RETURN
(
TRUE
);
DBUG_RETURN
(
TRUE
);
}
}
{
{
TABLE_LIST
*
duplicate
;
TABLE_LIST
*
duplicate
;
if
((
duplicate
=
unique_table
(
thd
,
table_list
,
table_list
->
next_global
,
0
)))
if
((
duplicate
=
unique_table
(
thd
,
table_list
,
table_list
->
next_global
,
0
)))
{
{
update_non_unique_table_error
(
table_list
,
"DELETE"
,
duplicate
);
update_non_unique_table_error
(
table_list
,
operation
,
duplicate
);
DBUG_RETURN
(
TRUE
);
DBUG_RETURN
(
TRUE
);
}
}
}
}
...
@@ -933,7 +935,8 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
...
@@ -933,7 +935,8 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
if
(
!
dont_send_ok
)
if
(
!
dont_send_ok
)
{
{
enum
legacy_db_type
table_type
;
enum
legacy_db_type
table_type
;
mysql_frm_type
(
thd
,
path
,
&
table_type
);
if
(
mysql_frm_type
(
thd
,
path
,
&
table_type
)
==
FRMTYPE_VIEW
)
goto
trunc_by_del
;
if
(
table_type
==
DB_TYPE_UNKNOWN
)
if
(
table_type
==
DB_TYPE_UNKNOWN
)
{
{
my_error
(
ER_NO_SUCH_TABLE
,
MYF
(
0
),
my_error
(
ER_NO_SUCH_TABLE
,
MYF
(
0
),
...
...
sql/sql_lex.cc
View file @
9e2dcb5e
...
@@ -1835,6 +1835,7 @@ bool st_lex::can_use_merged()
...
@@ -1835,6 +1835,7 @@ bool st_lex::can_use_merged()
case
SQLCOM_UPDATE_MULTI
:
case
SQLCOM_UPDATE_MULTI
:
case
SQLCOM_DELETE
:
case
SQLCOM_DELETE
:
case
SQLCOM_DELETE_MULTI
:
case
SQLCOM_DELETE_MULTI
:
case
SQLCOM_TRUNCATE
:
case
SQLCOM_INSERT
:
case
SQLCOM_INSERT
:
case
SQLCOM_INSERT_SELECT
:
case
SQLCOM_INSERT_SELECT
:
case
SQLCOM_REPLACE
:
case
SQLCOM_REPLACE
:
...
...
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