~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/crc32/crc32udf.cc

  • Committer: Monty Taylor
  • Date: 2009-12-21 06:46:30 UTC
  • mto: (1253.2.3 out-of-tree)
  • mto: This revision was merged to the branch mainline in revision 1250.
  • Revision ID: mordred@inaugust.com-20091221064630-xaxd6pzqr8djvw3f
Removed global sql_list.h include.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
21
 
 
22
 
#include <drizzled/plugin.h>
 
20
#include <drizzled/server_includes.h>
23
21
#include <drizzled/plugin/function.h>
24
22
#include <drizzled/item/func.h>
25
 
#include <drizzled/algorithm/crc32.h>
 
23
#include <drizzled/hash/crc32.h>
26
24
 
27
25
#include <string>
28
26
 
31
29
 
32
30
class Crc32Function :public Item_int_func
33
31
{
 
32
  String value;
34
33
public:
35
34
  int64_t val_int();
36
35
  
58
57
int64_t Crc32Function::val_int()
59
58
{
60
59
  assert(fixed == true);
61
 
  String value;
62
60
  String *res=args[0]->val_str(&value);
63
61
  
64
62
  if (res == NULL)
68
66
  }
69
67
 
70
68
  null_value= false;
71
 
  return static_cast<int64_t>(drizzled::algorithm::crc32(res->ptr(), res->length()));
 
69
  return static_cast<int64_t>(drizzled::hash::crc32(res->ptr(), res->length()));
72
70
}
73
71
 
74
72
plugin::Create_function<Crc32Function> *crc32udf= NULL;
75
73
 
76
 
static int initialize(module::Context &context)
 
74
static int initialize(plugin::Registry &registry)
77
75
{
78
76
  crc32udf= new plugin::Create_function<Crc32Function>("crc32");
79
 
  context.add(crc32udf);
80
 
  return 0;
81
 
}
82
 
 
83
 
DRIZZLE_PLUGIN(initialize, NULL, NULL);
 
77
  registry.add(crc32udf);
 
78
  return 0;
 
79
}
 
80
 
 
81
static int finalize(plugin::Registry &registry)  
 
82
{
 
83
  registry.remove(crc32udf);
 
84
  delete crc32udf;
 
85
  return 0;
 
86
}
 
87
 
 
88
DRIZZLE_PLUGIN(initialize, finalize, NULL, NULL);