Debian Codegraph @

mysql-test/suite/sys_vars/t/foreign_key_checks_basic.test

raw
1 ############## mysql-test\t\foreign_key_checks_basic.test #####################
2 # #
3 # Variable Name: foreign_key_checks #
4 # Scope: SESSION #
5 # Access Type: Dynamic #
6 # Data Type: boolean #
7 # Default Value: NA #
8 # Range: NA #
9 # #
10 # #
11 # Creation Date: 2008-02-07 #
12 # Author: Rizwan #
13 # #
14 # Description: Test Cases of Dynamic System Variable foreign_key_checks #
15 # that checks the behavior of this variable in the following ways#
16 # * Default Value #
17 # * Valid & Invalid values #
18 # * Scope & Access method #
19 # * Data Integrity #
20 # #
21 # Reference: http://dev.mysql.com/doc/refman/5.1/en/ #
22 # server-system-variables.html #
23 # #
24 ###############################################################################
25
26 --source include/load_sysvars.inc
27
28 ########################################################################
29 # START OF foreign_key_checks TESTS #
30 ########################################################################
31
32
33 ################################################################################
34 # Saving initial value of foreign_key_checks in a temporary variable #
35 ################################################################################
36
37 SET @session_start_value = @@session.foreign_key_checks;
38 SELECT @session_start_value;
39
40 --echo '#--------------------FN_DYNVARS_032_01------------------------#'
41 ########################################################################
42 # Display the DEFAULT value of foreign_key_checks #
43 ########################################################################
44
45 SET @@session.foreign_key_checks = 1;
46 SET @@session.foreign_key_checks = DEFAULT;
47 SELECT @@session.foreign_key_checks;
48
49
50 --echo '#---------------------FN_DYNVARS_032_02-------------------------#'
51 #############################################################################
52 # Check if foreign_key_checks can be accessed with and without @@ sign #
53 #############################################################################
54
55 SET foreign_key_checks = 1;
56 SELECT @@foreign_key_checks;
57
58 --Error ER_UNKNOWN_TABLE
59 SELECT session.foreign_key_checks;
60
61 --Error ER_UNKNOWN_TABLE
62 SELECT local.foreign_key_checks;
63
64 SET session foreign_key_checks = 0;
65 SELECT @@session.foreign_key_checks;
66
67
68 --echo '#--------------------FN_DYNVARS_032_03------------------------#'
69 ########################################################################
70 # change the value of foreign_key_checks to a valid value #
71 ########################################################################
72
73 SET @@session.foreign_key_checks = 0;
74 SELECT @@session.foreign_key_checks;
75 SET @@session.foreign_key_checks = 1;
76 SELECT @@session.foreign_key_checks;
77
78
79 --echo '#--------------------FN_DYNVARS_032_04-------------------------#'
80 ###########################################################################
81 # Change the value of foreign_key_checks to invalid value #
82 ###########################################################################
83
84 --Error ER_WRONG_VALUE_FOR_VAR
85 SET @@session.foreign_key_checks = -1;
86 --Error ER_WRONG_VALUE_FOR_VAR
87 SET @@session.foreign_key_checks = 2;
88 --Error ER_WRONG_VALUE_FOR_VAR
89 SET @@session.foreign_key_checks = "T";
90 --Error ER_WRONG_VALUE_FOR_VAR
91 SET @@session.foreign_key_checks = "Y";
92 --Error ER_WRONG_VALUE_FOR_VAR
93 SET @@session.foreign_key_checks = TRÜE;
94 --Error ER_WRONG_VALUE_FOR_VAR
95 SET @@session.foreign_key_checks = ÕN;
96 --error ER_PARSE_ERROR
97 SET @@session.foreign_key_checks = OF;
98 --Error ER_WRONG_VALUE_FOR_VAR
99 SET @@session.foreign_key_checks = ÓFF;
100 --Error ER_WRONG_VALUE_FOR_VAR
101 SET @@session.foreign_key_checks = '¹';
102 --Error ER_WRONG_VALUE_FOR_VAR
103 SET @@session.foreign_key_checks = NO;
104
105
106 --echo '#-------------------FN_DYNVARS_032_05----------------------------#'
107 ###########################################################################
108 # Test if accessing global foreign_key_checks gives error #
109 ###########################################################################
110
111 SET @@global.foreign_key_checks = 0;
112 SELECT @@global.foreign_key_checks;
113 SET @@global.foreign_key_checks = 1;
114
115 --echo '#----------------------FN_DYNVARS_032_06------------------------#'
116 #########################################################################
117 # Check if the value in GLOBAL Table contains variable value #
118 #########################################################################
119
120 --disable_warnings
121 SELECT count(VARIABLE_VALUE) FROM performance_schema.global_variables WHERE VARIABLE_NAME='foreign_key_checks';
122 --enable_warnings
123
124 --echo '#----------------------FN_DYNVARS_032_07------------------------#'
125 #########################################################################
126 # Check if the value in GLOBAL Table matches value in variable #
127 #########################################################################
128
129 --disable_warnings
130 SELECT IF(@@session.foreign_key_checks, "ON", "OFF") = VARIABLE_VALUE
131 FROM performance_schema.session_variables
132 WHERE VARIABLE_NAME='foreign_key_checks';
133 --enable_warnings
134 SELECT @@session.foreign_key_checks;
135 --disable_warnings
136 SELECT VARIABLE_VALUE
137 FROM performance_schema.session_variables
138 WHERE VARIABLE_NAME='foreign_key_checks';
139 --enable_warnings
140
141
142 --echo '#---------------------FN_DYNVARS_032_08-------------------------#'
143 ###################################################################
144 # Check if ON and OFF values can be used on variable #
145 ###################################################################
146
147 SET @@session.foreign_key_checks = OFF;
148 SELECT @@session.foreign_key_checks;
149 SET @@session.foreign_key_checks = ON;
150 SELECT @@session.foreign_key_checks;
151
152 --echo '#---------------------FN_DYNVARS_032_09----------------------#'
153 ###################################################################
154 # Check if TRUE and FALSE values can be used on variable #
155 ###################################################################
156
157 SET @@session.foreign_key_checks = TRUE;
158 SELECT @@session.foreign_key_checks;
159 SET @@session.foreign_key_checks = FALSE;
160 SELECT @@session.foreign_key_checks;
161
162 ##############################
163 # Restore initial value #
164 ##############################
165
166 SET @@session.foreign_key_checks = @session_start_value;
167 SELECT @@session.foreign_key_checks;
168
169 ###############################################################
170 # END OF foreign_key_checks TESTS #
171 ###############################################################