Skip to content

Commit a3e149f

Browse files
authored
Fix #589 (#592)
1 parent a9b19d5 commit a3e149f

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

pkg/frontend/mysql_cmd_executor.go

+37
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,33 @@ func (mce *MysqlCmdExecutor) handleSelectDatabase(sel *tree.Select) error {
868868
return nil
869869
}
870870

871+
/*
872+
handle "SELECT @@max_allowed_packet"
873+
*/
874+
func (mce *MysqlCmdExecutor) handleMaxAllowedPacket() error {
875+
var err error = nil
876+
ses := mce.routine.GetSession()
877+
proto := mce.routine.GetClientProtocol().(*MysqlProtocol)
878+
879+
col := new(MysqlColumn)
880+
col.SetColumnType(defines.MYSQL_TYPE_LONG)
881+
col.SetName("@@max_allowed_packet")
882+
ses.Mrs.AddColumn(col)
883+
884+
var data = make([]interface{},1)
885+
//16MB
886+
data[0] = 16777216
887+
ses.Mrs.AddRow(data)
888+
889+
mer := NewMysqlExecutionResult(0, 0, 0, 0, ses.Mrs)
890+
resp := NewResponse(ResultResponse, 0, int(COM_QUERY), mer)
891+
892+
if err := proto.SendResponse(resp); err != nil {
893+
return fmt.Errorf("routine send response failed. error:%v ", err)
894+
}
895+
return err
896+
}
897+
871898
/*
872899
handle Load Data statement
873900
*/
@@ -1012,6 +1039,16 @@ func (mce *MysqlCmdExecutor) doComQuery(sql string) error {
10121039
continue
10131040
}
10141041
}
1042+
}else if ve, ok := sc.Exprs[0].Expr.(*tree.VarExpr); ok {
1043+
if strings.ToLower(ve.Name) == "max_allowed_packet" {
1044+
err = mce.handleMaxAllowedPacket()
1045+
if err != nil {
1046+
return err
1047+
}
1048+
1049+
//next statement
1050+
continue
1051+
}
10151052
}
10161053
}
10171054
}

0 commit comments

Comments
 (0)