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
8ecc7537
Commit
8ecc7537
authored
Aug 02, 2018
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-16884 Remove tests for field_type() in Item_cache_temporal
parent
c7115428
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
38 deletions
+44
-38
sql/field.cc
sql/field.cc
+2
-2
sql/item.cc
sql/item.cc
+1
-27
sql/item.h
sql/item.h
+28
-7
sql/sql_type.h
sql/sql_type.h
+13
-2
No files found.
sql/field.cc
View file @
8ecc7537
...
...
@@ -5800,7 +5800,7 @@ Item *Field_temporal::get_equal_const_item_datetime(THD *thd,
case
ANY_SUBST
:
if
(
!
is_temporal_type_with_date
(
const_item
->
field_type
()))
{
Datetime
dt
(
thd
,
const_item
,
TIME_FUZZY_DATES
|
TIME_INVALID_DATES
);
Datetime
dt
(
thd
,
const_item
,
Datetime
::
comparison_flags_for_get_date
()
);
if
(
!
dt
.
is_valid_datetime
())
return
NULL
;
return
new
(
thd
->
mem_root
)
...
...
@@ -6633,7 +6633,7 @@ Item *Field_newdate::get_equal_const_item(THD *thd, const Context &ctx,
if
(
!
is_temporal_type_with_date
(
const_item
->
field_type
()))
{
// Get the value of const_item with conversion from TIME to DATETIME
Datetime
dt
(
thd
,
const_item
,
TIME_FUZZY_DATES
|
TIME_INVALID_DATES
);
Datetime
dt
(
thd
,
const_item
,
Datetime
::
comparison_flags_for_get_date
()
);
if
(
!
dt
.
is_valid_datetime
())
return
NULL
;
/*
...
...
sql/item.cc
View file @
8ecc7537
...
...
@@ -118,7 +118,7 @@ void Item::push_note_converted_to_positive_complement(THD *thd)
longlong
Item
::
val_datetime_packed_result
()
{
MYSQL_TIME
ltime
,
tmp
;
if
(
get_date_result
(
&
ltime
,
TIME_FUZZY_DATES
|
TIME_INVALID_DATES
))
if
(
get_date_result
(
&
ltime
,
Datetime
::
comparison_flags_for_get_date
()
))
return
0
;
if
(
ltime
.
time_type
!=
MYSQL_TIMESTAMP_TIME
)
return
pack_time
(
&
ltime
);
...
...
@@ -9996,32 +9996,6 @@ Item_cache_temporal::Item_cache_temporal(THD *thd, const Type_handler *handler)
}
longlong
Item_cache_temporal
::
val_datetime_packed
()
{
if
(
Item_cache_temporal
::
field_type
()
==
MYSQL_TYPE_TIME
)
return
Item
::
val_datetime_packed
();
// TIME-to-DATETIME conversion needed
if
((
!
value_cached
&&
!
cache_value
())
||
null_value
)
{
null_value
=
TRUE
;
return
0
;
}
return
value
;
}
longlong
Item_cache_temporal
::
val_time_packed
()
{
if
(
Item_cache_temporal
::
field_type
()
!=
MYSQL_TYPE_TIME
)
return
Item
::
val_time_packed
();
// DATETIME-to-TIME conversion needed
if
((
!
value_cached
&&
!
cache_value
())
||
null_value
)
{
null_value
=
TRUE
;
return
0
;
}
return
value
;
}
bool
Item_cache_temporal
::
cache_value
()
{
if
(
!
example
)
...
...
sql/item.h
View file @
8ecc7537
...
...
@@ -1654,15 +1654,13 @@ class Item: public Value_source,
// Get a DATE or DATETIME value in numeric packed format for comparison
virtual
longlong
val_datetime_packed
()
{
ulonglong
fuzzydate
=
TIME_FUZZY_DATES
|
TIME_INVALID_DATES
;
Datetime
dt
(
current_thd
,
this
,
fuzzydate
);
return
dt
.
is_valid_datetime
()
?
pack_time
(
dt
.
get_mysql_time
())
:
0
;
ulonglong
fuzzydate
=
Datetime
::
comparison_flags_for_get_date
();
return
Datetime
(
current_thd
,
this
,
fuzzydate
).
to_packed
();
}
// Get a TIME value in numeric packed format for comparison
virtual
longlong
val_time_packed
()
{
Time
tm
(
this
,
Time
::
comparison_flags_for_get_date
());
return
tm
.
is_valid_time
()
?
pack_time
(
tm
.
get_mysql_time
())
:
0
;
return
Time
(
this
,
Time
::
comparison_flags_for_get_date
()).
to_packed
();
}
longlong
val_datetime_packed_result
();
longlong
val_time_packed_result
()
...
...
@@ -6491,8 +6489,6 @@ class Item_cache_temporal: public Item_cache_int
protected:
Item_cache_temporal
(
THD
*
thd
,
const
Type_handler
*
handler
);
public:
longlong
val_datetime_packed
();
longlong
val_time_packed
();
bool
cache_value
();
bool
get_date
(
MYSQL_TIME
*
ltime
,
ulonglong
fuzzydate
);
int
save_in_field
(
Field
*
field
,
bool
no_conversions
);
...
...
@@ -6517,6 +6513,15 @@ class Item_cache_time: public Item_cache_temporal
Item
*
get_copy
(
THD
*
thd
)
{
return
get_item_copy
<
Item_cache_time
>
(
thd
,
this
);
}
Item
*
make_literal
(
THD
*
);
longlong
val_datetime_packed
()
{
ulonglong
fuzzy
=
Datetime
::
comparison_flags_for_get_date
();
return
has_value
()
?
Datetime
(
current_thd
,
this
,
fuzzy
).
to_longlong
()
:
0
;
}
longlong
val_time_packed
()
{
return
has_value
()
?
value
:
0
;
}
longlong
val_int
()
{
return
has_value
()
?
Time
(
this
).
to_longlong
()
:
0
;
...
...
@@ -6544,6 +6549,14 @@ class Item_cache_datetime: public Item_cache_temporal
Item
*
get_copy
(
THD
*
thd
)
{
return
get_item_copy
<
Item_cache_datetime
>
(
thd
,
this
);
}
Item
*
make_literal
(
THD
*
);
longlong
val_datetime_packed
()
{
return
has_value
()
?
value
:
0
;
}
longlong
val_time_packed
()
{
return
Time
(
this
,
Time
::
comparison_flags_for_get_date
()).
to_packed
();
}
longlong
val_int
()
{
return
has_value
()
?
Datetime
(
this
).
to_longlong
()
:
0
;
...
...
@@ -6571,6 +6584,14 @@ class Item_cache_date: public Item_cache_temporal
Item
*
get_copy
(
THD
*
thd
)
{
return
get_item_copy
<
Item_cache_date
>
(
thd
,
this
);
}
Item
*
make_literal
(
THD
*
);
longlong
val_datetime_packed
()
{
return
has_value
()
?
value
:
0
;
}
longlong
val_time_packed
()
{
return
Time
(
this
,
Time
::
comparison_flags_for_get_date
()).
to_packed
();
}
longlong
val_int
()
{
return
has_value
()
?
Date
(
this
).
to_longlong
()
:
0
;
}
double
val_real
()
{
return
has_value
()
?
Date
(
this
).
to_double
()
:
0
;
}
String
*
val_str
(
String
*
to
)
...
...
sql/sql_type.h
View file @
8ecc7537
...
...
@@ -164,6 +164,7 @@ class Temporal: protected MYSQL_TIME
double
d
=
(
double
)
num
+
frac
/
(
double
)
TIME_SECOND_PART_FACTOR
;
return
negate
?
-
d
:
d
;
}
longlong
to_packed
()
const
{
return
::
pack_time
(
this
);
}
public:
};
...
...
@@ -373,8 +374,8 @@ class Time: private Temporal
{
DBUG_ASSERT
(
is_valid_time_slow
());
DBUG_ASSERT
(
other
->
is_valid_time_slow
());
longlong
p0
=
pack_time
(
this
);
longlong
p1
=
pack_time
(
other
);
longlong
p0
=
to_packed
(
);
longlong
p1
=
other
->
to_packed
(
);
if
(
p0
<
p1
)
return
-
1
;
if
(
p0
>
p1
)
...
...
@@ -415,6 +416,10 @@ class Time: private Temporal
{
return
is_valid_time
()
?
Temporal
::
to_decimal
(
to
)
:
bad_to_decimal
(
to
);
}
longlong
to_packed
()
const
{
return
is_valid_time
()
?
Temporal
::
to_packed
()
:
0
;
}
};
...
...
@@ -459,6 +464,8 @@ class Temporal_with_date: protected Temporal
{
return
::
check_date_with_warn
(
this
,
flags
,
MYSQL_TIMESTAMP_ERROR
);
}
static
sql_mode_t
comparison_flags_for_get_date
()
{
return
TIME_INVALID_DATES
|
TIME_FUZZY_DATES
;
}
};
...
...
@@ -666,6 +673,10 @@ class Datetime: public Temporal_with_date
{
return
is_valid_datetime
()
?
Temporal
::
to_decimal
(
to
)
:
bad_to_decimal
(
to
);
}
longlong
to_packed
()
const
{
return
is_valid_datetime
()
?
Temporal
::
to_packed
()
:
0
;
}
};
/*
...
...
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