~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/memcached_stats/memcached_stats.cc

  • Committer: Stewart Smith
  • Author(s): Marko Mäkelä, Stewart Smith
  • Date: 2010-11-17 05:52:09 UTC
  • mto: (2021.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1971.
  • Revision ID: stewart@flamingspork.com-20101117055209-69m035q6h7e1txrc
Merge Revision revid:marko.makela@oracle.com-20100629113248-fvl48lnzr44z94gg from MySQL InnoDB

Original revid:marko.makela@oracle.com-20100629113248-fvl48lnzr44z94gg

Original Authors: Marko Mkel <marko.makela@oracle.com>
Original commit message:
Bug#52199 utf32: mbminlen=4, mbmaxlen=4, type->mbminlen=0, type->mbmaxlen=4

Merge and adjust a forgotten change to fix this bug.
rb://393 approved by Jimmy Yang
  ------------------------------------------------------------------------
  r3794 | marko | 2009-01-07 14:14:53 +0000 (Wed, 07 Jan 2009) | 18 lines

  branches/6.0: Allow the minimum length of a multi-byte character to be
  up to 4 bytes. (Bug #35391)

  dtype_t, dict_col_t: Replace mbminlen:2, mbmaxlen:3 with mbminmaxlen:5.
  In this way, the 5 bits can hold two values of 0..4, and the storage size
  of the fields will not cross the 64-bit boundary.  Encode the values as
  DATA_MBMAX * mbmaxlen + mbminlen.  Define the auxiliary macros
  DB_MBMINLEN(mbminmaxlen), DB_MBMAXLEN(mbminmaxlen), and
  DB_MINMAXLEN(mbminlen, mbmaxlen).

  Try to trim and pad UTF-16 and UTF-32 with spaces as appropriate.

  Alexander Barkov suggested the use of cs->cset->fill(cs, buff, len, 0x20).
  ha_innobase::store_key_val_for_row() now does that, but the added function
  row_mysql_pad_col() does not, because it doesn't have the MySQL TABLE object.

  rb://49 approved by Heikki Tuuri
  ------------------------------------------------------------------------

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* 
2
 
 * Copyright (C) 2009, Padraig O'Sullivan
 
2
 * Copyright (c) 2009, Padraig O'Sullivan
3
3
 * All rights reserved.
4
4
 *
5
5
 * Redistribution and use in source and binary forms, with or without
40
40
#include <map>
41
41
 
42
42
namespace po=boost::program_options;
43
 
 
44
 
namespace drizzle_plugin
45
 
{
46
 
 
 
43
using namespace std;
 
44
using namespace drizzled;
47
45
 
48
46
/*
49
47
 * DATA_DICTIONARY tables.
55
53
/*
56
54
 * System variable related variables.
57
55
 */
58
 
static std::string sysvar_memcached_servers;
 
56
static char *sysvar_memcached_servers= NULL;
59
57
 
60
58
/**
61
59
 * Initialize the memcached stats plugin.
63
61
 * @param[in] registry the drizzled::plugin::Registry singleton
64
62
 * @return false on success; true on failure.
65
63
 */
66
 
static int init(drizzled::module::Context &context)
 
64
static int init(module::Context &context)
67
65
{
68
 
  const drizzled::module::option_map &vm= context.getOptions();
 
66
  const module::option_map &vm= context.getOptions();
 
67
 
 
68
  if(vm.count("servers"))
 
69
  {
 
70
    sysvar_memcached_servers= strdup(vm["servers"].as<string>().c_str());
 
71
  }
 
72
 
 
73
  else
 
74
  {
 
75
    sysvar_memcached_servers= strdup("");
 
76
  }
 
77
 
 
78
  SysvarHolder &sysvar_holder= SysvarHolder::singleton();
 
79
  sysvar_holder.setServersString(sysvar_memcached_servers);
 
80
  sysvar_holder.setMemoryPtr(sysvar_memcached_servers);
69
81
 
70
82
  /* we are good to go */
71
 
  stats_table_tool= new StatsTableTool; 
 
83
  stats_table_tool= new(std::nothrow)StatsTableTool; 
72
84
  context.add(stats_table_tool);
73
85
 
74
 
  analysis_table_tool= new AnalysisTableTool;
 
86
  analysis_table_tool= new(std::nothrow)AnalysisTableTool;
75
87
  context.add(analysis_table_tool);
76
88
 
77
 
  context.registerVariable(new sys_var_std_string("servers",
78
 
                                                  sysvar_memcached_servers));
79
 
                          
80
89
  return 0;
81
90
}
82
91
 
 
92
static int check_memc_servers(Session *,
 
93
                              drizzle_sys_var *,
 
94
                              void *save,
 
95
                              drizzle_value *value)
 
96
{
 
97
  char buff[STRING_BUFFER_USUAL_SIZE];
 
98
  int len= sizeof(buff);
 
99
  const char *input= value->val_str(value, buff, &len);
 
100
 
 
101
  if (input)
 
102
  {
 
103
    SysvarHolder &sysvar_holder= SysvarHolder::singleton();
 
104
    sysvar_holder.setServersStringVar(input);
 
105
    *(bool *) save= (bool) true;
 
106
    return 0;
 
107
  }
 
108
 
 
109
  *(bool *) save= (bool) false;
 
110
  return 1;
 
111
}
 
112
 
 
113
static void set_memc_servers(Session *,
 
114
                             drizzle_sys_var *,
 
115
                             void *var_ptr,
 
116
                             const void *save)
 
117
{
 
118
  if (*(bool *) save != false)
 
119
  {
 
120
    SysvarHolder &sysvar_holder= SysvarHolder::singleton();
 
121
    sysvar_holder.updateServersSysvar((const char **) var_ptr);
 
122
  }
 
123
}
 
124
 
 
125
static DRIZZLE_SYSVAR_STR(servers,
 
126
                          sysvar_memcached_servers,
 
127
                          PLUGIN_VAR_OPCMDARG,
 
128
                          N_("List of memcached servers."),
 
129
                          check_memc_servers, /* check func */
 
130
                          set_memc_servers, /* update func */
 
131
                          ""); /* default value */
 
132
 
83
133
static void init_options(drizzled::module::option_context &context)
84
134
{
85
135
  context("servers",
86
 
          po::value<std::string>()->default_value(""),
87
 
          _("List of memcached servers."));
 
136
          po::value<string>(),
 
137
          N_("List of memcached servers."));
88
138
}
89
139
 
90
 
} /* namespace drizzle_plugin */
 
140
static drizzle_sys_var *system_variables[]=
 
141
{
 
142
  DRIZZLE_SYSVAR(servers),
 
143
  NULL
 
144
};
91
145
 
92
146
DRIZZLE_DECLARE_PLUGIN
93
147
{
97
151
  "Padraig O'Sullivan",
98
152
  N_("Memcached Stats as I_S tables"),
99
153
  PLUGIN_LICENSE_BSD,
100
 
  drizzle_plugin::init,   /* Plugin Init      */
101
 
  NULL, /* depends */
102
 
  drizzle_plugin::init_options    /* config options   */
 
154
  init,   /* Plugin Init      */
 
155
  system_variables, /* system variables */
 
156
  init_options    /* config options   */
103
157
}
104
158
DRIZZLE_DECLARE_PLUGIN_END;