oceanbase / obconnector-c

OceanBase Client for C. A driver to connect applications developed in C language to OceanBase Database.
https://open.oceanbase.com
GNU Lesser General Public License v2.1
25 stars 24 forks source link

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

Open guziqiu opened 1 year ago

guziqiu commented 1 year ago

Check Before Asking

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=2124+7