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
a4ffe9e4
Commit
a4ffe9e4
authored
Apr 20, 2007
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into magare.gmz:/home/kgeorge/mysql/autopush/B27786-5.0-opt
parents
f3e261a9
e0444ba4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
2 deletions
+66
-2
mysql-test/r/view.result
mysql-test/r/view.result
+35
-0
mysql-test/t/view.test
mysql-test/t/view.test
+16
-0
sql/sql_lex.h
sql/sql_lex.h
+8
-0
sql/sql_view.cc
sql/sql_view.cc
+7
-2
No files found.
mysql-test/r/view.result
View file @
a4ffe9e4
...
...
@@ -3319,4 +3319,39 @@ lgid clid
2 YES
DROP VIEW v1;
DROP table t1,t2;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2),(3);
CREATE VIEW v1 AS SELECT a FROM t1 ORDER BY a;
SELECT * FROM t1 UNION SELECT * FROM v1;
a
1
2
3
EXPLAIN SELECT * FROM t1 UNION SELECT * FROM v1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
2 UNION t1 ALL NULL NULL NULL NULL 3
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
SELECT * FROM v1 UNION SELECT * FROM t1;
a
1
2
3
EXPLAIN SELECT * FROM v1 UNION SELECT * FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
2 UNION t1 ALL NULL NULL NULL NULL 3
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
SELECT * FROM t1 UNION SELECT * FROM v1 ORDER BY a;
a
1
2
3
EXPLAIN SELECT * FROM t1 UNION SELECT * FROM v1 ORDER BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
2 UNION t1 ALL NULL NULL NULL NULL 3
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL Using filesort
DROP VIEW v1;
DROP TABLE t1;
End of 5.0 tests.
mysql-test/t/view.test
View file @
a4ffe9e4
...
...
@@ -3205,4 +3205,20 @@ SELECT * FROM v1;
DROP
VIEW
v1
;
DROP
table
t1
,
t2
;
#
# Bug#27786: Inconsistent Operation Performing UNION On View With ORDER BY
#
CREATE
TABLE
t1
(
a
INT
);
INSERT
INTO
t1
VALUES
(
1
),(
2
),(
3
);
CREATE
VIEW
v1
AS
SELECT
a
FROM
t1
ORDER
BY
a
;
SELECT
*
FROM
t1
UNION
SELECT
*
FROM
v1
;
EXPLAIN
SELECT
*
FROM
t1
UNION
SELECT
*
FROM
v1
;
SELECT
*
FROM
v1
UNION
SELECT
*
FROM
t1
;
EXPLAIN
SELECT
*
FROM
v1
UNION
SELECT
*
FROM
t1
;
SELECT
*
FROM
t1
UNION
SELECT
*
FROM
v1
ORDER
BY
a
;
EXPLAIN
SELECT
*
FROM
t1
UNION
SELECT
*
FROM
v1
ORDER
BY
a
;
DROP
VIEW
v1
;
DROP
TABLE
t1
;
--
echo
End
of
5.0
tests
.
sql/sql_lex.h
View file @
a4ffe9e4
...
...
@@ -468,6 +468,7 @@ class st_select_lex_unit: public st_select_lex_node {
bool
change_result
(
select_subselect
*
result
,
select_subselect
*
old_result
);
void
set_limit
(
st_select_lex
*
values
);
void
set_thd
(
THD
*
thd_arg
)
{
thd
=
thd_arg
;
}
inline
bool
is_union
();
friend
void
lex_start
(
THD
*
thd
,
uchar
*
buf
,
uint
length
);
friend
int
subselect_union_engine
::
exec
();
...
...
@@ -700,6 +701,13 @@ class st_select_lex: public st_select_lex_node
};
typedef
class
st_select_lex
SELECT_LEX
;
inline
bool
st_select_lex_unit
::
is_union
()
{
return
first_select
()
->
next_select
()
&&
first_select
()
->
next_select
()
->
linkage
==
UNION_TYPE
;
}
#define ALTER_ADD_COLUMN 1
#define ALTER_DROP_COLUMN 2
#define ALTER_CHANGE_COLUMN 4
...
...
sql/sql_view.cc
View file @
a4ffe9e4
...
...
@@ -1263,13 +1263,18 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
unit
->
slave
=
save_slave
;
// fix include_down initialisation
}
/*
We can safely ignore the VIEW's ORDER BY if we merge into union
branch, as order is not important there.
*/
if
(
!
table
->
select_lex
->
master_unit
()
->
is_union
())
table
->
select_lex
->
order_list
.
push_back
(
&
lex
->
select_lex
.
order_list
);
/*
This SELECT_LEX will be linked in global SELECT_LEX list
to make it processed by mysql_handle_derived(),
but it will not be included to SELECT_LEX tree, because it
will not be executed
*/
table
->
select_lex
->
order_list
.
push_back
(
&
lex
->
select_lex
.
order_list
);
*/
goto
ok
;
}
...
...
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