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
6c7360b5
Commit
6c7360b5
authored
Feb 07, 2011
by
Igor Babaev
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
7e206872
cbeab250
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
5 deletions
+48
-5
mysql-test/r/view.result
mysql-test/r/view.result
+20
-0
mysql-test/t/view.test
mysql-test/t/view.test
+25
-1
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+2
-3
sql/sql_select.cc
sql/sql_select.cc
+1
-1
No files found.
mysql-test/r/view.result
View file @
6c7360b5
...
...
@@ -3939,3 +3939,23 @@ Handler_read_rnd 0
Handler_read_rnd_next 17
DROP VIEW v;
DROP TABLE t1, t2;
#
# Bug#702403: crash with multiple equalities and a view
#
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (10);
CREATE TABLE t2 (pk int PRIMARY KEY, b int, INDEX idx (b));
INSERT INTO t2 VALUES (1,2), (3,4);
CREATE TABLE t3 (pk int PRIMARY KEY, b int, INDEX idx (b));
INSERT INTO t3 VALUES (1,2), (3,4);
CREATE VIEW v1 AS SELECT * FROM t1;
EXPLAIN
SELECT * FROM v1, t2, t3
WHERE t3.pk = v1.a AND t2.b = 1 AND t2.b = t3.pk AND v1.a BETWEEN 2 AND 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
SELECT * FROM v1, t2, t3
WHERE t3.pk = v1.a AND t2.b = 1 AND t2.b = t3.pk AND v1.a BETWEEN 2 AND 5;
a pk b pk b
DROP VIEW v1;
DROP TABLE t1, t2, t3;
mysql-test/t/view.test
View file @
6c7360b5
...
...
@@ -3929,7 +3929,6 @@ DROP TABLE t1;
--
echo
# -- End of 5.1 tests.
--
echo
# -----------------------------------------------------------------
--
echo
#
--
echo
# Bug #59696 Optimizer does not use equalities for conditions over view
--
echo
#
...
...
@@ -3959,3 +3958,28 @@ SHOW STATUS LIKE 'Handler_read_%';
DROP
VIEW
v
;
DROP
TABLE
t1
,
t2
;
--
echo
#
--
echo
# Bug#702403: crash with multiple equalities and a view
--
echo
#
CREATE
TABLE
t1
(
a
int
);
INSERT
INTO
t1
VALUES
(
10
);
CREATE
TABLE
t2
(
pk
int
PRIMARY
KEY
,
b
int
,
INDEX
idx
(
b
));
INSERT
INTO
t2
VALUES
(
1
,
2
),
(
3
,
4
);
CREATE
TABLE
t3
(
pk
int
PRIMARY
KEY
,
b
int
,
INDEX
idx
(
b
));
INSERT
INTO
t3
VALUES
(
1
,
2
),
(
3
,
4
);
CREATE
VIEW
v1
AS
SELECT
*
FROM
t1
;
EXPLAIN
SELECT
*
FROM
v1
,
t2
,
t3
WHERE
t3
.
pk
=
v1
.
a
AND
t2
.
b
=
1
AND
t2
.
b
=
t3
.
pk
AND
v1
.
a
BETWEEN
2
AND
5
;
SELECT
*
FROM
v1
,
t2
,
t3
WHERE
t3
.
pk
=
v1
.
a
AND
t2
.
b
=
1
AND
t2
.
b
=
t3
.
pk
AND
v1
.
a
BETWEEN
2
AND
5
;
DROP
VIEW
v1
;
DROP
TABLE
t1
,
t2
,
t3
;
sql/item_cmpfunc.cc
View file @
6c7360b5
...
...
@@ -5523,7 +5523,6 @@ Item_equal::Item_equal(Item_field *f1, Item_field *f2)
const_item_cache
=
0
;
fields
.
push_back
(
f1
);
fields
.
push_back
(
f2
);
f1
->
item_equal
=
f2
->
item_equal
=
this
;
}
Item_equal
::
Item_equal
(
Item
*
c
,
Item_field
*
f
)
...
...
@@ -5601,7 +5600,6 @@ void Item_equal::add(Item *c)
void
Item_equal
::
add
(
Item_field
*
f
)
{
fields
.
push_back
(
f
);
f
->
item_equal
=
this
;
}
uint
Item_equal
::
members
()
...
...
@@ -5714,7 +5712,7 @@ void Item_equal::update_const()
bool
Item_equal
::
fix_fields
(
THD
*
thd
,
Item
**
ref
)
{
List_iterator_fast
<
Item_field
>
li
(
fields
);
Item
*
item
;
Item
_field
*
item
;
not_null_tables_cache
=
used_tables_cache
=
0
;
const_item_cache
=
0
;
while
((
item
=
li
++
))
...
...
@@ -5725,6 +5723,7 @@ bool Item_equal::fix_fields(THD *thd, Item **ref)
not_null_tables_cache
|=
tmp_table_map
;
if
(
item
->
maybe_null
)
maybe_null
=
1
;
item
->
item_equal
=
this
;
}
fix_length_and_dec
();
fixed
=
1
;
...
...
sql/sql_select.cc
View file @
6c7360b5
...
...
@@ -9589,7 +9589,7 @@ static COND *build_equal_items_for_cond(THD *thd, COND *cond,
List_iterator_fast
<
Item_equal
>
it
(
cond_equal
.
current_level
);
while
((
item_equal
=
it
++
))
{
item_equal
->
fix_
length_and_dec
(
);
item_equal
->
fix_
fields
(
thd
,
NULL
);
item_equal
->
update_used_tables
();
set_if_bigger
(
thd
->
lex
->
current_select
->
max_equal_elems
,
item_equal
->
members
());
...
...
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