~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/uncompressed_length/uncompressed_length.cc

  • Committer: Monty Taylor
  • Date: 2008-11-24 05:39:31 UTC
  • mto: This revision was merged to the branch mainline in revision 610.
  • Revision ID: mordred@solanthus.local-20081124053931-tzlxsgkdvs3b7n8n
Reverted libuuid check code. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 
20
 
#include "config.h"
21
 
#include <drizzled/plugin/function.h>
22
 
#include <drizzled/function/math/int.h>
23
 
#include "plugin/compression/uncompressed_length.h"
24
 
 
25
 
#include <string>
26
 
 
27
 
using namespace std;
28
 
using namespace drizzled;
29
 
 
 
1
/* Copyright (C) 2006 MySQL AB
 
2
 
 
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.
 
6
 
 
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.
 
11
 
 
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 */
 
15
 
 
16
#include <drizzled/common_includes.h>
 
17
#include <drizzled/sql_udf.h>
 
18
#include <drizzled/functions/int.h>
 
19
 
 
20
class Item_func_uncompressed_length : public Item_int_func
 
21
{
 
22
  String value;
 
23
public:
 
24
  Item_func_uncompressed_length():Item_int_func(){}
 
25
  const char *func_name() const{return "uncompressed_length";}
 
26
  void fix_length_and_dec() { max_length=10; }
 
27
  int64_t val_int();
 
28
};
30
29
 
31
30
int64_t Item_func_uncompressed_length::val_int()
32
31
{
35
34
  if (!res)
36
35
  {
37
36
    null_value=1;
38
 
    return 0;
 
37
    return 0; /* purecov: inspected */
39
38
  }
40
39
  null_value=0;
41
40
  if (res->is_empty()) return 0;
50
49
  return uint4korr(res->ptr()) & 0x3FFFFFFF;
51
50
}
52
51
 
 
52
Item_func* create_uncompressed_lengthudf_item(MEM_ROOT* m)
 
53
{
 
54
  return  new (m) Item_func_uncompressed_length();
 
55
}
 
56
 
 
57
static struct udf_func uncompressed_lengthudf = {
 
58
  { C_STRING_WITH_LEN("uncompressed_length") },
 
59
  create_uncompressed_lengthudf_item
 
60
};
 
61
 
 
62
static int uncompressed_lengthudf_plugin_init(void *p)
 
63
{
 
64
  udf_func **f = (udf_func**) p;
 
65
 
 
66
  *f= &uncompressed_lengthudf;
 
67
 
 
68
  return 0;
 
69
}
 
70
 
 
71
static int uncompressed_lengthudf_plugin_deinit(void *p)
 
72
{
 
73
  udf_func *udff = (udf_func *) p;
 
74
  (void)udff;
 
75
  return 0;
 
76
}
 
77
 
 
78
mysql_declare_plugin(uncompressed_length)
 
79
{
 
80
  DRIZZLE_UDF_PLUGIN,
 
81
  "uncompressed_length",
 
82
  "1.0",
 
83
  "Stewart Smith",
 
84
  "UDF for compress()",
 
85
  PLUGIN_LICENSE_GPL,
 
86
  uncompressed_lengthudf_plugin_init, /* Plugin Init */
 
87
  uncompressed_lengthudf_plugin_deinit, /* Plugin Deinit */
 
88
  NULL,   /* status variables */
 
89
  NULL,   /* system variables */
 
90
  NULL    /* config options */
 
91
}
 
92
mysql_declare_plugin_end;