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
98b3f288
Commit
98b3f288
authored
Nov 05, 2017
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-14217 [db crash] Recursive CTE when SELECT includes new field
parent
4e34eaf1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
7 deletions
+62
-7
mysql-test/r/cte_recursive.result
mysql-test/r/cte_recursive.result
+23
-0
mysql-test/t/cte_recursive.test
mysql-test/t/cte_recursive.test
+28
-0
sql/sql_union.cc
sql/sql_union.cc
+11
-7
No files found.
mysql-test/r/cte_recursive.result
View file @
98b3f288
...
@@ -2881,3 +2881,26 @@ f
...
@@ -2881,3 +2881,26 @@ f
2
2
set standard_compliant_cte=default;
set standard_compliant_cte=default;
DROP TABLE t;
DROP TABLE t;
#
# MDEV-14217 [db crash] Recursive CTE when SELECT includes new field
#
CREATE TEMPORARY TABLE a_tbl (
a VARCHAR(33) PRIMARY KEY,
b VARCHAR(33)
);
INSERT INTO a_tbl VALUES ('block0', 'block0'), ('block1', NULL);
WITH RECURSIVE Q0 AS (
SELECT T0.a, T0.b, 5
FROM a_tbl T0
WHERE b IS NULL
UNION ALL
SELECT T1.a, T1.b
FROM Q0
JOIN a_tbl T1
ON T1.a=Q0.a
) SELECT distinct(Q0.a), Q0.b
FROM Q0;
ERROR 21000: The used SELECT statements have a different number of columns
DROP TABLE a_tbl;
WITH RECURSIVE x AS (SELECT 1,2 UNION ALL SELECT 1 FROM x) SELECT * FROM x;
ERROR 21000: The used SELECT statements have a different number of columns
mysql-test/t/cte_recursive.test
View file @
98b3f288
...
@@ -1928,3 +1928,31 @@ set standard_compliant_cte=default;
...
@@ -1928,3 +1928,31 @@ set standard_compliant_cte=default;
DROP
TABLE
t
;
DROP
TABLE
t
;
--
echo
#
--
echo
# MDEV-14217 [db crash] Recursive CTE when SELECT includes new field
--
echo
#
CREATE
TEMPORARY
TABLE
a_tbl
(
a
VARCHAR
(
33
)
PRIMARY
KEY
,
b
VARCHAR
(
33
)
);
INSERT
INTO
a_tbl
VALUES
(
'block0'
,
'block0'
),
(
'block1'
,
NULL
);
--
error
ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
WITH
RECURSIVE
Q0
AS
(
SELECT
T0
.
a
,
T0
.
b
,
5
FROM
a_tbl
T0
WHERE
b
IS
NULL
UNION
ALL
SELECT
T1
.
a
,
T1
.
b
FROM
Q0
JOIN
a_tbl
T1
ON
T1
.
a
=
Q0
.
a
)
SELECT
distinct
(
Q0
.
a
),
Q0
.
b
FROM
Q0
;
DROP
TABLE
a_tbl
;
--
error
ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
WITH
RECURSIVE
x
AS
(
SELECT
1
,
2
UNION
ALL
SELECT
1
FROM
x
)
SELECT
*
FROM
x
;
sql/sql_union.cc
View file @
98b3f288
...
@@ -770,13 +770,7 @@ bool st_select_lex_unit::join_union_type_handlers(THD *thd_arg,
...
@@ -770,13 +770,7 @@ bool st_select_lex_unit::join_union_type_handlers(THD *thd_arg,
holders
[
pos
].
set_handler
(
item_type_handler
);
holders
[
pos
].
set_handler
(
item_type_handler
);
else
else
{
{
if
(
first_sl
->
item_list
.
elements
!=
sl
->
item_list
.
elements
)
DBUG_ASSERT
(
first_sl
->
item_list
.
elements
==
sl
->
item_list
.
elements
);
{
my_message
(
ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
,
ER_THD
(
thd_arg
,
ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
),
MYF
(
0
));
DBUG_RETURN
(
true
);
}
if
(
holders
[
pos
].
aggregate_for_result
(
item_type_handler
))
if
(
holders
[
pos
].
aggregate_for_result
(
item_type_handler
))
{
{
my_error
(
ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
,
MYF
(
0
),
my_error
(
ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
,
MYF
(
0
),
...
@@ -1024,6 +1018,16 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
...
@@ -1024,6 +1018,16 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
goto
err
;
goto
err
;
}
}
}
}
else
{
if
(
first_sl
->
item_list
.
elements
!=
sl
->
item_list
.
elements
)
{
my_message
(
ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
,
ER_THD
(
thd_arg
,
ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
),
MYF
(
0
));
goto
err
;
}
}
if
(
is_recursive
)
if
(
is_recursive
)
{
{
if
(
!
with_element
->
is_anchor
(
sl
))
if
(
!
with_element
->
is_anchor
(
sl
))
...
...
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