Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in storage/ndb/tools/NdbImportCsv.cpp date functions #126

Open
smkniazi opened this issue Apr 14, 2022 · 0 comments
Open

Bug in storage/ndb/tools/NdbImportCsv.cpp date functions #126

smkniazi opened this issue Apr 14, 2022 · 0 comments

Comments

@smkniazi
Copy link
Collaborator

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant