Return NULL or zero when value is not parsed completely in parseDateTimeBestEffortOr* functions

This commit is contained in:
Alexey Milovidov 2020-06-14 04:45:03 +03:00
parent f53da4d36b
commit fae12d5e42
3 changed files with 20 additions and 2 deletions

View File

@ -722,9 +722,9 @@ struct ConvertThroughParsing
parsed = ToDataType::tryReadText(vec_to[i], read_buffer, ToDataType::maxPrecision(), vec_to.getScale()); parsed = ToDataType::tryReadText(vec_to[i], read_buffer, ToDataType::maxPrecision(), vec_to.getScale());
else else
parsed = tryParseImpl<ToDataType>(vec_to[i], read_buffer, local_time_zone); parsed = tryParseImpl<ToDataType>(vec_to[i], read_buffer, local_time_zone);
}
parsed = parsed && isAllRead(read_buffer); parsed = parsed && isAllRead(read_buffer);
}
if (!parsed) if (!parsed)
vec_to[i] = 0; vec_to[i] = 0;

View File

@ -0,0 +1,6 @@
\N
0000-00-00 00:00:00
\N
0000-00-00 00:00:00.000
\N
0000-00-00 00:00:00

View File

@ -0,0 +1,12 @@
SELECT parseDateTimeBestEffort('<Empty>'); -- { serverError 6 }
SELECT parseDateTimeBestEffortOrNull('<Empty>');
SELECT parseDateTimeBestEffortOrZero('<Empty>');
SELECT parseDateTime64BestEffort('<Empty>'); -- { serverError 6 }
SELECT parseDateTime64BestEffortOrNull('<Empty>');
SELECT parseDateTime64BestEffortOrZero('<Empty>');
SET date_time_input_format = 'best_effort';
SELECT toDateTime('<Empty>'); -- { serverError 41 }
SELECT toDateTimeOrNull('<Empty>');
SELECT toDateTimeOrZero('<Empty>');