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
59d239e1
Commit
59d239e1
authored
Jul 03, 2009
by
Sergey Glukhov
Browse files
Options
Browse Files
Download
Plain Diff
5.0-bugteam->5.1-bugteam merge
parents
45d59063
2dd70946
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
172 additions
and
3 deletions
+172
-3
mysql-test/r/view.result
mysql-test/r/view.result
+111
-0
mysql-test/t/view.test
mysql-test/t/view.test
+32
-0
sql/sql_insert.cc
sql/sql_insert.cc
+29
-3
No files found.
mysql-test/r/view.result
View file @
59d239e1
...
@@ -3718,6 +3718,117 @@ DROP TABLE t1;
...
@@ -3718,6 +3718,117 @@ DROP TABLE t1;
# -- End of test case for Bug#40825
# -- End of test case for Bug#40825
#
# Bug #45806 crash when replacing into a view with a join!
#
CREATE TABLE t1(a INT UNIQUE);
CREATE VIEW v1 AS SELECT t1.a FROM t1, t1 AS a;
INSERT INTO t1 VALUES (1), (2);
REPLACE INTO v1(a) SELECT 1 FROM t1,t1 AS c;
SELECT * FROM v1;
a
1
2
1
2
REPLACE INTO v1(a) SELECT 3 FROM t1,t1 AS c;
SELECT * FROM v1;
a
1
2
3
1
2
3
1
2
3
DELETE FROM t1 WHERE a=3;
INSERT INTO v1(a) SELECT 1 FROM t1,t1 AS c
ON DUPLICATE KEY UPDATE `v1`.`a`= 1;
SELECT * FROM v1;
a
1
2
1
2
CREATE VIEW v2 AS SELECT t1.a FROM t1, v1 AS a;
REPLACE INTO v2(a) SELECT 1 FROM t1,t1 AS c;
SELECT * FROM v2;
a
1
2
1
2
1
2
1
2
REPLACE INTO v2(a) SELECT 3 FROM t1,t1 AS c;
SELECT * FROM v2;
a
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
INSERT INTO v2(a) SELECT 1 FROM t1,t1 AS c
ON DUPLICATE KEY UPDATE `v2`.`a`= 1;
SELECT * FROM v2;
a
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
DROP VIEW v1;
DROP VIEW v2;
DROP TABLE t1;
# -- End of test case for Bug#45806
# -----------------------------------------------------------------
# -----------------------------------------------------------------
# -- End of 5.0 tests.
# -- End of 5.0 tests.
# -----------------------------------------------------------------
# -----------------------------------------------------------------
...
...
mysql-test/t/view.test
View file @
59d239e1
...
@@ -3703,6 +3703,38 @@ DROP TABLE t1;
...
@@ -3703,6 +3703,38 @@ DROP TABLE t1;
--
echo
# -- End of test case for Bug#40825
--
echo
# -- End of test case for Bug#40825
--
echo
--
echo
--
echo
#
--
echo
# Bug #45806 crash when replacing into a view with a join!
--
echo
#
CREATE
TABLE
t1
(
a
INT
UNIQUE
);
CREATE
VIEW
v1
AS
SELECT
t1
.
a
FROM
t1
,
t1
AS
a
;
INSERT
INTO
t1
VALUES
(
1
),
(
2
);
REPLACE
INTO
v1
(
a
)
SELECT
1
FROM
t1
,
t1
AS
c
;
SELECT
*
FROM
v1
;
REPLACE
INTO
v1
(
a
)
SELECT
3
FROM
t1
,
t1
AS
c
;
SELECT
*
FROM
v1
;
DELETE
FROM
t1
WHERE
a
=
3
;
INSERT
INTO
v1
(
a
)
SELECT
1
FROM
t1
,
t1
AS
c
ON
DUPLICATE
KEY
UPDATE
`v1`
.
`a`
=
1
;
SELECT
*
FROM
v1
;
CREATE
VIEW
v2
AS
SELECT
t1
.
a
FROM
t1
,
v1
AS
a
;
REPLACE
INTO
v2
(
a
)
SELECT
1
FROM
t1
,
t1
AS
c
;
SELECT
*
FROM
v2
;
REPLACE
INTO
v2
(
a
)
SELECT
3
FROM
t1
,
t1
AS
c
;
SELECT
*
FROM
v2
;
INSERT
INTO
v2
(
a
)
SELECT
1
FROM
t1
,
t1
AS
c
ON
DUPLICATE
KEY
UPDATE
`v2`
.
`a`
=
1
;
SELECT
*
FROM
v2
;
DROP
VIEW
v1
;
DROP
VIEW
v2
;
DROP
TABLE
t1
;
--
echo
# -- End of test case for Bug#45806
--
echo
# -----------------------------------------------------------------
--
echo
# -----------------------------------------------------------------
--
echo
# -- End of 5.0 tests.
--
echo
# -- End of 5.0 tests.
--
echo
# -----------------------------------------------------------------
--
echo
# -----------------------------------------------------------------
...
...
sql/sql_insert.cc
View file @
59d239e1
...
@@ -1115,6 +1115,33 @@ static bool mysql_prepare_insert_check_table(THD *thd, TABLE_LIST *table_list,
...
@@ -1115,6 +1115,33 @@ static bool mysql_prepare_insert_check_table(THD *thd, TABLE_LIST *table_list,
}
}
/*
Get extra info for tables we insert into
@param table table(TABLE object) we insert into,
might be NULL in case of view
@param table(TABLE_LIST object) or view we insert into
*/
static
void
prepare_for_positional_update
(
TABLE
*
table
,
TABLE_LIST
*
tables
)
{
if
(
table
)
{
if
(
table
->
reginfo
.
lock_type
!=
TL_WRITE_DELAYED
)
table
->
prepare_for_position
();
return
;
}
DBUG_ASSERT
(
tables
->
view
);
List_iterator
<
TABLE_LIST
>
it
(
*
tables
->
view_tables
);
TABLE_LIST
*
tbl
;
while
((
tbl
=
it
++
))
prepare_for_positional_update
(
tbl
->
table
,
tbl
);
return
;
}
/*
/*
Prepare items in INSERT statement
Prepare items in INSERT statement
...
@@ -1264,9 +1291,8 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
...
@@ -1264,9 +1291,8 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
Only call prepare_for_posistion() if we are not performing a DELAYED
Only call prepare_for_posistion() if we are not performing a DELAYED
operation. It will instead be executed by delayed insert thread.
operation. It will instead be executed by delayed insert thread.
*/
*/
if
((
duplic
==
DUP_UPDATE
||
duplic
==
DUP_REPLACE
)
&&
if
(
duplic
==
DUP_UPDATE
||
duplic
==
DUP_REPLACE
)
(
table
->
reginfo
.
lock_type
!=
TL_WRITE_DELAYED
))
prepare_for_positional_update
(
table
,
table_list
);
table
->
prepare_for_position
();
DBUG_RETURN
(
FALSE
);
DBUG_RETURN
(
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