1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-01 06:46:55 +03:00

Make date handling more in-line with MySQL

Date limit of year 1400 was used due to Boost's limits.

This patch strips out the use of Boost for date handling and sets the
lower limit to year 1000.
This commit is contained in:
Andrew Hutchings
2016-08-30 11:25:16 +01:00
parent 9a76bfc0f3
commit 0bea3e4ab1
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;