Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Major
-
Resolution: Not a Bug
-
Affects Version/s: 10.0.16
-
Fix Version/s: N/A
-
Component/s: Temporal Types
-
Labels:None
-
Environment:Redhat Linux 2.6.32-431.29.2.el6.x86_64
10.0.16-MariaDB-log
Description
We came across this issue when a developer tried to set a date value to 2015-04-31 only 30 days in April.
If using the above value it will set that date column to null not throw an error.
Test case
CREATE TABLE test.baddate (
id int(11) NOT NULL AUTO_INCREMENT,
testtext varchar(255) DEFAULT NULL,
startdate date DEFAULT '1970-01-01',
enddate date DEFAULT '1970-01-01',
PRIMARY KEY (id),
INDEX UK_baddate_testtext (testtext)
)
ENGINE = INNODB
AUTO_INCREMENT = 8
AVG_ROW_LENGTH = 5461
CHARACTER SET latin1
COLLATE latin1_swedish_ci
COMMENT = 'Testing of date bug in update with erroneous date';
Insert some values
INSERT INTO test.baddate(testtext) SELECT tp.Table_name FROM mysql.tables_priv tp;
Check the contents All dates set to 01/01/1970
SELECT * FROM test.baddate;
Update to erroneous date value
UPDATE test.baddate SET enddate = '2013-10-32';
Evaluate the result
SELECT * FROM test.baddate;
Date is now null in the column set to erroneous date
Gliffy Diagrams
Attachments
Issue Links
- relates to
-
MDEV-7635 update defaults and simplify mysqld config parameters
-
- Open
-
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
Hi Peter,
Do you actually mean NULL, or do you mean '0000-00-00'?
If you get NULL, please provide the output of SHOW VARIABLES and the full output of the commands that you run (you don't have to insert from tables_priv if it's confidential, just put some 'foo' values there).
If you mean '0000-00-00', then please note that when you run the UPDATE, you get a warning (or a bunch of warnings) like this:
It works the same way in MySQL, it is an expected and documented behavior. See
http://dev.mysql.com/doc/refman/5.6/en/datetime.html
So, for the first example, '2015-04-31':
For the second example, '2013-10-32':
Hopes it clarifies the matter.