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
144c7f8b
Commit
144c7f8b
authored
Feb 21, 2018
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding Field_timestamp::sql_mode_for_timestamp() to reuse duplicate code
parent
5417002d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
18 deletions
+16
-18
sql/field.cc
sql/field.cc
+15
-18
sql/field.h
sql/field.h
+1
-0
No files found.
sql/field.cc
View file @
144c7f8b
...
...
@@ -5016,6 +5016,13 @@ copy_or_convert_to_datetime(THD *thd, const MYSQL_TIME *from, MYSQL_TIME *to)
}
sql_mode_t
Field_timestamp
::
sql_mode_for_timestamp
(
THD
*
thd
)
const
{
// We don't want to store invalid or fuzzy datetime values in TIMESTAMP
return
(
thd
->
variables
.
sql_mode
&
MODE_NO_ZERO_DATE
)
|
MODE_NO_ZERO_IN_DATE
;
}
int
Field_timestamp
::
store_time_dec
(
const
MYSQL_TIME
*
ltime
,
uint
dec
)
{
int
unused
;
...
...
@@ -5024,9 +5031,7 @@ int Field_timestamp::store_time_dec(const MYSQL_TIME *ltime, uint dec)
MYSQL_TIME
l_time
;
bool
valid
=
!
copy_or_convert_to_datetime
(
thd
,
ltime
,
&
l_time
)
&&
!
check_date
(
&
l_time
,
pack_time
(
&
l_time
)
!=
0
,
(
thd
->
variables
.
sql_mode
&
MODE_NO_ZERO_DATE
)
|
MODE_NO_ZERO_IN_DATE
,
&
unused
);
sql_mode_for_timestamp
(
thd
),
&
unused
);
return
store_TIME_with_warning
(
thd
,
&
l_time
,
&
str
,
false
,
valid
);
}
...
...
@@ -5039,11 +5044,8 @@ int Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs)
ErrConvString
str
(
from
,
len
,
cs
);
THD
*
thd
=
get_thd
();
/* We don't want to store invalid or fuzzy datetime values in TIMESTAMP */
have_smth_to_conv
=
!
str_to_datetime
(
cs
,
from
,
len
,
&
l_time
,
(
thd
->
variables
.
sql_mode
&
MODE_NO_ZERO_DATE
)
|
MODE_NO_ZERO_IN_DATE
,
&
status
);
sql_mode_for_timestamp
(
thd
),
&
status
);
return
store_TIME_with_warning
(
thd
,
&
l_time
,
&
str
,
status
.
warnings
,
have_smth_to_conv
);
}
...
...
@@ -5056,9 +5058,8 @@ int Field_timestamp::store(double nr)
ErrConvDouble
str
(
nr
);
THD
*
thd
=
get_thd
();
longlong
tmp
=
double_to_datetime
(
nr
,
&
l_time
,
(
thd
->
variables
.
sql_mode
&
MODE_NO_ZERO_DATE
)
|
MODE_NO_ZERO_IN_DATE
,
&
error
);
longlong
tmp
=
double_to_datetime
(
nr
,
&
l_time
,
sql_mode_for_timestamp
(
thd
),
&
error
);
return
store_TIME_with_warning
(
thd
,
&
l_time
,
&
str
,
error
,
tmp
!=
-
1
);
}
...
...
@@ -5070,10 +5071,8 @@ int Field_timestamp::store(longlong nr, bool unsigned_val)
ErrConvInteger
str
(
nr
,
unsigned_val
);
THD
*
thd
=
get_thd
();
/* We don't want to store invalid or fuzzy datetime values in TIMESTAMP */
longlong
tmp
=
number_to_datetime
(
nr
,
0
,
&
l_time
,
(
thd
->
variables
.
sql_mode
&
MODE_NO_ZERO_DATE
)
|
MODE_NO_ZERO_IN_DATE
,
&
error
);
longlong
tmp
=
number_to_datetime
(
nr
,
0
,
&
l_time
,
sql_mode_for_timestamp
(
thd
),
&
error
);
return
store_TIME_with_warning
(
thd
,
&
l_time
,
&
str
,
error
,
tmp
!=
-
1
);
}
...
...
@@ -5398,10 +5397,8 @@ int Field_timestamp::store_decimal(const my_decimal *d)
error
=
2
;
}
else
tmp
=
number_to_datetime
(
nr
,
sec_part
,
&
ltime
,
TIME_NO_ZERO_IN_DATE
|
(
thd
->
variables
.
sql_mode
&
MODE_NO_ZERO_DATE
),
&
error
);
tmp
=
number_to_datetime
(
nr
,
sec_part
,
&
ltime
,
sql_mode_for_timestamp
(
thd
),
&
error
);
return
store_TIME_with_warning
(
thd
,
&
ltime
,
&
str
,
error
,
tmp
!=
-
1
);
}
...
...
sql/field.h
View file @
144c7f8b
...
...
@@ -2359,6 +2359,7 @@ class Field_temporal_with_date: public Field_temporal {
class
Field_timestamp
:
public
Field_temporal
{
protected:
sql_mode_t
sql_mode_for_timestamp
(
THD
*
thd
)
const
;
int
store_TIME_with_warning
(
THD
*
,
MYSQL_TIME
*
,
const
ErrConv
*
,
int
warnings
,
bool
have_smth_to_conv
);
public:
...
...
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