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]: stmt接口查询mysql模式下的time数据类型错误 #5

Open
2 tasks done
guziqiu opened this issue Feb 7, 2023 · 0 comments
Open
2 tasks done

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

guziqiu opened this issue Feb 7, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@guziqiu
Copy link

guziqiu commented Feb 7, 2023

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

@guziqiu guziqiu added the bug Something isn't working label Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant