@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_
| 1334 | does not have a safe replacement. |
| 1335 | */ |
| 1336 | Timeval_null |
| 1337 | THD::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 |
no test coverage detected