~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/compress/compressudf.cc

  • Committer: Monty Taylor
  • Date: 2008-11-18 22:12:56 UTC
  • mto: (589.1.3 devel)
  • mto: This revision was merged to the branch mainline in revision 589.
  • Revision ID: monty@inaugust.com-20081118221256-ap2kmj073pdw7uap
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
15
 
16
16
#include <drizzled/common_includes.h>
 
17
#include <drizzled/sql_udf.h>
17
18
#include <drizzled/item/func.h>
18
19
#include <drizzled/item/strfunc.h>
19
20
#include <drizzled/error.h>
 
21
#include <drizzled/sql_error.h>
20
22
#include <zlib.h>
21
23
 
22
24
class Item_func_compress: public Item_str_func
58
60
  new_size= res->length() + res->length() / 5 + 12;
59
61
 
60
62
  // Check new_size overflow: new_size <= res->length()
61
 
  if (((uint32_t) (new_size+5) <= res->length()) || 
 
63
  if (((uint32_t) (new_size+5) <= res->length()) ||
62
64
      buffer.realloc((uint32_t) new_size + 4 + 1))
63
65
  {
64
66
    null_value= 1;
69
71
 
70
72
  // As far as we have checked res->is_empty() we can use ptr()
71
73
  if ((err= compress(body, &new_size,
72
 
                     (const Bytef*)res->ptr(), res->length())) != Z_OK)
 
74
                     (const Bytef*)res->ptr(), res->length())) != Z_OK)
73
75
  {
74
76
    code= err==Z_MEM_ERROR ? ER_ZLIB_Z_MEM_ERROR : ER_ZLIB_Z_BUF_ERROR;
75
 
    push_warning(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR, code, ER(code));
 
77
    push_warning(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
 
78
                 code, ER(code));
76
79
    null_value= 1;
77
80
    return 0;
78
81
  }