MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / my_timeval_round

Function my_timeval_round

sql/sql_time.cc:1410–1429  ·  view source on GitHub ↗

Round timeval value to the given precision. @param IN/OUT ts The value to round. @param dec Precision. @return False on success, true on error. */

Source from the content-addressed store, hash-verified

1408 @return False on success, true on error.
1409*/
1410bool my_timeval_round(struct timeval *tv, uint decimals)
1411{
1412 DBUG_ASSERT(decimals <= DATETIME_MAX_DECIMALS);
1413 uint nanoseconds= msec_round_add[decimals];
1414 tv->tv_usec+= (nanoseconds + 500) / 1000;
1415 if (tv->tv_usec < 1000000)
1416 goto ret;
1417
1418 tv->tv_usec= 0;
1419 tv->tv_sec++;
1420 if (!IS_TIME_T_VALID_FOR_TIMESTAMP(tv->tv_sec))
1421 {
1422 tv->tv_sec= TIMESTAMP_MAX_VALUE;
1423 return true;
1424 }
1425
1426ret:
1427 my_timeval_trunc(tv, decimals);
1428 return false;
1429}
1430
1431
1432/**

Callers

nothing calls this directly

Calls 1

my_timeval_truncFunction · 0.85

Tested by

no test coverage detected