1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems, Inc.
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.
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.
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
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/server_includes.h>
21
17
#include <drizzled/session.h>
22
18
#include <drizzled/error.h>
23
19
#include <drizzled/function/str/strfunc.h>
24
#include "plugin/compression/uncompress.h"
30
using namespace drizzled;
23
class Item_func_uncompress: public Item_str_func
27
Item_func_uncompress(): Item_str_func(){}
28
void fix_length_and_dec(){ maybe_null= 1; max_length= MAX_BLOB_WIDTH; }
29
const char *func_name() const{return "uncompress";}
30
String *val_str(String *) ;
32
33
String *Item_func_uncompress::val_str(String *str)
75
76
code= ((err == Z_BUF_ERROR) ? ER_ZLIB_Z_BUF_ERROR :
76
((err == Z_MEM_ERROR) ? ER_ZLIB_Z_MEM_ERROR : ER_ZLIB_Z_DATA_ERROR));
77
((err == Z_MEM_ERROR) ? ER_ZLIB_Z_MEM_ERROR : ER_ZLIB_Z_DATA_ERROR));
77
78
push_warning(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR, code, ER(code));
86
Item_func* create_uncompressudf_item(MEM_ROOT* m)
88
return new (m) Item_func_uncompress();
91
static struct udf_func uncompressudf = {
92
{ C_STRING_WITH_LEN("uncompress") },
93
create_uncompressudf_item
96
static int uncompressudf_plugin_init(void *p)
98
udf_func **f = (udf_func**) p;
105
static int uncompressudf_plugin_deinit(void *p)
107
udf_func *udff = (udf_func *) p;
112
mysql_declare_plugin(uncompress)
118
"UDF for compress()",
120
uncompressudf_plugin_init, /* Plugin Init */
121
uncompressudf_plugin_deinit, /* Plugin Deinit */
122
NULL, /* status variables */
123
NULL, /* system variables */
124
NULL /* config options */
126
mysql_declare_plugin_end;