1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

Merge pull request #4 from LinuxJedi/MCOL-274

Make date handling more in-line with MySQL
This commit is contained in:
dhall-InfiniDB
2016-09-02 09:15:00 -05:00
committed by GitHub
16 changed files with 129 additions and 168 deletions

View File

@ -31,8 +31,6 @@ using namespace std;
#include <boost/algorithm/string/case_conv.hpp>
using namespace boost::algorithm;
#include <boost/tokenizer.hpp>
#include <boost/date_time/gregorian/gregorian.hpp>
using namespace boost::gregorian;
#include "calpontsystemcatalog.h"
#include "calpontselectexecutionplan.h"
#include "columnresult.h"
@ -644,24 +642,14 @@ bool mysql_str_to_datetime( const string& input, DateTime& output, bool& isDate
return false;
}
try
{
boost::gregorian::date d(year, mon, day);
// one more check - boost allows year 10000 but we want to limit at 9999
if( year > 9999 )
{
output.reset();
return false;
}
output.year = d.year();
output.month = d.month();
output.day = d.day();
}
catch (...)
if (!isDateValid(day, mon, year))
{
output.reset();
return false;
}
output.year = year;
output.month = mon;
output.day = day;
/**
* Now we need to deal with the time portion.

View File

@ -228,11 +228,17 @@ inline
bool isDateValid ( int day, int month, int year)
{
bool valid = true;
if ( year == 0 && month == 0 && year == 0 )
{
return true;
}
int daycheck = getDaysInMonth( month );
if( month == 2 && isLeapYear( year ) )
// 29 days in February in a leap year
daycheck = 29;
if ( ( year < 1400 ) || ( year > 9999 ) )
if ( ( year < 1000 ) || ( year > 9999 ) )
valid = false;
else if ( month < 1 || month > 12 )
valid = false;