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
98ba2bf4
Commit
98ba2bf4
authored
Aug 21, 2015
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean-up: moving compare_collation() from Item to Item_bool_func.
parent
1bae0d9e
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
32 deletions
+43
-32
sql/field.cc
sql/field.cc
+8
-8
sql/field.h
sql/field.h
+15
-10
sql/item.h
sql/item.h
+0
-1
sql/item_cmpfunc.h
sql/item_cmpfunc.h
+1
-0
sql/opt_table_elimination.cc
sql/opt_table_elimination.cc
+13
-8
sql/sql_select.cc
sql/sql_select.cc
+6
-5
No files found.
sql/field.cc
View file @
98ba2bf4
...
...
@@ -1249,7 +1249,7 @@ double Field::pos_in_interval_val_str(Field *min, Field *max, uint data_offset)
/*
This handles all numeric and BIT data types.
*/
bool
Field
::
can_optimize_keypart_ref
(
const
Item_func
*
cond
,
bool
Field
::
can_optimize_keypart_ref
(
const
Item_
bool_
func
*
cond
,
const
Item
*
item
)
const
{
DBUG_ASSERT
(
cmp_type
()
!=
STRING_RESULT
);
...
...
@@ -5289,7 +5289,7 @@ my_decimal *Field_temporal::val_decimal(my_decimal *d)
}
bool
Field_temporal
::
can_optimize_keypart_ref
(
const
Item_func
*
cond
,
bool
Field_temporal
::
can_optimize_keypart_ref
(
const
Item_
bool_
func
*
cond
,
const
Item
*
value
)
const
{
return
true
;
// Field is of TIME_RESULT, which supersedes everything else.
...
...
@@ -6488,7 +6488,7 @@ uint32 Field_longstr::max_data_length() const
bool
Field_longstr
::
cmp_to_string_with_same_collation
(
const
Item_func
*
cond
,
Field_longstr
::
cmp_to_string_with_same_collation
(
const
Item_
bool_
func
*
cond
,
const
Item
*
item
)
const
{
return
item
->
cmp_type
()
==
STRING_RESULT
&&
...
...
@@ -6497,7 +6497,7 @@ Field_longstr::cmp_to_string_with_same_collation(const Item_func *cond,
bool
Field_longstr
::
cmp_to_string_with_stricter_collation
(
const
Item_func
*
cond
,
Field_longstr
::
cmp_to_string_with_stricter_collation
(
const
Item_
bool_
func
*
cond
,
const
Item
*
item
)
const
{
return
item
->
cmp_type
()
==
STRING_RESULT
&&
...
...
@@ -6506,7 +6506,7 @@ Field_longstr::cmp_to_string_with_stricter_collation(const Item_func *cond,
}
bool
Field_longstr
::
can_optimize_keypart_ref
(
const
Item_func
*
cond
,
bool
Field_longstr
::
can_optimize_keypart_ref
(
const
Item_
bool_
func
*
cond
,
const
Item
*
item
)
const
{
DBUG_ASSERT
(
cmp_type
()
==
STRING_RESULT
);
...
...
@@ -6514,7 +6514,7 @@ bool Field_longstr::can_optimize_keypart_ref(const Item_func *cond,
}
bool
Field_longstr
::
can_optimize_hash_join
(
const
Item_func
*
cond
,
bool
Field_longstr
::
can_optimize_hash_join
(
const
Item_
bool_
func
*
cond
,
const
Item
*
item
)
const
{
DBUG_ASSERT
(
cmp_type
()
==
STRING_RESULT
);
...
...
@@ -8561,7 +8561,7 @@ uint Field_num::is_equal(Create_field *new_field)
}
bool
Field_enum
::
can_optimize_keypart_ref
(
const
Item_func
*
cond
,
bool
Field_enum
::
can_optimize_keypart_ref
(
const
Item_
bool_
func
*
cond
,
const
Item
*
item
)
const
{
DBUG_ASSERT
(
cmp_type
()
==
INT_RESULT
);
...
...
@@ -8576,7 +8576,7 @@ bool Field_enum::can_optimize_keypart_ref(const Item_func *cond,
case
REAL_RESULT
:
return
true
;
case
STRING_RESULT
:
return
charset
()
==
((
Item_func
*
)
cond
)
->
compare_collation
();
return
charset
()
==
cond
->
compare_collation
();
case
IMPOSSIBLE_RESULT
:
case
ROW_RESULT
:
DBUG_ASSERT
(
0
);
...
...
sql/field.h
View file @
98ba2bf4
...
...
@@ -1012,16 +1012,16 @@ class Field
return
(
double
)
0.5
;
}
virtual
bool
can_optimize_keypart_ref
(
const
Item_func
*
cond
,
virtual
bool
can_optimize_keypart_ref
(
const
Item_
bool_
func
*
cond
,
const
Item
*
item
)
const
;
virtual
bool
can_optimize_hash_join
(
const
Item_func
*
cond
,
virtual
bool
can_optimize_hash_join
(
const
Item_
bool_
func
*
cond
,
const
Item
*
item
)
const
{
return
can_optimize_keypart_ref
(
cond
,
item
);
}
virtual
bool
can_optimize_group_min_max
(
const
Item_bool_func
*
cond
,
const
Item
*
const_item
)
const
;
bool
can_optimize_outer_join_table_elimination
(
const
Item_func
*
cond
,
bool
can_optimize_outer_join_table_elimination
(
const
Item_
bool_
func
*
cond
,
const
Item
*
item
)
const
{
// Exactly the same rules with REF access
...
...
@@ -1207,9 +1207,9 @@ class Field_longstr :public Field_str
return
report_if_important_data
(
copier
->
source_end_pos
(),
end
,
count_spaces
);
}
bool
cmp_to_string_with_same_collation
(
const
Item_func
*
cond
,
bool
cmp_to_string_with_same_collation
(
const
Item_
bool_
func
*
cond
,
const
Item
*
item
)
const
;
bool
cmp_to_string_with_stricter_collation
(
const
Item_func
*
cond
,
bool
cmp_to_string_with_stricter_collation
(
const
Item_
bool_
func
*
cond
,
const
Item
*
item
)
const
;
public:
Field_longstr
(
uchar
*
ptr_arg
,
uint32
len_arg
,
uchar
*
null_ptr_arg
,
...
...
@@ -1222,8 +1222,10 @@ class Field_longstr :public Field_str
int
store_decimal
(
const
my_decimal
*
d
);
uint32
max_data_length
()
const
;
bool
match_collation_to_optimize_range
()
const
{
return
true
;
}
bool
can_optimize_keypart_ref
(
const
Item_func
*
cond
,
const
Item
*
item
)
const
;
bool
can_optimize_hash_join
(
const
Item_func
*
cond
,
const
Item
*
item
)
const
;
bool
can_optimize_keypart_ref
(
const
Item_bool_func
*
cond
,
const
Item
*
item
)
const
;
bool
can_optimize_hash_join
(
const
Item_bool_func
*
cond
,
const
Item
*
item
)
const
;
bool
can_optimize_group_min_max
(
const
Item_bool_func
*
cond
,
const
Item
*
const_item
)
const
;
};
...
...
@@ -1653,7 +1655,8 @@ class Field_null :public Field_str {
uint
size_of
()
const
{
return
sizeof
(
*
this
);
}
uint32
max_display_length
()
{
return
4
;
}
void
move_field_offset
(
my_ptrdiff_t
ptr_diff
)
{}
bool
can_optimize_keypart_ref
(
const
Item_func
*
cond
,
const
Item
*
item
)
const
bool
can_optimize_keypart_ref
(
const
Item_bool_func
*
cond
,
const
Item
*
item
)
const
{
DBUG_ASSERT
(
0
);
return
false
;
...
...
@@ -1696,7 +1699,8 @@ class Field_temporal: public Field {
{
return
pos_in_interval_val_real
(
min
,
max
);
}
bool
can_optimize_keypart_ref
(
const
Item_func
*
cond
,
const
Item
*
item
)
const
;
bool
can_optimize_keypart_ref
(
const
Item_bool_func
*
cond
,
const
Item
*
item
)
const
;
bool
can_optimize_group_min_max
(
const
Item_bool_func
*
cond
,
const
Item
*
const_item
)
const
;
};
...
...
@@ -2773,7 +2777,8 @@ class Field_enum :public Field_str {
virtual
const
uchar
*
unpack
(
uchar
*
to
,
const
uchar
*
from
,
const
uchar
*
from_end
,
uint
param_data
);
bool
can_optimize_keypart_ref
(
const
Item_func
*
cond
,
const
Item
*
item
)
const
;
bool
can_optimize_keypart_ref
(
const
Item_bool_func
*
cond
,
const
Item
*
item
)
const
;
bool
can_optimize_group_min_max
(
const
Item_bool_func
*
cond
,
const
Item
*
const_item
)
const
{
...
...
sql/item.h
View file @
98ba2bf4
...
...
@@ -1229,7 +1229,6 @@ class Item: public Type_std_attributes
virtual
Item
*
get_tmp_table_item
(
THD
*
thd
)
{
return
copy_or_same
(
thd
);
}
static
CHARSET_INFO
*
default_charset
();
virtual
CHARSET_INFO
*
compare_collation
()
const
{
return
NULL
;
}
/*
For backward compatibility, to make numeric
...
...
sql/item_cmpfunc.h
View file @
98ba2bf4
...
...
@@ -162,6 +162,7 @@ class Item_bool_func :public Item_int_func
Item_bool_func
(
THD
*
thd
,
List
<
Item
>
&
list
)
:
Item_int_func
(
thd
,
list
)
{
}
Item_bool_func
(
THD
*
thd
,
Item_bool_func
*
item
)
:
Item_int_func
(
thd
,
item
)
{}
bool
is_bool_type
()
{
return
true
;
}
virtual
CHARSET_INFO
*
compare_collation
()
const
{
return
NULL
;
}
void
fix_length_and_dec
()
{
decimals
=
0
;
max_length
=
1
;
}
uint
decimal_precision
()
const
{
return
1
;
}
};
...
...
sql/opt_table_elimination.cc
View file @
98ba2bf4
...
...
@@ -534,7 +534,8 @@ void build_eq_mods_for_cond(THD *thd, Dep_analysis_context *dac,
Item
*
cond
);
static
void
check_equality
(
Dep_analysis_context
*
dac
,
Dep_module_expr
**
eq_mod
,
uint
and_level
,
Item_func
*
cond
,
Item
*
left
,
Item
*
right
);
uint
and_level
,
Item_bool_func
*
cond
,
Item
*
left
,
Item
*
right
);
static
Dep_module_expr
*
merge_eq_mods
(
Dep_module_expr
*
start
,
Dep_module_expr
*
new_fields
,
...
...
@@ -1199,27 +1200,30 @@ void build_eq_mods_for_cond(THD *thd, Dep_analysis_context *ctx,
case
Item_func
:
:
BETWEEN
:
{
Item
*
fld
;
if
(
!
((
Item_func_between
*
)
cond
)
->
negated
&&
Item_func_between
*
func
=
(
Item_func_between
*
)
cond_func
;
if
(
!
func
->
negated
&&
(
fld
=
args
[
0
]
->
real_item
())
->
type
()
==
Item
::
FIELD_ITEM
&&
args
[
1
]
->
eq
(
args
[
2
],
((
Item_field
*
)
fld
)
->
field
->
binary
()))
{
check_equality
(
ctx
,
eq_mod
,
*
and_level
,
cond_
func
,
args
[
0
],
args
[
1
]);
check_equality
(
ctx
,
eq_mod
,
*
and_level
,
cond_
func
,
args
[
1
],
args
[
0
]);
check_equality
(
ctx
,
eq_mod
,
*
and_level
,
func
,
args
[
0
],
args
[
1
]);
check_equality
(
ctx
,
eq_mod
,
*
and_level
,
func
,
args
[
1
],
args
[
0
]);
}
break
;
}
case
Item_func
:
:
EQ_FUNC
:
case
Item_func
:
:
EQUAL_FUNC
:
{
check_equality
(
ctx
,
eq_mod
,
*
and_level
,
cond_func
,
args
[
0
],
args
[
1
]);
check_equality
(
ctx
,
eq_mod
,
*
and_level
,
cond_func
,
args
[
1
],
args
[
0
]);
Item_bool_rowready_func2
*
func
=
(
Item_bool_rowready_func2
*
)
cond_func
;
check_equality
(
ctx
,
eq_mod
,
*
and_level
,
func
,
args
[
0
],
args
[
1
]);
check_equality
(
ctx
,
eq_mod
,
*
and_level
,
func
,
args
[
1
],
args
[
0
]);
break
;
}
case
Item_func
:
:
ISNULL_FUNC
:
{
Item
*
tmp
=
new
(
thd
->
mem_root
)
Item_null
(
thd
);
if
(
tmp
)
check_equality
(
ctx
,
eq_mod
,
*
and_level
,
cond_func
,
args
[
0
],
tmp
);
check_equality
(
ctx
,
eq_mod
,
*
and_level
,
(
Item_func_isnull
*
)
cond_func
,
args
[
0
],
tmp
);
break
;
}
case
Item_func
:
:
MULT_EQUAL_FUNC
:
...
...
@@ -1479,7 +1483,8 @@ Dep_module_expr *merge_eq_mods(Dep_module_expr *start,
static
void
check_equality
(
Dep_analysis_context
*
ctx
,
Dep_module_expr
**
eq_mod
,
uint
and_level
,
Item_func
*
cond
,
Item
*
left
,
Item
*
right
)
uint
and_level
,
Item_bool_func
*
cond
,
Item
*
left
,
Item
*
right
)
{
if
((
left
->
used_tables
()
&
ctx
->
usable_tables
)
&&
!
(
right
->
used_tables
()
&
RAND_TABLE_BIT
)
&&
...
...
sql/sql_select.cc
View file @
98ba2bf4
...
...
@@ -4147,7 +4147,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
/// Used when finding key fields
struct
KEY_FIELD
{
Field
*
field
;
Item_
func
*
cond
;
Item_
bool_func
*
cond
;
Item
*
val
;
///< May be empty if diff constant
uint
level
;
uint
optimize
;
...
...
@@ -4400,7 +4400,7 @@ static uint get_semi_join_select_list_index(Field *field)
static
void
add_key_field
(
JOIN
*
join
,
KEY_FIELD
**
key_fields
,
uint
and_level
,
Item_func
*
cond
,
KEY_FIELD
**
key_fields
,
uint
and_level
,
Item_
bool_
func
*
cond
,
Field
*
field
,
bool
eq_func
,
Item
**
value
,
uint
num_values
,
table_map
usable_tables
,
SARGABLE_PARAM
**
sargables
)
{
...
...
@@ -4552,7 +4552,7 @@ add_key_field(JOIN *join,
static
void
add_key_equal_fields
(
JOIN
*
join
,
KEY_FIELD
**
key_fields
,
uint
and_level
,
Item_func
*
cond
,
Item
*
field_item
,
Item_
bool_
func
*
cond
,
Item
*
field_item
,
bool
eq_func
,
Item
**
val
,
uint
num_values
,
table_map
usable_tables
,
SARGABLE_PARAM
**
sargables
)
...
...
@@ -12511,7 +12511,8 @@ Item_equal *find_item_equal(COND_EQUAL *cond_equal, Field *field,
*/
static
bool
check_simple_equality
(
THD
*
thd
,
Item
*
left_item
,
Item
*
right_item
,
Item
*
item
,
COND_EQUAL
*
cond_equal
)
const
Item_bool_func
*
item
,
COND_EQUAL
*
cond_equal
)
{
Item
*
orig_left_item
=
left_item
;
Item
*
orig_right_item
=
right_item
;
...
...
@@ -12653,7 +12654,7 @@ static bool check_simple_equality(THD *thd, Item *left_item, Item *right_item,
eq_item
->
quick_fix_field
();
item
=
eq_item
;
}
if
((
cs
!=
((
Item_func
*
)
item
)
->
compare_collation
())
||
if
((
cs
!=
item
->
compare_collation
())
||
!
cs
->
coll
->
propagate
(
cs
,
0
,
0
))
return
FALSE
;
}
...
...
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