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
81194d92
Commit
81194d92
authored
Oct 20, 2014
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-6649 Different warnings for TIME and TIME(N) when @@old_mode=zero_date_time_cast
parent
af4d469a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
11 deletions
+45
-11
mysql-test/r/old-mode.result
mysql-test/r/old-mode.result
+13
-0
mysql-test/t/old-mode.test
mysql-test/t/old-mode.test
+9
-0
sql/field.cc
sql/field.cc
+22
-11
sql/field.h
sql/field.h
+1
-0
No files found.
mysql-test/r/old-mode.result
View file @
81194d92
...
...
@@ -101,3 +101,16 @@ Warnings:
Warning 1292 Incorrect datetime value: '0000-00-00 00:20:12'
Warning 1292 Truncated incorrect datetime value: '-00:20:12'
DROP TABLE t1;
#
# MDEV-6649 Different warnings for TIME and TIME(N) when @@old_mode=zero_date_time_cast
#
SET @@old_mode=zero_date_time_cast;
CREATE TABLE t1 (a TIME,b TIME(1));
INSERT INTO t1 VALUES (TIME'830:20:30',TIME'830:20:30');
SELECT TO_DAYS(a), TO_DAYS(b) FROM t1;
TO_DAYS(a) TO_DAYS(b)
NULL NULL
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
Warning 1264 Out of range value for column 'b' at row 1
DROP TABLE t1;
mysql-test/t/old-mode.test
View file @
81194d92
...
...
@@ -64,3 +64,12 @@ INSERT INTO t1 VALUES (NULL, '00:20:12');
INSERT
INTO
t1
VALUES
(
NULL
,
'-00:20:12'
);
SELECT
IF
(
1
,
ADDDATE
(
IFNULL
(
a
,
b
),
0
),
1
)
FROM
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# MDEV-6649 Different warnings for TIME and TIME(N) when @@old_mode=zero_date_time_cast
--
echo
#
SET
@@
old_mode
=
zero_date_time_cast
;
CREATE
TABLE
t1
(
a
TIME
,
b
TIME
(
1
));
INSERT
INTO
t1
VALUES
(
TIME
'830:20:30'
,
TIME
'830:20:30'
);
SELECT
TO_DAYS
(
a
),
TO_DAYS
(
b
)
FROM
t1
;
DROP
TABLE
t1
;
sql/field.cc
View file @
81194d92
...
...
@@ -5442,6 +5442,21 @@ String *Field_time::val_str(String *str,
}
bool
Field_time
::
check_zero_in_date_with_warn
(
ulonglong
fuzzydate
)
{
if
(
!
(
fuzzydate
&
TIME_TIME_ONLY
)
&&
(
fuzzydate
&
TIME_NO_ZERO_IN_DATE
))
{
THD
*
thd
=
get_thd
();
push_warning_printf
(
thd
,
Sql_condition
::
WARN_LEVEL_WARN
,
ER_WARN_DATA_OUT_OF_RANGE
,
ER
(
ER_WARN_DATA_OUT_OF_RANGE
),
field_name
,
thd
->
get_stmt_da
()
->
current_row_for_warning
());
return
true
;
}
return
false
;
}
/**
@note
Normally we would not consider 'time' as a valid date, but we allow
...
...
@@ -5451,16 +5466,8 @@ String *Field_time::val_str(String *str,
bool
Field_time
::
get_date
(
MYSQL_TIME
*
ltime
,
ulonglong
fuzzydate
)
{
if
(
!
(
fuzzydate
&
TIME_TIME_ONLY
)
&&
(
fuzzydate
&
TIME_NO_ZERO_IN_DATE
))
{
THD
*
thd
=
get_thd
();
push_warning_printf
(
thd
,
Sql_condition
::
WARN_LEVEL_WARN
,
ER_WARN_DATA_OUT_OF_RANGE
,
ER
(
ER_WARN_DATA_OUT_OF_RANGE
),
field_name
,
thd
->
get_stmt_da
()
->
current_row_for_warning
());
return
1
;
}
if
(
check_zero_in_date_with_warn
(
fuzzydate
))
return
true
;
long
tmp
=
(
long
)
sint3korr
(
ptr
);
ltime
->
neg
=
0
;
if
(
tmp
<
0
)
...
...
@@ -5565,6 +5572,8 @@ double Field_time_with_dec::val_real(void)
bool
Field_time_hires
::
get_date
(
MYSQL_TIME
*
ltime
,
ulonglong
fuzzydate
)
{
if
(
check_zero_in_date_with_warn
(
fuzzydate
))
return
true
;
uint32
len
=
pack_length
();
longlong
packed
=
read_bigendian
(
ptr
,
len
);
...
...
@@ -5578,7 +5587,7 @@ bool Field_time_hires::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate)
ltime
->
time_type
=
MYSQL_TIMESTAMP_TIME
;
ltime
->
hour
+=
(
ltime
->
month
*
32
+
ltime
->
day
)
*
24
;
ltime
->
month
=
ltime
->
day
=
0
;
return
!
(
fuzzydate
&
TIME_TIME_ONLY
)
&&
(
fuzzydate
&
TIME_NO_ZERO_IN_DATE
)
;
return
false
;
}
...
...
@@ -5623,6 +5632,8 @@ void Field_timef::store_TIME(MYSQL_TIME *ltime)
bool
Field_timef
::
get_date
(
MYSQL_TIME
*
ltime
,
ulonglong
fuzzydate
)
{
if
(
check_zero_in_date_with_warn
(
fuzzydate
))
return
true
;
longlong
tmp
=
my_time_packed_from_binary
(
ptr
,
dec
);
TIME_from_longlong_time_packed
(
ltime
,
tmp
);
return
false
;
...
...
sql/field.h
View file @
81194d92
...
...
@@ -1885,6 +1885,7 @@ protected:
virtual
void
store_TIME
(
MYSQL_TIME
*
ltime
);
int
store_TIME_with_warning
(
MYSQL_TIME
*
ltime
,
const
ErrConv
*
str
,
int
was_cut
,
int
have_smth_to_conv
);
bool
check_zero_in_date_with_warn
(
ulonglong
fuzzydate
);
public:
Field_time
(
uchar
*
ptr_arg
,
uint
length_arg
,
uchar
*
null_ptr_arg
,
uchar
null_bit_arg
,
enum
utype
unireg_check_arg
,
...
...
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