mysqlnd: Fractional seconds truncated in prepared statements, if value of decimals is AUTO_SEC_PART_DIGITS (=39).
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C
- Star
- 40.4k
- Fork
- 8.2k
- Merge trung bình
- 2 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 96
Mô tả
Description
This issue was initially reported for MariaDB Connector/C (which uses part of mysqlnd):
In some cases both MySQL and MariaDB server will send the value 39 (=AUTO_SEC_PART_DIGITS) for datetime and time decimals. The binary protocol implementation however will only set fractional seconds if decimals is <= 6.
The following code:
<?php
$link= mysqli_connect("localhost", "georg", null, "test", 0, "/tmp/mysql.sock");
$stmt = $link->prepare("select FROM_UNIXTIME('1992.1'), FROM_UNIXTIME('1992.0')");
$stmt->execute();
$stmt->bind_result($binval[0],$binval[1]);
$stmt->fetch();
$stmt->close();
$result = $link->query("select FROM_UNIXTIME('1992.1'), FROM_UNIXTIME('1992.0')");
$txtval = $result->fetch_row();
$result->close();
$err_cnt= 0;
for ($i=0; $i < 2; $i++)
if ($txtval[$i] != $binval[$i])
printf("[%03d] Expected '%s' (text protocol), got '%s' (binary protocol)\n",
$err_cnt++, $txtval[$i], $binval[$i]);
printf("Done!\n");
?>
Resulted in this output:
[000] Expected '1970-01-01 01:33:12.100000' (text protocol), got '1970-01-01 01:33:12' (binary protocol)
Done!
But I expected this output instead:
Done!
Metadata sent by server:
$> mariadb --column-type-info -e"select from_unixtime('1922.1')"
Field 1: `from_unixtime('1922.1')`
Org_field: ``
Catalog: `def`
Database: ``
Table: ``
Org_table: ``
Type: DATETIME
Collation: binary (63)
Length: 26
Max_length: 26
Decimals: 39
Flags: BINARY
PHP Version
PHP 8.4.0-dev
Operating System
No response
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với việc xử lý giao thức nhị phân của mysqlnd cho metadata DATETIME và TIME, sử dụng bản tái hiện được cung cấp của câu lệnh prepared mysqli và phần so sánh với giao thức văn bản. Kiểm tra trường hợp máy chủ báo các chữ số thập phân là 39 (AUTO_SEC_PART_DIGITS), sau đó thêm hoặc cập nhật phạm vi kiểm thử hồi quy để các giây lẻ được giữ lại và phép so sánh in ra “Done!”. از
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- c, mysql, php
- Lĩnh vực
- databases
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100