MCPcopy Create free account
hub / github.com/MariaDB/server / safe_timeval_replacement_for_nonzero_datetime

Method safe_timeval_replacement_for_nonzero_datetime

sql/sql_class.cc:1336–1348  ·  view source on GitHub ↗

@brief Convert a non-zero DATETIME to its safe timeval based representation, which guarantees a safe roundtrip DATETIME->timeval->DATETIME, e.g. to optimize: WHERE timestamp_arg0 = datetime_arg1 in the way that we replace "datetime_arg1" to its TIMESTAMP equivalent "timestamp_arg1" and switch from DATETIME comparison to TIMESTAMP comparison: WHERE timestamp_arg0 = timestamp_

Source from the content-addressed store, hash-verified

1334 does not have a safe replacement.
1335*/
1336Timeval_null
1337THD::safe_timeval_replacement_for_nonzero_datetime(const Datetime &dt)
1338{
1339 used|= THD::TIME_ZONE_USED;
1340 DBUG_ASSERT(non_zero_date(dt.get_mysql_time()));
1341 uint error= 0;
1342 const MYSQL_TIME *ltime= dt.get_mysql_time();
1343 my_time_t sec= variables.time_zone->TIME_to_gmt_sec(ltime, &error);
1344 if (error /* (1) */ ||
1345 !variables.time_zone->is_monotone_continuous_around(sec) /* (2) */)
1346 return Timeval_null();
1347 return Timeval_null(sec, ltime->second_part);
1348}
1349
1350
1351#ifdef _WIN32

Callers 1

Calls 5

non_zero_dateFunction · 0.85
Timeval_nullClass · 0.85
TIME_to_gmt_secMethod · 0.80
get_mysql_timeMethod · 0.45

Tested by

no test coverage detected