~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/compress/compressudf.cc

  • Committer: Monty Taylor
  • Date: 2009-03-08 23:45:12 UTC
  • mto: (923.2.1 mordred)
  • mto: This revision was merged to the branch mainline in revision 921.
  • Revision ID: mordred@inaugust.com-20090308234512-tqkygxtu1iaig23s
Removed C99 isnan() usage, which allows us to remove the util/math.{cc,h} workarounds. Yay for standards!

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/item_func.h>
18
 
#include <drizzled/item_strfunc.h>
19
 
#include <drizzled/drizzled_error_messages.h>
 
16
#include <drizzled/server_includes.h>
 
17
#include <drizzled/sql_udf.h>
 
18
#include <drizzled/item/func.h>
 
19
#include <drizzled/function/str/strfunc.h>
 
20
#include <drizzled/error.h>
 
21
#include <drizzled/sql_error.h>
 
22
#include <drizzled/current_session.h>
20
23
#include <zlib.h>
21
24
 
22
25
class Item_func_compress: public Item_str_func
58
61
  new_size= res->length() + res->length() / 5 + 12;
59
62
 
60
63
  // Check new_size overflow: new_size <= res->length()
61
 
  if (((uint32_t) (new_size+5) <= res->length()) || 
 
64
  if (((uint32_t) (new_size+5) <= res->length()) ||
62
65
      buffer.realloc((uint32_t) new_size + 4 + 1))
63
66
  {
64
67
    null_value= 1;
69
72
 
70
73
  // As far as we have checked res->is_empty() we can use ptr()
71
74
  if ((err= compress(body, &new_size,
72
 
                     (const Bytef*)res->ptr(), res->length())) != Z_OK)
 
75
                     (const Bytef*)res->ptr(), res->length())) != Z_OK)
73
76
  {
74
77
    code= err==Z_MEM_ERROR ? ER_ZLIB_Z_MEM_ERROR : ER_ZLIB_Z_BUF_ERROR;
75
 
    push_warning(current_thd, DRIZZLE_ERROR::WARN_LEVEL_ERROR, code, ER(code));
 
78
    push_warning(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
 
79
                 code, ER(code));
76
80
    null_value= 1;
77
81
    return 0;
78
82
  }
119
123
  return 0;
120
124
}
121
125
 
122
 
mysql_declare_plugin(compress)
 
126
drizzle_declare_plugin(compress)
123
127
{
124
128
  DRIZZLE_UDF_PLUGIN,
125
129
  "compress",
133
137
  NULL,   /* system variables */
134
138
  NULL    /* config options */
135
139
}
136
 
mysql_declare_plugin_end;
 
140
drizzle_declare_plugin_end;