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
f10effe4
Commit
f10effe4
authored
May 16, 2007
by
kostja@vajra.(none)
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal.mysql.com:/home/bk/mysql-5.0-runtime
into vajra.(none):/opt/local/work/mysql-5.0-21483
parents
35616ba5
747842e1
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
436 additions
and
77 deletions
+436
-77
mysql-test/r/insert.result
mysql-test/r/insert.result
+116
-0
mysql-test/t/insert.test
mysql-test/t/insert.test
+139
-0
sql/sp_head.cc
sql/sp_head.cc
+8
-0
sql/sql_base.cc
sql/sql_base.cc
+2
-2
sql/sql_insert.cc
sql/sql_insert.cc
+165
-75
sql/sql_lex.h
sql/sql_lex.h
+6
-0
No files found.
mysql-test/r/insert.result
View file @
f10effe4
...
@@ -346,3 +346,119 @@ f1 f2
...
@@ -346,3 +346,119 @@ f1 f2
12 NULL
12 NULL
drop view v1;
drop view v1;
drop table t1,t2;
drop table t1,t2;
DROP TABLE IF EXISTS t1;
DROP FUNCTION IF EXISTS f1;
DROP FUNCTION IF EXISTS f2;
CREATE TABLE t1 (i INT);
CREATE FUNCTION f1() RETURNS INT
BEGIN
INSERT INTO t1 VALUES (1);
RETURN 1;
END |
CREATE FUNCTION f2() RETURNS INT
BEGIN
INSERT DELAYED INTO t1 VALUES (2);
RETURN 1;
END |
SELECT f1();
f1()
1
SELECT f2();
f2()
1
INSERT INTO t1 VALUES (3);
INSERT DELAYED INTO t1 VALUES (4);
INSERT INTO t1 VALUES (f1());
ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
INSERT DELAYED INTO t1 VALUES (f1());
ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
INSERT INTO t1 VALUES (f2());
ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
INSERT DELAYED INTO t1 VALUES (f2());
ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
INSERT INTO t1 VALUES (NEW.i);
INSERT INTO t1 VALUES (1);
ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
INSERT DELAYED INTO t1 VALUES (1);
ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
SELECT * FROM t1;
i
1
2
3
4
DROP FUNCTION f2;
DROP FUNCTION f1;
DROP TABLE t1;
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (i INT);
CREATE TABLE t2 (i INT);
CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
INSERT DELAYED INTO t2 VALUES (NEW.i);
CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW
INSERT DELAYED INTO t2 VALUES (NEW.i);
CREATE TRIGGER t1_bd BEFORE DELETE ON t1 FOR EACH ROW
INSERT DELAYED INTO t2 VALUES (OLD.i);
INSERT INTO t1 VALUES (1);
INSERT DELAYED INTO t1 VALUES (2);
SELECT * FROM t1;
i
1
2
UPDATE t1 SET i = 3 WHERE i = 1;
SELECT * FROM t1;
i
3
2
DELETE FROM t1 WHERE i = 3;
SELECT * FROM t1;
i
2
SELECT * FROM t2;
i
1
2
3
3
DROP TABLE t1, t2;
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (i INT);
CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
SET @a= NEW.i;
SET @a= 0;
INSERT DELAYED INTO t1 VALUES (1);
SELECT @a;
@a
1
INSERT DELAYED INTO t1 VALUES (2);
SELECT @a;
@a
2
DROP TABLE t1;
CREATE TABLE t1 (i INT);
CREATE TABLE t2 (i INT);
CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW
INSERT INTO t2 VALUES (NEW.i);
CREATE TRIGGER t1_au AFTER UPDATE ON t1 FOR EACH ROW
INSERT DELAYED INTO t2 VALUES (NEW.i);
CREATE TRIGGER t1_ad AFTER DELETE ON t1 FOR EACH ROW
INSERT DELAYED INTO t2 VALUES (OLD.i);
INSERT DELAYED INTO t1 VALUES (1);
SELECT * FROM t1;
i
1
UPDATE t1 SET i = 2 WHERE i = 1;
SELECT * FROM t1;
i
2
DELETE FROM t1 WHERE i = 2;
SELECT * FROM t1;
i
SELECT * FROM t2;
i
1
2
2
DROP TABLE t1, t2;
End of 5.0 tests.
mysql-test/t/insert.test
View file @
f10effe4
...
@@ -216,3 +216,142 @@ select * from t1;
...
@@ -216,3 +216,142 @@ select * from t1;
drop
view
v1
;
drop
view
v1
;
drop
table
t1
,
t2
;
drop
table
t1
,
t2
;
#
# BUG#21483: Server abort or deadlock on INSERT DELAYED with another
# implicit insert
#
# The solution is to downgrade INSERT DELAYED to normal INSERT if the
# statement uses functions and access tables or triggers, or is called
# from a function or a trigger.
#
--
disable_warnings
DROP
TABLE
IF
EXISTS
t1
;
DROP
FUNCTION
IF
EXISTS
f1
;
DROP
FUNCTION
IF
EXISTS
f2
;
--
enable_warnings
CREATE
TABLE
t1
(
i
INT
);
delimiter
|
;
CREATE
FUNCTION
f1
()
RETURNS
INT
BEGIN
INSERT
INTO
t1
VALUES
(
1
);
RETURN
1
;
END
|
CREATE
FUNCTION
f2
()
RETURNS
INT
BEGIN
INSERT
DELAYED
INTO
t1
VALUES
(
2
);
RETURN
1
;
END
|
delimiter
;
|
SELECT
f1
();
SELECT
f2
();
INSERT
INTO
t1
VALUES
(
3
);
INSERT
DELAYED
INTO
t1
VALUES
(
4
);
--
error
ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
INSERT
INTO
t1
VALUES
(
f1
());
--
error
ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
INSERT
DELAYED
INTO
t1
VALUES
(
f1
());
--
error
ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
INSERT
INTO
t1
VALUES
(
f2
());
--
error
ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
INSERT
DELAYED
INTO
t1
VALUES
(
f2
());
CREATE
TRIGGER
t1_bi
BEFORE
INSERT
ON
t1
FOR
EACH
ROW
INSERT
INTO
t1
VALUES
(
NEW
.
i
);
--
error
ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
INSERT
INTO
t1
VALUES
(
1
);
--
error
ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
INSERT
DELAYED
INTO
t1
VALUES
(
1
);
SELECT
*
FROM
t1
;
DROP
FUNCTION
f2
;
DROP
FUNCTION
f1
;
DROP
TABLE
t1
;
#
# BUG#20497: Trigger with INSERT DELAYED causes Error 1165
#
# Fixed by the patch for Bug#21483
#
--
disable_warnings
DROP
TABLE
IF
EXISTS
t1
,
t2
;
--
enable_warnings
CREATE
TABLE
t1
(
i
INT
);
CREATE
TABLE
t2
(
i
INT
);
CREATE
TRIGGER
t1_bi
BEFORE
INSERT
ON
t1
FOR
EACH
ROW
INSERT
DELAYED
INTO
t2
VALUES
(
NEW
.
i
);
CREATE
TRIGGER
t1_bu
BEFORE
UPDATE
ON
t1
FOR
EACH
ROW
INSERT
DELAYED
INTO
t2
VALUES
(
NEW
.
i
);
CREATE
TRIGGER
t1_bd
BEFORE
DELETE
ON
t1
FOR
EACH
ROW
INSERT
DELAYED
INTO
t2
VALUES
(
OLD
.
i
);
INSERT
INTO
t1
VALUES
(
1
);
INSERT
DELAYED
INTO
t1
VALUES
(
2
);
SELECT
*
FROM
t1
;
UPDATE
t1
SET
i
=
3
WHERE
i
=
1
;
SELECT
*
FROM
t1
;
DELETE
FROM
t1
WHERE
i
=
3
;
SELECT
*
FROM
t1
;
SELECT
*
FROM
t2
;
DROP
TABLE
t1
,
t2
;
#
# BUG#21714: Wrong NEW.value and server abort on INSERT DELAYED to a
# table with a trigger
#
# Fixed by the patch for Bug#21483
#
--
disable_warnings
DROP
TABLE
IF
EXISTS
t1
,
t2
;
--
enable_warnings
CREATE
TABLE
t1
(
i
INT
);
CREATE
TRIGGER
t1_bi
BEFORE
INSERT
ON
t1
FOR
EACH
ROW
SET
@
a
=
NEW
.
i
;
SET
@
a
=
0
;
INSERT
DELAYED
INTO
t1
VALUES
(
1
);
SELECT
@
a
;
INSERT
DELAYED
INTO
t1
VALUES
(
2
);
SELECT
@
a
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
i
INT
);
CREATE
TABLE
t2
(
i
INT
);
CREATE
TRIGGER
t1_ai
AFTER
INSERT
ON
t1
FOR
EACH
ROW
INSERT
INTO
t2
VALUES
(
NEW
.
i
);
CREATE
TRIGGER
t1_au
AFTER
UPDATE
ON
t1
FOR
EACH
ROW
INSERT
DELAYED
INTO
t2
VALUES
(
NEW
.
i
);
CREATE
TRIGGER
t1_ad
AFTER
DELETE
ON
t1
FOR
EACH
ROW
INSERT
DELAYED
INTO
t2
VALUES
(
OLD
.
i
);
INSERT
DELAYED
INTO
t1
VALUES
(
1
);
SELECT
*
FROM
t1
;
UPDATE
t1
SET
i
=
2
WHERE
i
=
1
;
SELECT
*
FROM
t1
;
DELETE
FROM
t1
WHERE
i
=
2
;
SELECT
*
FROM
t1
;
SELECT
*
FROM
t2
;
DROP
TABLE
t1
,
t2
;
--
echo
End
of
5.0
tests
.
sql/sp_head.cc
View file @
f10effe4
...
@@ -3489,6 +3489,14 @@ sp_head::merge_table_list(THD *thd, TABLE_LIST *table, LEX *lex_for_tmp_check)
...
@@ -3489,6 +3489,14 @@ sp_head::merge_table_list(THD *thd, TABLE_LIST *table, LEX *lex_for_tmp_check)
tlen
+=
alen
;
tlen
+=
alen
;
tname
[
tlen
]
=
'\0'
;
tname
[
tlen
]
=
'\0'
;
/*
Upgrade the lock type because this table list will be used
only in pre-locked mode, in which DELAYED inserts are always
converted to normal inserts.
*/
if
(
table
->
lock_type
==
TL_WRITE_DELAYED
)
table
->
lock_type
=
TL_WRITE
;
/*
/*
We ignore alias when we check if table was already marked as temporary
We ignore alias when we check if table was already marked as temporary
(and therefore should not be prelocked). Otherwise we will erroneously
(and therefore should not be prelocked). Otherwise we will erroneously
...
...
sql/sql_base.cc
View file @
f10effe4
...
@@ -2633,7 +2633,7 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags)
...
@@ -2633,7 +2633,7 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags)
*/
*/
if
(
!
thd
->
prelocked_mode
&&
!
thd
->
lex
->
requires_prelocking
()
&&
if
(
!
thd
->
prelocked_mode
&&
!
thd
->
lex
->
requires_prelocking
()
&&
thd
->
lex
->
sroutines_list
.
elements
)
thd
->
lex
->
uses_stored_routines
()
)
{
{
bool
first_no_prelocking
,
need_prelocking
,
tabs_changed
;
bool
first_no_prelocking
,
need_prelocking
,
tabs_changed
;
TABLE_LIST
**
save_query_tables_last
=
thd
->
lex
->
query_tables_last
;
TABLE_LIST
**
save_query_tables_last
=
thd
->
lex
->
query_tables_last
;
...
@@ -2821,7 +2821,7 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags)
...
@@ -2821,7 +2821,7 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags)
*/
*/
if
(
tables
->
view
&&
!
thd
->
prelocked_mode
&&
if
(
tables
->
view
&&
!
thd
->
prelocked_mode
&&
!
thd
->
lex
->
requires_prelocking
()
&&
!
thd
->
lex
->
requires_prelocking
()
&&
tables
->
view
->
sroutines_list
.
elements
)
tables
->
view
->
uses_stored_routines
()
)
{
{
/* We have at least one table in TL here. */
/* We have at least one table in TL here. */
if
(
!
query_tables_last_own
)
if
(
!
query_tables_last_own
)
...
...
sql/sql_insert.cc
View file @
f10effe4
This diff is collapsed.
Click to expand it.
sql/sql_lex.h
View file @
f10effe4
...
@@ -886,6 +886,12 @@ class Query_tables_list
...
@@ -886,6 +886,12 @@ class Query_tables_list
query_tables_own_last
=
0
;
query_tables_own_last
=
0
;
}
}
}
}
/**
true if the parsed tree contains references to stored procedures
or functions, false otherwise
*/
bool
uses_stored_routines
()
const
{
return
sroutines_list
.
elements
!=
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