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
45769429
Commit
45769429
authored
Nov 14, 2018
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-17698 MEMORY engine performance regression
parent
f7184777
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
11 deletions
+39
-11
sql/item.h
sql/item.h
+4
-0
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+7
-11
sql/sql_type_int.h
sql/sql_type_int.h
+28
-0
No files found.
sql/item.h
View file @
45769429
...
@@ -1028,6 +1028,10 @@ class Item: public Value_source,
...
@@ -1028,6 +1028,10 @@ class Item: public Value_source,
If value is not null null_value flag will be reset to FALSE.
If value is not null null_value flag will be reset to FALSE.
*/
*/
virtual
longlong
val_int
()
=
0
;
virtual
longlong
val_int
()
=
0
;
Longlong_hybrid
to_longlong_hybrid
()
{
return
Longlong_hybrid
(
val_int
(),
unsigned_flag
);
}
/**
/**
Get a value for CAST(x AS SIGNED).
Get a value for CAST(x AS SIGNED).
Too large positive unsigned integer values are converted
Too large positive unsigned integer values are converted
...
...
sql/item_cmpfunc.cc
View file @
45769429
...
@@ -2067,7 +2067,7 @@ bool Item_func_between::fix_length_and_dec()
...
@@ -2067,7 +2067,7 @@ bool Item_func_between::fix_length_and_dec()
if
(
!
args
[
0
]
||
!
args
[
1
]
||
!
args
[
2
])
if
(
!
args
[
0
]
||
!
args
[
1
]
||
!
args
[
2
])
return
TRUE
;
return
TRUE
;
if
(
m_comparator
.
aggregate_for_comparison
(
Item_func_between
::
func_name
(),
if
(
m_comparator
.
aggregate_for_comparison
(
Item_func_between
::
func_name
(),
args
,
3
,
tru
e
))
args
,
3
,
fals
e
))
{
{
DBUG_ASSERT
(
current_thd
->
is_error
());
DBUG_ASSERT
(
current_thd
->
is_error
());
return
TRUE
;
return
TRUE
;
...
@@ -2171,23 +2171,19 @@ longlong Item_func_between::val_int_cmp_string()
...
@@ -2171,23 +2171,19 @@ longlong Item_func_between::val_int_cmp_string()
longlong
Item_func_between
::
val_int_cmp_int
()
longlong
Item_func_between
::
val_int_cmp_int
()
{
{
longlong
value
=
args
[
0
]
->
val_int
(),
a
,
b
;
Longlong_hybrid
value
=
args
[
0
]
->
to_longlong_hybrid
()
;
if
((
null_value
=
args
[
0
]
->
null_value
))
if
((
null_value
=
args
[
0
]
->
null_value
))
return
0
;
/* purecov: inspected */
return
0
;
/* purecov: inspected */
a
=
args
[
1
]
->
val_int
();
Longlong_hybrid
a
=
args
[
1
]
->
to_longlong_hybrid
();
b
=
args
[
2
]
->
val_int
();
Longlong_hybrid
b
=
args
[
2
]
->
to_longlong_hybrid
();
if
(
!
args
[
1
]
->
null_value
&&
!
args
[
2
]
->
null_value
)
if
(
!
args
[
1
]
->
null_value
&&
!
args
[
2
]
->
null_value
)
return
(
longlong
)
((
value
>=
a
&&
value
<=
b
)
!=
negated
);
return
(
longlong
)
((
value
.
cmp
(
a
)
>=
0
&&
value
.
cmp
(
b
)
<=
0
)
!=
negated
);
if
(
args
[
1
]
->
null_value
&&
args
[
2
]
->
null_value
)
if
(
args
[
1
]
->
null_value
&&
args
[
2
]
->
null_value
)
null_value
=
true
;
null_value
=
true
;
else
if
(
args
[
1
]
->
null_value
)
else
if
(
args
[
1
]
->
null_value
)
{
null_value
=
value
.
cmp
(
b
)
<=
0
;
// not null if false range.
null_value
=
value
<=
b
;
// not null if false range.
}
else
else
{
null_value
=
value
.
cmp
(
a
)
>=
0
;
null_value
=
value
>=
a
;
}
return
(
longlong
)
(
!
null_value
&&
negated
);
return
(
longlong
)
(
!
null_value
&&
negated
);
}
}
...
...
sql/sql_type_int.h
View file @
45769429
...
@@ -24,12 +24,25 @@ class Longlong_hybrid
...
@@ -24,12 +24,25 @@ class Longlong_hybrid
protected:
protected:
longlong
m_value
;
longlong
m_value
;
bool
m_unsigned
;
bool
m_unsigned
;
int
cmp_signed
(
const
Longlong_hybrid
&
other
)
const
{
return
m_value
<
other
.
m_value
?
-
1
:
m_value
==
other
.
m_value
?
0
:
1
;
}
int
cmp_unsigned
(
const
Longlong_hybrid
&
other
)
const
{
return
(
ulonglong
)
m_value
<
(
ulonglong
)
other
.
m_value
?
-
1
:
m_value
==
other
.
m_value
?
0
:
1
;
}
public:
public:
Longlong_hybrid
(
longlong
nr
,
bool
unsigned_flag
)
Longlong_hybrid
(
longlong
nr
,
bool
unsigned_flag
)
:
m_value
(
nr
),
m_unsigned
(
unsigned_flag
)
:
m_value
(
nr
),
m_unsigned
(
unsigned_flag
)
{
}
{
}
longlong
value
()
const
{
return
m_value
;
}
longlong
value
()
const
{
return
m_value
;
}
bool
is_unsigned
()
const
{
return
m_unsigned
;
}
bool
is_unsigned
()
const
{
return
m_unsigned
;
}
bool
is_unsigned_outside_of_signed_range
()
const
{
return
m_unsigned
&&
((
ulonglong
)
m_value
)
>
(
ulonglong
)
LONGLONG_MAX
;
}
bool
neg
()
const
{
return
m_value
<
0
&&
!
m_unsigned
;
}
bool
neg
()
const
{
return
m_value
<
0
&&
!
m_unsigned
;
}
ulonglong
abs
()
const
ulonglong
abs
()
const
{
{
...
@@ -39,6 +52,21 @@ class Longlong_hybrid
...
@@ -39,6 +52,21 @@ class Longlong_hybrid
return
((
ulonglong
)
LONGLONG_MAX
)
+
1
;
return
((
ulonglong
)
LONGLONG_MAX
)
+
1
;
return
m_value
<
0
?
-
m_value
:
m_value
;
return
m_value
<
0
?
-
m_value
:
m_value
;
}
}
int
cmp
(
const
Longlong_hybrid
&
other
)
const
{
if
(
m_unsigned
==
other
.
m_unsigned
)
return
m_unsigned
?
cmp_unsigned
(
other
)
:
cmp_signed
(
other
);
if
(
is_unsigned_outside_of_signed_range
())
return
1
;
if
(
other
.
is_unsigned_outside_of_signed_range
())
return
-
1
;
/*
The unsigned argument is in the range 0..LONGLONG_MAX.
The signed argument is in the range LONGLONG_MIN..LONGLONG_MAX.
Safe to compare as signed.
*/
return
cmp_signed
(
other
);
}
};
};
#endif // SQL_TYPE_INT_INCLUDED
#endif // SQL_TYPE_INT_INCLUDED
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