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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
fe145b09
Commit
fe145b09
authored
Feb 02, 2011
by
Georgi Kodinov
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
d98270e1
72ae1d65
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
81 additions
and
15 deletions
+81
-15
config.h.cmake
config.h.cmake
+5
-0
configure.cmake
configure.cmake
+11
-0
include/my_time.h
include/my_time.h
+13
-0
mysql-test/r/func_time.result
mysql-test/r/func_time.result
+18
-0
mysql-test/t/func_time.test
mysql-test/t/func_time.test
+18
-0
mysql-test/t/variables.test
mysql-test/t/variables.test
+1
-1
sql-common/my_time.c
sql-common/my_time.c
+1
-1
sql/mysqld.cc
sql/mysqld.cc
+7
-6
sql/sql_class.h
sql/sql_class.h
+1
-1
sql/sys_vars.cc
sql/sys_vars.cc
+6
-6
No files found.
config.h.cmake
View file @
fe145b09
...
@@ -614,4 +614,9 @@
...
@@ -614,4 +614,9 @@
#define PROTOCOL_VERSION 10
#define PROTOCOL_VERSION 10
/* time_t related defines */
#cmakedefine SIZEOF_TIME_T @SIZEOF_TIME_T@
#cmakedefine TIME_T_UNSIGNED @TIME_T_UNSIGNED@
#endif
#endif
configure.cmake
View file @
fe145b09
...
@@ -574,6 +574,7 @@ MY_CHECK_TYPE_SIZE(uint32 UINT32)
...
@@ -574,6 +574,7 @@ MY_CHECK_TYPE_SIZE(uint32 UINT32)
MY_CHECK_TYPE_SIZE
(
u_int32_t U_INT32_T
)
MY_CHECK_TYPE_SIZE
(
u_int32_t U_INT32_T
)
MY_CHECK_TYPE_SIZE
(
int64 INT64
)
MY_CHECK_TYPE_SIZE
(
int64 INT64
)
MY_CHECK_TYPE_SIZE
(
uint64 UINT64
)
MY_CHECK_TYPE_SIZE
(
uint64 UINT64
)
MY_CHECK_TYPE_SIZE
(
time_t TIME_T
)
SET
(
CMAKE_EXTRA_INCLUDE_FILES sys/types.h
)
SET
(
CMAKE_EXTRA_INCLUDE_FILES sys/types.h
)
MY_CHECK_TYPE_SIZE
(
bool BOOL
)
MY_CHECK_TYPE_SIZE
(
bool BOOL
)
SET
(
CMAKE_EXTRA_INCLUDE_FILES
)
SET
(
CMAKE_EXTRA_INCLUDE_FILES
)
...
@@ -593,6 +594,16 @@ ENDIF()
...
@@ -593,6 +594,16 @@ ENDIF()
# Code tests
# Code tests
#
#
# check whether time_t is unsigned
CHECK_C_SOURCE_COMPILES
(
"
int main()
{
int array[(((time_t)-1) > 0) ? 1 : -1];
return 0;
}"
TIME_T_UNSIGNED
)
CHECK_C_SOURCE_COMPILES
(
"
CHECK_C_SOURCE_COMPILES
(
"
#ifdef _WIN32
#ifdef _WIN32
#include <winsock2.h>
#include <winsock2.h>
...
...
include/my_time.h
View file @
fe145b09
...
@@ -50,6 +50,19 @@ typedef long my_time_t;
...
@@ -50,6 +50,19 @@ typedef long my_time_t;
/* two-digit years < this are 20..; >= this are 19.. */
/* two-digit years < this are 20..; >= this are 19.. */
#define YY_PART_YEAR 70
#define YY_PART_YEAR 70
/*
check for valid times only if the range of time_t is greater than
the range of my_time_t
*/
#if SIZEOF_TIME_T > 4 || defined(TIME_T_UNSIGNED)
# define IS_TIME_T_VALID_FOR_TIMESTAMP(x) \
((x) <= TIMESTAMP_MAX_VALUE && \
(x) >= TIMESTAMP_MIN_VALUE)
#else
# define IS_TIME_T_VALID_FOR_TIMESTAMP(x) \
((x) >= TIMESTAMP_MIN_VALUE)
#endif
/* Flags to str_to_datetime */
/* Flags to str_to_datetime */
#define TIME_FUZZY_DATE 1
#define TIME_FUZZY_DATE 1
#define TIME_DATETIME_ONLY 2
#define TIME_DATETIME_ONLY 2
...
...
mysql-test/r/func_time.result
View file @
fe145b09
...
@@ -1273,6 +1273,24 @@ date_add('1000-01-01 00:00:00', interval '1.03:02:01.05' day_microsecond)
...
@@ -1273,6 +1273,24 @@ date_add('1000-01-01 00:00:00', interval '1.03:02:01.05' day_microsecond)
select date_add('1000-01-01 00:00:00', interval '1.02' day_microsecond);
select date_add('1000-01-01 00:00:00', interval '1.02' day_microsecond);
date_add('1000-01-01 00:00:00', interval '1.02' day_microsecond)
date_add('1000-01-01 00:00:00', interval '1.02' day_microsecond)
1000-01-01 00:00:01.020000
1000-01-01 00:00:01.020000
#
# Bug #52315 part 2 : utc_date() crashes when system time > year 2037
#
SET TIMESTAMP=-147490000;
SELECT UTC_TIMESTAMP();
SET TIMESTAMP=2147483648;
SELECT UTC_TIMESTAMP();
SET TIMESTAMP=2147483646;
SELECT UTC_TIMESTAMP();
SET TIMESTAMP=2147483647;
SELECT UTC_TIMESTAMP();
SET TIMESTAMP=0;
SELECT UTC_TIMESTAMP();
SET TIMESTAMP=-1;
SELECT UTC_TIMESTAMP();
SET TIMESTAMP=1;
SELECT UTC_TIMESTAMP();
SET TIMESTAMP=0;
End of 5.0 tests
End of 5.0 tests
select date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND);
select date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND);
date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND)
date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND)
...
...
mysql-test/t/func_time.test
View file @
fe145b09
...
@@ -802,6 +802,24 @@ select LAST_DAY('2007-12-06 08:59:19.05') - INTERVAL 1 SECOND;
...
@@ -802,6 +802,24 @@ select LAST_DAY('2007-12-06 08:59:19.05') - INTERVAL 1 SECOND;
select
date_add
(
'1000-01-01 00:00:00'
,
interval
'1.03:02:01.05'
day_microsecond
);
select
date_add
(
'1000-01-01 00:00:00'
,
interval
'1.03:02:01.05'
day_microsecond
);
select
date_add
(
'1000-01-01 00:00:00'
,
interval
'1.02'
day_microsecond
);
select
date_add
(
'1000-01-01 00:00:00'
,
interval
'1.02'
day_microsecond
);
--
echo
#
--
echo
# Bug #52315 part 2 : utc_date() crashes when system time > year 2037
--
echo
#
--
disable_result_log
SET
TIMESTAMP
=-
147490000
;
SELECT
UTC_TIMESTAMP
();
--
error
ER_WRONG_VALUE_FOR_VAR
SET
TIMESTAMP
=
2147483648
;
SELECT
UTC_TIMESTAMP
();
SET
TIMESTAMP
=
2147483646
;
SELECT
UTC_TIMESTAMP
();
SET
TIMESTAMP
=
2147483647
;
SELECT
UTC_TIMESTAMP
();
SET
TIMESTAMP
=
0
;
SELECT
UTC_TIMESTAMP
();
SET
TIMESTAMP
=-
1
;
SELECT
UTC_TIMESTAMP
();
SET
TIMESTAMP
=
1
;
SELECT
UTC_TIMESTAMP
();
SET
TIMESTAMP
=
0
;
--
enable_result_log
--
echo
End
of
5.0
tests
--
echo
End
of
5.0
tests
#
#
...
...
mysql-test/t/variables.test
View file @
fe145b09
...
@@ -779,7 +779,7 @@ SET @@myisam_mmap_size= 500M;
...
@@ -779,7 +779,7 @@ SET @@myisam_mmap_size= 500M;
--
echo
# Bug #52315: utc_date() crashes when system time > year 2037
--
echo
# Bug #52315: utc_date() crashes when system time > year 2037
--
echo
#
--
echo
#
--
error
0
,
ER_
UNKNOWN_ERRO
R
--
error
0
,
ER_
WRONG_VALUE_FOR_VA
R
SET
TIMESTAMP
=
2
*
1024
*
1024
*
1024
;
SET
TIMESTAMP
=
2
*
1024
*
1024
*
1024
;
--
echo
#Should not crash
--
echo
#Should not crash
--
disable_result_log
--
disable_result_log
...
...
sql-common/my_time.c
View file @
fe145b09
...
@@ -992,7 +992,7 @@ my_system_gmt_sec(const MYSQL_TIME *t_src, long *my_timezone,
...
@@ -992,7 +992,7 @@ my_system_gmt_sec(const MYSQL_TIME *t_src, long *my_timezone,
with unsigned time_t tmp+= shift*86400L might result in a number,
with unsigned time_t tmp+= shift*86400L might result in a number,
larger then TIMESTAMP_MAX_VALUE, so another check will work.
larger then TIMESTAMP_MAX_VALUE, so another check will work.
*/
*/
if
(
(
tmp
<
TIMESTAMP_MIN_VALUE
)
||
(
tmp
>
TIMESTAMP_MAX_VALUE
))
if
(
!
IS_TIME_T_VALID_FOR_TIMESTAMP
(
tmp
))
tmp
=
0
;
tmp
=
0
;
return
(
my_time_t
)
tmp
;
return
(
my_time_t
)
tmp
;
...
...
sql/mysqld.cc
View file @
fe145b09
...
@@ -3080,12 +3080,6 @@ static int init_common_variables()
...
@@ -3080,12 +3080,6 @@ static int init_common_variables()
max_system_variables
.
pseudo_thread_id
=
(
ulong
)
~
0
;
max_system_variables
.
pseudo_thread_id
=
(
ulong
)
~
0
;
server_start_time
=
flush_status_time
=
my_time
(
0
);
server_start_time
=
flush_status_time
=
my_time
(
0
);
/* TODO: remove this when my_time_t is 64 bit compatible */
if
(
server_start_time
>=
(
time_t
)
MY_TIME_T_MAX
)
{
sql_print_error
(
"This MySQL server doesn't support dates later then 2038"
);
return
1
;
}
rpl_filter
=
new
Rpl_filter
;
rpl_filter
=
new
Rpl_filter
;
binlog_filter
=
new
Rpl_filter
;
binlog_filter
=
new
Rpl_filter
;
...
@@ -3124,6 +3118,13 @@ static int init_common_variables()
...
@@ -3124,6 +3118,13 @@ static int init_common_variables()
*/
*/
mysql_bin_log
.
init_pthread_objects
();
mysql_bin_log
.
init_pthread_objects
();
/* TODO: remove this when my_time_t is 64 bit compatible */
if
(
!
IS_TIME_T_VALID_FOR_TIMESTAMP
(
server_start_time
))
{
sql_print_error
(
"This MySQL server doesn't support dates later then 2038"
);
return
1
;
}
if
(
gethostname
(
glob_hostname
,
sizeof
(
glob_hostname
))
<
0
)
if
(
gethostname
(
glob_hostname
,
sizeof
(
glob_hostname
))
<
0
)
{
{
strmake
(
glob_hostname
,
STRING_WITH_LEN
(
"localhost"
));
strmake
(
glob_hostname
,
STRING_WITH_LEN
(
"localhost"
));
...
...
sql/sql_class.h
View file @
fe145b09
...
@@ -2280,7 +2280,7 @@ public:
...
@@ -2280,7 +2280,7 @@ public:
/*TODO: this will be obsolete when we have support for 64 bit my_time_t */
/*TODO: this will be obsolete when we have support for 64 bit my_time_t */
inline
bool
is_valid_time
()
inline
bool
is_valid_time
()
{
{
return
(
start_time
<
(
time_t
)
MY_TIME_T_MAX
);
return
(
IS_TIME_T_VALID_FOR_TIMESTAMP
(
start_time
));
}
}
void
set_time_after_lock
()
{
utime_after_lock
=
my_micro_time
();
}
void
set_time_after_lock
()
{
utime_after_lock
=
my_micro_time
();
}
ulonglong
current_utime
()
{
return
my_micro_time
();
}
ulonglong
current_utime
()
{
return
my_micro_time
();
}
...
...
sql/sys_vars.cc
View file @
fe145b09
...
@@ -2430,17 +2430,17 @@ static ulonglong read_timestamp(THD *thd)
...
@@ -2430,17 +2430,17 @@ static ulonglong read_timestamp(THD *thd)
static
bool
check_timestamp
(
sys_var
*
self
,
THD
*
thd
,
set_var
*
var
)
static
bool
check_timestamp
(
sys_var
*
self
,
THD
*
thd
,
set_var
*
var
)
{
{
time_t
val
;
longlong
val
;
if
(
!
var
->
value
)
if
(
!
var
->
value
)
return
FALSE
;
return
FALSE
;
val
=
(
time_t
)
var
->
save_result
.
ulonglong_value
;
val
=
(
longlong
)
var
->
save_result
.
ulonglong_value
;
if
(
val
<
(
time_t
)
MY_TIME_T_MIN
||
val
>
(
time_t
)
MY_TIME_T_MAX
)
if
(
val
!=
0
&&
// this is how you set the default value
(
val
<
TIMESTAMP_MIN_VALUE
||
val
>
TIMESTAMP_MAX_VALUE
))
{
{
my_message
(
ER_UNKNOWN_ERROR
,
char
buf
[
64
];
"This version of MySQL doesn't support dates later than 2038"
,
my_error
(
ER_WRONG_VALUE_FOR_VAR
,
MYF
(
0
),
"timestamp"
,
llstr
(
val
,
buf
));
MYF
(
0
));
return
TRUE
;
return
TRUE
;
}
}
return
FALSE
;
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