mirror of https://gitee.com/bigwinds/arangodb
Bug fix/date function portability (#4972)
* fix casts to use defined bit width * adjust regex so it also works on elderly compiler infrastructure * optimized regex * work around MSVC bit shortage * howto manipulate logging of the SUT * improve regexp readability
This commit is contained in:
parent
da09f76183
commit
a07a0fe990
|
@ -298,6 +298,8 @@ syntax --option value --sub:option value. Using Valgrind could look like this:
|
|||
--extraArgs:scheduler.threads 1 \
|
||||
--extraArgs:javascript.gc-frequency 1000000 \
|
||||
--extraArgs:javascript.gc-interval 65536 \
|
||||
--extraArgs:log.level debug \
|
||||
--extraArgs:log.force-direct true \
|
||||
--javascript.v8-contexts 2 \
|
||||
--valgrind /usr/bin/valgrind \
|
||||
--valgrindargs:log-file /tmp/valgrindlog.%p
|
||||
|
@ -306,6 +308,9 @@ syntax --option value --sub:option value. Using Valgrind could look like this:
|
|||
- we specify some arangod arguments via --extraArgs which increase the server performance
|
||||
- we specify to run using valgrind (this is supported by all facilities)
|
||||
- we specify some valgrind commandline arguments
|
||||
- we set the loglevel to debug
|
||||
- we force the logging not to happen asynchroneous
|
||||
- eventually you may still add temporary `console.log()` statements to tests you debug.
|
||||
|
||||
Running a single unittestsuite
|
||||
------------------------------
|
||||
|
|
|
@ -317,10 +317,10 @@ AqlValue Functions::AddOrSubtractUnitFromTimestamp(Query* query,
|
|||
tp_sys_clock_ms resTime;
|
||||
if (isSubtract) {
|
||||
resTime = tp_sys_clock_ms{sys_days(ymd) + day_time.to_duration() -
|
||||
std::chrono::duration_cast<milliseconds>(ms)};
|
||||
std::chrono::duration_cast<duration<int64_t, std::milli>>(ms)};
|
||||
} else {
|
||||
resTime = tp_sys_clock_ms{sys_days(ymd) + day_time.to_duration() +
|
||||
std::chrono::duration_cast<milliseconds>(ms)};
|
||||
std::chrono::duration_cast<duration<int64_t, std::milli>>(ms)};
|
||||
}
|
||||
return TimeAqlValue(resTime);
|
||||
}
|
||||
|
@ -2409,7 +2409,7 @@ AqlValue Functions::RegexReplace(arangodb::aql::Query* query,
|
|||
AqlValue Functions::DateNow(arangodb::aql::Query*, transaction::Methods*,
|
||||
VPackFunctionParameters const&) {
|
||||
auto millis =
|
||||
duration_cast<milliseconds>(system_clock::now().time_since_epoch());
|
||||
std::chrono::duration_cast<duration<int64_t, std::milli>>(system_clock::now().time_since_epoch());
|
||||
uint64_t dur = millis.count();
|
||||
return AqlValue(AqlValueHintUInt(dur));
|
||||
}
|
||||
|
@ -2462,12 +2462,14 @@ AqlValue Functions::DateFromParameters(
|
|||
funcName = "DATE_ISO8601";
|
||||
}
|
||||
tp_sys_clock_ms tp;
|
||||
duration<int64_t, std::milli> time;
|
||||
|
||||
if (parameters.size() == 1) {
|
||||
if (!ParameterToTimePoint(query, trx, parameters, tp, funcName.c_str(),
|
||||
0)) {
|
||||
return AqlValue(AqlValueHintNull());
|
||||
}
|
||||
time = tp.time_since_epoch();
|
||||
} else {
|
||||
if (parameters.size() < 3 || parameters.size() > 7) {
|
||||
// YMD is a must
|
||||
|
@ -2557,12 +2559,16 @@ AqlValue Functions::DateFromParameters(
|
|||
}
|
||||
}
|
||||
|
||||
tp = sys_days(ymd) + h + min + s + ms;
|
||||
time = sys_days(ymd).time_since_epoch();
|
||||
time += h;
|
||||
time += min;
|
||||
time += s;
|
||||
time += ms;
|
||||
tp = tp_sys_clock_ms(time);
|
||||
}
|
||||
|
||||
if (asTimestamp) {
|
||||
auto millis = duration_cast<milliseconds>(tp.time_since_epoch());
|
||||
return AqlValue(AqlValueHintInt(millis.count()));
|
||||
return AqlValue(AqlValueHintInt(time.count()));
|
||||
} else {
|
||||
return TimeAqlValue(tp);
|
||||
}
|
||||
|
|
|
@ -39,9 +39,22 @@ bool arangodb::basics::parse_dateTime(
|
|||
boost::algorithm::trim(dateTime);
|
||||
|
||||
std::regex iso8601_regex(
|
||||
"(\\+|\\-)?\\d+(\\-\\d{1,2}(\\-\\d{1,2})?)?(((\\ "
|
||||
"|T)\\d\\d\\:\\d\\d(\\:\\d\\d(\\.\\d{1,3})?)?(z|Z|(\\+|\\-)\\d\\d\\:"
|
||||
"\\d\\d)?)?|(z|Z)?)?");
|
||||
"(\\+|\\-)?\\d+(\\-\\d{1,2}(\\-\\d{1,2})?)?" // YY[YY]-MM-DD
|
||||
"("
|
||||
"("
|
||||
// Time is optional
|
||||
"(\\ |T)" // T or blank separates date and time
|
||||
"\\d\\d\\:\\d\\d" // time: hh:mm
|
||||
"(\\:\\d\\d(\\.\\d{1,3})?)?" // Optional: :ss.mmms
|
||||
"("
|
||||
"z|Z|" // trailing Z or start of timezone
|
||||
"(\\+|\\-)"
|
||||
"\\d\\d\\:\\d\\d" // timezone hh:mm
|
||||
")?"
|
||||
")|"
|
||||
"(z|Z)" // Z
|
||||
")?"
|
||||
);
|
||||
|
||||
if (!std::regex_match(dateTime, iso8601_regex)) {
|
||||
LOG_TOPIC(DEBUG, arangodb::Logger::FIXME)
|
||||
|
@ -207,4 +220,4 @@ bool arangodb::basics::regex_isoDuration(std::string const& isoDuration, std::sm
|
|||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue