~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/compression/uncompress.cc

  • Committer: Brian Aker
  • Date: 2011-01-12 06:45:23 UTC
  • mto: (2073.1.4 catalogs)
  • mto: This revision was merged to the branch mainline in revision 2080.
  • Revision ID: brian@tangent.org-20110112064523-rqhptaqbph22qmj1
RemoveĀ customĀ error.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
21
 
 
 
20
#include "config.h"
 
21
#include <drizzled/session.h>
22
22
#include <drizzled/error.h>
23
23
#include <drizzled/function/str/strfunc.h>
24
 
#include <drizzled/session.h>
25
 
 
26
 
#include <plugin/compression/uncompress.h>
 
24
#include "plugin/compression/uncompress.h"
27
25
 
28
26
#include <zlib.h>
29
27
#include <string>
37
35
  String *res= args[0]->val_str(str);
38
36
  ulong new_size;
39
37
  int err;
40
 
  drizzled::error_t code;
 
38
  uint32_t code;
41
39
 
42
40
  if (!res)
43
41
    goto err;
48
46
  /* If length is less than 4 bytes, data is corrupt */
49
47
  if (res->length() <= 4)
50
48
  {
51
 
    push_warning_printf(&getSession(), DRIZZLE_ERROR::WARN_LEVEL_ERROR,
 
49
    push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
52
50
                        ER_ZLIB_Z_DATA_ERROR,
53
51
                        ER(ER_ZLIB_Z_DATA_ERROR));
54
52
    goto err;
56
54
 
57
55
  /* Size of uncompressed data is stored as first 4 bytes of field */
58
56
  new_size= uint4korr(res->ptr()) & 0x3FFFFFFF;
59
 
  if (new_size > getSession().variables.max_allowed_packet)
 
57
  if (new_size > current_session->variables.max_allowed_packet)
60
58
  {
61
 
    push_warning_printf(&getSession(), DRIZZLE_ERROR::WARN_LEVEL_ERROR,
 
59
    push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
62
60
                        ER_TOO_BIG_FOR_UNCOMPRESS,
63
61
                        ER(ER_TOO_BIG_FOR_UNCOMPRESS),
64
 
                        getSession().variables.max_allowed_packet);
 
62
                        current_session->variables.max_allowed_packet);
65
63
    goto err;
66
64
  }
67
 
 
68
65
  if (buffer.realloc((uint32_t)new_size))
69
66
    goto err;
70
67
 
77
74
 
78
75
  code= ((err == Z_BUF_ERROR) ? ER_ZLIB_Z_BUF_ERROR :
79
76
         ((err == Z_MEM_ERROR) ? ER_ZLIB_Z_MEM_ERROR : ER_ZLIB_Z_DATA_ERROR));
80
 
  push_warning(&getSession(), DRIZZLE_ERROR::WARN_LEVEL_ERROR, code, ER(code));
 
77
  push_warning(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR, code, ER(code));
81
78
 
82
79
err:
83
80
  null_value= 1;