pika-tools icon indicating copy to clipboard operation
pika-tools copied to clipboard

pika-port-3 迁移string时将二进制内容截断问题

Open xinhua5 opened this issue 2 years ago • 0 comments

pika-port 迁移 string时,将二进制内容转成c_str时,将二进制数据截断,导致数据丢失,value内容类似:

   1 0000000: 0000 0080 1400 0000 0000 0000 0100 0000  ................
   2 0000010: 0000 0000 0000 0000 0000 0000 0000 0000  ................
   3 0000020: 0000 0000 0000 0000 0000 0000 0000 0000  ................
   4 0000030: 0000 0000 0000 0000 0000 0000 0000 0000  ................
   5 0000040: 0000 0000 0000 0000 0000 0000 0000 0000  ................
   6 0000050: 0000 0000 0000 0000 0000 0000 0000 0000  ................
   7 0000060: 0000 0000 0000 0000 0000 0000 0000 0000  ................
   8 0000070: 0000 0000 0000 0000 0000 0000 0000 0000  ................
   9 0000080: 0000 0000 0000 0000 0f00 0000 0000 0000  ................
  10 0000090: 6269 6e61 7279 3a6c 6f67 6973 7469 6306  binary:logistic.

pika_port_3函数MigrateStringsDB()处理key和value是将string转换成c_str(),导致二进制数据在字符\00时被截断

    argv.push_back("SET");
    argv.push_back(iter->key().ToString().c_str());
    argv.push_back(parsed_strings_value.value().ToString().c_str());

xinhua5 avatar Oct 27 '22 01:10 xinhua5