code: func parseTypeAndLength(metadata []byte) (
  	fieldType mysql_proto.FieldType_Type,
  	length int,
  	remaining []byte,
  	err error) {
  
  	if len(metadata) < 2 {
  		return mysql_proto.FieldType_STRING, 0, nil, errors.New(
  			"not enough metadata bytes")
  	}
  
  	byte1 := int(metadata[0])
  	byte2 := int(metadata[1])
  
  	var realType mysql_proto.FieldType_Type
  	if (byte1 & 0x30) != 0x30 { // see mysql issue #37426
  		realType = mysql_proto.FieldType_Type(byte1 | 0x30)
  		length = byte2 | (((byte1 & 0x30) ^ 0x30) << 4)
  	} else {
  		realType = mysql_proto.FieldType_Type(byte1)
  		length = byte2
  	}
  
  	if realType != mysql_proto.FieldType_SET &&
  		realType != mysql_proto.FieldType_ENUM &&
  		realType != mysql_proto.FieldType_STRING &&
  		realType != mysql_proto.FieldType_VAR_STRING {
  
  		return mysql_proto.FieldType_STRING, 0, nil, errors.Newf(
  			"Invalid real type: %s (%d)",
  			realType.String(),
  			realType)
  	}
  
  	return realType, length, metadata[2:], nil
  }
docs: // This continas field descriptors for string types as defined by sql/field.h.
  // In particular:
  //
  // Field (abstract)
  // |
  // ...
  // |
  // +--Field_str (abstract)
  // |  +--Field_longstr
  // |  |  +--Field_string
  // |  |  +--Field_varstring
  // |  |  +--Field_blob
  // |  |     +--Field_geom
  // |  |
  // |  +--Field_null
  // |  +--Field_enum
  // |     +--Field_set
  // ...
  // This is used for extracting type / length info from string field's metadata.