Open
Description
For time "1111-11-11 11:11:11.123" with precision 3 packing and unpacking corrupts the time
date_str= "1111-11-11 11:11:11.123"
MYSQL_TIME l_time;
MYSQL_TIME_STATUS status;
bool ret = str_to_datetime(date_str, date_str_len, &l_time, 0, &status);
size_t packed_len = col->getSizeInBytes();
int precision = col->getPrecision();
std::cout << date_str << " Precision is " << precision << " size : " << packed_len << " sign "
<< l_time.neg << " table: " << table_dic->getName() << std::endl;
Datetime2 d2;
d2.day = l_time.day;
d2.month = l_time.month;
d2.year = l_time.year;
d2.hour = l_time.hour;
d2.minute = l_time.minute;
d2.second = l_time.second;
d2.fraction = l_time.second_part;
d2.sign = 1;
std::cout << "mysql " << l_time.year << " " << l_time.month << " " << l_time.day << " "
<< l_time.hour << " " << l_time.minute << " " << l_time.second << " "
<< l_time.second_part << std::endl;
unsigned char packed[packed_len];
pack_datetime2(d2, packed, precision);
Datetime2 d3;
unpack_datetime2(d3, packed, precision);
std::cout << "unpacked " << d3.year << " " << d3.month << " " << d3.day << " " << d3.hour << " "
<< d3.minute << " " << d3.second << " " << d3.fraction << std::endl;
output
1111-11-11 11:11:11.123 Precision is 3 size : 7 sign 0 table: date_table3
mysql 1111 11 11 11 11 11 123000
unpacked 1111 11 11 11 11 27 5035
Metadata
Metadata
Assignees
Labels
No labels