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
f89a27b4
Commit
f89a27b4
authored
Dec 02, 2018
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-17319 Assertion `ts_type != MYSQL_TIMESTAMP_TIME' failed upon inserting into TIME field
parent
17e371ff
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
65 additions
and
58 deletions
+65
-58
mysql-test/main/temporal_literal.result
mysql-test/main/temporal_literal.result
+6
-6
mysql-test/main/type_time.result
mysql-test/main/type_time.result
+9
-0
mysql-test/main/type_time.test
mysql-test/main/type_time.test
+12
-0
mysql-test/suite/versioning/r/sysvars.result
mysql-test/suite/versioning/r/sysvars.result
+3
-3
sql/field.cc
sql/field.cc
+20
-27
sql/field.h
sql/field.h
+10
-11
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+0
-1
sql/sql_table.cc
sql/sql_table.cc
+0
-1
sql/sql_type.cc
sql/sql_type.cc
+5
-9
No files found.
mysql-test/main/temporal_literal.result
View file @
f89a27b4
...
@@ -294,17 +294,17 @@ SELECT TIMESTAMP'2001-00-00 00:00:00.9999999';
...
@@ -294,17 +294,17 @@ SELECT TIMESTAMP'2001-00-00 00:00:00.9999999';
TIMESTAMP'2001-00-00 00:00:00.9999999'
TIMESTAMP'2001-00-00 00:00:00.9999999'
2001-00-00 00:00:00.999999
2001-00-00 00:00:00.999999
Warnings:
Warnings:
Note 1292 Truncated incorrect
datetime
value: '2001-00-00 00:00:00.9999999'
Note 1292 Truncated incorrect
DATETIME
value: '2001-00-00 00:00:00.9999999'
SELECT TIMESTAMP'2001-00-01 00:00:00.9999999';
SELECT TIMESTAMP'2001-00-01 00:00:00.9999999';
TIMESTAMP'2001-00-01 00:00:00.9999999'
TIMESTAMP'2001-00-01 00:00:00.9999999'
2001-00-01 00:00:00.999999
2001-00-01 00:00:00.999999
Warnings:
Warnings:
Note 1292 Truncated incorrect
datetime
value: '2001-00-01 00:00:00.9999999'
Note 1292 Truncated incorrect
DATETIME
value: '2001-00-01 00:00:00.9999999'
SELECT TIMESTAMP'2001-01-00 00:00:00.9999999';
SELECT TIMESTAMP'2001-01-00 00:00:00.9999999';
TIMESTAMP'2001-01-00 00:00:00.9999999'
TIMESTAMP'2001-01-00 00:00:00.9999999'
2001-01-00 00:00:00.999999
2001-01-00 00:00:00.999999
Warnings:
Warnings:
Note 1292 Truncated incorrect
datetime
value: '2001-01-00 00:00:00.9999999'
Note 1292 Truncated incorrect
DATETIME
value: '2001-01-00 00:00:00.9999999'
#
#
# String literal with bad dates and nanoseconds to DATETIME(N)
# String literal with bad dates and nanoseconds to DATETIME(N)
#
#
...
@@ -416,7 +416,7 @@ SELECT TIME'10:10:10.1234567';
...
@@ -416,7 +416,7 @@ SELECT TIME'10:10:10.1234567';
TIME'10:10:10.1234567'
TIME'10:10:10.1234567'
10:10:10.123456
10:10:10.123456
Warnings:
Warnings:
Note 1292 Truncated incorrect
time
value: '10:10:10.1234567'
Note 1292 Truncated incorrect
TIME
value: '10:10:10.1234567'
SELECT TIME('10:10:10.1234567');
SELECT TIME('10:10:10.1234567');
TIME('10:10:10.1234567')
TIME('10:10:10.1234567')
10:10:10.123456
10:10:10.123456
...
@@ -440,7 +440,7 @@ SELECT TIMESTAMP'2001-01-01 10:10:10.1234567';
...
@@ -440,7 +440,7 @@ SELECT TIMESTAMP'2001-01-01 10:10:10.1234567';
TIMESTAMP'2001-01-01 10:10:10.1234567'
TIMESTAMP'2001-01-01 10:10:10.1234567'
2001-01-01 10:10:10.123456
2001-01-01 10:10:10.123456
Warnings:
Warnings:
Note 1292 Truncated incorrect
datetime
value: '2001-01-01 10:10:10.1234567'
Note 1292 Truncated incorrect
DATETIME
value: '2001-01-01 10:10:10.1234567'
SELECT TIMESTAMP('2001-01-01 10:10:10.1234567');
SELECT TIMESTAMP('2001-01-01 10:10:10.1234567');
TIMESTAMP('2001-01-01 10:10:10.1234567')
TIMESTAMP('2001-01-01 10:10:10.1234567')
2001-01-01 10:10:10.123456
2001-01-01 10:10:10.123456
...
@@ -463,7 +463,7 @@ Warning 1292 Truncated incorrect datetime value: '2001-01-01 10:10:10.1234567xyz
...
@@ -463,7 +463,7 @@ Warning 1292 Truncated incorrect datetime value: '2001-01-01 10:10:10.1234567xyz
CREATE TABLE t1 (a TIME(6));
CREATE TABLE t1 (a TIME(6));
INSERT INTO t1 VALUES (TIME'10:20:30.1234567');
INSERT INTO t1 VALUES (TIME'10:20:30.1234567');
Warnings:
Warnings:
Note 1292 Truncated incorrect
time
value: '10:20:30.1234567'
Note 1292 Truncated incorrect
TIME
value: '10:20:30.1234567'
INSERT INTO t1 VALUES (TIME('10:20:30.1234567'));
INSERT INTO t1 VALUES (TIME('10:20:30.1234567'));
Warnings:
Warnings:
Note 1292 Truncated incorrect time value: '10:20:30.1234567'
Note 1292 Truncated incorrect time value: '10:20:30.1234567'
...
...
mysql-test/main/type_time.result
View file @
f89a27b4
...
@@ -2168,5 +2168,14 @@ Warning 1292 Truncated incorrect datetime value: 'z'
...
@@ -2168,5 +2168,14 @@ Warning 1292 Truncated incorrect datetime value: 'z'
Warning 1292 Truncated incorrect datetime value: 'z'
Warning 1292 Truncated incorrect datetime value: 'z'
Warning 1292 Truncated incorrect time value: 'z'
Warning 1292 Truncated incorrect time value: 'z'
#
#
# MDEV-17319 Assertion `ts_type != MYSQL_TIMESTAMP_TIME' failed upon inserting into TIME field
#
CREATE TABLE t1 (t TIME);
SET SESSION SQL_MODE='TRADITIONAL';
INSERT INTO t1 VALUES ('0000-00-00 00:00:00'),('0000-00-00 00:00:00');
ERROR 22007: Incorrect time value: '0000-00-00 00:00:00' for column 't' at row 1
SET sql_mode=DEFAULT;
DROP TABLE t1;
#
# End of 10.4 tests
# End of 10.4 tests
#
#
mysql-test/main/type_time.test
View file @
f89a27b4
...
@@ -1409,6 +1409,18 @@ DROP TABLE IF EXISTS t1;
...
@@ -1409,6 +1409,18 @@ DROP TABLE IF EXISTS t1;
SELECT
TIMESTAMP
(
0
)
=
'z'
,
DATE
(
0
)
=
'z'
,
TIME
(
0
)
=
'z'
;
SELECT
TIMESTAMP
(
0
)
=
'z'
,
DATE
(
0
)
=
'z'
,
TIME
(
0
)
=
'z'
;
--
echo
#
--
echo
# MDEV-17319 Assertion `ts_type != MYSQL_TIMESTAMP_TIME' failed upon inserting into TIME field
--
echo
#
CREATE
TABLE
t1
(
t
TIME
);
SET
SESSION
SQL_MODE
=
'TRADITIONAL'
;
--
error
ER_TRUNCATED_WRONG_VALUE
INSERT
INTO
t1
VALUES
(
'0000-00-00 00:00:00'
),(
'0000-00-00 00:00:00'
);
SET
sql_mode
=
DEFAULT
;
DROP
TABLE
t1
;
--
echo
#
--
echo
#
--
echo
# End of 10.4 tests
--
echo
# End of 10.4 tests
--
echo
#
--
echo
#
mysql-test/suite/versioning/r/sysvars.result
View file @
f89a27b4
...
@@ -53,7 +53,7 @@ Variable_name Value
...
@@ -53,7 +53,7 @@ Variable_name Value
system_versioning_asof 1900-01-01 00:00:00.000000
system_versioning_asof 1900-01-01 00:00:00.000000
set global system_versioning_asof= timestamp'1911-11-11 11:11:11.1111119';
set global system_versioning_asof= timestamp'1911-11-11 11:11:11.1111119';
Warnings:
Warnings:
Note 1292 Truncated incorrect
datetime
value: '1911-11-11 11:11:11.1111119'
Note 1292 Truncated incorrect
DATETIME
value: '1911-11-11 11:11:11.1111119'
show global variables like 'system_versioning_asof';
show global variables like 'system_versioning_asof';
Variable_name Value
Variable_name Value
system_versioning_asof 1911-11-11 11:11:11.111111
system_versioning_asof 1911-11-11 11:11:11.111111
...
@@ -80,7 +80,7 @@ Variable_name Value
...
@@ -80,7 +80,7 @@ Variable_name Value
system_versioning_asof 1900-01-01 00:00:00.000000
system_versioning_asof 1900-01-01 00:00:00.000000
set system_versioning_asof= timestamp'1911-11-11 11:11:11.1111119';
set system_versioning_asof= timestamp'1911-11-11 11:11:11.1111119';
Warnings:
Warnings:
Note 1292 Truncated incorrect
datetime
value: '1911-11-11 11:11:11.1111119'
Note 1292 Truncated incorrect
DATETIME
value: '1911-11-11 11:11:11.1111119'
show variables like 'system_versioning_asof';
show variables like 'system_versioning_asof';
Variable_name Value
Variable_name Value
system_versioning_asof 1911-11-11 11:11:11.111111
system_versioning_asof 1911-11-11 11:11:11.111111
...
@@ -136,7 +136,7 @@ drop table t;
...
@@ -136,7 +136,7 @@ drop table t;
SET sql_mode=TIME_ROUND_FRACTIONAL;
SET sql_mode=TIME_ROUND_FRACTIONAL;
SET @@global.system_versioning_asof= timestamp'2001-12-31 23:59:59.9999999';
SET @@global.system_versioning_asof= timestamp'2001-12-31 23:59:59.9999999';
Warnings:
Warnings:
Note 1292 Truncated incorrect
datetime
value: '2001-12-31 23:59:59.9999999'
Note 1292 Truncated incorrect
DATETIME
value: '2001-12-31 23:59:59.9999999'
SELECT @@global.system_versioning_asof;
SELECT @@global.system_versioning_asof;
@@global.system_versioning_asof
@@global.system_versioning_asof
2002-01-01 00:00:00.000000
2002-01-01 00:00:00.000000
...
...
sql/field.cc
View file @
f89a27b4
...
@@ -33,11 +33,6 @@
...
@@ -33,11 +33,6 @@
#include "rpl_rli.h" // Pull in Relay_log_info
#include "rpl_rli.h" // Pull in Relay_log_info
#include "slave.h" // Pull in rpl_master_has_bug()
#include "slave.h" // Pull in rpl_master_has_bug()
#include "strfunc.h" // find_type2, find_set
#include "strfunc.h" // find_type2, find_set
#include "sql_time.h" // str_to_datetime_with_warn,
// str_to_time_with_warn,
// TIME_to_timestamp,
// make_time, make_date,
// make_truncated_value_warning
#include "tztime.h" // struct Time_zone
#include "tztime.h" // struct Time_zone
#include "filesort.h" // change_double_for_sort
#include "filesort.h" // change_double_for_sort
#include "log_event.h" // class Table_map_log_event
#include "log_event.h" // class Table_map_log_event
...
@@ -5040,7 +5035,7 @@ int Field_timestamp::store_TIME_with_warning(THD *thd, const Datetime *dt,
...
@@ -5040,7 +5035,7 @@ int Field_timestamp::store_TIME_with_warning(THD *thd, const Datetime *dt,
// Handle totally bad values
// Handle totally bad values
if
(
!
dt
->
is_valid_datetime
())
if
(
!
dt
->
is_valid_datetime
())
{
{
set_datetime_warning
(
WARN_DATA_TRUNCATED
,
str
,
MYSQL_TIMESTAMP_DATETIME
,
1
);
set_datetime_warning
(
WARN_DATA_TRUNCATED
,
str
,
"datetime"
,
1
);
store_TIMESTAMP
(
zero
);
store_TIMESTAMP
(
zero
);
return
1
;
return
1
;
}
}
...
@@ -5054,8 +5049,7 @@ int Field_timestamp::store_TIME_with_warning(THD *thd, const Datetime *dt,
...
@@ -5054,8 +5049,7 @@ int Field_timestamp::store_TIME_with_warning(THD *thd, const Datetime *dt,
INSERT INTO t1 (ts) VALUES ('0000-00-00 00:00:00 some tail');
INSERT INTO t1 (ts) VALUES ('0000-00-00 00:00:00 some tail');
*/
*/
store_TIMESTAMP
(
zero
);
store_TIMESTAMP
(
zero
);
return
store_TIME_return_code_with_warnings
(
was_cut
,
str
,
return
store_TIME_return_code_with_warnings
(
was_cut
,
str
,
"datetime"
);
MYSQL_TIMESTAMP_DATETIME
);
}
}
// Convert DATETIME to TIMESTAMP
// Convert DATETIME to TIMESTAMP
...
@@ -5064,7 +5058,7 @@ int Field_timestamp::store_TIME_with_warning(THD *thd, const Datetime *dt,
...
@@ -5064,7 +5058,7 @@ int Field_timestamp::store_TIME_with_warning(THD *thd, const Datetime *dt,
my_time_t
timestamp
=
TIME_to_timestamp
(
thd
,
l_time
,
&
conversion_error
);
my_time_t
timestamp
=
TIME_to_timestamp
(
thd
,
l_time
,
&
conversion_error
);
if
(
timestamp
==
0
&&
l_time
->
second_part
==
0
)
if
(
timestamp
==
0
&&
l_time
->
second_part
==
0
)
{
{
set_datetime_warning
(
ER_WARN_DATA_OUT_OF_RANGE
,
str
,
MYSQL_TIMESTAMP_DATETIME
,
1
);
set_datetime_warning
(
ER_WARN_DATA_OUT_OF_RANGE
,
str
,
"datetime"
,
1
);
store_TIMESTAMP
(
zero
);
store_TIMESTAMP
(
zero
);
return
1
;
// date was fine but pointed to a DST gap
return
1
;
// date was fine but pointed to a DST gap
}
}
...
@@ -5076,11 +5070,10 @@ int Field_timestamp::store_TIME_with_warning(THD *thd, const Datetime *dt,
...
@@ -5076,11 +5070,10 @@ int Field_timestamp::store_TIME_with_warning(THD *thd, const Datetime *dt,
// Calculate return value and send warnings if needed
// Calculate return value and send warnings if needed
if
(
unlikely
(
conversion_error
))
// e.g. DATETIME in the DST gap
if
(
unlikely
(
conversion_error
))
// e.g. DATETIME in the DST gap
{
{
set_datetime_warning
(
conversion_error
,
str
,
MYSQL_TIMESTAMP_DATETIME
,
1
);
set_datetime_warning
(
conversion_error
,
str
,
"datetime"
,
1
);
return
1
;
return
1
;
}
}
return
store_TIME_return_code_with_warnings
(
was_cut
,
str
,
return
store_TIME_return_code_with_warnings
(
was_cut
,
str
,
"datetime"
);
MYSQL_TIMESTAMP_DATETIME
);
}
}
...
@@ -5157,7 +5150,7 @@ int Field_timestamp::store_timestamp(my_time_t ts, ulong sec_part)
...
@@ -5157,7 +5150,7 @@ int Field_timestamp::store_timestamp(my_time_t ts, ulong sec_part)
ErrConvString
s
(
ErrConvString
s
(
STRING_WITH_LEN
(
"0000-00-00 00:00:00.000000"
)
-
(
decimals
()
?
6
-
decimals
()
:
7
),
STRING_WITH_LEN
(
"0000-00-00 00:00:00.000000"
)
-
(
decimals
()
?
6
-
decimals
()
:
7
),
system_charset_info
);
system_charset_info
);
set_datetime_warning
(
WARN_DATA_TRUNCATED
,
&
s
,
MYSQL_TIMESTAMP_DATETIME
,
1
);
set_datetime_warning
(
WARN_DATA_TRUNCATED
,
&
s
,
"datetime"
,
1
);
return
1
;
return
1
;
}
}
return
0
;
return
0
;
...
@@ -5536,7 +5529,7 @@ uint Field_temporal::is_equal(Create_field *new_field)
...
@@ -5536,7 +5529,7 @@ uint Field_temporal::is_equal(Create_field *new_field)
void
Field_temporal
::
set_warnings
(
Sql_condition
::
enum_warning_level
trunc_level
,
void
Field_temporal
::
set_warnings
(
Sql_condition
::
enum_warning_level
trunc_level
,
const
ErrConv
*
str
,
int
was_cut
,
const
ErrConv
*
str
,
int
was_cut
,
timestamp_type
ts_type
)
const
char
*
typestr
)
{
{
/*
/*
error code logic:
error code logic:
...
@@ -5549,9 +5542,9 @@ void Field_temporal::set_warnings(Sql_condition::enum_warning_level trunc_level,
...
@@ -5549,9 +5542,9 @@ void Field_temporal::set_warnings(Sql_condition::enum_warning_level trunc_level,
a DATE field and non-zero time part is thrown away.
a DATE field and non-zero time part is thrown away.
*/
*/
if
(
was_cut
&
MYSQL_TIME_WARN_TRUNCATED
)
if
(
was_cut
&
MYSQL_TIME_WARN_TRUNCATED
)
set_datetime_warning
(
trunc_level
,
WARN_DATA_TRUNCATED
,
str
,
t
s_type
,
1
);
set_datetime_warning
(
trunc_level
,
WARN_DATA_TRUNCATED
,
str
,
t
ypestr
,
1
);
if
(
was_cut
&
MYSQL_TIME_WARN_OUT_OF_RANGE
)
if
(
was_cut
&
MYSQL_TIME_WARN_OUT_OF_RANGE
)
set_datetime_warning
(
ER_WARN_DATA_OUT_OF_RANGE
,
str
,
t
s_type
,
1
);
set_datetime_warning
(
ER_WARN_DATA_OUT_OF_RANGE
,
str
,
t
ypestr
,
1
);
}
}
...
@@ -5572,13 +5565,12 @@ int Field_datetime::store_TIME_with_warning(const Datetime *dt,
...
@@ -5572,13 +5565,12 @@ int Field_datetime::store_TIME_with_warning(const Datetime *dt,
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED
;
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED
;
// Handle totally bad values
// Handle totally bad values
if
(
!
dt
->
is_valid_datetime
())
if
(
!
dt
->
is_valid_datetime
())
return
store_invalid_with_warning
(
str
,
was_cut
,
MYSQL_TIMESTAMP_DATETIME
);
return
store_invalid_with_warning
(
str
,
was_cut
,
"datetime"
);
// Store the value
// Store the value
DBUG_ASSERT
(
!
dt
->
fraction_remainder
(
decimals
()));
DBUG_ASSERT
(
!
dt
->
fraction_remainder
(
decimals
()));
store_datetime
(
*
dt
);
store_datetime
(
*
dt
);
// Caclulate return value and send warnings if needed
// Caclulate return value and send warnings if needed
return
store_TIME_return_code_with_warnings
(
was_cut
,
str
,
return
store_TIME_return_code_with_warnings
(
was_cut
,
str
,
"datetime"
);
MYSQL_TIMESTAMP_DATETIME
);
}
}
...
@@ -5720,12 +5712,12 @@ int Field_time::store_TIME_with_warning(const Time *t,
...
@@ -5720,12 +5712,12 @@ int Field_time::store_TIME_with_warning(const Time *t,
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED
;
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED
;
// Handle totally bad values
// Handle totally bad values
if
(
!
t
->
is_valid_time
())
if
(
!
t
->
is_valid_time
())
return
store_invalid_with_warning
(
str
,
warn
,
MYSQL_TIMESTAMP_TIME
);
return
store_invalid_with_warning
(
str
,
warn
,
"time"
);
// Store the value
// Store the value
DBUG_ASSERT
(
!
t
->
fraction_remainder
(
decimals
()));
DBUG_ASSERT
(
!
t
->
fraction_remainder
(
decimals
()));
store_TIME
(
*
t
);
store_TIME
(
*
t
);
// Calculate return value and send warnings if needed
// Calculate return value and send warnings if needed
return
store_TIME_return_code_with_warnings
(
warn
,
str
,
MYSQL_TIMESTAMP_TIME
);
return
store_TIME_return_code_with_warnings
(
warn
,
str
,
"time"
);
}
}
...
@@ -6219,7 +6211,8 @@ int Field_year::store_time_dec(const MYSQL_TIME *ltime, uint dec_arg)
...
@@ -6219,7 +6211,8 @@ int Field_year::store_time_dec(const MYSQL_TIME *ltime, uint dec_arg)
if
(
Field_year
::
store
(
ltime
->
year
,
0
))
if
(
Field_year
::
store
(
ltime
->
year
,
0
))
return
1
;
return
1
;
set_datetime_warning
(
WARN_DATA_TRUNCATED
,
&
str
,
ltime
->
time_type
,
1
);
const
char
*
typestr
=
Temporal
::
type_name_by_timestamp_type
(
ltime
->
time_type
);
set_datetime_warning
(
WARN_DATA_TRUNCATED
,
&
str
,
typestr
,
1
);
return
0
;
return
0
;
}
}
...
@@ -6291,14 +6284,13 @@ int Field_date_common::store_TIME_with_warning(const Datetime *dt,
...
@@ -6291,14 +6284,13 @@ int Field_date_common::store_TIME_with_warning(const Datetime *dt,
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED
;
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED
;
// Handle totally bad values
// Handle totally bad values
if
(
!
dt
->
is_valid_datetime
())
if
(
!
dt
->
is_valid_datetime
())
return
store_invalid_with_warning
(
str
,
was_cut
,
MYSQL_TIMESTAMP_DATE
);
return
store_invalid_with_warning
(
str
,
was_cut
,
"date"
);
// Store the value
// Store the value
if
(
!
dt
->
hhmmssff_is_zero
())
if
(
!
dt
->
hhmmssff_is_zero
())
was_cut
|=
MYSQL_TIME_NOTE_TRUNCATED
;
was_cut
|=
MYSQL_TIME_NOTE_TRUNCATED
;
store_datetime
(
*
dt
);
store_datetime
(
*
dt
);
// Caclulate return value and send warnings if needed
// Caclulate return value and send warnings if needed
return
store_TIME_return_code_with_warnings
(
was_cut
,
str
,
return
store_TIME_return_code_with_warnings
(
was_cut
,
str
,
"date"
);
MYSQL_TIMESTAMP_DATE
);
}
}
int
Field_date_common
::
store
(
const
char
*
from
,
size_t
len
,
CHARSET_INFO
*
cs
)
int
Field_date_common
::
store
(
const
char
*
from
,
size_t
len
,
CHARSET_INFO
*
cs
)
...
@@ -10863,12 +10855,13 @@ Field::set_warning(Sql_condition::enum_warning_level level, uint code,
...
@@ -10863,12 +10855,13 @@ Field::set_warning(Sql_condition::enum_warning_level level, uint code,
void
Field
::
set_datetime_warning
(
Sql_condition
::
enum_warning_level
level
,
void
Field
::
set_datetime_warning
(
Sql_condition
::
enum_warning_level
level
,
uint
code
,
const
ErrConv
*
str
,
uint
code
,
const
ErrConv
*
str
,
timestamp_type
ts_type
,
int
cuted_increment
)
const
char
*
typestr
,
int
cuted_increment
)
const
const
{
{
THD
*
thd
=
get_thd
();
THD
*
thd
=
get_thd
();
if
(
thd
->
really_abort_on_warning
()
&&
level
>=
Sql_condition
::
WARN_LEVEL_WARN
)
if
(
thd
->
really_abort_on_warning
()
&&
level
>=
Sql_condition
::
WARN_LEVEL_WARN
)
make_truncated_value_warning
(
thd
,
level
,
str
,
ts_type
,
field_name
.
str
);
thd
->
push_warning_truncated_value_for_field
(
level
,
typestr
,
str
->
ptr
(),
field_name
.
str
);
else
else
set_warning
(
level
,
code
,
cuted_increment
);
set_warning
(
level
,
code
,
cuted_increment
);
}
}
...
...
sql/field.h
View file @
f89a27b4
...
@@ -1368,13 +1368,13 @@ class Field: public Value_source
...
@@ -1368,13 +1368,13 @@ class Field: public Value_source
return
set_warning
(
Sql_condition
::
WARN_LEVEL_NOTE
,
code
,
cuted_increment
);
return
set_warning
(
Sql_condition
::
WARN_LEVEL_NOTE
,
code
,
cuted_increment
);
}
}
void
set_datetime_warning
(
Sql_condition
::
enum_warning_level
,
uint
code
,
void
set_datetime_warning
(
Sql_condition
::
enum_warning_level
,
uint
code
,
const
ErrConv
*
str
,
timestamp_type
ts_type
,
const
ErrConv
*
str
,
const
char
*
typestr
,
int
cuted_increment
)
const
;
int
cuted_increment
)
const
;
void
set_datetime_warning
(
uint
code
,
void
set_datetime_warning
(
uint
code
,
const
ErrConv
*
str
,
timestamp_type
ts_type
,
const
ErrConv
*
str
,
const
char
*
typestr
,
int
cuted_increment
)
const
int
cuted_increment
)
const
{
{
set_datetime_warning
(
Sql_condition
::
WARN_LEVEL_WARN
,
code
,
str
,
t
s_type
,
set_datetime_warning
(
Sql_condition
::
WARN_LEVEL_WARN
,
code
,
str
,
t
ypestr
,
cuted_increment
);
cuted_increment
);
}
}
void
set_warning_truncated_wrong_value
(
const
char
*
type
,
const
char
*
value
);
void
set_warning_truncated_wrong_value
(
const
char
*
type
,
const
char
*
value
);
...
@@ -2598,33 +2598,32 @@ class Field_temporal: public Field {
...
@@ -2598,33 +2598,32 @@ class Field_temporal: public Field {
Item
*
get_equal_const_item_datetime
(
THD
*
thd
,
const
Context
&
ctx
,
Item
*
get_equal_const_item_datetime
(
THD
*
thd
,
const
Context
&
ctx
,
Item
*
const_item
);
Item
*
const_item
);
void
set_warnings
(
Sql_condition
::
enum_warning_level
trunc_level
,
void
set_warnings
(
Sql_condition
::
enum_warning_level
trunc_level
,
const
ErrConv
*
str
,
int
was_cut
,
timestamp_type
ts_type
);
const
ErrConv
*
str
,
int
was_cut
,
const
char
*
typestr
);
int
store_TIME_return_code_with_warnings
(
int
warn
,
const
ErrConv
*
str
,
int
store_TIME_return_code_with_warnings
(
int
warn
,
const
ErrConv
*
str
,
timestamp_type
ts_type
)
const
char
*
typestr
)
{
{
if
(
!
MYSQL_TIME_WARN_HAVE_WARNINGS
(
warn
)
&&
if
(
!
MYSQL_TIME_WARN_HAVE_WARNINGS
(
warn
)
&&
MYSQL_TIME_WARN_HAVE_NOTES
(
warn
))
MYSQL_TIME_WARN_HAVE_NOTES
(
warn
))
{
{
set_warnings
(
Sql_condition
::
WARN_LEVEL_NOTE
,
str
,
set_warnings
(
Sql_condition
::
WARN_LEVEL_NOTE
,
str
,
warn
|
MYSQL_TIME_WARN_TRUNCATED
,
t
s_type
);
warn
|
MYSQL_TIME_WARN_TRUNCATED
,
t
ypestr
);
return
3
;
return
3
;
}
}
set_warnings
(
Sql_condition
::
WARN_LEVEL_WARN
,
str
,
warn
,
t
s_type
);
set_warnings
(
Sql_condition
::
WARN_LEVEL_WARN
,
str
,
warn
,
t
ypestr
);
return
warn
?
2
:
0
;
return
warn
?
2
:
0
;
}
}
int
store_invalid_with_warning
(
const
ErrConv
*
str
,
int
was_cut
,
int
store_invalid_with_warning
(
const
ErrConv
*
str
,
int
was_cut
,
timestamp_type
ts_type
)
const
char
*
typestr
)
{
{
DBUG_ASSERT
(
was_cut
);
DBUG_ASSERT
(
was_cut
);
reset
();
reset
();
Sql_condition
::
enum_warning_level
level
=
Sql_condition
::
WARN_LEVEL_WARN
;
Sql_condition
::
enum_warning_level
level
=
Sql_condition
::
WARN_LEVEL_WARN
;
if
(
was_cut
&
MYSQL_TIME_WARN_ZERO_DATE
)
if
(
was_cut
&
MYSQL_TIME_WARN_ZERO_DATE
)
{
{
DBUG_ASSERT
(
ts_type
!=
MYSQL_TIMESTAMP_TIME
);
set_warnings
(
level
,
str
,
MYSQL_TIME_WARN_OUT_OF_RANGE
,
typestr
);
set_warnings
(
level
,
str
,
MYSQL_TIME_WARN_OUT_OF_RANGE
,
ts_type
);
return
2
;
return
2
;
}
}
set_warnings
(
level
,
str
,
MYSQL_TIME_WARN_TRUNCATED
,
t
s_type
);
set_warnings
(
level
,
str
,
MYSQL_TIME_WARN_TRUNCATED
,
t
ypestr
);
return
1
;
return
1
;
}
}
public:
public:
...
...
sql/item_cmpfunc.cc
View file @
f89a27b4
...
@@ -31,7 +31,6 @@
...
@@ -31,7 +31,6 @@
#include <m_ctype.h>
#include <m_ctype.h>
#include "sql_select.h"
#include "sql_select.h"
#include "sql_parse.h" // check_stack_overrun
#include "sql_parse.h" // check_stack_overrun
#include "sql_time.h" // make_truncated_value_warning
#include "sql_base.h" // dynamic_column_error_message
#include "sql_base.h" // dynamic_column_error_message
...
...
sql/sql_table.cc
View file @
f89a27b4
...
@@ -33,7 +33,6 @@
...
@@ -33,7 +33,6 @@
// partition_info
// partition_info
// NOT_A_PARTITION_ID
// NOT_A_PARTITION_ID
#include "sql_db.h" // load_db_opt_by_name
#include "sql_db.h" // load_db_opt_by_name
#include "sql_time.h" // make_truncated_value_warning
#include "records.h" // init_read_record, end_read_record
#include "records.h" // init_read_record, end_read_record
#include "filesort.h" // filesort_free_buffers
#include "filesort.h" // filesort_free_buffers
#include "sql_select.h" // setup_order
#include "sql_select.h" // setup_order
...
...
sql/sql_type.cc
View file @
f89a27b4
...
@@ -7767,7 +7767,6 @@ static bool have_important_literal_warnings(const MYSQL_TIME_STATUS *status)
...
@@ -7767,7 +7767,6 @@ static bool have_important_literal_warnings(const MYSQL_TIME_STATUS *status)
static
void
literal_warn
(
THD
*
thd
,
const
Item
*
item
,
static
void
literal_warn
(
THD
*
thd
,
const
Item
*
item
,
const
char
*
str
,
size_t
length
,
CHARSET_INFO
*
cs
,
const
char
*
str
,
size_t
length
,
CHARSET_INFO
*
cs
,
timestamp_type
time_type
,
const
MYSQL_TIME_STATUS
*
st
,
const
MYSQL_TIME_STATUS
*
st
,
const
char
*
typestr
,
bool
send_error
)
const
char
*
typestr
,
bool
send_error
)
{
{
...
@@ -7776,9 +7775,9 @@ static void literal_warn(THD *thd, const Item *item,
...
@@ -7776,9 +7775,9 @@ static void literal_warn(THD *thd, const Item *item,
if
(
st
->
warnings
)
// e.g. a note on nanosecond truncation
if
(
st
->
warnings
)
// e.g. a note on nanosecond truncation
{
{
ErrConvString
err
(
str
,
length
,
cs
);
ErrConvString
err
(
str
,
length
,
cs
);
make_truncated_value_warning
(
thd
,
thd
->
push_warning_wrong_or_truncated_value
(
Sql_condition
::
time_warn_level
(
st
->
warnings
),
Sql_condition
::
time_warn_level
(
st
->
warnings
),
&
err
,
time_type
,
0
);
false
,
typestr
,
err
.
ptr
(),
NullS
);
}
}
}
}
else
if
(
send_error
)
else
if
(
send_error
)
...
@@ -7803,8 +7802,7 @@ Type_handler_date_common::create_literal_item(THD *thd,
...
@@ -7803,8 +7802,7 @@ Type_handler_date_common::create_literal_item(THD *thd,
tmp
.
get_mysql_time
()
->
time_type
==
MYSQL_TIMESTAMP_DATE
&&
tmp
.
get_mysql_time
()
->
time_type
==
MYSQL_TIMESTAMP_DATE
&&
!
have_important_literal_warnings
(
&
st
))
!
have_important_literal_warnings
(
&
st
))
item
=
new
(
thd
->
mem_root
)
Item_date_literal
(
thd
,
tmp
.
get_mysql_time
());
item
=
new
(
thd
->
mem_root
)
Item_date_literal
(
thd
,
tmp
.
get_mysql_time
());
literal_warn
(
thd
,
item
,
str
,
length
,
cs
,
MYSQL_TIMESTAMP_DATE
,
literal_warn
(
thd
,
item
,
str
,
length
,
cs
,
&
st
,
"DATE"
,
send_error
);
&
st
,
"DATE"
,
send_error
);
return
item
;
return
item
;
}
}
...
@@ -7824,8 +7822,7 @@ Type_handler_temporal_with_date::create_literal_item(THD *thd,
...
@@ -7824,8 +7822,7 @@ Type_handler_temporal_with_date::create_literal_item(THD *thd,
!
have_important_literal_warnings
(
&
st
))
!
have_important_literal_warnings
(
&
st
))
item
=
new
(
thd
->
mem_root
)
Item_datetime_literal
(
thd
,
tmp
.
get_mysql_time
(),
item
=
new
(
thd
->
mem_root
)
Item_datetime_literal
(
thd
,
tmp
.
get_mysql_time
(),
st
.
precision
);
st
.
precision
);
literal_warn
(
thd
,
item
,
str
,
length
,
cs
,
MYSQL_TIMESTAMP_DATETIME
,
literal_warn
(
thd
,
item
,
str
,
length
,
cs
,
&
st
,
"DATETIME"
,
send_error
);
&
st
,
"DATETIME"
,
send_error
);
return
item
;
return
item
;
}
}
...
@@ -7845,7 +7842,6 @@ Type_handler_time_common::create_literal_item(THD *thd,
...
@@ -7845,7 +7842,6 @@ Type_handler_time_common::create_literal_item(THD *thd,
!
have_important_literal_warnings
(
&
st
))
!
have_important_literal_warnings
(
&
st
))
item
=
new
(
thd
->
mem_root
)
Item_time_literal
(
thd
,
tmp
.
get_mysql_time
(),
item
=
new
(
thd
->
mem_root
)
Item_time_literal
(
thd
,
tmp
.
get_mysql_time
(),
st
.
precision
);
st
.
precision
);
literal_warn
(
thd
,
item
,
str
,
length
,
cs
,
MYSQL_TIMESTAMP_TIME
,
literal_warn
(
thd
,
item
,
str
,
length
,
cs
,
&
st
,
"TIME"
,
send_error
);
&
st
,
"TIME"
,
send_error
);
return
item
;
return
item
;
}
}
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