~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/compression/uncompress.cc

merge lp:~linuxjedi/drizzle/trunk-remove-drizzleadmin

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
 
#include <drizzled/session.h>
 
20
#include <config.h>
 
21
 
22
22
#include <drizzled/error.h>
23
23
#include <drizzled/function/str/strfunc.h>
24
 
#include "plugin/compression/uncompress.h"
 
24
#include <drizzled/session.h>
 
25
#include <drizzled/system_variables.h>
 
26
#include <plugin/compression/uncompress.h>
25
27
 
26
28
#include <zlib.h>
27
29
#include <string>
46
48
  /* If length is less than 4 bytes, data is corrupt */
47
49
  if (res->length() <= 4)
48
50
  {
49
 
    push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
 
51
    push_warning_printf(&getSession(), DRIZZLE_ERROR::WARN_LEVEL_ERROR,
50
52
                        ER_ZLIB_Z_DATA_ERROR,
51
53
                        ER(ER_ZLIB_Z_DATA_ERROR));
52
54
    goto err;
54
56
 
55
57
  /* Size of uncompressed data is stored as first 4 bytes of field */
56
58
  new_size= uint4korr(res->ptr()) & 0x3FFFFFFF;
57
 
  if (new_size > current_session->variables.max_allowed_packet)
 
59
  if (new_size > getSession().variables.max_allowed_packet)
58
60
  {
59
 
    push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
 
61
    push_warning_printf(&getSession(), DRIZZLE_ERROR::WARN_LEVEL_ERROR,
60
62
                        ER_TOO_BIG_FOR_UNCOMPRESS,
61
63
                        ER(ER_TOO_BIG_FOR_UNCOMPRESS),
62
 
                        current_session->variables.max_allowed_packet);
 
64
                        getSession().variables.max_allowed_packet);
63
65
    goto err;
64
66
  }
65
 
  if (buffer.realloc((uint32_t)new_size))
66
 
    goto err;
 
67
 
 
68
  buffer.realloc(new_size);
67
69
 
68
70
  if ((err= uncompress((Byte*)buffer.ptr(), &new_size,
69
71
                       ((const Bytef*)res->ptr())+4,res->length())) == Z_OK)
74
76
 
75
77
  code= ((err == Z_BUF_ERROR) ? ER_ZLIB_Z_BUF_ERROR :
76
78
         ((err == Z_MEM_ERROR) ? ER_ZLIB_Z_MEM_ERROR : ER_ZLIB_Z_DATA_ERROR));
77
 
  push_warning(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR, code, ER(code));
 
79
  push_warning(&getSession(), DRIZZLE_ERROR::WARN_LEVEL_ERROR, code, ER(code));
78
80
 
79
81
err:
80
82
  null_value= 1;