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
971538f4
Commit
971538f4
authored
May 25, 2016
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding various tests for combinations of
UNION, ROLLUP, GROUP_CONCAT, for better coverage.
parent
2fc6e790
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
439 additions
and
0 deletions
+439
-0
mysql-test/r/parser.result
mysql-test/r/parser.result
+257
-0
mysql-test/t/parser.test
mysql-test/t/parser.test
+182
-0
No files found.
mysql-test/r/parser.result
View file @
971538f4
This diff is collapsed.
Click to expand it.
mysql-test/t/parser.test
View file @
971538f4
...
...
@@ -1043,3 +1043,185 @@ INSERT INTO t1 SELECT 1 LIMIT 1 UNION SELECT 2;
CREATE
TABLE
t1
AS
SELECT
1
ORDER
BY
1
UNION
SELECT
2
;
--
error
ER_PARSE_ERROR
CREATE
TABLE
t1
AS
SELECT
1
LIMIT
1
UNION
SELECT
2
;
--
echo
#
--
echo
# MDEV-8909 union parser cleanup
--
echo
#
--
echo
# UNION with a non-parenthesized term
--
echo
# The following two queries return a wrong result
--
echo
# This will change when MDEV-10120 is fixed
--
echo
# For now, we're testing the parser.
CREATE
TABLE
t1
(
a
INT
);
INSERT
INTO
t1
VALUES
(
10
),(
20
),(
30
);
SELECT
1
AS
a
UNION
SELECT
a
FROM
t1
GROUP
BY
a
ORDER
BY
GROUP_CONCAT
(
a
);
SELECT
1
AS
a
UNION
SELECT
a
FROM
t1
GROUP
BY
a
ORDER
BY
GROUP_CONCAT
(
a
ORDER
BY
a
);
DROP
TABLE
t1
;
--
echo
# UNION with a parenthesed term
CREATE
TABLE
t1
(
a
INT
);
INSERT
INTO
t1
VALUES
(
10
),(
20
),(
30
);
SELECT
1
AS
a
UNION
(
SELECT
a
FROM
t1
GROUP
BY
a
ORDER
BY
GROUP_CONCAT
(
a
ORDER
BY
a
)
LIMIT
2
);
--
error
ER_INVALID_GROUP_FUNC_USE
SELECT
1
AS
a
UNION
(
SELECT
a
FROM
t1
GROUP
BY
a
ORDER
BY
GROUP_CONCAT
(
a
));
--
error
ER_INVALID_GROUP_FUNC_USE
SELECT
1
AS
a
UNION
(
SELECT
a
FROM
t1
GROUP
BY
a
ORDER
BY
GROUP_CONCAT
(
a
))
LIMIT
1
;
--
error
ER_INVALID_GROUP_FUNC_USE
SELECT
1
AS
a
UNION
(
SELECT
a
FROM
t1
GROUP
BY
a
ORDER
BY
GROUP_CONCAT
(
a
))
ORDER
BY
a
;
--
error
ER_INVALID_GROUP_FUNC_USE
SELECT
1
AS
a
UNION
(
SELECT
a
FROM
t1
GROUP
BY
a
ORDER
BY
GROUP_CONCAT
(
a
))
ORDER
BY
a
LIMIT
1
;
DROP
TABLE
t1
;
--
echo
# UNION with a parethesized term with ROLLUP
CREATE
TABLE
t1
(
a
INT
);
INSERT
INTO
t1
VALUES
(
10
),(
20
),(
30
);
--
error
ER_WRONG_USAGE
SELECT
1
AS
a
UNION
(
SELECT
a
FROM
t1
GROUP
BY
a
WITH
ROLLUP
);
--
error
ER_WRONG_USAGE
SELECT
1
AS
a
UNION
(
SELECT
a
FROM
t1
GROUP
BY
a
WITH
ROLLUP
)
LIMIT
1
;
--
error
ER_WRONG_USAGE
SELECT
1
AS
a
UNION
(
SELECT
a
FROM
t1
GROUP
BY
a
WITH
ROLLUP
)
ORDER
BY
a
LIMIT
1
;
--
error
ER_WRONG_USAGE
SELECT
1
AS
a
UNION
(
SELECT
a
FROM
t1
GROUP
BY
a
WITH
ROLLUP
LIMIT
2
);
--
error
ER_WRONG_USAGE
SELECT
1
AS
a
UNION
(
SELECT
a
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
a
);
--
error
ER_WRONG_USAGE
SELECT
1
AS
a
UNION
(
SELECT
a
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
GROUP_CONCAT
(
a
));
--
error
ER_WRONG_USAGE
SELECT
1
AS
a
UNION
(
SELECT
a
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
GROUP_CONCAT
(
a
ORDER
BY
a
));
DROP
TABLE
t1
;
--
echo
# UNION with a non-parethesized term with ROLLUP
--
echo
# This will change after: MDEV-10120 Wrong result of UNION .. ORDER BY GROUP_CONCAT()
--
echo
# Currently we're testing the parser only
CREATE
TABLE
t1
(
a
INT
);
INSERT
INTO
t1
VALUES
(
10
),(
20
),(
30
);
SELECT
1
AS
a
UNION
SELECT
a
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
GROUP_CONCAT
(
a
);
SELECT
1
AS
a
UNION
SELECT
a
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
GROUP_CONCAT
(
a
ORDER
BY
a
);
SELECT
1
AS
a
UNION
SELECT
a
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
GROUP_CONCAT
(
a
ORDER
BY
a
)
LIMIT
1
;
DROP
TABLE
t1
;
--
echo
# Derived table with ROLLUP
CREATE
TABLE
t1
(
a
INT
);
INSERT
INTO
t1
VALUES
(
10
),(
20
),(
30
);
SELECT
*
FROM
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
)
t1
;
SELECT
*
FROM
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
)
t1
LIMIT
1
;
SELECT
*
FROM
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
)
t1
ORDER
BY
a
;
SELECT
*
FROM
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
)
t1
ORDER
BY
a
LIMIT
1
;
SELECT
*
FROM
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
)
t1
ORDER
BY
a
DESC
LIMIT
1
;
SELECT
a
,
GROUP_CONCAT
(
a
)
FROM
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
)
t1
ORDER
BY
GROUP_CONCAT
(
a
);
SELECT
a
,
GROUP_CONCAT
(
a
)
FROM
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
)
t1
ORDER
BY
GROUP_CONCAT
(
a
ORDER
BY
a
);
SELECT
a
,
GROUP_CONCAT
(
a
)
FROM
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
)
t1
ORDER
BY
GROUP_CONCAT
(
a
)
LIMIT
1
;
SELECT
a
,
GROUP_CONCAT
(
a
)
FROM
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
)
t1
ORDER
BY
GROUP_CONCAT
(
a
ORDER
BY
a
)
LIMIT
1
;
SELECT
a
,
GROUP_CONCAT
(
a
)
FROM
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
)
t1
GROUP
BY
a
ORDER
BY
GROUP_CONCAT
(
a
);
SELECT
a
,
GROUP_CONCAT
(
a
)
FROM
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
)
t1
GROUP
BY
a
ORDER
BY
GROUP_CONCAT
(
a
ORDER
BY
a
);
SELECT
a
,
GROUP_CONCAT
(
a
)
FROM
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
)
t1
GROUP
BY
a
ORDER
BY
GROUP_CONCAT
(
a
)
DESC
;
SELECT
a
,
GROUP_CONCAT
(
a
)
FROM
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
)
t1
GROUP
BY
a
ORDER
BY
GROUP_CONCAT
(
a
ORDER
BY
a
)
DESC
;
SELECT
a
,
GROUP_CONCAT
(
a
)
FROM
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
)
t1
GROUP
BY
a
ORDER
BY
GROUP_CONCAT
(
a
)
LIMIT
1
;
SELECT
a
,
GROUP_CONCAT
(
a
)
FROM
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
)
t1
GROUP
BY
a
ORDER
BY
GROUP_CONCAT
(
a
ORDER
BY
a
)
LIMIT
1
;
SELECT
a
,
GROUP_CONCAT
(
a
)
FROM
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
)
t1
GROUP
BY
a
ORDER
BY
GROUP_CONCAT
(
a
)
DESC
LIMIT
1
;
SELECT
a
,
GROUP_CONCAT
(
a
)
FROM
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
)
t1
GROUP
BY
a
ORDER
BY
GROUP_CONCAT
(
a
ORDER
BY
a
)
DESC
LIMIT
1
;
--
error
ER_WRONG_USAGE
SELECT
*
FROM
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
a
)
t1
;
--
error
ER_WRONG_USAGE
SELECT
*
FROM
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
a
LIMIT
1
)
t1
;
--
error
ER_WRONG_USAGE
SELECT
*
FROM
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
GROUP_CONCAT
(
a
))
t1
;
--
error
ER_WRONG_USAGE
SELECT
*
FROM
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
GROUP_CONCAT
(
a
ORDER
BY
a
))
t1
;
DROP
TABLE
t1
;
--
echo
# Subquery, one row, ROLLUP
CREATE
TABLE
t1
(
a
INT
);
INSERT
INTO
t1
VALUES
(
10
);
SELECT
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
HAVING
a
IS
NULL
);
SELECT
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
HAVING
a
IS
NOT
NULL
);
SELECT
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
LIMIT
1
);
SELECT
(
SELECT
GROUP_CONCAT
(
a
)
FROM
t1
GROUP
BY
a
WITH
ROLLUP
LIMIT
1
);
SELECT
(
SELECT
GROUP_CONCAT
(
a
ORDER
BY
a
)
FROM
t1
GROUP
BY
a
WITH
ROLLUP
LIMIT
1
);
SELECT
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
HAVING
a
IS
NULL
)
FROM
t1
;
SELECT
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
HAVING
a
IS
NOT
NULL
)
FROM
t1
;
SELECT
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
LIMIT
1
)
FROM
t1
;
SELECT
(
SELECT
GROUP_CONCAT
(
a
)
FROM
t1
GROUP
BY
a
WITH
ROLLUP
LIMIT
1
)
FROM
t1
;
SELECT
(
SELECT
GROUP_CONCAT
(
a
ORDER
BY
a
)
FROM
t1
GROUP
BY
a
WITH
ROLLUP
LIMIT
1
)
FROM
t1
;
--
error
ER_SUBQUERY_NO_1_ROW
SELECT
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
);
--
error
ER_SUBQUERY_NO_1_ROW
SELECT
(
SELECT
GROUP_CONCAT
(
a
)
FROM
t1
GROUP
BY
a
WITH
ROLLUP
);
--
error
ER_SUBQUERY_NO_1_ROW
SELECT
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
)
FROM
t1
;
--
error
ER_SUBQUERY_NO_1_ROW
SELECT
(
SELECT
GROUP_CONCAT
(
a
)
FROM
t1
GROUP
BY
a
WITH
ROLLUP
)
FROM
t1
;
--
error
ER_WRONG_USAGE
SELECT
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
a
);
--
error
ER_WRONG_USAGE
SELECT
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
a
LIMIT
1
);
--
error
ER_WRONG_USAGE
SELECT
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
GROUP_CONCAT
(
a
));
--
error
ER_WRONG_USAGE
SELECT
(
SELECT
GROUP_CONCAT
(
a
ORDER
BY
a
)
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
a
LIMIT
1
)
AS
a
;
--
error
ER_WRONG_USAGE
SELECT
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
a
)
FROM
t1
;
--
error
ER_WRONG_USAGE
SELECT
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
a
LIMIT
1
)
FROM
t1
;
--
error
ER_WRONG_USAGE
SELECT
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
GROUP_CONCAT
(
a
))
FROM
t1
;
--
error
ER_WRONG_USAGE
SELECT
(
SELECT
GROUP_CONCAT
(
a
ORDER
BY
a
)
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
a
LIMIT
1
)
AS
a
FROM
t1
;
DROP
TABLE
t1
;
--
echo
# Subquery, multiple rows, ROLLUP
CREATE
TABLE
t1
(
a
INT
);
INSERT
INTO
t1
VALUES
(
10
),(
20
),(
30
);
SELECT
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
LIMIT
1
);
SELECT
(
SELECT
GROUP_CONCAT
(
a
)
FROM
t1
GROUP
BY
a
WITH
ROLLUP
LIMIT
1
);
SELECT
(
SELECT
GROUP_CONCAT
(
a
ORDER
BY
a
)
FROM
t1
GROUP
BY
a
WITH
ROLLUP
LIMIT
1
);
SELECT
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
LIMIT
1
)
FROM
t1
;
SELECT
(
SELECT
GROUP_CONCAT
(
a
)
FROM
t1
GROUP
BY
a
WITH
ROLLUP
LIMIT
1
)
FROM
t1
;
SELECT
(
SELECT
GROUP_CONCAT
(
a
ORDER
BY
a
)
FROM
t1
GROUP
BY
a
WITH
ROLLUP
LIMIT
1
)
FROM
t1
;
--
error
ER_SUBQUERY_NO_1_ROW
SELECT
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
);
--
error
ER_SUBQUERY_NO_1_ROW
SELECT
(
SELECT
GROUP_CONCAT
(
a
)
FROM
t1
GROUP
BY
a
WITH
ROLLUP
);
--
error
ER_SUBQUERY_NO_1_ROW
SELECT
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
)
FROM
t1
;
--
error
ER_SUBQUERY_NO_1_ROW
SELECT
(
SELECT
GROUP_CONCAT
(
a
)
FROM
t1
GROUP
BY
a
WITH
ROLLUP
)
FROM
t1
;
--
error
ER_WRONG_USAGE
SELECT
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
a
);
--
error
ER_WRONG_USAGE
SELECT
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
a
LIMIT
1
);
--
error
ER_WRONG_USAGE
SELECT
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
GROUP_CONCAT
(
a
));
--
error
ER_WRONG_USAGE
SELECT
(
SELECT
GROUP_CONCAT
(
a
ORDER
BY
a
)
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
a
LIMIT
1
)
AS
a
;
--
error
ER_WRONG_USAGE
SELECT
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
a
)
FROM
t1
;
--
error
ER_WRONG_USAGE
SELECT
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
a
LIMIT
1
)
FROM
t1
;
--
error
ER_WRONG_USAGE
SELECT
(
SELECT
*
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
GROUP_CONCAT
(
a
))
FROM
t1
;
--
error
ER_WRONG_USAGE
SELECT
(
SELECT
GROUP_CONCAT
(
a
ORDER
BY
a
)
FROM
t1
GROUP
BY
a
WITH
ROLLUP
ORDER
BY
a
LIMIT
1
)
AS
a
FROM
t1
;
DROP
TABLE
t1
;
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