1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
############## mysql-test\t\character_set_database_func.test #################
# #
# Variable Name: character_set_database #
# Scope: GLOBAL | SESSION #
# Access Type: Dynamic #
# Data Type: string #
# Default Value: latin1 (session), latin1 (global) #
# Range: NA #
# #
# #
# Creation Date: 2008-03-08 #
# Author: Rizwan #
# #
# Description: Test Cases of Dynamic System Variable character_set_database #
# that checks the behavior of this variable #
# #
# Reference: http://dev.mysql.com/doc/refman/5.1/en/ #
# server-system-variables.html #
# #
###############################################################################
--source include/have_utf8.inc
--echo '#--------------------FN_DYNVARS_008_01-------------------------#'
########################################################################
# Check if setting character_set_database is changed in new connection #
########################################################################
#save
SET @global_character_set_database = @@global.character_set_database;
SET @session_character_set_database = @@session.character_set_database;
SET @session_character_set_server = @@session.character_set_server;
SET @global_character_set_server = @@global.character_set_server;
SET @@global.character_set_database = utf8;
connect (con1,localhost,root,,,,);
connection con1;
SELECT @@global.character_set_database;
SELECT @@session.character_set_database;
disconnect con1;
--echo '#--------------------FN_DYNVARS_008_02-------------------------#'
#############################################################
# Begin the functionality Testing of character_set_database #
#############################################################
connection default;
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
#==============================================================================
--echo '--check if setting session character_set_database effects new databases'
#==============================================================================
SET @@session.character_set_server = utf8;
SELECT @@session.character_set_database;
SET @@session.character_set_database = latin5;
SELECT @@session.character_set_database;
CREATE DATABASE db1;
USE db1;
SHOW CREATE DATABASE db1;
CREATE TABLE t1(a INT, b VARCHAR(40));
SHOW CREATE TABLE t1;
DROP TABLE t1;
DROP DATABASE db1;
#==============================================================================
--echo '--ascii character set specified--'
#==============================================================================
CREATE DATABASE db1 CHARACTER SET ascii;
USE db1;
SHOW CREATE DATABASE db1;
CREATE TABLE t1(a INT, b VARCHAR(40));
SHOW CREATE TABLE t1;
DROP TABLE t1;
DROP DATABASE db1;
#==============================================================================
--echo '------Check if load data uses character_set_database----------'
#==============================================================================
USE test;
CREATE TABLE t1 (a CHAR(4) CHARACTER SET utf8) ENGINE=MyISAM CHARACTER SET utf8;
--echo 'Verify with latin';
SET @@session.character_set_database = latin1;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/std_data/charset_utf8.txt' INTO TABLE t1;
SELECT count(*) FROM t1 WHERE CHAR_LENGTH(a)>1;
TRUNCATE TABLE t1;
--echo 'Verify with utf8';
SET @@session.character_set_database = utf8;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/std_data/charset_utf8.txt' INTO TABLE t1;
SELECT count(*) FROM t1 WHERE CHAR_LENGTH(a)>1;
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
#==============================================================================
SET GLOBAL character_set_server=latin5;
connect (con2, localhost, root,,);
connection con2;
CREATE DATABASE csdb CHARACTER SET = utf8;
USE csdb;
DROP DATABASE csdb;
SELECT @@character_set_database;
connection default;
disconnect con2;
#restore
SET @@global.character_set_database = @global_character_set_database;
SET @@session.character_set_database = @session_character_set_database;
SET @@session.character_set_server = @session_character_set_server;
SET @@global.character_set_server = @global_character_set_server;
############################################################
# End of functionality Testing for character_set_database #
############################################################
|