Debian Codegraph @

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

raw
1 ############## mysql-test\t\sql_safe_updates_basic.test #######################
2 # #
3 # Variable Name: sql_safe_updates #
4 # Scope: SESSION #
5 # Access Type: Dynamic #
6 # Data Type: boolean #
7 # Default Value: #
8 # Range: 0,1 #
9 # #
10 # #
11 # Creation Date: 2008-02-07 #
12 # Author: Rizwan #
13 # #
14 # Description: Test Cases of Dynamic System Variable sql_safe_updates #
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 # START OF sql_safe_updates TESTS #
29 ########################################################################
30
31
32 ################################################################################
33 # Saving initial value of sql_safe_updates in a temporary variable #
34 ################################################################################
35
36 SET @session_start_value = @@session.sql_safe_updates;
37 SELECT @session_start_value;
38
39 --echo '#--------------------FN_DYNVARS_163_01------------------------#'
40 ########################################################################
41 # Display the DEFAULT value of sql_safe_updates #
42 ########################################################################
43
44 SET @@session.sql_safe_updates = 0;
45 SET @@session.sql_safe_updates = DEFAULT;
46 SELECT @@session.sql_safe_updates;
47
48 SET @@session.sql_safe_updates = 1;
49 SET @@session.sql_safe_updates = DEFAULT;
50 SELECT @@session.sql_safe_updates;
51
52
53 --echo '#---------------------FN_DYNVARS_163_02-------------------------#'
54 #############################################################################
55 # Check if sql_safe_updates can be accessed with and without @@ sign #
56 #############################################################################
57
58 SET sql_safe_updates = 1;
59 SELECT @@sql_safe_updates;
60
61 --Error ER_UNKNOWN_TABLE
62 SELECT session.sql_safe_updates;
63
64 --Error ER_UNKNOWN_TABLE
65 SELECT local.sql_safe_updates;
66
67 SET session sql_safe_updates = 0;
68 SELECT @@session.sql_safe_updates;
69
70
71 --echo '#--------------------FN_DYNVARS_163_03------------------------#'
72 ########################################################################
73 # change the value of sql_safe_updates to a valid value #
74 ########################################################################
75
76 SET @@session.sql_safe_updates = 0;
77 SELECT @@session.sql_safe_updates;
78 SET @@session.sql_safe_updates = 1;
79 SELECT @@session.sql_safe_updates;
80
81
82 --echo '#--------------------FN_DYNVARS_163_04-------------------------#'
83 ###########################################################################
84 # Change the value of sql_safe_updates to invalid value #
85 ###########################################################################
86
87 --Error ER_WRONG_VALUE_FOR_VAR
88 SET @@session.sql_safe_updates = -1;
89 --Error ER_WRONG_VALUE_FOR_VAR
90 SET @@session.sql_safe_updates = 2;
91 --Error ER_WRONG_VALUE_FOR_VAR
92 SET @@session.sql_safe_updates = "T";
93 --Error ER_WRONG_VALUE_FOR_VAR
94 SET @@session.sql_safe_updates = "Y";
95 --Error ER_WRONG_VALUE_FOR_VAR
96 SET @@session.sql_safe_updates = TRÜE;
97 --Error ER_WRONG_VALUE_FOR_VAR
98 SET @@session.sql_safe_updates = ÕN;
99 --error ER_PARSE_ERROR
100 SET @@session.sql_safe_updates = OF;
101 --Error ER_WRONG_VALUE_FOR_VAR
102 SET @@session.sql_safe_updates = ÓFF;
103 --Error ER_WRONG_VALUE_FOR_VAR
104 SET @@session.sql_safe_updates = '¹';
105 --Error ER_WRONG_VALUE_FOR_VAR
106 SET @@session.sql_safe_updates = NO;
107
108
109 --echo '#-------------------FN_DYNVARS_163_05----------------------------#'
110 ###########################################################################
111 # Test if accessing global sql_safe_updates gives error #
112 ###########################################################################
113
114 SET @@global.sql_safe_updates = 1-@@global.sql_safe_updates;
115 SELECT @@global.sql_safe_updates;
116 SET @@global.sql_safe_updates = 1-@@global.sql_safe_updates;
117 SELECT @@global.sql_safe_updates;
118
119 --echo '#----------------------FN_DYNVARS_163_06------------------------#'
120 #########################################################################
121 # Check if the value in GLOBAL Table contains variable value #
122 #########################################################################
123
124 --disable_warnings
125 SELECT count(VARIABLE_VALUE)
126 FROM performance_schema.global_variables
127 WHERE VARIABLE_NAME='sql_safe_updates';
128 --enable_warnings
129
130 --echo '#----------------------FN_DYNVARS_163_07------------------------#'
131 #########################################################################
132 # Check if the value in GLOBAL Table matches value in variable #
133 #########################################################################
134
135 --disable_warnings
136 SELECT IF(@@session.sql_safe_updates, "ON", "OFF") = VARIABLE_VALUE
137 FROM performance_schema.session_variables
138 WHERE VARIABLE_NAME='sql_safe_updates';
139 --enable_warnings
140 SELECT @@session.sql_safe_updates;
141 --disable_warnings
142 SELECT VARIABLE_VALUE
143 FROM performance_schema.session_variables
144 WHERE VARIABLE_NAME='sql_safe_updates';
145 --enable_warnings
146
147 --echo '#---------------------FN_DYNVARS_163_08-------------------------#'
148 ###################################################################
149 # Check if ON and OFF values can be used on variable #
150 ###################################################################
151
152 SET @@session.sql_safe_updates = OFF;
153 SELECT @@session.sql_safe_updates;
154 SET @@session.sql_safe_updates = ON;
155 SELECT @@session.sql_safe_updates;
156
157 --echo '#---------------------FN_DYNVARS_163_09----------------------#'
158 ###################################################################
159 # Check if TRUE and FALSE values can be used on variable #
160 ###################################################################
161
162 SET @@session.sql_safe_updates = TRUE;
163 SELECT @@session.sql_safe_updates;
164 SET @@session.sql_safe_updates = FALSE;
165 SELECT @@session.sql_safe_updates;
166
167 ##############################
168 # Restore initial value #
169 ##############################
170
171 SET @@session.sql_safe_updates = @session_start_value;
172 SELECT @@session.sql_safe_updates;
173
174 ###############################################################
175 # END OF sql_safe_updates TESTS #
176 ###############################################################