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

Function my_decimal_from_datetime_packed

sql/sql_time.cc:1544–1567  ·  view source on GitHub ↗

Unpack packed numeric temporal value to date/time value and then convert to decimal representation. @param OUT dec The variable to write to. @param type MySQL field type. @param packed_value Packed numeric temporal representation. @return A decimal value in on of the following formats, depending on type: YYYYMMDD, hhmmss.ffffff or YYMMDDhhmm

Source from the content-addressed store, hash-verified

1542 on type: YYYYMMDD, hhmmss.ffffff or YYMMDDhhmmss.ffffff.
1543*/
1544my_decimal *my_decimal_from_datetime_packed(my_decimal *dec,
1545 enum enum_field_types type,
1546 longlong packed_value)
1547{
1548 MYSQL_TIME ltime;
1549 switch (type)
1550 {
1551 case MYSQL_TYPE_TIME:
1552 TIME_from_longlong_time_packed(&ltime, packed_value);
1553 return time2my_decimal(&ltime, dec);
1554 case MYSQL_TYPE_DATE:
1555 TIME_from_longlong_date_packed(&ltime, packed_value);
1556 ulonglong2decimal(TIME_to_ulonglong_date(&ltime), dec);
1557 return dec;
1558 case MYSQL_TYPE_DATETIME:
1559 case MYSQL_TYPE_TIMESTAMP:
1560 TIME_from_longlong_datetime_packed(&ltime, packed_value);
1561 return date2my_decimal(&ltime, dec);
1562 default:
1563 DBUG_ASSERT(0);
1564 ulonglong2decimal(0, dec);
1565 return dec;
1566 }
1567}
1568
1569
1570/**

Callers

nothing calls this directly

Calls 7

time2my_decimalFunction · 0.85
ulonglong2decimalFunction · 0.85
TIME_to_ulonglong_dateFunction · 0.85
date2my_decimalFunction · 0.85

Tested by

no test coverage detected