############## mysql-test\t\character_set_server_func.test  ###################
#                                                                             #
# Variable Name: character_set_server                                         #
# Scope: GLOBAL | SESSION                                                     #
# Access Type: Dynamic                                                        #
# Data Type: string                                                           #
# Default Value: utf8 (session), latin1 (global)                              #
# Range: NA                                                                   #
#                                                                             #
#                                                                             #
# Creation Date: 2008-03-08                                                   #
# Author:  Rizwan                                                             #
#                                                                             #
# Description: Test Cases of Dynamic System Variable character_set_server     #
#              that checks the behavior of this variable                      #
#                                                                             #
# Reference: http://dev.mysql.com/doc/refman/5.1/en/                          #
#  server-system-variables.html                                               #
#                                                                             #
###############################################################################
--echo '#--------------------FN_DYNVARS_009_01-------------------------#'
######################################################################
# Check if setting character_set_server is changed in new connection # 
######################################################################

#save
SET @global_character_set_server = @@global.character_set_server;
SET @session_character_set_server = @@session.character_set_server;


SET @@global.character_set_server = utf8;
--echo 'connect (con1,localhost,root,,,,)'
connect (con1,localhost,root,,,,);
--echo 'connection con1'
connection con1;
SELECT @@global.character_set_server;
SELECT @@session.character_set_server;
disconnect con1;

--echo '#--------------------FN_DYNVARS_009_02-------------------------#'
#############################################################
# Begin the functionality Testing of character_set_server   #
#############################################################

--echo 'connection default'
connection default;
#The server character set and collation are used as default values if the database 
#character set and collation are not specified in CREATE DATABASE statements.

#==============================================================================
--echo '---global character_set_server should not effects current connection---'
#==============================================================================

SET @@global.character_set_server = utf8;
CREATE DATABASE db1;
USE db1;
SHOW CREATE DATABASE db1;
DROP DATABASE db1;
select @@character_set_database;

#==============================================================================
--echo '---session character_set_server should effects current connection---'
#==============================================================================
SET @@session.character_set_server = utf8;
CREATE DATABASE db1;
USE db1;
SHOW CREATE DATABASE db1;
DROP DATABASE db1;
select @@character_set_database;

#==============================================================================
--echo '----test with new connection----'
#==============================================================================

--echo 'connect (con1,localhost,root,,,,)'
connect (con1,localhost,root,,,,);
--echo 'connection con1'
connection con1;

SELECT @@session.character_set_server;

--echo '----------character set not specified---------'
CREATE DATABASE db1;
USE db1;
SHOW CREATE DATABASE db1;
DROP DATABASE db1;
SELECT @@character_set_database;

--echo '----------ascii character set specified----------'
CREATE DATABASE db1 character set ascii;
USE db1;
SHOW CREATE DATABASE db1;
DROP DATABASE db1;
select @@character_set_database;

disconnect con1;

#restore
--echo 'connection default;'
connection default;
SET @@global.character_set_server = @global_character_set_server;
SET @@session.character_set_server = @session_character_set_server;

############################################################
# End of functionality Testing for character_set_server    #
############################################################
