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
18f033b7
Commit
18f033b7
authored
Nov 12, 2004
by
dlenev@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/dlenev/src/mysql-5.0-bg5890
parents
232abd5f
e7a24660
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
2 deletions
+42
-2
mysql-test/r/trigger.result
mysql-test/r/trigger.result
+12
-0
mysql-test/t/trigger.test
mysql-test/t/trigger.test
+17
-0
sql/sql_delete.cc
sql/sql_delete.cc
+7
-2
sql/sql_trigger.h
sql/sql_trigger.h
+6
-0
No files found.
mysql-test/r/trigger.result
View file @
18f033b7
...
@@ -174,3 +174,15 @@ create trigger tx1 before insert on t1 for each row set new.x1col = 'x';
...
@@ -174,3 +174,15 @@ create trigger tx1 before insert on t1 for each row set new.x1col = 'x';
insert into t1 values ('y');
insert into t1 values ('y');
drop trigger t1.tx1;
drop trigger t1.tx1;
drop table t1;
drop table t1;
create table t1 (i int) engine=myisam;
insert into t1 values (1), (2);
create trigger trg1 before delete on t1 for each row set @del_before:= @del_before + old.i;
create trigger trg2 after delete on t1 for each row set @del_after:= @del_after + old.i;
set @del_before:=0, @del_after:= 0;
delete from t1;
select @del_before, @del_after;
@del_before @del_after
3 3
drop trigger t1.trg1;
drop trigger t1.trg2;
drop table t1;
mysql-test/t/trigger.test
View file @
18f033b7
...
@@ -207,3 +207,20 @@ create trigger tx1 before insert on t1 for each row set new.x1col = 'x';
...
@@ -207,3 +207,20 @@ create trigger tx1 before insert on t1 for each row set new.x1col = 'x';
insert
into
t1
values
(
'y'
);
insert
into
t1
values
(
'y'
);
drop
trigger
t1
.
tx1
;
drop
trigger
t1
.
tx1
;
drop
table
t1
;
drop
table
t1
;
#
# Test for bug #5890 "Triggers fail for DELETE without WHERE".
# If we are going to delete all rows in table but DELETE triggers exist
# we should perform row-by-row deletion instead of using optimized
# delete_all_rows() method.
#
create
table
t1
(
i
int
)
engine
=
myisam
;
insert
into
t1
values
(
1
),
(
2
);
create
trigger
trg1
before
delete
on
t1
for
each
row
set
@
del_before
:=
@
del_before
+
old
.
i
;
create
trigger
trg2
after
delete
on
t1
for
each
row
set
@
del_after
:=
@
del_after
+
old
.
i
;
set
@
del_before
:=
0
,
@
del_after
:=
0
;
delete
from
t1
;
select
@
del_before
,
@
del_after
;
drop
trigger
t1
.
trg1
;
drop
trigger
t1
.
trg2
;
drop
table
t1
;
sql/sql_delete.cc
View file @
18f033b7
...
@@ -63,9 +63,14 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, SQL_LIST *order,
...
@@ -63,9 +63,14 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, SQL_LIST *order,
if
(
thd
->
lex
->
duplicates
==
DUP_IGNORE
)
if
(
thd
->
lex
->
duplicates
==
DUP_IGNORE
)
select_lex
->
no_error
=
1
;
select_lex
->
no_error
=
1
;
/* Test if the user wants to delete all rows */
/*
Test if the user wants to delete all rows and deletion doesn't have
any side-effects (because of triggers), so we can use optimized
handler::delete_all_rows() method.
*/
if
(
!
using_limit
&&
const_cond
&&
(
!
conds
||
conds
->
val_int
())
&&
if
(
!
using_limit
&&
const_cond
&&
(
!
conds
||
conds
->
val_int
())
&&
!
(
specialflag
&
(
SPECIAL_NO_NEW_FUNC
|
SPECIAL_SAFE_MODE
)))
!
(
specialflag
&
(
SPECIAL_NO_NEW_FUNC
|
SPECIAL_SAFE_MODE
))
&&
!
(
table
->
triggers
&&
table
->
triggers
->
has_delete_triggers
()))
{
{
deleted
=
table
->
file
->
records
;
deleted
=
table
->
file
->
records
;
if
(
!
(
error
=
table
->
file
->
delete_all_rows
()))
if
(
!
(
error
=
table
->
file
->
delete_all_rows
()))
...
...
sql/sql_trigger.h
View file @
18f033b7
...
@@ -58,5 +58,11 @@ public:
...
@@ -58,5 +58,11 @@ public:
static
bool
check_n_load
(
THD
*
thd
,
const
char
*
db
,
const
char
*
table_name
,
static
bool
check_n_load
(
THD
*
thd
,
const
char
*
db
,
const
char
*
table_name
,
TABLE
*
table
);
TABLE
*
table
);
bool
has_delete_triggers
()
{
return
(
bodies
[
TRG_EVENT_DELETE
][
TRG_ACTION_BEFORE
]
||
bodies
[
TRG_EVENT_DELETE
][
TRG_ACTION_AFTER
]);
}
friend
class
Item_trigger_field
;
friend
class
Item_trigger_field
;
};
};
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