From 9d99bf5ae5119f347368fd460b0753424c3b39b2 Mon Sep 17 00:00:00 2001 From: robi Date: Sat, 1 Sep 2018 00:17:38 +0800 Subject: [PATCH 1/3] server: make long data type no longer check nullBitMap --- server/conn_stmt.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/server/conn_stmt.go b/server/conn_stmt.go index d874d8ea3d182..f91da9e53b350 100644 --- a/server/conn_stmt.go +++ b/server/conn_stmt.go @@ -246,15 +246,14 @@ 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 boundParams[i] != nil { args[i] = boundParams[i] continue } - + if nullBitmap[i>>3]&(1<<(uint(i)%8)) > 0 { + args[i] = nil + continue + } if (i<<1)+1 >= len(paramTypes) { return mysql.ErrMalformPacket } From d362b4a0a9496822f5ff5560afe8e7a93a322b7f Mon Sep 17 00:00:00 2001 From: robi Date: Mon, 3 Sep 2018 10:33:45 +0800 Subject: [PATCH 2/3] trigger CI run --- server/conn_stmt.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/conn_stmt.go b/server/conn_stmt.go index f91da9e53b350..48a7c4a87705e 100644 --- a/server/conn_stmt.go +++ b/server/conn_stmt.go @@ -250,10 +250,12 @@ func parseStmtArgs(args []interface{}, boundParams [][]byte, nullBitmap, paramTy args[i] = boundParams[i] continue } + if nullBitmap[i>>3]&(1<<(uint(i)%8)) > 0 { args[i] = nil continue } + if (i<<1)+1 >= len(paramTypes) { return mysql.ErrMalformPacket } From 1b8174b4f4507be1ca49dce2f05767043dbcb095 Mon Sep 17 00:00:00 2001 From: robi Date: Tue, 4 Sep 2018 11:08:54 +0800 Subject: [PATCH 3/3] address comment --- server/conn_stmt.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/conn_stmt.go b/server/conn_stmt.go index 48a7c4a87705e..eb589e147e20e 100644 --- a/server/conn_stmt.go +++ b/server/conn_stmt.go @@ -246,11 +246,18 @@ func parseStmtArgs(args []interface{}, boundParams [][]byte, nullBitmap, paramTy var isNull bool for i := 0; i < len(args); i++ { + // 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