1
/* Copyright (C) 2006 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16
#include <drizzled/common_includes.h>
17
#include <drizzled/item_func.h>
19
class Item_func_uncompressed_length : public Item_int_func
23
Item_func_uncompressed_length():Item_int_func(){}
24
const char *func_name() const{return "uncompressed_length";}
25
void fix_length_and_dec() { max_length=10; }
29
int64_t Item_func_uncompressed_length::val_int()
32
String *res= args[0]->val_str(&value);
36
return 0; /* purecov: inspected */
39
if (res->is_empty()) return 0;
42
res->ptr() using is safe because we have tested that string is not empty,
43
res->c_ptr() is not used because:
44
- we do not need \0 terminated string to get first 4 bytes
45
- c_ptr() tests simbol after string end (uninitialiozed memory) which
48
return uint4korr(res->ptr()) & 0x3FFFFFFF;
51
Item_func* create_uncompressed_lengthudf_item(MEM_ROOT* m)
53
return new (m) Item_func_uncompressed_length();
56
static struct udf_func uncompressed_lengthudf = {
57
{ C_STRING_WITH_LEN("uncompressed_length") },
58
create_uncompressed_lengthudf_item
61
static int uncompressed_lengthudf_plugin_init(void *p)
63
udf_func **f = (udf_func**) p;
65
*f= &uncompressed_lengthudf;
70
static int uncompressed_lengthudf_plugin_deinit(void *p)
72
udf_func *udff = (udf_func *) p;
77
mysql_declare_plugin(uncompressed_length)
80
"uncompressed_length",
85
uncompressed_lengthudf_plugin_init, /* Plugin Init */
86
uncompressed_lengthudf_plugin_deinit, /* Plugin Deinit */
87
NULL, /* status variables */
88
NULL, /* system variables */
89
NULL /* config options */
91
mysql_declare_plugin_end;