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
c99f9766
Commit
c99f9766
authored
Aug 05, 2019
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-19166 Assertion `!is_zero_datetime()' failed in Timestamp_or_zero_datetime::tv
parent
e2446528
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
10 deletions
+39
-10
mysql-test/main/type_temporal_innodb.result
mysql-test/main/type_temporal_innodb.result
+13
-0
mysql-test/main/type_temporal_innodb.test
mysql-test/main/type_temporal_innodb.test
+15
-0
sql/item.cc
sql/item.cc
+1
-1
sql/item_timefunc.cc
sql/item_timefunc.cc
+1
-1
sql/sql_type.h
sql/sql_type.h
+9
-8
No files found.
mysql-test/main/type_temporal_innodb.result
View file @
c99f9766
...
...
@@ -172,3 +172,16 @@ CREATE TABLE tbl SELECT * FROM t1 WHERE t1.c1 = (SELECT c2 FROM t2 WHERE pk = 6)
ERROR 22007: Truncated incorrect datetime value: '0000-00-00 00:00:00'
DROP TABLE t1,t2;
SET sql_mode=DEFAULT;
#
# MDEV-19166 Assertion `!is_zero_datetime()' failed in Timestamp_or_zero_datetime::tv
#
CREATE TABLE t1 (f TIMESTAMP DEFAULT 0) ENGINE=InnoDB;
INSERT INTO t1 VALUES ('2024-02-29');
SELECT * FROM t1 WHERE SUBSTR(1 FROM BIT_LENGTH(f) FOR DEFAULT(f));
f
Warnings:
Warning 1292 Truncated incorrect INTEGER value: ''
DROP TABLE t1;
#
# End of 10.4 tests
#
mysql-test/main/type_temporal_innodb.test
View file @
c99f9766
...
...
@@ -81,3 +81,18 @@ CREATE TABLE tbl SELECT * FROM t1 WHERE t1.c1 = (SELECT c2 FROM t2 WHERE pk = 6)
# ^^^ there is no column c2 in table t2
DROP
TABLE
t1
,
t2
;
SET
sql_mode
=
DEFAULT
;
--
echo
#
--
echo
# MDEV-19166 Assertion `!is_zero_datetime()' failed in Timestamp_or_zero_datetime::tv
--
echo
#
CREATE
TABLE
t1
(
f
TIMESTAMP
DEFAULT
0
)
ENGINE
=
InnoDB
;
INSERT
INTO
t1
VALUES
(
'2024-02-29'
);
SELECT
*
FROM
t1
WHERE
SUBSTR
(
1
FROM
BIT_LENGTH
(
f
)
FOR
DEFAULT
(
f
));
DROP
TABLE
t1
;
--
echo
#
--
echo
# End of 10.4 tests
--
echo
#
sql/item.cc
View file @
c99f9766
...
...
@@ -9909,7 +9909,7 @@ Datetime Item_cache_timestamp::to_datetime(THD *thd)
null_value
=
true
;
return
Datetime
();
}
return
Datetime
(
thd
,
Timestamp_or_zero_datetime
(
m_native
).
tv
()
);
return
m_native
.
to_datetime
(
thd
);
}
...
...
sql/item_timefunc.cc
View file @
c99f9766
...
...
@@ -1220,7 +1220,7 @@ bool Item_func_unix_timestamp::get_timestamp_value(my_time_t *seconds,
Timestamp_or_zero_datetime_native_null
native
(
current_thd
,
args
[
0
],
true
);
if
((
null_value
=
native
.
is_null
()
||
native
.
is_zero_datetime
()))
return
true
;
Timestamp
_or_zero_datetime
tm
(
native
);
Timestamp
tm
(
native
);
*
seconds
=
tm
.
tv
().
tv_sec
;
*
second_part
=
tm
.
tv
().
tv_usec
;
return
false
;
...
...
sql/sql_type.h
View file @
c99f9766
...
...
@@ -2377,6 +2377,10 @@ class Timestamp: protected Timeval
}
bool
to_TIME
(
THD
*
thd
,
MYSQL_TIME
*
ltime
,
date_mode_t
fuzzydate
)
const
;
bool
to_native
(
Native
*
to
,
uint
decimals
)
const
;
Datetime
to_datetime
(
THD
*
thd
)
const
{
return
Datetime
(
thd
,
*
this
);
}
long
fraction_remainder
(
uint
dec
)
const
{
return
my_time_fraction_remainder
(
tv_usec
,
dec
);
...
...
@@ -2417,7 +2421,7 @@ class Timestamp: protected Timeval
- real TIMESTAMP (seconds and microseconds since epoch), or
- zero datetime '0000-00-00 00:00:00.000000'
*/
class
Timestamp_or_zero_datetime
:
p
ublic
Timestamp
class
Timestamp_or_zero_datetime
:
p
rotected
Timestamp
{
bool
m_is_zero_datetime
;
public:
...
...
@@ -2434,14 +2438,11 @@ class Timestamp_or_zero_datetime: public Timestamp
Timestamp_or_zero_datetime
(
THD
*
thd
,
const
MYSQL_TIME
*
ltime
,
uint
*
err_code
);
Datetime
to_datetime
(
THD
*
thd
)
const
{
return
Datetime
(
thd
,
*
this
);
if
(
is_zero_datetime
())
return
Datetime
();
return
Timestamp
::
to_datetime
(
thd
);
}
bool
is_zero_datetime
()
const
{
return
m_is_zero_datetime
;
}
const
struct
timeval
&
tv
()
const
{
DBUG_ASSERT
(
!
is_zero_datetime
());
return
Timestamp
::
tv
();
}
void
trunc
(
uint
decimals
)
{
if
(
!
is_zero_datetime
())
...
...
@@ -2487,7 +2488,7 @@ class Timestamp_or_zero_datetime_native:
{
return
is_zero_datetime
()
?
Datetime
()
:
Datetime
(
thd
,
Timestamp
_or_zero_datetime
(
*
this
).
tv
());
Datetime
(
thd
,
Timestamp
(
*
this
).
tv
());
}
bool
is_zero_datetime
()
const
{
...
...
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