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 */
16
#define DRIZZLE_SERVER 1 /* for thd variable max_allowed_packet */
17
16
#include <drizzled/server_includes.h>
18
#include <drizzled/drizzled_error_messages.h>
17
#include <drizzled/session.h>
18
#include <drizzled/error.h>
19
#include <drizzled/function/str/strfunc.h>
46
47
/* If length is less than 4 bytes, data is corrupt */
47
48
if (res->length() <= 4)
49
push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
51
ER(ER_ZLIB_Z_DATA_ERROR));
50
push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
52
ER(ER_ZLIB_Z_DATA_ERROR));
55
56
/* Size of uncompressed data is stored as first 4 bytes of field */
56
57
new_size= uint4korr(res->ptr()) & 0x3FFFFFFF;
57
if (new_size > current_thd->variables.max_allowed_packet)
58
if (new_size > current_session->variables.max_allowed_packet)
59
push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
60
ER_TOO_BIG_FOR_UNCOMPRESS,
61
ER(ER_TOO_BIG_FOR_UNCOMPRESS),
62
current_thd->variables.max_allowed_packet);
60
push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
61
ER_TOO_BIG_FOR_UNCOMPRESS,
62
ER(ER_TOO_BIG_FOR_UNCOMPRESS),
63
current_session->variables.max_allowed_packet);
65
66
if (buffer.realloc((uint32_t)new_size))
68
69
if ((err= uncompress((Byte*)buffer.ptr(), &new_size,
69
((const Bytef*)res->ptr())+4,res->length())) == Z_OK)
70
((const Bytef*)res->ptr())+4,res->length())) == Z_OK)
71
72
buffer.length((uint32_t) new_size);
75
76
code= ((err == Z_BUF_ERROR) ? ER_ZLIB_Z_BUF_ERROR :
76
77
((err == Z_MEM_ERROR) ? ER_ZLIB_Z_MEM_ERROR : ER_ZLIB_Z_DATA_ERROR));
77
push_warning(current_thd, DRIZZLE_ERROR::WARN_LEVEL_ERROR, code, ER(code));
78
push_warning(current_session, DRIZZLE_ERROR::WARN_LEVEL_ERROR, code, ER(code));
122
123
NULL, /* system variables */
123
124
NULL /* config options */
125
mysql_declare_plugin_end;
126
drizzle_declare_plugin_end;