我正在发送COM_EXECUTE_STMT消息,服务器总是返回:
错误1048 - #23000 - 列'number_tinyint'不能为空
查询是这样的:
insert into numbers (
number_tinyint,
number_smallint,
number_mediumint,
number_int,
number_bigint,
number_decimal,
number_float,
number_double
) values
(
?, 679, 778, 875468, 100007654, 198.657809, 432.8, ?)
我发送的是:
0: 18 00 00 00 17 01 00 00 . . . . . . . .
1: 00 00 01 00 00 00 00 00 . . . . . . . .
2: 01 01 05 0a 29 5c 8f c2 . . . . ) \ . .
3: f5 b0 58 40 . . X @
简化阅读:
18 00 00 - size
00 - sequence
17 - type
01 00 00 00 - statement id
00 - flags
01 00 00 00 - iteration-count
00 00 - null bitmap
01 - new params bound flag
01 - byte type
05 - double type
0a - byte value - 10
29 5c 8f c2 f5 b0 58 40 - double value
语句参数为10(对于tinyint列)和98.765(对于双列)。从我所看到的消息被正确编码但它总是因某种原因失败(at least from what the documentation says)
我在这里错过了什么吗?
答案 0 :(得分:1)
从您链接的文档:
payload: [ deletia ] n NULL-bitmap, length: (num-params+7)/8
因此,在您的情况下使用两个参数,NULL位图的长度应为(2 + 7)/ 8 = 1字节,而您当前有一个2字节的位图。