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 |
||
670.2.2
by Monty Taylor
Got rid of the rest of common_includes. Now on to server_includes. |
20 |
#include <drizzled/server_includes.h> |
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. |
21 |
#include <drizzled/sql_udf.h> |
584.4.6
by Monty Taylor
Moved stuff into item/ |
22 |
#include <drizzled/item/func.h> |
139.1.2
by Stewart Smith
CRC32() as UDF |
23 |
#include <zlib.h> |
24 |
||
139.1.8
by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot. |
25 |
class Item_func_crc32 :public Item_int_func |
26 |
{
|
|
27 |
String value; |
|
28 |
public: |
|
29 |
Item_func_crc32() :Item_int_func() { unsigned_flag= 1; } |
|
30 |
const char *func_name() const { return "crc32"; } |
|
31 |
void fix_length_and_dec() { max_length=10; } |
|
32 |
int64_t val_int(); |
|
33 |
};
|
|
34 |
||
35 |
int64_t Item_func_crc32::val_int() |
|
36 |
{
|
|
37 |
assert(fixed == 1); |
|
38 |
String *res=args[0]->val_str(&value); |
|
39 |
if (!res) |
|
40 |
{
|
|
41 |
null_value=1; |
|
42 |
return 0; /* purecov: inspected */ |
|
43 |
}
|
|
44 |
null_value=0; |
|
481
by Brian Aker
Remove all of uchar. |
45 |
return (int64_t) crc32(0L, (unsigned char*)res->ptr(), res->length()); |
139.1.8
by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot. |
46 |
}
|
47 |
||
48 |
Item_func* create_crc32udf_item(MEM_ROOT* m) |
|
49 |
{
|
|
50 |
return new (m) Item_func_crc32(); |
|
51 |
}
|
|
52 |
||
53 |
static struct udf_func crc32udf = { |
|
54 |
{ C_STRING_WITH_LEN("crc32") }, |
|
55 |
create_crc32udf_item
|
|
56 |
};
|
|
139.1.2
by Stewart Smith
CRC32() as UDF |
57 |
|
58 |
static int crc32udf_plugin_init(void *p) |
|
59 |
{
|
|
139.1.8
by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot. |
60 |
udf_func **f = (udf_func**) p; |
61 |
||
62 |
*f= &crc32udf; |
|
139.1.2
by Stewart Smith
CRC32() as UDF |
63 |
|
64 |
return 0; |
|
65 |
}
|
|
66 |
||
67 |
static int crc32udf_plugin_deinit(void *p) |
|
68 |
{
|
|
69 |
udf_func *udff = (udf_func *) p; |
|
139.1.4
by Stewart Smith
merge mainline and update md5 and crc32 plugins to new interface |
70 |
(void)udff; |
139.1.2
by Stewart Smith
CRC32() as UDF |
71 |
return 0; |
72 |
}
|
|
73 |
||
139.1.4
by Stewart Smith
merge mainline and update md5 and crc32 plugins to new interface |
74 |
mysql_declare_plugin(crc32) |
139.1.2
by Stewart Smith
CRC32() as UDF |
75 |
{
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
76 |
DRIZZLE_UDF_PLUGIN, |
139.1.2
by Stewart Smith
CRC32() as UDF |
77 |
"crc32", |
139.1.4
by Stewart Smith
merge mainline and update md5 and crc32 plugins to new interface |
78 |
"1.0", |
139.1.2
by Stewart Smith
CRC32() as UDF |
79 |
"Stewart Smith", |
80 |
"UDF for computing CRC32", |
|
81 |
PLUGIN_LICENSE_GPL, |
|
82 |
crc32udf_plugin_init, /* Plugin Init */ |
|
83 |
crc32udf_plugin_deinit, /* Plugin Deinit */ |
|
84 |
NULL, /* status variables */ |
|
85 |
NULL, /* system variables */ |
|
86 |
NULL /* config options */ |
|
87 |
}
|
|
88 |
mysql_declare_plugin_end; |