584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
1999.6.1
by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file |
4 |
* Copyright (C) 2008 Sun Microsystems, Inc.
|
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU General Public License as published by
|
|
8 |
* the Free Software Foundation; version 2 of the License.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
18 |
*/
|
|
19 |
||
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
20 |
#include <config.h> |
2148.7.12
by Brian Aker
Merge in header fixes. |
21 |
|
22 |
#include <drizzled/plugin.h> |
|
1093.1.62
by Monty Taylor
Moved UDFs to slot organization. |
23 |
#include <drizzled/plugin/function.h> |
584.4.6
by Monty Taylor
Moved stuff into item/ |
24 |
#include <drizzled/item/func.h> |
1259.6.2
by Joe Daly
rename hash_algorithm to algorithm |
25 |
#include <drizzled/algorithm/crc32.h> |
139.1.2
by Stewart Smith
CRC32() as UDF |
26 |
|
942.1.12
by Monty Taylor
Converted udf_func into a factory. |
27 |
#include <string> |
28 |
||
29 |
using namespace std; |
|
1093.1.62
by Monty Taylor
Moved UDFs to slot organization. |
30 |
using namespace drizzled; |
942.1.12
by Monty Taylor
Converted udf_func into a factory. |
31 |
|
2275.2.18
by Olaf van der Spek
Prune |
32 |
class Crc32Function : public Item_int_func |
139.1.8
by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot. |
33 |
{
|
34 |
public: |
|
35 |
int64_t val_int(); |
|
1086.2.1
by devananda
cleaned up formatting in crc32udf.cc |
36 |
|
2275.2.18
by Olaf van der Spek
Prune |
37 |
Crc32Function() |
1086.2.1
by devananda
cleaned up formatting in crc32udf.cc |
38 |
{
|
1086.2.3
by devananda
formatting cleanup |
39 |
unsigned_flag= true; |
1086.2.1
by devananda
cleaned up formatting in crc32udf.cc |
40 |
}
|
41 |
||
42 |
const char *func_name() const |
|
43 |
{
|
|
44 |
return "crc32"; |
|
45 |
}
|
|
46 |
||
47 |
void fix_length_and_dec() |
|
48 |
{
|
|
49 |
max_length= 10; |
|
50 |
}
|
|
51 |
||
52 |
bool check_argument_count(int n) |
|
53 |
{
|
|
54 |
return (n == 1); |
|
55 |
}
|
|
139.1.8
by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot. |
56 |
};
|
57 |
||
1086.2.2
by devananda
fixed case: crc32Function -> Crc32Function |
58 |
int64_t Crc32Function::val_int() |
139.1.8
by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot. |
59 |
{
|
1086.2.3
by devananda
formatting cleanup |
60 |
assert(fixed == true); |
1271.2.1
by Tim Penhey
Move the member variable to be local to the function. |
61 |
String value; |
139.1.8
by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot. |
62 |
String *res=args[0]->val_str(&value); |
1086.2.1
by devananda
cleaned up formatting in crc32udf.cc |
63 |
|
1086.2.3
by devananda
formatting cleanup |
64 |
if (res == NULL) |
139.1.8
by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot. |
65 |
{
|
1086.2.3
by devananda
formatting cleanup |
66 |
null_value= true; |
67 |
return 0; |
|
139.1.8
by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot. |
68 |
}
|
1086.2.3
by devananda
formatting cleanup |
69 |
|
70 |
null_value= false; |
|
1411.7.5
by Siddharth Prakash Singh
code refactoring - removing the type when calling crc32 |
71 |
return static_cast<int64_t>(drizzled::algorithm::crc32(res->ptr(), res->length())); |
139.1.8
by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot. |
72 |
}
|
73 |
||
1530.2.6
by Monty Taylor
Moved plugin::Context to module::Context. |
74 |
static int initialize(module::Context &context) |
139.1.2
by Stewart Smith
CRC32() as UDF |
75 |
{
|
2275.2.18
by Olaf van der Spek
Prune |
76 |
context.add(new plugin::Create_function<Crc32Function>("crc32")); |
1086.2.1
by devananda
cleaned up formatting in crc32udf.cc |
77 |
return 0; |
78 |
}
|
|
139.1.2
by Stewart Smith
CRC32() as UDF |
79 |
|
1633.6.2
by Vijay Samuel
Reverted changes. |
80 |
DRIZZLE_PLUGIN(initialize, NULL, NULL); |