################## mysql-test\t\max_allowed_packet_func.test ##################
#                                                                             #
# Variable Name: max_allowed_packet                                           #
# Scope: GLOBAL | SESSION                                                     #
# Access Type: Dynamic                                                        #
# Data Type: numeric                                                          #
# Default Value:4194304                                                       #
# Range:1024-1073741824                                                       #
#                                                                             #
#                                                                             #
# Creation Date: 2008-03-07                                                   #
# Author:  Salman Rawala                                                      #
#                                                                             #
# Description: Test Cases of Dynamic System Variable max_allowed_packet       #
#              that checks the functionality of this variable                 #
#                                                                             #
# Reference:                                                                  #
#  http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html        #
#                                                                             #
###############################################################################

#due to lost connection on win64
--source include/not_windows.inc

SET @start_max_allowed_packet= @@global.max_allowed_packet;
SET @start_value= @@global.net_buffer_length;

--disable_warnings
drop table if exists t1;
--enable_warnings

#########################
#   Creating new table  #
#########################

--echo ## Creating new table t1 ##
CREATE TABLE t1
(
id INT NOT NULL auto_increment,
PRIMARY KEY (id),
name BLOB
);

--echo '#--------------------FN_DYNVARS_070_01-------------------------#'
###############################################################################
#    Setting initial value of max_allowed_packet to 1024 at session level 
#    should result in an error (session variable is readonly)
###############################################################################

--echo ## Setting value of max_allowed packet and net_buffer_length to 1024 ## 
--error ER_VARIABLE_IS_READONLY
SET @@session.max_allowed_packet = 1024;
SELECT @@session.max_allowed_packet;

--error ER_VARIABLE_IS_READONLY
SET @@session.net_buffer_length = 1024;
SELECT @@session.net_buffer_length;


--echo '#--------------------FN_DYNVARS_070_02-------------------------#'
###############################################################################
#    Setting value of max_allowed_packet to 1024 at global level and
#    verifying its behavior after inserting data greater than 1024 bytes
###############################################################################

--echo ## Setting value of max_allowed packet and net_buffer_length to 1024 ##
SET @@global.max_allowed_packet = 1024;
SET @@global.net_buffer_length = 1024;
SELECT @@global.max_allowed_packet;
SELECT @@global.net_buffer_length;

--echo ## Creating new connection test_con1 ##
connect (test_con1,localhost,root,,);
connection test_con1;

--echo ## Inserting and fetching data of length greater than 1024 ##
--Error 0,ER_NET_PACKET_TOO_LARGE
INSERT into t1(name) values("aaassssssssddddddddffffffgggggggg, askdlfjalsdkjfalksdjflaksdjfalkjdflaksjdflakjdflajsflajflajdfalsjfdlajfladjslfajdflajdsflajsflakjsdfla;kjflsdjkf;aljfa;lkdsfjla;sjlkajffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllakjsdffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa;;;;;;;;;;;;;;;;;;;;;;;;;;;dsklfjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjkljffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdkskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");

disconnect test_con1;
connection default;
drop table t1;
SET @@global.max_allowed_packet= @start_max_allowed_packet;
SET @@global.net_buffer_length= @start_value;

