Bug #1730 DATE Data constrain

Submitted: 1 Nov 2003 0:55 Modified: 4 Oct 2005 11:58
Reporter: Giuliano Lotta Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version:4.0.16 OS:Windows (Windows 2000)
Assigned to: CPU Architecture:Any

[1 Nov 2003 0:55] Giuliano Lotta
Description:
Create a table (MyIsam, InnoDB,...) with a DATE field. Enter in the date filed a _wrong_ date:

2003-11-31 (!)
2003-02-30 (!!)
2003-02-31 (!!!)

the server (mysql-max) accept it like it would be a valid date !!

Giuliano Lotta

How to repeat:
For creating the table an check the error I used che control center 0.9.3 beta

Just follow the description.

Suggested fix:
The only check is done in the present realese, is if the month is littler/equal of 12, and il the day is littler/equal of 31, for ALL the months !!

Is should at least be checked relations between day<-> month, i.e. a few lines code like:
siwtch { 
case february: ;  
case november, april, june, september: 
default: ;
};

 
or better a code that implement a check boudary also on february/bisestile years !!
[1 Nov 2003 8:01] Dean Ellis
I am changing this to a Feature Request, as MySQL's limited validity testing on date values is documented behaviour.  You may read more about it here:

http://www.mysql.com/doc/en/Using_DATE.html

Thank you
[4 Oct 2005 11:58] Hartmut Holzgraefe
In 4.1 you'll get at least a warning when trying to insert impossible values,
in 5.0 you can even force errors with "sql_mode=TRADITIONAL"

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.049 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.