Details
-
Bug
-
Status: Open (View Workflow)
-
Minor
-
Resolution: Unresolved
-
12.3.3
-
None
Description
Summary:
Embedded: prepared TIME parameter reports column length 16 instead of 23
Environment:
MariaDB 12.3.3 embedded (libmariadbd), Linux arm64.
Server path reports 23; embedded reports 16 for the same prepared TIME parameter.
Steps to reproduce:
1. Start the embedded server.
2. Prepare a statement that returns a TIME parameter, e.g. SELECT ? .
3. Bind a TIME value containing a sign / >24h / fractional seconds
(e.g. negative over-24h TIME with microseconds) and execute.
4. Read the result column metadata (mysql_stmt_result_metadata +
mysql_fetch_field / MYSQL_FIELD.length).
Expected:
MYSQL_FIELD.length = 23 (same as the normal server), because
MAX_TIME_FULL_WIDTH is 23 ("-DDDDDD HH:MM:SS.######").
Actual:
MYSQL_FIELD.length = 16 for embedded.
The row values themselves are identical; only the declared display width differs.
Root cause (source):
sql/sql_prepare.cc:
- non-embedded Item_param::set_param_time uses MAX_TIME_FULL_WIDTH
- embedded Item_param::set_param_time uses MAX_TIME_WIDTH
sql/sql_const.h: - MAX_TIME_WIDTH = 16
- MAX_TIME_FULL_WIDTH = 23
Commit a8a757c6bb32bbf291afdf33df861127489889ab (wl#173, 2011) redefined
MAX_TIME_WIDTH from 23 to 16, added MAX_TIME_FULL_WIDTH = 23, and updated only
the ordinary path.
Impact:
Metadata-only. No data corruption observed. Clients that use MYSQL_FIELD.length
for buffer sizing or display width may truncate the value.
Proposed fix:
In the embedded set_param_time call, use MAX_TIME_FULL_WIDTH instead of
MAX_TIME_WIDTH (one line).
Workaround:
Clients can ignore the declared length and use the actual row length.