~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/compression/compress.cc

  • Committer: Brian Aker
  • Date: 2010-12-08 22:35:56 UTC
  • mfrom: (1819.9.158 update-innobase)
  • Revision ID: brian@tangent.org-20101208223556-37mi4omqg7lkjzf3
Merge in Stewart's changes, 1.3 changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
15
 
16
 
#include <drizzled/common_includes.h>
17
 
#include <drizzled/sql_udf.h>
 
16
#include "config.h"
 
17
#include <drizzled/plugin/function.h>
18
18
#include <drizzled/item/func.h>
19
 
#include <drizzled/item/strfunc.h>
 
19
#include <drizzled/function/str/strfunc.h>
20
20
#include <drizzled/error.h>
21
21
#include <drizzled/sql_error.h>
 
22
#include <drizzled/current_session.h>
22
23
#include <zlib.h>
23
 
 
24
 
class Item_func_compress: public Item_str_func
25
 
{
26
 
  String buffer;
27
 
public:
28
 
  Item_func_compress():Item_str_func(){}
29
 
  void fix_length_and_dec(){max_length= (args[0]->max_length*120)/100+12;}
30
 
  const char *func_name() const{return "compress";}
31
 
  String *val_str(String *) ;
32
 
};
 
24
#include "plugin/compression/compress.h"
 
25
 
 
26
#include <string>
 
27
 
 
28
using namespace std;
 
29
using namespace drizzled;
33
30
 
34
31
String *Item_func_compress::val_str(String *str)
35
32
{
96
93
}
97
94
 
98
95
 
99
 
Item_func* create_compressudf_item(MEM_ROOT* m)
100
 
{
101
 
  return  new (m) Item_func_compress();
102
 
}
103
 
 
104
 
static struct udf_func compressudf = {
105
 
  { C_STRING_WITH_LEN("compress") },
106
 
  create_compressudf_item
107
 
};
108
 
 
109
 
static int compressudf_plugin_init(void *p)
110
 
{
111
 
  udf_func **f = (udf_func**) p;
112
 
 
113
 
  *f= &compressudf;
114
 
 
115
 
  return 0;
116
 
}
117
 
 
118
 
static int compressudf_plugin_deinit(void *p)
119
 
{
120
 
  udf_func *udff = (udf_func *) p;
121
 
  (void)udff;
122
 
  return 0;
123
 
}
124
 
 
125
 
mysql_declare_plugin(compress)
126
 
{
127
 
  DRIZZLE_UDF_PLUGIN,
128
 
  "compress",
129
 
  "1.0",
130
 
  "Stewart Smith",
131
 
  "UDF for compress()",
132
 
  PLUGIN_LICENSE_GPL,
133
 
  compressudf_plugin_init, /* Plugin Init */
134
 
  compressudf_plugin_deinit, /* Plugin Deinit */
135
 
  NULL,   /* status variables */
136
 
  NULL,   /* system variables */
137
 
  NULL    /* config options */
138
 
}
139
 
mysql_declare_plugin_end;