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
3c47809b
Commit
3c47809b
authored
Oct 06, 2015
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean-up: changing switch(result_type()) followed by a test for temporal types
in case of STRING_RESULT to switch(cmp_type()).
parent
56cd7d0c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
74 deletions
+66
-74
sql/item_func.cc
sql/item_func.cc
+57
-63
sql/sql_select.cc
sql/sql_select.cc
+9
-11
No files found.
sql/item_func.cc
View file @
3c47809b
...
...
@@ -871,7 +871,7 @@ void Item_func_num1::fix_length_and_dec()
String
*
Item_func_hybrid_field_type
::
val_str
(
String
*
str
)
{
DBUG_ASSERT
(
fixed
==
1
);
switch
(
Item_func_hybrid_field_type
::
result
_type
())
{
switch
(
Item_func_hybrid_field_type
::
cmp
_type
())
{
case
DECIMAL_RESULT
:
{
my_decimal
decimal_value
,
*
val
;
...
...
@@ -898,24 +898,23 @@ String *Item_func_hybrid_field_type::val_str(String *str)
str
->
set_real
(
nr
,
decimals
,
collation
.
collation
);
break
;
}
case
STRING_RESULT
:
if
(
is_temporal_type
(
field_type
()))
case
TIME_RESULT
:
{
MYSQL_TIME
ltime
;
if
(
date_op
(
&
ltime
,
field_type
()
==
MYSQL_TYPE_TIME
?
TIME_TIME_ONLY
:
0
)
||
str
->
alloc
(
MAX_DATE_STRING_REP_LENGTH
))
{
MYSQL_TIME
ltime
;
if
(
date_op
(
&
ltime
,
field_type
()
==
MYSQL_TYPE_TIME
?
TIME_TIME_ONLY
:
0
)
||
str
->
alloc
(
MAX_DATE_STRING_REP_LENGTH
))
{
null_value
=
1
;
return
(
String
*
)
0
;
}
ltime
.
time_type
=
mysql_type_to_time_type
(
field_type
());
str
->
length
(
my_TIME_to_str
(
&
ltime
,
const_cast
<
char
*>
(
str
->
ptr
()),
decimals
));
str
->
set_charset
(
&
my_charset_bin
);
return
str
;
null_value
=
1
;
return
(
String
*
)
0
;
}
ltime
.
time_type
=
mysql_type_to_time_type
(
field_type
());
str
->
length
(
my_TIME_to_str
(
&
ltime
,
const_cast
<
char
*>
(
str
->
ptr
()),
decimals
));
str
->
set_charset
(
&
my_charset_bin
);
return
str
;
}
case
STRING_RESULT
:
return
str_op
(
&
str_value
);
case
TIME_RESULT
:
case
ROW_RESULT
:
DBUG_ASSERT
(
0
);
}
...
...
@@ -926,7 +925,7 @@ String *Item_func_hybrid_field_type::val_str(String *str)
double
Item_func_hybrid_field_type
::
val_real
()
{
DBUG_ASSERT
(
fixed
==
1
);
switch
(
Item_func_hybrid_field_type
::
result
_type
())
{
switch
(
Item_func_hybrid_field_type
::
cmp
_type
())
{
case
DECIMAL_RESULT
:
{
my_decimal
decimal_value
,
*
val
;
...
...
@@ -943,24 +942,23 @@ double Item_func_hybrid_field_type::val_real()
}
case
REAL_RESULT
:
return
real_op
();
case
STRING
_RESULT
:
case
TIME
_RESULT
:
{
if
(
is_temporal_type
(
field_type
()))
MYSQL_TIME
ltime
;
if
(
date_op
(
&
ltime
,
field_type
()
==
MYSQL_TYPE_TIME
?
TIME_TIME_ONLY
:
0
))
{
MYSQL_TIME
ltime
;
if
(
date_op
(
&
ltime
,
field_type
()
==
MYSQL_TYPE_TIME
?
TIME_TIME_ONLY
:
0
))
{
null_value
=
1
;
return
0
;
}
ltime
.
time_type
=
mysql_type_to_time_type
(
field_type
());
return
TIME_to_double
(
&
ltime
);
null_value
=
1
;
return
0
;
}
ltime
.
time_type
=
mysql_type_to_time_type
(
field_type
());
return
TIME_to_double
(
&
ltime
);
}
case
STRING_RESULT
:
{
String
*
res
=
str_op
(
&
str_value
);
return
res
?
double_from_string_with_check
(
res
)
:
0.0
;
}
case
TIME_RESULT
:
case
ROW_RESULT
:
DBUG_ASSERT
(
0
);
}
...
...
@@ -971,7 +969,7 @@ double Item_func_hybrid_field_type::val_real()
longlong
Item_func_hybrid_field_type
::
val_int
()
{
DBUG_ASSERT
(
fixed
==
1
);
switch
(
Item_func_hybrid_field_type
::
result
_type
())
{
switch
(
Item_func_hybrid_field_type
::
cmp
_type
())
{
case
DECIMAL_RESULT
:
{
my_decimal
decimal_value
,
*
val
;
...
...
@@ -985,24 +983,23 @@ longlong Item_func_hybrid_field_type::val_int()
return
int_op
();
case
REAL_RESULT
:
return
(
longlong
)
rint
(
real_op
());
case
STRING
_RESULT
:
case
TIME
_RESULT
:
{
if
(
is_temporal_type
(
field_type
()))
MYSQL_TIME
ltime
;
if
(
date_op
(
&
ltime
,
field_type
()
==
MYSQL_TYPE_TIME
?
TIME_TIME_ONLY
:
0
))
{
MYSQL_TIME
ltime
;
if
(
date_op
(
&
ltime
,
field_type
()
==
MYSQL_TYPE_TIME
?
TIME_TIME_ONLY
:
0
))
{
null_value
=
1
;
return
0
;
}
ltime
.
time_type
=
mysql_type_to_time_type
(
field_type
());
return
TIME_to_ulonglong
(
&
ltime
);
null_value
=
1
;
return
0
;
}
ltime
.
time_type
=
mysql_type_to_time_type
(
field_type
());
return
TIME_to_ulonglong
(
&
ltime
);
}
case
STRING_RESULT
:
{
String
*
res
=
str_op
(
&
str_value
);
return
res
?
longlong_from_string_with_check
(
res
)
:
0
;
}
case
TIME_RESULT
:
case
ROW_RESULT
:
DBUG_ASSERT
(
0
);
}
...
...
@@ -1014,7 +1011,7 @@ my_decimal *Item_func_hybrid_field_type::val_decimal(my_decimal *decimal_value)
{
my_decimal
*
val
=
decimal_value
;
DBUG_ASSERT
(
fixed
==
1
);
switch
(
Item_func_hybrid_field_type
::
result
_type
())
{
switch
(
Item_func_hybrid_field_type
::
cmp
_type
())
{
case
DECIMAL_RESULT
:
val
=
decimal_op
(
decimal_value
);
break
;
...
...
@@ -1030,26 +1027,25 @@ my_decimal *Item_func_hybrid_field_type::val_decimal(my_decimal *decimal_value)
double2my_decimal
(
E_DEC_FATAL_ERROR
,
result
,
decimal_value
);
break
;
}
case
STRING
_RESULT
:
case
TIME
_RESULT
:
{
if
(
is_temporal_type
(
field_type
()))
MYSQL_TIME
ltime
;
if
(
date_op
(
&
ltime
,
field_type
()
==
MYSQL_TYPE_TIME
?
TIME_TIME_ONLY
:
0
))
{
MYSQL_TIME
ltime
;
if
(
date_op
(
&
ltime
,
field_type
()
==
MYSQL_TYPE_TIME
?
TIME_TIME_ONLY
:
0
))
{
my_decimal_set_zero
(
decimal_value
);
null_value
=
1
;
return
0
;
}
ltime
.
time_type
=
mysql_type_to_time_type
(
field_type
());
return
date2my_decimal
(
&
ltime
,
decimal_value
);
my_decimal_set_zero
(
decimal_value
);
null_value
=
1
;
return
0
;
}
ltime
.
time_type
=
mysql_type_to_time_type
(
field_type
());
return
date2my_decimal
(
&
ltime
,
decimal_value
);
}
case
STRING_RESULT
:
{
String
*
res
=
str_op
(
&
str_value
);
return
res
?
decimal_from_string_with_check
(
decimal_value
,
res
)
:
0
;
}
case
ROW_RESULT
:
case
TIME_RESULT
:
DBUG_ASSERT
(
0
);
}
return
val
;
...
...
@@ -1060,7 +1056,7 @@ bool Item_func_hybrid_field_type::get_date(MYSQL_TIME *ltime,
ulonglong
fuzzydate
)
{
DBUG_ASSERT
(
fixed
==
1
);
switch
(
Item_func_hybrid_field_type
::
result
_type
())
{
switch
(
Item_func_hybrid_field_type
::
cmp
_type
())
{
case
DECIMAL_RESULT
:
{
my_decimal
value
,
*
res
;
...
...
@@ -1088,12 +1084,12 @@ bool Item_func_hybrid_field_type::get_date(MYSQL_TIME *ltime,
goto
err
;
break
;
}
case
TIME_RESULT
:
return
date_op
(
ltime
,
fuzzydate
|
(
field_type
()
==
MYSQL_TYPE_TIME
?
TIME_TIME_ONLY
:
0
));
case
STRING_RESULT
:
{
if
(
is_temporal_type
(
field_type
()))
return
date_op
(
ltime
,
fuzzydate
|
(
field_type
()
==
MYSQL_TYPE_TIME
?
TIME_TIME_ONLY
:
0
));
char
buff
[
40
];
String
tmp
(
buff
,
sizeof
(
buff
),
&
my_charset_bin
),
*
res
;
if
(
!
(
res
=
str_op
(
&
tmp
))
||
...
...
@@ -1101,10 +1097,8 @@ bool Item_func_hybrid_field_type::get_date(MYSQL_TIME *ltime,
ltime
,
fuzzydate
))
goto
err
;
break
;
break
;
}
case
ROW_RESULT
:
case
TIME_RESULT
:
DBUG_ASSERT
(
0
);
}
...
...
sql/sql_select.cc
View file @
3c47809b
...
...
@@ -22410,7 +22410,7 @@ calc_group_buffer(JOIN *join,ORDER *group)
}
else
{
switch
(
group_item
->
result
_type
())
{
switch
(
group_item
->
cmp
_type
())
{
case
REAL_RESULT
:
key_length
+=
sizeof
(
double
);
break
;
...
...
@@ -22422,22 +22422,20 @@ calc_group_buffer(JOIN *join,ORDER *group)
(
group_item
->
decimals
?
1
:
0
),
group_item
->
decimals
);
break
;
case
STRING
_RESULT
:
case
TIME
_RESULT
:
{
enum
enum_field_types
type
=
group_item
->
field_type
();
/*
As items represented as DATE/TIME fields in the group buffer
have STRING_RESULT result type, we increase the length
by 8 as maximum pack length of such fields.
*/
if
(
type
==
MYSQL_TYPE_TIME
||
type
==
MYSQL_TYPE_DATE
||
type
==
MYSQL_TYPE_DATETIME
||
type
==
MYSQL_TYPE_TIMESTAMP
)
{
key_length
+=
8
;
}
else
if
(
type
==
MYSQL_TYPE_BLOB
)
key_length
+=
8
;
break
;
}
case
STRING_RESULT
:
{
enum
enum_field_types
type
=
group_item
->
field_type
();
if
(
type
==
MYSQL_TYPE_BLOB
)
key_length
+=
MAX_BLOB_WIDTH
;
// Can't be used as a key
else
{
...
...
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