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
c383ec95
Commit
c383ec95
authored
Jan 27, 2006
by
jonas@perch.ndb.mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge joreland@bk-internal.mysql.com:/home/bk/mysql-5.1-new
into perch.ndb.mysql.com:/home/jonas/src/mysql-5.1-new
parents
935e7a31
3b500fc3
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
162 additions
and
15 deletions
+162
-15
mysql-test/r/join_nested.result
mysql-test/r/join_nested.result
+17
-3
mysql-test/r/ps.result
mysql-test/r/ps.result
+34
-0
mysql-test/t/join_nested.test
mysql-test/t/join_nested.test
+14
-0
mysql-test/t/ps.test
mysql-test/t/ps.test
+30
-0
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+6
-0
sql/item_cmpfunc.h
sql/item_cmpfunc.h
+1
-0
sql/sql_select.cc
sql/sql_select.cc
+60
-12
No files found.
mysql-test/r/join_nested.result
View file @
c383ec95
...
@@ -960,7 +960,7 @@ id select_type table type possible_keys key key_len ref rows Extra
...
@@ -960,7 +960,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where
1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 Using where
1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 Using where
1 SIMPLE t5 ALL
NULL
NULL NULL NULL 3 Using where
1 SIMPLE t5 ALL
idx_b
NULL NULL NULL 3 Using where
1 SIMPLE t7 ALL NULL NULL NULL NULL 2 Using where
1 SIMPLE t7 ALL NULL NULL NULL NULL 2 Using where
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t8 ALL NULL NULL NULL NULL 2 Using where
1 SIMPLE t8 ALL NULL NULL NULL NULL 2 Using where
...
@@ -1009,7 +1009,7 @@ id select_type table type possible_keys key key_len ref rows Extra
...
@@ -1009,7 +1009,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where
1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 Using where
1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 Using where
1 SIMPLE t5 ALL
NULL
NULL NULL NULL 3 Using where
1 SIMPLE t5 ALL
idx_b
NULL NULL NULL 3 Using where
1 SIMPLE t7 ALL NULL NULL NULL NULL 2 Using where
1 SIMPLE t7 ALL NULL NULL NULL NULL 2 Using where
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 2 Using where
1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 2 Using where
...
@@ -1059,7 +1059,7 @@ id select_type table type possible_keys key key_len ref rows Extra
...
@@ -1059,7 +1059,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where
1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 Using where
1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 Using where
1 SIMPLE t5 ALL
NULL
NULL NULL NULL 3 Using where
1 SIMPLE t5 ALL
idx_b
NULL NULL NULL 3 Using where
1 SIMPLE t7 ALL NULL NULL NULL NULL 2 Using where
1 SIMPLE t7 ALL NULL NULL NULL NULL 2 Using where
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 2 Using where
1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 2 Using where
...
@@ -1467,3 +1467,17 @@ id select_type table type possible_keys key key_len ref rows Extra
...
@@ -1467,3 +1467,17 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t6 ref a a 5 test.t4.b X
1 SIMPLE t6 ref a a 5 test.t4.b X
1 SIMPLE t5 ref a a 5 test.t3.b X
1 SIMPLE t5 ref a a 5 test.t3.b X
drop table t0, t1, t2, t3, t4, t5, t6, t7;
drop table t0, t1, t2, t3, t4, t5, t6, t7;
create table t1 (a int);
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t2 (a int, filler char(100), key(a));
insert into t2 select A.a + 10*B.a, '' from t1 A, t1 B;
create table t3 like t2;
insert into t3 select * from t2;
explain select * from t1 left join
(t2 left join t3 on (t2.a = t3.a))
on (t1.a = t2.a);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10
1 SIMPLE t2 ref a a 5 test.t1.a 1
1 SIMPLE t3 ref a a 5 test.t2.a 1
drop table t1, t2, t3;
mysql-test/r/ps.result
View file @
c383ec95
...
@@ -825,6 +825,40 @@ execute stmt;
...
@@ -825,6 +825,40 @@ execute stmt;
drop table t1;
drop table t1;
set names default;
set names default;
deallocate prepare stmt;
deallocate prepare stmt;
create table t1 (
word_id mediumint(8) unsigned not null default '0',
formatted varchar(20) not null default ''
);
insert into t1 values
(80,'pendant'), (475,'pretendants'), (989,'tendances'),
(1019,'cependant'),(1022,'abondance'),(1205,'independants'),
(13,'lessiver'),(25,'lambiner'),(46,'situer'),(71,'terminer'),
(82,'decrocher');
select count(*) from t1 where formatted like '%NDAN%';
count(*)
6
select count(*) from t1 where formatted like '%ER';
count(*)
5
prepare stmt from "select count(*) from t1 where formatted like ?";
set @like="%NDAN%";
execute stmt using @like;
count(*)
6
set @like="%ER";
execute stmt using @like;
count(*)
5
set @like="%NDAN%";
execute stmt using @like;
count(*)
6
set @like="%ER";
execute stmt using @like;
count(*)
5
deallocate prepare stmt;
drop table t1;
create table t1 (id int);
create table t1 (id int);
prepare ins_call from "insert into t1 (id) values (1)";
prepare ins_call from "insert into t1 (id) values (1)";
execute ins_call;
execute ins_call;
...
...
mysql-test/t/join_nested.test
View file @
c383ec95
...
@@ -900,3 +900,17 @@ explain select * from t2 left join
...
@@ -900,3 +900,17 @@ explain select * from t2 left join
join
t5
on
t5
.
a
=
t3
.
b
)
on
t3
.
a
=
t2
.
b
;
join
t5
on
t5
.
a
=
t3
.
b
)
on
t3
.
a
=
t2
.
b
;
drop
table
t0
,
t1
,
t2
,
t3
,
t4
,
t5
,
t6
,
t7
;
drop
table
t0
,
t1
,
t2
,
t3
,
t4
,
t5
,
t6
,
t7
;
# BUG#16393
create
table
t1
(
a
int
);
insert
into
t1
values
(
0
),(
1
),(
2
),(
3
),(
4
),(
5
),(
6
),(
7
),(
8
),(
9
);
create
table
t2
(
a
int
,
filler
char
(
100
),
key
(
a
));
insert
into
t2
select
A
.
a
+
10
*
B
.
a
,
''
from
t1
A
,
t1
B
;
create
table
t3
like
t2
;
insert
into
t3
select
*
from
t2
;
explain
select
*
from
t1
left
join
(
t2
left
join
t3
on
(
t2
.
a
=
t3
.
a
))
on
(
t1
.
a
=
t2
.
a
);
drop
table
t1
,
t2
,
t3
;
mysql-test/t/ps.test
View file @
c383ec95
...
@@ -870,6 +870,36 @@ drop table t1;
...
@@ -870,6 +870,36 @@ drop table t1;
set
names
default
;
set
names
default
;
deallocate
prepare
stmt
;
deallocate
prepare
stmt
;
#
# A test case for Bug#12734 "prepared statement may return incorrect result
# set for a select SQL request": test that canDoTurboBM is reset for each
# execute of a prepared statement.
#
create
table
t1
(
word_id
mediumint
(
8
)
unsigned
not
null
default
'0'
,
formatted
varchar
(
20
)
not
null
default
''
);
insert
into
t1
values
(
80
,
'pendant'
),
(
475
,
'pretendants'
),
(
989
,
'tendances'
),
(
1019
,
'cependant'
),(
1022
,
'abondance'
),(
1205
,
'independants'
),
(
13
,
'lessiver'
),(
25
,
'lambiner'
),(
46
,
'situer'
),(
71
,
'terminer'
),
(
82
,
'decrocher'
);
select
count
(
*
)
from
t1
where
formatted
like
'%NDAN%'
;
select
count
(
*
)
from
t1
where
formatted
like
'%ER'
;
prepare
stmt
from
"select count(*) from t1 where formatted like ?"
;
set
@
like
=
"%NDAN%"
;
execute
stmt
using
@
like
;
set
@
like
=
"%ER"
;
execute
stmt
using
@
like
;
set
@
like
=
"%NDAN%"
;
execute
stmt
using
@
like
;
set
@
like
=
"%ER"
;
execute
stmt
using
@
like
;
deallocate
prepare
stmt
;
drop
table
t1
;
# End of 4.1 tests
# End of 4.1 tests
#
#
...
...
sql/item_cmpfunc.cc
View file @
c383ec95
...
@@ -3059,6 +3059,12 @@ bool Item_func_like::fix_fields(THD *thd, Item **ref)
...
@@ -3059,6 +3059,12 @@ bool Item_func_like::fix_fields(THD *thd, Item **ref)
return
FALSE
;
return
FALSE
;
}
}
void
Item_func_like
::
cleanup
()
{
canDoTurboBM
=
FALSE
;
Item_bool_func2
::
cleanup
();
}
#ifdef USE_REGEX
#ifdef USE_REGEX
bool
bool
...
...
sql/item_cmpfunc.h
View file @
c383ec95
...
@@ -1001,6 +1001,7 @@ class Item_func_like :public Item_bool_func2
...
@@ -1001,6 +1001,7 @@ class Item_func_like :public Item_bool_func2
cond_result
eq_cmp_result
()
const
{
return
COND_TRUE
;
}
cond_result
eq_cmp_result
()
const
{
return
COND_TRUE
;
}
const
char
*
func_name
()
const
{
return
"like"
;
}
const
char
*
func_name
()
const
{
return
"like"
;
}
bool
fix_fields
(
THD
*
thd
,
Item
**
ref
);
bool
fix_fields
(
THD
*
thd
,
Item
**
ref
);
void
cleanup
();
};
};
#ifdef USE_REGEX
#ifdef USE_REGEX
...
...
sql/sql_select.cc
View file @
c383ec95
...
@@ -2960,6 +2960,56 @@ sort_keyuse(KEYUSE *a,KEYUSE *b)
...
@@ -2960,6 +2960,56 @@ sort_keyuse(KEYUSE *a,KEYUSE *b)
}
}
/*
Add to KEY_FIELD array all 'ref' access candidates within nested join
SYNPOSIS
add_key_fields_for_nj()
nested_join_table IN Nested join pseudo-table to process
end INOUT End of the key field array
and_level INOUT And-level
DESCRIPTION
This function populates KEY_FIELD array with entries generated from the
ON condition of the given nested join, and does the same for nested joins
contained within this nested join.
NOTES
We can add accesses to the tables that are direct children of this nested
join (1), and are not inner tables w.r.t their neighbours (2).
Example for #1 (outer brackets pair denotes nested join this function is
invoked for):
... LEFT JOIN (t1 LEFT JOIN (t2 ... ) ) ON cond
Example for #2:
... LEFT JOIN (t1 LEFT JOIN t2 ) ON cond
In examples 1-2 for condition cond, we can add 'ref' access candidates to
t1 only.
Example #3:
... LEFT JOIN (t1, t2 LEFT JOIN t3 ON inner_cond) ON cond
Here we can add 'ref' access candidates for t1 and t2, but not for t3.
*/
static
void
add_key_fields_for_nj
(
TABLE_LIST
*
nested_join_table
,
KEY_FIELD
**
end
,
uint
*
and_level
)
{
List_iterator
<
TABLE_LIST
>
li
(
nested_join_table
->
nested_join
->
join_list
);
table_map
tables
=
0
;
TABLE_LIST
*
table
;
DBUG_ASSERT
(
nested_join_table
->
nested_join
);
while
((
table
=
li
++
))
{
if
(
table
->
nested_join
)
add_key_fields_for_nj
(
table
,
end
,
and_level
);
else
if
(
!
table
->
on_expr
)
tables
|=
table
->
table
->
map
;
}
add_key_fields
(
end
,
and_level
,
nested_join_table
->
on_expr
,
tables
);
}
/*
/*
Update keyuse array with all possible keys we can use to fetch rows
Update keyuse array with all possible keys we can use to fetch rows
...
@@ -3024,23 +3074,21 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
...
@@ -3024,23 +3074,21 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
into account as well.
into account as well.
*/
*/
if
(
*
join_tab
[
i
].
on_expr_ref
)
if
(
*
join_tab
[
i
].
on_expr_ref
)
{
add_key_fields
(
&
end
,
&
and_level
,
*
join_tab
[
i
].
on_expr_ref
,
add_key_fields
(
&
end
,
&
and_level
,
*
join_tab
[
i
].
on_expr_ref
,
join_tab
[
i
].
table
->
map
);
join_tab
[
i
].
table
->
map
);
}
}
else
/* Process ON conditions for the nested joins */
{
List_iterator
<
TABLE_LIST
>
li
(
*
join_tab
->
join
->
join_list
);
TABLE_LIST
*
table
;
while
((
table
=
li
++
))
{
{
TABLE_LIST
*
tab
=
join_tab
[
i
].
table
->
pos_in_table_list
;
if
(
table
->
nested_join
)
TABLE_LIST
*
embedding
=
tab
->
embedding
;
add_key_fields_for_nj
(
table
,
&
end
,
&
and_level
);
if
(
embedding
)
{
NESTED_JOIN
*
nested_join
=
embedding
->
nested_join
;
if
(
nested_join
->
join_list
.
head
()
==
tab
)
add_key_fields
(
&
end
,
&
and_level
,
embedding
->
on_expr
,
nested_join
->
used_tables
);
}
}
}
}
}
/* fill keyuse with found key parts */
/* fill keyuse with found key parts */
for
(
;
field
!=
end
;
field
++
)
for
(
;
field
!=
end
;
field
++
)
add_key_part
(
keyuse
,
field
);
add_key_part
(
keyuse
,
field
);
...
...
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