Bug #16758 | DATE_FORMAT(time_column,...) - incorrect result | ||
---|---|---|---|
Submitted: | 24 Jan 2006 22:44 | Modified: | 2 Feb 2006 19:59 |
Reporter: | Mark V | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server | Severity: | S5 (Performance) |
Version: | 5.0.18-nt | OS: | Windows (WIN-XP-Pro (latest patches)) |
Assigned to: | CPU Architecture: | Any |
[24 Jan 2006 22:44]
Mark V
[25 Jan 2006 0:00]
Mark V
Correction: There are no warnings issued in either case. I misread the MySQL output - apologies.
[27 Jan 2006 22:43]
Jorge del Conde
Thanks for your bug report. I reproduced this under XP and FC4 using 5.0.18: mysql> SELECT * FROM scratch.dtf_behavior t1; +------------+----------+-----------+-----+ | date | time | trunctime | sec | +------------+----------+-----------+-----+ | 2005-10-03 | 10:13:58 | 10:13:00 | 118 | | 2005-10-03 | 10:13:59 | 10:13:00 | 119 | | 2005-10-03 | 10:14:00 | 00:00:00 | 0 | | 2005-10-03 | 10:14:01 | 10:14:00 | 61 | | 2005-10-03 | 10:14:01 | 10:14:00 | 61 | +------------+----------+-----------+-----+ 5 rows in set (0.00 sec) mysql>
[2 Feb 2006 9:47]
Yoshiaki Tajika
Sorry to interrupt and give you a comment, though I'm not a MySQL engineer but a mere user. Mark, you wrote like this; UPDATE scratch.dtf_behavior SET ... WHERE @s := CAST( TIME_FORMAT( t1.time, '%S' ) AS UNSIGNED ); When t1.time is '10:14:00', TIME_FORMAT(t1.time,'%S') returns a string '00'. And CAST(... AS UNSIGNED) converts it to integer 0. And the variable @s is set to 0, because The ':=' is an assignment operator. Finally the where clause becomes "WHERE 0", and that row is NOT updated. I say again what happened in order. You added 2 columns, trunctime and sec, by ALTER TABLE statement. At that time, these 2 columns of all 5 rows were automatically set to 00:00:00 and 0 respectively. Next, you tried to update these columns by UPDATE statement. But only 4 rows were affected (mysql client showed this message, didn't it?). The rest 1 row was not updated (i.e remained as 00:00:00 and 0), because the where clause evaluation was false. So everything works as designed, I think. My explanation makes sense?
[2 Feb 2006 19:59]
Mark V
Thanks for pointing that out. I've closed this bug, and set the severity indicator as low as possible. Apologies for the wild goose chase.