From 4538bcd52c4e914d337da8c91b8fc1bab8da78ee Mon Sep 17 00:00:00 2001 From: lysu Date: Wed, 5 Sep 2018 17:31:12 +0800 Subject: [PATCH] server: make long-data type no longer check nullBitmap (#7573) --- server/conn_stmt.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/server/conn_stmt.go b/server/conn_stmt.go index d874d8ea3d182..eb589e147e20e 100644 --- a/server/conn_stmt.go +++ b/server/conn_stmt.go @@ -246,15 +246,23 @@ func parseStmtArgs(args []interface{}, boundParams [][]byte, nullBitmap, paramTy var isNull bool for i := 0; i < len(args); i++ { - if nullBitmap[i>>3]&(1<<(uint(i)%8)) > 0 { - args[i] = nil - continue - } + // if params had received via ComStmtSendLongData, use them directly. + // ref https://dev.mysql.com/doc/internals/en/com-stmt-send-long-data.html + // see clientConn#handleStmtSendLongData if boundParams[i] != nil { args[i] = boundParams[i] continue } + // check nullBitMap to determine the NULL arguments. + // ref https://dev.mysql.com/doc/internals/en/com-stmt-execute.html + // notice: some client(e.g. mariadb) will set nullBitMap even if data had be sent via ComStmtSendLongData, + // so this check need place after boundParam's check. + if nullBitmap[i>>3]&(1<<(uint(i)%8)) > 0 { + args[i] = nil + continue + } + if (i<<1)+1 >= len(paramTypes) { return mysql.ErrMalformPacket }