sql - STR_TO_DATE discrepancy between MySQL 5.5 and MySQL 5.6 -


this sql returns date in mysql 5.5 null in mysql 5.6. why?

select date(str_to_date('2015-01', '%y-%m')) + interval 1 day; 

here's sql fiddle mysql 5.5 , 5.6. str_to_date returns date in both instances. converting result using date works. problem comes when trying add interval. doesn't matter if add interval str_to_date(...) or date(str_to_date(...)), result same. however, removing str_to_date makes work.

select     str_to_date('2015-01', '%y-%m') same_a1,     str_to_date('2015-01-01', '%y-%m') same_a2,     str_to_date('2015-01', '%y-%m-%d') same_a3,     str_to_date('2015-01-01', '%y-%m-%d') same_a4,     date(str_to_date('2015-01', '%y-%m')) same_b1,     date(str_to_date('2015-01-01', '%y-%m')) same_b2,     date(str_to_date('2015-01', '%y-%m-%d')) same_b3,     date(str_to_date('2015-01-01', '%y-%m-%d')) same_b4,     str_to_date('2015-01', '%y-%m') + interval 1 day same_c1,     str_to_date('2015-01-01', '%y-%m') + interval 1 day same_c2,     str_to_date('2015-01', '%y-%m-%d') + interval 1 day same_c3,     str_to_date('2015-01-01', '%y-%m-%d') + interval 1 day same_c4,     date(str_to_date('2015-01', '%y-%m')) + interval 1 day different_d1,     date(str_to_date('2015-01-01', '%y-%m')) + interval 1 day different_d2,     date(str_to_date('2015-01', '%y-%m-%d')) + interval 1 day different_d3,     date(str_to_date('2015-01-01', '%y-%m-%d')) + interval 1 day same_d4,     date('2015-01') + interval 1 day same_e1,     date('2015-01-01') + interval 1 day same_e2 ; 

i searched release notes couldn't find anything. going on? known change? bug?

it's known change, unwittingly introduced versions 5.1.59, 5.5.16 , 5.6.3 (but rolled in versions 5.1.62 , 5.5.21; retained in 5.6 line):

incompatible change: handling of date-related assertion modified.

however, consequence of change several functions become more strict when passed date() function value argument , reject incomplete dates day part of zero. these functions affected: convert_tz(), date_add(), date_sub(), dayofyear(), last_day(), timestampdiff(), to_days(), to_seconds(), week(), weekday(), weekofyear(), yearweek(). because changes date-handling behavior in general availability-status series (mysql 5.1 , 5.5), reverted in 5.1.62 , 5.5.21. change retained in mysql 5.6.

references: see bug #13458237.

you affected because + interval notation syntactic sugar around date_add() function.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -