From 51a17bd63d165304439434f6ec963c4e709ce6ae Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Fri, 17 Jul 2026 05:47:16 +0000 Subject: [PATCH] sql(mysql): return 13 not 12 from Time::to_binary when microseconds != 0 The encoder writes buffer[0..=12] (1 length byte + 12 payload bytes) but returned 12, so Value::to_data copied only buffer[0..12] and dropped the high byte of the u32 microseconds. The length prefix in buffer[0] is 12, so the emitted packet would advertise 12 payload bytes but carry only 11, desynchronizing the COM_STMT_EXECUTE stream. The TIME encode path is currently unreachable from JS: field_type_from_js maps JS Date to MYSQL_TYPE_DATETIME, so Value::Time is never constructed and this branch never runs today. Fixed so enabling TIME param binding in the future does not hit it. --- src/sql_jsc/mysql/MySQLValue.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sql_jsc/mysql/MySQLValue.rs b/src/sql_jsc/mysql/MySQLValue.rs index d6e4c49424e1..7e970583fd3d 100644 --- a/src/sql_jsc/mysql/MySQLValue.rs +++ b/src/sql_jsc/mysql/MySQLValue.rs @@ -806,7 +806,7 @@ impl Time { } else { buffer[0] = 12; // length buffer[9..13].copy_from_slice(&self.microseconds.to_le_bytes()); - 12 + 13 } } _ => unreachable!(),