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
3984062b
Commit
3984062b
authored
Jul 04, 2011
by
Igor Babaev
Browse files
Options
Browse Files
Download
Plain Diff
Merge.
parents
c9e969b6
3f7d51d0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
39 deletions
+54
-39
mysql-test/r/view.result
mysql-test/r/view.result
+31
-0
mysql-test/t/view.test
mysql-test/t/view.test
+21
-0
sql/item.cc
sql/item.cc
+0
-34
sql/item.h
sql/item.h
+2
-5
No files found.
mysql-test/r/view.result
View file @
3984062b
...
...
@@ -4246,3 +4246,34 @@ a MIN(b)
7 78
DROP VIEW v1;
DROP TABLE t1,t2;
#
# LP bug #804686: query over a derived table using a view
# with a degenerated where condition
#
CREATE TABLE t1 (a int, b int);
INSERT INTO t1 VALUES (0,0), (1,0), (0,0), (1,1), (1,0);
CREATE VIEW v1 AS SELECT a,b FROM t1;
CREATE VIEW v2 AS SELECT a, MAX(b) AS b FROM t1 GROUP BY a;
SELECT * FROM (SELECT b FROM v1 WHERE b = 0) t WHERE b<>0;
b
SELECT * FROM (SELECT b FROM v2 WHERE b = 0) t WHERE b<>0;
b
SELECT * FROM (SELECT b FROM v1 WHERE b = 0) t WHERE b;
b
SELECT * FROM (SELECT b FROM v2 WHERE b = 0) t WHERE b;
b
EXPLAIN EXTENDED
SELECT * FROM (SELECT b FROM v1 WHERE b = 0) t WHERE b;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
Warnings:
Note 1003 select `test`.`t1`.`b` AS `b` from `test`.`t1` where 0
EXPLAIN EXTENDED
SELECT * FROM (SELECT b FROM v2 WHERE b = 0) t WHERE b;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
3 DERIVED t1 ALL NULL NULL NULL NULL 5 100.00 Using temporary; Using filesort
Warnings:
Note 1003 select `v2`.`b` AS `b` from `test`.`v2` where 0
DROP VIEW v1,v2;
DROP TABLE t1;
mysql-test/t/view.test
View file @
3984062b
...
...
@@ -4192,3 +4192,24 @@ SELECT a, MIN(b) FROM v1 GROUP BY a;
DROP
VIEW
v1
;
DROP
TABLE
t1
,
t2
;
--
echo
#
--
echo
# LP bug #804686: query over a derived table using a view
--
echo
# with a degenerated where condition
--
echo
#
CREATE
TABLE
t1
(
a
int
,
b
int
);
INSERT
INTO
t1
VALUES
(
0
,
0
),
(
1
,
0
),
(
0
,
0
),
(
1
,
1
),
(
1
,
0
);
CREATE
VIEW
v1
AS
SELECT
a
,
b
FROM
t1
;
CREATE
VIEW
v2
AS
SELECT
a
,
MAX
(
b
)
AS
b
FROM
t1
GROUP
BY
a
;
SELECT
*
FROM
(
SELECT
b
FROM
v1
WHERE
b
=
0
)
t
WHERE
b
<>
0
;
SELECT
*
FROM
(
SELECT
b
FROM
v2
WHERE
b
=
0
)
t
WHERE
b
<>
0
;
SELECT
*
FROM
(
SELECT
b
FROM
v1
WHERE
b
=
0
)
t
WHERE
b
;
SELECT
*
FROM
(
SELECT
b
FROM
v2
WHERE
b
=
0
)
t
WHERE
b
;
EXPLAIN
EXTENDED
SELECT
*
FROM
(
SELECT
b
FROM
v1
WHERE
b
=
0
)
t
WHERE
b
;
EXPLAIN
EXTENDED
SELECT
*
FROM
(
SELECT
b
FROM
v2
WHERE
b
=
0
)
t
WHERE
b
;
DROP
VIEW
v1
,
v2
;
DROP
TABLE
t1
;
sql/item.cc
View file @
3984062b
...
...
@@ -6883,40 +6883,6 @@ bool Item_direct_ref::get_date(MYSQL_TIME *ltime,uint fuzzydate)
}
Item
*
Item_direct_ref_to_ident
::
transform
(
Item_transformer
transformer
,
uchar
*
argument
)
{
DBUG_ASSERT
(
!
current_thd
->
is_stmt_prepare
());
Item
*
new_item
=
ident
->
transform
(
transformer
,
argument
);
if
(
!
new_item
)
return
0
;
DBUG_ASSERT
(
new_item
->
type
()
==
FIELD_ITEM
||
new_item
->
type
()
==
REF_ITEM
);
if
(
ident
!=
new_item
)
current_thd
->
change_item_tree
((
Item
**
)
&
ident
,
new_item
);
return
(
this
->*
transformer
)(
argument
);
}
Item
*
Item_direct_ref_to_ident
::
compile
(
Item_analyzer
analyzer
,
uchar
**
arg_p
,
Item_transformer
transformer
,
uchar
*
arg_t
)
{
if
(
!
(
this
->*
analyzer
)(
arg_p
))
return
0
;
uchar
*
arg_v
=
*
arg_p
;
Item
*
new_item
=
ident
->
compile
(
analyzer
,
&
arg_v
,
transformer
,
arg_t
);
if
(
new_item
&&
ident
!=
new_item
)
{
DBUG_ASSERT
(
new_item
->
type
()
==
FIELD_ITEM
||
new_item
->
type
()
==
REF_ITEM
);
current_thd
->
change_item_tree
((
Item
**
)
&
ident
,
new_item
);
}
return
(
this
->*
transformer
)(
arg_t
);
}
Item_cache_wrapper
::~
Item_cache_wrapper
()
{
DBUG_ASSERT
(
expr_cache
==
0
);
...
...
sql/item.h
View file @
3984062b
...
...
@@ -2570,8 +2570,8 @@ public:
Field
*
get_tmp_table_field
()
{
return
result_field
?
result_field
:
(
*
ref
)
->
get_tmp_table_field
();
}
Item
*
get_tmp_table_item
(
THD
*
thd
);
inline
table_map
used_tables
()
const
;
inline
void
update_used_tables
();
table_map
used_tables
()
const
;
void
update_used_tables
();
bool
const_item
()
const
{
return
(
*
ref
)
->
const_item
();
...
...
@@ -2713,9 +2713,6 @@ public:
virtual
void
print
(
String
*
str
,
enum_query_type
query_type
)
{
ident
->
print
(
str
,
query_type
);
}
virtual
Item
*
transform
(
Item_transformer
transformer
,
uchar
*
arg
);
virtual
Item
*
compile
(
Item_analyzer
analyzer
,
uchar
**
arg_p
,
Item_transformer
transformer
,
uchar
*
arg_t
);
};
...
...
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