~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/compression/uncompress.cc

Blackhole, CSV, Pool of Threads,Single Thread, Multi Thread.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
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 <drizzled/server_includes.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>
30
28
 
31
29
using namespace std;
32
 
using namespace drizzled;
33
30
 
34
31
String *Item_func_uncompress::val_str(String *str)
35
32
{
37
34
  String *res= args[0]->val_str(str);
38
35
  ulong new_size;
39
36
  int err;
40
 
  drizzled::error_t code;
 
37
  uint32_t code;
41
38
 
42
39
  if (!res)
43
40
    goto err;
48
45
  /* If length is less than 4 bytes, data is corrupt */
49
46
  if (res->length() <= 4)
50
47
  {
51
 
    push_warning_printf(&getSession(), DRIZZLE_ERROR::WARN_LEVEL_ERROR,
 
48
    push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
52
49
                        ER_ZLIB_Z_DATA_ERROR,
53
50
                        ER(ER_ZLIB_Z_DATA_ERROR));
54
51
    goto err;
56
53
 
57
54
  /* Size of uncompressed data is stored as first 4 bytes of field */
58
55
  new_size= uint4korr(res->ptr()) & 0x3FFFFFFF;
59
 
  if (new_size > getSession().variables.max_allowed_packet)
 
56
  if (new_size > current_session->variables.max_allowed_packet)
60
57
  {
61
 
    push_warning_printf(&getSession(), DRIZZLE_ERROR::WARN_LEVEL_ERROR,
 
58
    push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
62
59
                        ER_TOO_BIG_FOR_UNCOMPRESS,
63
60
                        ER(ER_TOO_BIG_FOR_UNCOMPRESS),
64
 
                        getSession().variables.max_allowed_packet);
 
61
                        current_session->variables.max_allowed_packet);
65
62
    goto err;
66
63
  }
67
 
 
68
64
  if (buffer.realloc((uint32_t)new_size))
69
65
    goto err;
70
66
 
77
73
 
78
74
  code= ((err == Z_BUF_ERROR) ? ER_ZLIB_Z_BUF_ERROR :
79
75
         ((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));
 
76
  push_warning(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR, code, ER(code));
81
77
 
82
78
err:
83
79
  null_value= 1;