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 |
*
|
|
4 |
* Copyright (C) 2008 Sun Microsystems
|
|
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 |
||
1241.9.36
by Monty Taylor
ZOMG. I deleted drizzled/server_includes.h. |
20 |
#include "config.h" |
1093.1.62
by Monty Taylor
Moved UDFs to slot organization. |
21 |
#include <drizzled/plugin/function.h> |
584.4.6
by Monty Taylor
Moved stuff into item/ |
22 |
#include <drizzled/item/func.h> |
1259.6.2
by Joe Daly
rename hash_algorithm to algorithm |
23 |
#include <drizzled/algorithm/crc32.h> |
139.1.2
by Stewart Smith
CRC32() as UDF |
24 |
|
942.1.12
by Monty Taylor
Converted udf_func into a factory. |
25 |
#include <string> |
26 |
||
27 |
using namespace std; |
|
1093.1.62
by Monty Taylor
Moved UDFs to slot organization. |
28 |
using namespace drizzled; |
942.1.12
by Monty Taylor
Converted udf_func into a factory. |
29 |
|
1086.2.2
by devananda
fixed case: crc32Function -> Crc32Function |
30 |
class Crc32Function :public Item_int_func |
139.1.8
by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot. |
31 |
{
|
32 |
public: |
|
33 |
int64_t val_int(); |
|
1086.2.1
by devananda
cleaned up formatting in crc32udf.cc |
34 |
|
1086.2.2
by devananda
fixed case: crc32Function -> Crc32Function |
35 |
Crc32Function() :Item_int_func() |
1086.2.1
by devananda
cleaned up formatting in crc32udf.cc |
36 |
{
|
1086.2.3
by devananda
formatting cleanup |
37 |
unsigned_flag= true; |
1086.2.1
by devananda
cleaned up formatting in crc32udf.cc |
38 |
}
|
39 |
||
40 |
const char *func_name() const |
|
41 |
{
|
|
42 |
return "crc32"; |
|
43 |
}
|
|
44 |
||
45 |
void fix_length_and_dec() |
|
46 |
{
|
|
47 |
max_length= 10; |
|
48 |
}
|
|
49 |
||
50 |
bool check_argument_count(int n) |
|
51 |
{
|
|
52 |
return (n == 1); |
|
53 |
}
|
|
139.1.8
by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot. |
54 |
};
|
55 |
||
1086.2.2
by devananda
fixed case: crc32Function -> Crc32Function |
56 |
int64_t Crc32Function::val_int() |
139.1.8
by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot. |
57 |
{
|
1086.2.3
by devananda
formatting cleanup |
58 |
assert(fixed == true); |
1271.2.1
by Tim Penhey
Move the member variable to be local to the function. |
59 |
String value; |
139.1.8
by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot. |
60 |
String *res=args[0]->val_str(&value); |
1086.2.1
by devananda
cleaned up formatting in crc32udf.cc |
61 |
|
1086.2.3
by devananda
formatting cleanup |
62 |
if (res == NULL) |
139.1.8
by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot. |
63 |
{
|
1086.2.3
by devananda
formatting cleanup |
64 |
null_value= true; |
65 |
return 0; |
|
139.1.8
by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot. |
66 |
}
|
1086.2.3
by devananda
formatting cleanup |
67 |
|
68 |
null_value= false; |
|
1411.7.5
by Siddharth Prakash Singh
code refactoring - removing the type when calling crc32 |
69 |
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. |
70 |
}
|
71 |
||
1093.1.62
by Monty Taylor
Moved UDFs to slot organization. |
72 |
plugin::Create_function<Crc32Function> *crc32udf= NULL; |
139.1.2
by Stewart Smith
CRC32() as UDF |
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 |
{
|
1093.1.62
by Monty Taylor
Moved UDFs to slot organization. |
76 |
crc32udf= new plugin::Create_function<Crc32Function>("crc32"); |
1324.2.2
by Monty Taylor
Use the plugin::Context everywhere. |
77 |
context.add(crc32udf); |
1086.2.1
by devananda
cleaned up formatting in crc32udf.cc |
78 |
return 0; |
79 |
}
|
|
139.1.2
by Stewart Smith
CRC32() as UDF |
80 |
|
1633.6.2
by Vijay Samuel
Reverted changes. |
81 |
DRIZZLE_PLUGIN(initialize, NULL, NULL); |