Bug #6832 | NO_ZERO_DATE does not prevent zero dates | ||
---|---|---|---|
Submitted: | 25 Nov 2004 20:58 | Modified: | 24 May 2005 19:15 |
Reporter: | Trudy Pelzer | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server | Severity: | S3 (Non-critical) |
Version: | SuSE 9.1 | OS: | 5.0.2-alpha-debug |
Assigned to: | CPU Architecture: | Any |
[25 Nov 2004 20:58]
Trudy Pelzer
[3 May 2005 17:48]
Charles Sanders
I would like to add to this bug. According to documentation, I should not be able to insert an invalid date in a timestamp field, but I can. I get a warning and the timestamp value in the table is 0. Need some way to configure the server to return an error and NOT perform the insert/update when given an invalid date. Example: create table test (id integer, col_time timestamp); insert into test (id, col_time) values (1, '2004-30-30'); Query OK, 1 row affected, 1 warning (0.03 sec) select * from test; +------+---------------------+ | id | col_time | +------+---------------------+ | 1 | 0000-00-00 00:00:00 | +------+---------------------+ 1 row in set (0.00 sec) If I insert/update an invaid date value, I do not want the insert/update performed. I want an error throw.
[23 May 2005 14:30]
Michael Widenius
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.mysql.com/documentation/ and the instructions on how to report a bug at http://bugs.mysql.com/how-to-report.php Additional info: This is not a bug but a documentation issue NO_ZERO_DATES means the following: If NO_ZERO_DATES is not set it means that 0000-00-00 is a legal value in DATE and DATETIME fields. In other words, one should NOT get any warnings for this. If NO_ZERO_DATES is set and we are NOT in strict or traditional mode, it means that one will get a warning when inserting a zero date into a date or datetime column, but the statement will not be aborted. This is the same thing as inserting a too-long character string into a CHAR/VARCHAR field. By default MySQL just does a warning and continues. If NO_ZERO_DATES are set and we are in strict or traditional mode, one will get an error if a ZERO date is inserted, as if one had tried to insert a too long character string into a CHAR/VARCHAR field.
[24 May 2005 19:15]
Paul DuBois
I have clarified the descriptions for NO_ZERO_DATE (and NO_ZERO_IN_DATE).