Skip to content

[Bug]: stmt接口查询mysql模式下的time数据类型错误 #5

@guziqiu

Description

@guziqiu

Check Before Asking

  • Please check the issue list and confirm this bug is encountered for the first time.
  • Please try full text in English and attach precise description.

Environment

centos7.9
gcc 4.8.5
obconnector-c v2.2.1
Prepared Statement 接口

Fast Reproduce Steps

使用stmt接口查询time类型数据,出现数据丢失问题

CREATE TABLE `c_time1` (
  `c_time` time(6) DEFAULT NULL
);
insert into c_time2 values ('511:2:3.0');

使用gdb查看数据,收到的数据为255:2:3.0


(gdb) s
ma_net_safe_read (mysql=0x694440) at /root/obconnector-c/libmariadb/mariadb_lib.c:281
281     {
(gdb) n
283       ulong len=0;
(gdb) n
281     {
(gdb) n
289       if (len == packet_error || len == 0)
(gdb) n
281     {
(gdb) n
311             if (cli_report_progress(mysql, (uchar *)pos, (uint) (len-1)))
(gdb) n
286       if (net->pvio != 0)
(gdb) n
287         len=ma_net_read(net);
(gdb) n
289       if (len == packet_error || len == 0)
(gdb) p *(net->buff+3)@10
$164 = "\000\000\000\000\000\377\002\003\000"
(gdb) p /t *(net->buff+3)@10
$165 = {0, 0, 0, 0, 0, 11111111, 10, 11, 0, 0}
(gdb) p /t *(net->buff)@10
$166 = {0, 0, 1100, 0, 0, 0, 0, 0, 11111111, 10}
(gdb) p  *(net->buff+2)
$167 = 12 '\f'
(gdb)
(gdb) p /t *(net->buff)@16
$188 = {0, 0, 1100, 0, 0, 0, 0, 0, 11111111, 10, 11, 0, 0, 0, 0, 0}
(gdb) p /d *(net->buff)@16
$189 = {0, 0, 12, 0, 0, 0, 0, 0, 255, 2, 3, 0, 0, 0, 0, 0}
(gdb)

Actual Behavior

mysql模式下time类型的数据,数据库中的数据为511:2:3.0
使用stmt接口时,收到的数据为255:2:3.0

Expected Behavior

No response

Other Information

(gdb) p /d (net->buff)@12
$5 = {0, 0, 8, 0, 21, 0, 0, 0, 7, 2, 3, 0}
在mysql数据库中将时间转换成了天数,511=21
24+7

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions