~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/table_function.cc

  • Committer: Mark Atwood
  • Date: 2011-08-09 01:21:52 UTC
  • mfrom: (2380.1.2 drizzle-autoconf)
  • Revision ID: me@mark.atwood.name-20110809012152-zxq2dgan8e6nsvse
mergeĀ lp:~brianaker/drizzle/autoreconf

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
 
20
#include <config.h>
21
21
 
22
22
#include <drizzled/current_session.h>
23
23
#include <drizzled/gettext.h>
24
 
#include <drizzled/global_charset_info.h>
 
24
#include <drizzled/charset.h>
25
25
#include <drizzled/plugin/table_function.h>
26
26
#include <drizzled/session.h>
27
27
#include <drizzled/show.h>
28
28
#include <drizzled/table_function_container.h>
 
29
#include <drizzled/sql_lex.h>
29
30
 
30
31
#include <vector>
31
32
 
32
 
namespace drizzled
33
 
{
 
33
namespace drizzled {
34
34
 
35
35
static TableFunctionContainer table_functions;
36
36
 
40
40
  proto.set_type(drizzled::message::Table::FUNCTION);
41
41
  proto.set_creation_timestamp(0);
42
42
  proto.set_update_timestamp(0);
 
43
  message::set_is_replicated(proto, false);
 
44
  message::set_definer(proto, SYSTEM_USER);
43
45
}
44
46
 
45
47
bool plugin::TableFunction::addPlugin(plugin::TableFunction *tool)
46
48
{
47
49
  assert(tool != NULL);
48
 
  table_functions.addFunction(tool); 
 
50
  table_functions.addFunction(tool);
49
51
  return false;
50
52
}
51
53
 
60
62
  table_functions.getNames(arg, set_of_names);
61
63
}
62
64
 
 
65
LEX& plugin::TableFunction::Generator::lex()
 
66
{
 
67
        return getSession().lex();
 
68
}
 
69
 
 
70
statement::Statement& plugin::TableFunction::Generator::statement()
 
71
{
 
72
        return *lex().statement;
 
73
}
 
74
 
63
75
plugin::TableFunction::Generator *plugin::TableFunction::generator(Field **arg)
64
76
{
65
77
  return new Generator(arg);
95
107
  field_options->set_default_null(is_default_null);
96
108
  field_constraints->set_is_notnull(not is_default_null);
97
109
 
98
 
  switch (type) 
 
110
  switch (type)
99
111
  {
100
112
  case TableFunction::STRING:
101
113
    {
149
161
 
150
162
bool plugin::TableFunction::Generator::sub_populate(uint32_t field_size)
151
163
{
152
 
  bool ret;
153
 
  uint64_t difference;
154
 
 
155
164
  columns_iterator= columns;
156
 
  ret= populate();
157
 
  difference= columns_iterator - columns;
 
165
  bool ret= populate();
 
166
  uint64_t difference= columns_iterator - columns;
158
167
 
159
 
  if (ret == true)
160
 
  {
 
168
  if (ret)
161
169
    assert(difference == field_size);
162
 
  }
163
 
 
164
170
  return ret;
165
171
}
166
172
 
209
215
void plugin::TableFunction::Generator::push(bool arg)
210
216
{
211
217
  if (arg)
212
 
  {
213
218
    (*columns_iterator)->store("YES", 3, scs);
214
 
  }
215
219
  else
216
 
  {
217
220
    (*columns_iterator)->store("NO", 2, scs);
218
 
  }
219
 
 
220
221
  columns_iterator++;
221
222
}
222
223
 
223
224
bool plugin::TableFunction::Generator::isWild(const std::string &predicate)
224
225
{
225
 
  if (not getSession().lex->wild)
226
 
    return false;
227
 
 
228
 
  bool match= wild_case_compare(system_charset_info,
229
 
                                predicate.c_str(),
230
 
                                getSession().lex->wild->ptr());
231
 
 
232
 
  return match;
 
226
  return lex().wild ? wild_case_compare(system_charset_info, predicate.c_str(), lex().wild->ptr()) : false;
233
227
}
234
228
 
235
229
} /* namespace drizzled */