1 # Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; version 2 of the License.
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
12 # You should have received a copy of the GNU General Public License
13 # along with this program; if not, write to the Free Software
14 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 # This part converts any old privilege tables to privilege tables suitable
17 # for current version of MySQL
19 # You can safely ignore all 'Duplicate column' and 'Unknown column' errors
20 # because these just mean that your tables are already up to date.
21 # This script is safe to run even if your tables are already up to date!
23 # On unix, you should use the mysql_fix_privilege_tables script to execute
25 # On windows you should do 'mysql --force mysql < mysql_fix_privilege_tables.sql'
28 set storage_engine=MyISAM;
30 ALTER TABLE user add File_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL;
32 # Detect whether or not we had the Grant_priv column
34 SELECT @hadGrantPriv:=1 FROM user WHERE Grant_priv LIKE '%';
36 ALTER TABLE user add Grant_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add References_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Index_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Alter_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL;
37 ALTER TABLE host add Grant_priv enum('N','Y') NOT NULL,add References_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Index_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Alter_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL;
38 ALTER TABLE db add Grant_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add References_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Index_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Alter_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL;
40 # Fix privileges for old tables
41 UPDATE user SET Grant_priv=File_priv,References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0;
42 UPDATE db SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0;
43 UPDATE host SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0;
46 # The second alter changes ssl_type to new 4.0.2 format
47 # Adding columns needed by GRANT .. REQUIRE (openssl)
50 ADD ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci NOT NULL,
51 ADD ssl_cipher BLOB NOT NULL,
52 ADD x509_issuer BLOB NOT NULL,
53 ADD x509_subject BLOB NOT NULL;
54 ALTER TABLE user MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') NOT NULL;
59 ALTER TABLE tables_priv
60 ADD KEY Grantor (Grantor);
62 ALTER TABLE tables_priv
63 MODIFY Host char(60) NOT NULL default '',
64 MODIFY Db char(64) NOT NULL default '',
65 MODIFY User char(16) NOT NULL default '',
66 MODIFY Table_name char(64) NOT NULL default '',
67 MODIFY Grantor char(77) NOT NULL default '',
69 CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
71 ALTER TABLE tables_priv
72 MODIFY Column_priv set('Select','Insert','Update','References')
73 COLLATE utf8_general_ci DEFAULT '' NOT NULL,
74 MODIFY Table_priv set('Select','Insert','Update','Delete','Create',
75 'Drop','Grant','References','Index','Alter',
76 'Create View','Show view','Trigger')
77 COLLATE utf8_general_ci DEFAULT '' NOT NULL,
78 COMMENT='Table privileges';
84 # Name change of Type -> Column_priv from MySQL 3.22.12
86 ALTER TABLE columns_priv
87 CHANGE Type Column_priv set('Select','Insert','Update','References')
88 COLLATE utf8_general_ci DEFAULT '' NOT NULL;
90 ALTER TABLE columns_priv
91 MODIFY Host char(60) NOT NULL default '',
92 MODIFY Db char(64) NOT NULL default '',
93 MODIFY User char(16) NOT NULL default '',
94 MODIFY Table_name char(64) NOT NULL default '',
95 MODIFY Column_name char(64) NOT NULL default '',
97 CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin,
98 COMMENT='Column privileges';
100 ALTER TABLE columns_priv
101 MODIFY Column_priv set('Select','Insert','Update','References')
102 COLLATE utf8_general_ci DEFAULT '' NOT NULL;
105 # Add the new 'type' column to the func table.
108 ALTER TABLE func add type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL;
111 # Change the user,db and host tables to current format
114 # Detect whether we had Show_db_priv
115 SET @hadShowDbPriv:=0;
116 SELECT @hadShowDbPriv:=1 FROM user WHERE Show_db_priv LIKE '%';
119 ADD Show_db_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_priv,
120 ADD Super_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_db_priv,
121 ADD Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Super_priv,
122 ADD Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_tmp_table_priv,
123 ADD Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv,
124 ADD Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Execute_priv,
125 ADD Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Repl_slave_priv;
127 # Convert privileges so that users have similar privileges as before
129 UPDATE user SET Show_db_priv= Select_priv, Super_priv=Process_priv, Execute_priv=Process_priv, Create_tmp_table_priv='Y', Lock_tables_priv='Y', Repl_slave_priv=file_priv, Repl_client_priv=File_priv where user<>"" AND @hadShowDbPriv = 0;
132 # Add fields that can be used to limit number of questions and connections
136 ADD max_questions int(11) NOT NULL DEFAULT 0 AFTER x509_subject,
137 ADD max_updates int(11) unsigned NOT NULL DEFAULT 0 AFTER max_questions,
138 ADD max_connections int(11) unsigned NOT NULL DEFAULT 0 AFTER max_updates;
142 # Add Create_tmp_table_priv and Lock_tables_priv to db and host
146 ADD Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
147 ADD Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
149 ADD Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,
150 ADD Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL;
152 alter table user change max_questions max_questions int(11) unsigned DEFAULT 0 NOT NULL;
155 alter table db comment='Database privileges';
156 alter table host comment='Host privileges; Merged with database privileges';
157 alter table user comment='Users and global privileges';
158 alter table func comment='User defined functions';
160 # Convert all tables to UTF-8 with binary collation
161 # and reset all char columns to correct width
163 MODIFY Host char(60) NOT NULL default '',
164 MODIFY User char(16) NOT NULL default '',
165 ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
167 MODIFY Password char(41) character set latin1 collate latin1_bin NOT NULL default '',
168 MODIFY Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
169 MODIFY Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
170 MODIFY Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
171 MODIFY Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
172 MODIFY Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
173 MODIFY Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
174 MODIFY Reload_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
175 MODIFY Shutdown_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
176 MODIFY Process_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
177 MODIFY File_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
178 MODIFY Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
179 MODIFY References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
180 MODIFY Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
181 MODIFY Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
182 MODIFY Show_db_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
183 MODIFY Super_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
184 MODIFY Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
185 MODIFY Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
186 MODIFY Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
187 MODIFY Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
188 MODIFY Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
189 MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci DEFAULT '' NOT NULL;
192 MODIFY Host char(60) NOT NULL default '',
193 MODIFY Db char(64) NOT NULL default '',
194 MODIFY User char(16) NOT NULL default '',
195 ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
197 MODIFY Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
198 MODIFY Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
199 MODIFY Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
200 MODIFY Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
201 MODIFY Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
202 MODIFY Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
203 MODIFY Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
204 MODIFY References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
205 MODIFY Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
206 MODIFY Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
207 MODIFY Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
208 MODIFY Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
211 MODIFY Host char(60) NOT NULL default '',
212 MODIFY Db char(64) NOT NULL default '',
213 ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
215 MODIFY Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
216 MODIFY Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
217 MODIFY Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
218 MODIFY Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
219 MODIFY Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
220 MODIFY Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
221 MODIFY Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
222 MODIFY References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
223 MODIFY Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
224 MODIFY Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
225 MODIFY Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
226 MODIFY Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
229 ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
231 MODIFY type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL;
237 SET @old_log_state = @@global.general_log;
238 SET GLOBAL general_log = 'OFF';
239 ALTER TABLE general_log
240 MODIFY event_time TIMESTAMP NOT NULL,
241 MODIFY user_host MEDIUMTEXT NOT NULL,
242 MODIFY thread_id INTEGER NOT NULL,
243 MODIFY server_id INTEGER UNSIGNED NOT NULL,
244 MODIFY command_type VARCHAR(64) NOT NULL,
245 MODIFY argument MEDIUMTEXT NOT NULL;
246 SET GLOBAL general_log = @old_log_state;
248 SET @old_log_state = @@global.slow_query_log;
249 SET GLOBAL slow_query_log = 'OFF';
251 MODIFY start_time TIMESTAMP NOT NULL,
252 MODIFY user_host MEDIUMTEXT NOT NULL,
253 MODIFY query_time TIME NOT NULL,
254 MODIFY lock_time TIME NOT NULL,
255 MODIFY rows_sent INTEGER NOT NULL,
256 MODIFY rows_examined INTEGER NOT NULL,
257 MODIFY db VARCHAR(512) NOT NULL,
258 MODIFY last_insert_id INTEGER NOT NULL,
259 MODIFY insert_id INTEGER NOT NULL,
260 MODIFY server_id INTEGER UNSIGNED NOT NULL,
261 MODIFY sql_text MEDIUMTEXT NOT NULL;
262 SET GLOBAL slow_query_log = @old_log_state;
265 # Detect whether we had Create_view_priv
267 SET @hadCreateViewPriv:=0;
268 SELECT @hadCreateViewPriv:=1 FROM user WHERE Create_view_priv LIKE '%';
271 # Create VIEWs privileges (v5.0)
273 ALTER TABLE db ADD Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv;
274 ALTER TABLE db MODIFY Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv;
276 ALTER TABLE host ADD Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv;
277 ALTER TABLE host MODIFY Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv;
279 ALTER TABLE user ADD Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Repl_client_priv;
280 ALTER TABLE user MODIFY Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Repl_client_priv;
283 # Show VIEWs privileges (v5.0)
285 ALTER TABLE db ADD Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv;
286 ALTER TABLE db MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv;
288 ALTER TABLE host ADD Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv;
289 ALTER TABLE host MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv;
291 ALTER TABLE user ADD Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv;
292 ALTER TABLE user MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv;
295 # Assign create/show view privileges to people who have create provileges
297 UPDATE user SET Create_view_priv=Create_priv, Show_view_priv=Create_priv where user<>"" AND @hadCreateViewPriv = 0;
302 SET @hadCreateRoutinePriv:=0;
303 SELECT @hadCreateRoutinePriv:=1 FROM user WHERE Create_routine_priv LIKE '%';
306 # Create PROCEDUREs privileges (v5.0)
308 ALTER TABLE db ADD Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv;
309 ALTER TABLE db MODIFY Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv;
311 ALTER TABLE host ADD Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv;
312 ALTER TABLE host MODIFY Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv;
314 ALTER TABLE user ADD Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv;
315 ALTER TABLE user MODIFY Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv;
318 # Alter PROCEDUREs privileges (v5.0)
320 ALTER TABLE db ADD Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv;
321 ALTER TABLE db MODIFY Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv;
323 ALTER TABLE host ADD Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv;
324 ALTER TABLE host MODIFY Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv;
326 ALTER TABLE user ADD Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv;
327 ALTER TABLE user MODIFY Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv;
329 ALTER TABLE db ADD Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv;
330 ALTER TABLE db MODIFY Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv;
332 ALTER TABLE host ADD Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv;
333 ALTER TABLE host MODIFY Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv;
336 # Assign create/alter routine privileges to people who have create privileges
338 UPDATE user SET Create_routine_priv=Create_priv, Alter_routine_priv=Alter_priv where user<>"" AND @hadCreateRoutinePriv = 0;
339 UPDATE db SET Create_routine_priv=Create_priv, Alter_routine_priv=Alter_priv, Execute_priv=Select_priv where user<>"" AND @hadCreateRoutinePriv = 0;
340 UPDATE host SET Create_routine_priv=Create_priv, Alter_routine_priv=Alter_priv, Execute_priv=Select_priv where @hadCreateRoutinePriv = 0;
343 # Add max_user_connections resource limit
345 ALTER TABLE user ADD max_user_connections int(11) unsigned DEFAULT '0' NOT NULL AFTER max_connections;
348 # user.Create_user_priv
351 SET @hadCreateUserPriv:=0;
352 SELECT @hadCreateUserPriv:=1 FROM user WHERE Create_user_priv LIKE '%';
354 ALTER TABLE user ADD Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv;
355 ALTER TABLE user MODIFY Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv;
356 UPDATE user LEFT JOIN db USING (Host,User) SET Create_user_priv='Y'
357 WHERE @hadCreateUserPriv = 0 AND
358 (user.Grant_priv = 'Y' OR db.Grant_priv = 'Y');
364 ALTER TABLE procs_priv
366 CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
368 ALTER TABLE procs_priv
369 MODIFY Proc_priv set('Execute','Alter Routine','Grant')
370 COLLATE utf8_general_ci DEFAULT '' NOT NULL;
372 ALTER IGNORE TABLE procs_priv
373 MODIFY Routine_name char(64)
374 COLLATE utf8_general_ci DEFAULT '' NOT NULL;
376 ALTER TABLE procs_priv
377 ADD Routine_type enum('FUNCTION','PROCEDURE')
378 COLLATE utf8_general_ci NOT NULL AFTER Routine_name;
380 ALTER TABLE procs_priv
381 MODIFY Timestamp timestamp(14) AFTER Proc_priv;
387 # Correct the name fields to not binary, and expand sql_data_access
388 ALTER TABLE proc MODIFY name char(64) DEFAULT '' NOT NULL,
389 MODIFY specific_name char(64) DEFAULT '' NOT NULL,
390 MODIFY sql_data_access
395 ) DEFAULT 'CONTAINS_SQL' NOT NULL,
396 MODIFY body longblob NOT NULL,
397 MODIFY returns longblob NOT NULL,
404 'ONLY_FULL_GROUP_BY',
405 'NO_UNSIGNED_SUBTRACTION',
418 'NO_AUTO_VALUE_ON_ZERO',
419 'NO_BACKSLASH_ESCAPES',
420 'STRICT_TRANS_TABLES',
425 'ERROR_FOR_DIVISION_BY_ZERO',
427 'NO_AUTO_CREATE_USER',
428 'HIGH_NOT_PRECEDENCE',
429 'NO_ENGINE_SUBSTITUTION',
430 'PAD_CHAR_TO_FULL_LENGTH'
431 ) DEFAULT '' NOT NULL,
432 DEFAULT CHARACTER SET utf8;
434 # Correct the character set and collation
435 ALTER TABLE proc CONVERT TO CHARACTER SET utf8;
436 # Reset some fields after the conversion
437 ALTER TABLE proc MODIFY db
438 char(64) collate utf8_bin DEFAULT '' NOT NULL,
440 char(77) collate utf8_bin DEFAULT '' NOT NULL,
442 char(64) collate utf8_bin DEFAULT '' NOT NULL;
444 ALTER TABLE proc ADD character_set_client
445 char(32) collate utf8_bin DEFAULT NULL
447 ALTER TABLE proc MODIFY character_set_client
448 char(32) collate utf8_bin DEFAULT NULL;
450 SELECT CASE WHEN COUNT(*) > 0 THEN
451 CONCAT ("WARNING: NULL values of the 'character_set_client' column ('mysql.proc' table) have been updated with a default value (", @@character_set_client, "). Please verify if necessary.")
454 AS value FROM proc WHERE character_set_client IS NULL;
456 UPDATE proc SET character_set_client = @@character_set_client
457 WHERE character_set_client IS NULL;
459 ALTER TABLE proc ADD collation_connection
460 char(32) collate utf8_bin DEFAULT NULL
461 AFTER character_set_client;
462 ALTER TABLE proc MODIFY collation_connection
463 char(32) collate utf8_bin DEFAULT NULL;
465 SELECT CASE WHEN COUNT(*) > 0 THEN
466 CONCAT ("WARNING: NULL values of the 'collation_connection' column ('mysql.proc' table) have been updated with a default value (", @@collation_connection, "). Please verify if necessary.")
469 AS value FROM proc WHERE collation_connection IS NULL;
471 UPDATE proc SET collation_connection = @@collation_connection
472 WHERE collation_connection IS NULL;
474 ALTER TABLE proc ADD db_collation
475 char(32) collate utf8_bin DEFAULT NULL
476 AFTER collation_connection;
477 ALTER TABLE proc MODIFY db_collation
478 char(32) collate utf8_bin DEFAULT NULL;
480 SELECT CASE WHEN COUNT(*) > 0 THEN
481 CONCAT ("WARNING: NULL values of the 'db_collation' column ('mysql.proc' table) have been updated with default values. Please verify if necessary.")
484 AS value FROM proc WHERE db_collation IS NULL;
486 UPDATE proc AS p SET db_collation =
487 ( SELECT DEFAULT_COLLATION_NAME
488 FROM INFORMATION_SCHEMA.SCHEMATA
489 WHERE SCHEMA_NAME = p.db)
490 WHERE db_collation IS NULL;
492 ALTER TABLE proc ADD body_utf8 longblob DEFAULT NULL
494 ALTER TABLE proc MODIFY body_utf8 longblob DEFAULT NULL;
500 SET @hadEventPriv := 0;
501 SELECT @hadEventPriv :=1 FROM user WHERE Event_priv LIKE '%';
503 ALTER TABLE user add Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL AFTER Create_user_priv;
504 ALTER TABLE user MODIFY Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL AFTER Create_user_priv;
506 UPDATE user SET Event_priv=Super_priv WHERE @hadEventPriv = 0;
508 ALTER TABLE db add Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL;
509 ALTER TABLE db MODIFY Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL;
514 ALTER TABLE event DROP PRIMARY KEY;
515 ALTER TABLE event ADD PRIMARY KEY(db, name);
516 # Add sql_mode column just in case.
517 ALTER TABLE event ADD sql_mode set ('NOT_USED') AFTER on_completion;
518 # Update list of sql_mode values.
519 ALTER TABLE event MODIFY sql_mode
525 'ONLY_FULL_GROUP_BY',
526 'NO_UNSIGNED_SUBTRACTION',
539 'NO_AUTO_VALUE_ON_ZERO',
540 'NO_BACKSLASH_ESCAPES',
541 'STRICT_TRANS_TABLES',
546 'ERROR_FOR_DIVISION_BY_ZERO',
548 'NO_AUTO_CREATE_USER',
549 'HIGH_NOT_PRECEDENCE',
550 'NO_ENGINE_SUBSTITUTION',
551 'PAD_CHAR_TO_FULL_LENGTH'
552 ) DEFAULT '' NOT NULL AFTER on_completion;
553 ALTER TABLE event MODIFY name char(64) CHARACTER SET utf8 NOT NULL default '';
555 ALTER TABLE event MODIFY COLUMN originator INT UNSIGNED NOT NULL;
556 ALTER TABLE event ADD COLUMN originator INT UNSIGNED NOT NULL AFTER comment;
558 ALTER TABLE event MODIFY COLUMN status ENUM('ENABLED','DISABLED','SLAVESIDE_DISABLED') NOT NULL default 'ENABLED';
560 ALTER TABLE event ADD COLUMN time_zone char(64) CHARACTER SET latin1
561 NOT NULL DEFAULT 'SYSTEM' AFTER originator;
563 ALTER TABLE event ADD character_set_client
564 char(32) collate utf8_bin DEFAULT NULL
566 ALTER TABLE event MODIFY character_set_client
567 char(32) collate utf8_bin DEFAULT NULL;
569 ALTER TABLE event ADD collation_connection
570 char(32) collate utf8_bin DEFAULT NULL
571 AFTER character_set_client;
572 ALTER TABLE event MODIFY collation_connection
573 char(32) collate utf8_bin DEFAULT NULL;
575 ALTER TABLE event ADD db_collation
576 char(32) collate utf8_bin DEFAULT NULL
577 AFTER collation_connection;
578 ALTER TABLE event MODIFY db_collation
579 char(32) collate utf8_bin DEFAULT NULL;
581 ALTER TABLE event ADD body_utf8 longblob DEFAULT NULL
583 ALTER TABLE event MODIFY body_utf8 longblob DEFAULT NULL;
590 SET @hadTriggerPriv := 0;
591 SELECT @hadTriggerPriv :=1 FROM user WHERE Trigger_priv LIKE '%';
593 ALTER TABLE user ADD Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Event_priv;
594 ALTER TABLE user MODIFY Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Event_priv;
596 ALTER TABLE host ADD Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
597 ALTER TABLE host MODIFY Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
599 ALTER TABLE db ADD Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
600 ALTER TABLE db MODIFY Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
602 UPDATE user SET Trigger_priv=Super_priv WHERE @hadTriggerPriv = 0;
604 # Convering the host name to lower case for existing users
605 UPDATE user SET host=LOWER( host ) WHERE LOWER( host ) <> host;
607 # Activate the new, possible modified privilege tables
608 # This should not be needed, but gives us some extra testing that the above
609 # changes was correct