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
44d814f5
Commit
44d814f5
authored
Mar 12, 2008
by
anozdrin/alik@quad
Browse files
Options
Browse Files
Download
Plain Diff
Merge quad.:/mnt/raid/alik/MySQL/devel/5.0-rt
into quad.:/mnt/raid/alik/MySQL/devel/5.1-rt-merged
parents
a590e732
2b09a993
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
6 deletions
+63
-6
mysql-test/r/trigger-trans.result
mysql-test/r/trigger-trans.result
+19
-0
mysql-test/t/trigger-trans.test
mysql-test/t/trigger-trans.test
+32
-0
sql/sql_delete.cc
sql/sql_delete.cc
+12
-6
No files found.
mysql-test/r/trigger-trans.result
View file @
44d814f5
...
...
@@ -140,4 +140,23 @@ select * from t3;
c
1
drop table t1, t2, t3;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=innodb;
CREATE TABLE t2(b INT, FOREIGN KEY(b) REFERENCES t1(a)) ENGINE=innodb;
INSERT INTO t1 VALUES (1);
CREATE TRIGGER t1_bd BEFORE DELETE ON t1 FOR EACH ROW SET @a = 1;
CREATE TRIGGER t1_ad AFTER DELETE ON t1 FOR EACH ROW SET @b = 1;
SET @a = 0;
SET @b = 0;
TRUNCATE t1;
SELECT @a, @b;
@a @b
0 0
INSERT INTO t1 VALUES (1);
DELETE FROM t1;
SELECT @a, @b;
@a @b
1 1
DROP TABLE t2, t1;
End of 5.0 tests
mysql-test/t/trigger-trans.test
View file @
44d814f5
...
...
@@ -128,5 +128,37 @@ drop table t1, t2, t3;
disconnect
connection_update
;
disconnect
connection_aux
;
#
# Bug#34643: TRUNCATE crash if trigger and foreign key.
#
--
disable_warnings
DROP
TABLE
IF
EXISTS
t1
;
DROP
TABLE
IF
EXISTS
t2
;
--
enable_warnings
CREATE
TABLE
t1
(
a
INT
PRIMARY
KEY
)
ENGINE
=
innodb
;
CREATE
TABLE
t2
(
b
INT
,
FOREIGN
KEY
(
b
)
REFERENCES
t1
(
a
))
ENGINE
=
innodb
;
INSERT
INTO
t1
VALUES
(
1
);
CREATE
TRIGGER
t1_bd
BEFORE
DELETE
ON
t1
FOR
EACH
ROW
SET
@
a
=
1
;
CREATE
TRIGGER
t1_ad
AFTER
DELETE
ON
t1
FOR
EACH
ROW
SET
@
b
=
1
;
SET
@
a
=
0
;
SET
@
b
=
0
;
TRUNCATE
t1
;
SELECT
@
a
,
@
b
;
INSERT
INTO
t1
VALUES
(
1
);
DELETE
FROM
t1
;
SELECT
@
a
,
@
b
;
DROP
TABLE
t2
,
t1
;
--
echo
End
of
5.0
tests
sql/sql_delete.cc
View file @
44d814f5
...
...
@@ -45,6 +45,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
bool
transactional_table
,
safe_update
,
const_cond
;
bool
const_cond_result
;
ha_rows
deleted
=
0
;
bool
triggers_applicable
;
uint
usable_index
=
MAX_KEY
;
SELECT_LEX
*
select_lex
=
&
thd
->
lex
->
select_lex
;
THD
::
killed_state
killed_status
=
THD
::
NOT_KILLED
;
...
...
@@ -102,6 +103,11 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
/* Error evaluating val_int(). */
DBUG_RETURN
(
TRUE
);
}
/* NOTE: TRUNCATE must not invoke triggers. */
triggers_applicable
=
table
->
triggers
&&
thd
->
lex
->
sql_command
!=
SQLCOM_TRUNCATE
;
/*
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
...
...
@@ -123,9 +129,9 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
*/
if
(
!
using_limit
&&
const_cond_result
&&
!
(
specialflag
&
(
SPECIAL_NO_NEW_FUNC
|
SPECIAL_SAFE_MODE
))
&&
(
thd
->
lex
->
sql_command
==
SQLCOM_TRUNCATE
||
(
!
thd
->
current_stmt_binlog_row_based
&&
!
(
table
->
triggers
&&
table
->
triggers
->
has_delete_triggers
()))
))
!
triggers_applicable
&&
!
thd
->
current_stmt_binlog_row_based
&&
!
table
->
triggers
->
has_delete_triggers
(
))
{
/* Update the table->file->stats.records number */
table
->
file
->
info
(
HA_STATUS_VARIABLE
|
HA_STATUS_NO_LOCK
);
...
...
@@ -249,7 +255,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
init_ftfuncs
(
thd
,
select_lex
,
1
);
thd_proc_info
(
thd
,
"updating"
);
if
(
t
able
->
triggers
&&
if
(
t
riggers_applicable
&&
table
->
triggers
->
has_triggers
(
TRG_EVENT_DELETE
,
TRG_ACTION_AFTER
))
{
...
...
@@ -274,7 +280,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
if
(
!
(
select
&&
select
->
skip_record
())
&&
!
thd
->
is_error
()
)
{
if
(
t
able
->
triggers
&&
if
(
t
riggers_applicable
&&
table
->
triggers
->
process_triggers
(
thd
,
TRG_EVENT_DELETE
,
TRG_ACTION_BEFORE
,
FALSE
))
{
...
...
@@ -285,7 +291,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
if
(
!
(
error
=
table
->
file
->
ha_delete_row
(
table
->
record
[
0
])))
{
deleted
++
;
if
(
t
able
->
triggers
&&
if
(
t
riggers_applicable
&&
table
->
triggers
->
process_triggers
(
thd
,
TRG_EVENT_DELETE
,
TRG_ACTION_AFTER
,
FALSE
))
{
...
...
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