Debian Codegraph @

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

raw
1 ############ mysql-test\t\read_only_func.test ##################################
2 # #
3 #Variable Name: read_only #
4 #Scope: SESSION #
5 #Access Type: Dynamic #
6 #Data Type: BOOLEAN #
7 #Default Value: OFF #
8 #Values: ON, OFF #
9 # #
10 # #
11 #Creation Date: 2008-03-02 #
12 #Author: Sharique Abdullah #
13 # #
14 #Description: Test Cases of Dynamic System Variable "read_only" #
15 # that checks behavior of this variable in the following ways #
16 # * Functionality based on different values #
17 # #
18 #Reference: http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#
19 # option_mysqld_read_only #
20 # #
21 ################################################################################
22
23 --echo ** Setup **
24 --echo
25 #
26 # Setup
27 #
28
29
30 SET @default_read_only = @@read_only;
31
32 --echo '#--------------------FN_DYNVARS_140_01-------------------------#'
33 ###################################
34 #Setting Read only value ON #
35 ###################################
36
37 SET Global read_only=ON;
38
39 --disable_warnings
40 DROP TABLE IF EXISTS t1;
41 --enable_warnings
42
43 ##################################
44 # Creating table #
45 ##################################
46
47
48 # creating table
49 CREATE TABLE t1
50 (
51 id INT NOT NULL auto_increment,
52 PRIMARY KEY (id),
53 name BLOB
54 );
55
56 ##################################
57 # Inserting values #
58 ##################################
59
60
61 INSERT into t1(name) values("aaassssssssddddddddffffff");
62
63 ###################################
64 # Updating values #
65 ###################################
66
67 update t1 set name="jfjdf" where id=1;
68
69 ###############################################
70 # Select to see wether value is updated or not#
71 ###############################################
72
73 select * from t1 where id=1;
74
75 --echo '#--------------------FN_DYNVARS_140_02-------------------------#'
76 #########################################
77 #Creating user without Super privilege #
78 #########################################
79
80
81 --echo ** Creating new user with out super privilege**
82 CREATE user sameea;
83 --echo ** Connecting connn using username 'sameea' **
84 CONNECT (connn,localhost,sameea,,);
85
86 --Error ER_SPECIFIC_ACCESS_DENIED_ERROR
87 SET Global read_ONLY=ON;
88 --Error ER_OPTION_PREVENTS_STATEMENT
89 CREATE TABLE t2
90 (
91 id INT NOT NULL auto_increment,
92 PRIMARY KEY (id),
93 name BLOB
94 );
95
96 # With ps-protocol the error is ER_NO_SUCH_TABLE
97 --echo not updating values
98 --Error ER_OPTION_PREVENTS_STATEMENT,ER_NO_SUCH_TABLE
99 INSERT into t2(name) values("aaassssssssddddddddffffff");
100
101
102 --Error ER_OPTION_PREVENTS_STATEMENT,ER_NO_SUCH_TABLE
103 UPDATE t2 SET name="samia" where id=1;
104
105 --echo '#--------------------FN_DYNVARS_140_03-------------------------#'
106
107 ###########################
108 # Testing temporary table #
109 ###########################
110 CREATE TEMPORARY TABLE t3(a int);
111
112 --echo '#--------------------FN_DYNVARS_140_04-------------------------#'
113 ###########################
114 # Turning read_only OFF #
115 ###########################
116 --echo ** Connection default **
117 connection default;
118
119 SET Global read_only=OFF;
120 --echo ** Connection connn **
121 connection connn;
122
123 CREATE TABLE t2
124 (
125 id INT NOT NULL auto_increment,
126 PRIMARY KEY (id),
127 name BLOB
128 );
129 --echo updating values
130 INSERT into t2(name) values("aaassssssssdddddddd");
131
132 UPDATE t2 SET name="samia" where id=1;
133
134 #
135 # Cleanup
136 #
137 --echo ** Connection default **
138 connection default;
139
140 --echo ** Disconnecting connn **
141 DISCONNECT connn;
142
143 DROP USER sameea;
144
145 DROP TABLE t1;
146 DROP TABLE t2;
147 SET global read_only = @default_read_only;
148
149 --disable_info