mysqlnd: Fractional seconds truncated in prepared statements, if value of decimals is AUTO_SEC_PART_DIGITS (=39).
オープン
まだ誰も着手していません。
Bug
Extension: mysqlnd
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.1k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
提供されている mysqli プリペアドステートメントの再現例とそのテキストプロトコルとの比較を使って、まず DATETIME と TIME のメタデータに対する mysqlnd のバイナリプロトコル処理を確認します。サーバーが小数桁を 39 (AUTO_SEC_PART_DIGITS) と報告するケースを確認し、その後、小数秒が保持され、比較結果として “Done!” が出力されるように、リグレッションテストのカバレッジを追加または更新します。 از
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, mysql, php
- 領域
- databases
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100