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
fd4db68c
Commit
fd4db68c
authored
Jan 12, 2007
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge ibabaev@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into olga.mysql.com:/home/igor/mysql-5.0-opt
parents
6746efb1
35e36393
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
0 deletions
+81
-0
mysql-test/r/trigger.result
mysql-test/r/trigger.result
+32
-0
mysql-test/t/trigger.test
mysql-test/t/trigger.test
+46
-0
sql/item.h
sql/item.h
+3
-0
No files found.
mysql-test/r/trigger.result
View file @
fd4db68c
...
...
@@ -1278,4 +1278,36 @@ a b
2 b
3 c
drop table t1;
CREATE TABLE t1 (
id int NOT NULL DEFAULT '0',
a varchar(10) NOT NULL,
b varchar(10),
c varchar(10),
d timestamp NOT NULL,
PRIMARY KEY (id, a)
);
CREATE TABLE t2 (
fubar_id int unsigned NOT NULL DEFAULT '0',
last_change_time datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (fubar_id)
);
CREATE TRIGGER fubar_change
AFTER UPDATE ON t1
FOR EACH ROW
BEGIN
INSERT INTO t2 (fubar_id, last_change_time)
SELECT DISTINCT NEW.id AS fubar_id, NOW() AS last_change_time
FROM t1 WHERE (id = NEW.id) AND (OLD.c != NEW.c)
ON DUPLICATE KEY UPDATE
last_change_time =
IF((fubar_id = NEW.id)AND(OLD.c != NEW.c),NOW(),last_change_time);
END
|
INSERT INTO t1 (id,a, b,c,d) VALUES
(1,'a','b','c',now()),(2,'a','b','c',now());
UPDATE t1 SET c='Bang!' WHERE id=1;
SELECT fubar_id FROM t2;
fubar_id
1
DROP TABLE t1,t2;
End of 5.0 tests
mysql-test/t/trigger.test
View file @
fd4db68c
...
...
@@ -1548,4 +1548,50 @@ select * from t1;
drop
table
t1
;
#
# Bug#25398: crash when a trigger contains a SELECT with
# trigger fields in the select list under DISTINCT
#
CREATE
TABLE
t1
(
id
int
NOT
NULL
DEFAULT
'0'
,
a
varchar
(
10
)
NOT
NULL
,
b
varchar
(
10
),
c
varchar
(
10
),
d
timestamp
NOT
NULL
,
PRIMARY
KEY
(
id
,
a
)
);
CREATE
TABLE
t2
(
fubar_id
int
unsigned
NOT
NULL
DEFAULT
'0'
,
last_change_time
datetime
NOT
NULL
DEFAULT
'0000-00-00 00:00:00'
,
PRIMARY
KEY
(
fubar_id
)
);
DELIMITER
|
;
CREATE
TRIGGER
fubar_change
AFTER
UPDATE
ON
t1
FOR
EACH
ROW
BEGIN
INSERT
INTO
t2
(
fubar_id
,
last_change_time
)
SELECT
DISTINCT
NEW
.
id
AS
fubar_id
,
NOW
()
AS
last_change_time
FROM
t1
WHERE
(
id
=
NEW
.
id
)
AND
(
OLD
.
c
!=
NEW
.
c
)
ON
DUPLICATE
KEY
UPDATE
last_change_time
=
IF
((
fubar_id
=
NEW
.
id
)
AND
(
OLD
.
c
!=
NEW
.
c
),
NOW
(),
last_change_time
);
END
|
DELIMITER
;
|
INSERT
INTO
t1
(
id
,
a
,
b
,
c
,
d
)
VALUES
(
1
,
'a'
,
'b'
,
'c'
,
now
()),(
2
,
'a'
,
'b'
,
'c'
,
now
());
UPDATE
t1
SET
c
=
'Bang!'
WHERE
id
=
1
;
SELECT
fubar_id
FROM
t2
;
DROP
TABLE
t1
,
t2
;
--
echo
End
of
5.0
tests
sql/item.h
View file @
fd4db68c
...
...
@@ -2269,6 +2269,9 @@ public:
bool
fix_fields
(
THD
*
,
Item
**
);
void
print
(
String
*
str
);
table_map
used_tables
()
const
{
return
(
table_map
)
0L
;
}
Field
*
get_tmp_table_field
()
{
return
0
;
}
Item
*
copy_or_same
(
THD
*
thd
)
{
return
this
;
}
Item
*
get_tmp_table_item
(
THD
*
thd
)
{
return
copy_or_same
(
thd
);
}
void
cleanup
();
private:
...
...
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