~ubuntu-branches/ubuntu/gutsy/mysql-dfsg-5.0/gutsy

« back to all changes in this revision

Viewing changes to scripts/mysql_fix_privilege_tables.sql

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2007-04-03 09:43:01 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20070403094301-fnjhfr59hu72pvtg
Tags: 5.0.38-0ubuntu1
* Package the Enterprise version again (.37 was a community version), since
  Debian and we have always done so. This brings in a few more bug fixes and
  makes functional derivations less likely.
* debian/README.Maintainer: Add pointer to upstream download URL, since it
  is very hard to find the Enterprise versions.
* Disable 33_scripts__mysql_create_system_tables__no_test.dpatch, since that
  script was removed upstream.
* debian/patches/41_scripts__mysql_install_db.sh__no_test.dpatch: Adapted to
  changed formatting in new upstream version.
* Remove debian/patches/86_PATH_MAX.dpatch, fixed upstream.
* Add debian/patches/90_org_tables_definition.dpatch: Fix local variable
  declaration in libmysqld/sql_parse.cc to fix compilation with
  EMBEDDED_LIBRARY.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
 
 
1
--
 
2
-- The system tables of MySQL Server
 
3
--
 
4
 
 
5
set storage_engine=myisam;
 
6
 
 
7
CREATE TABLE IF NOT EXISTS db (   Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db,User), KEY User (User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Database privileges';
 
8
 
 
9
 
 
10
CREATE TABLE IF NOT EXISTS host (  Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Host privileges;  Merged with database privileges';
 
11
 
 
12
 
 
13
CREATE TABLE IF NOT EXISTS user (   Host char(60) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Password char(41) character set latin1 collate latin1_bin DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Reload_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Shutdown_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Process_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, File_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_db_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Super_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci DEFAULT '' NOT NULL, ssl_cipher BLOB NOT NULL, x509_issuer BLOB NOT NULL, x509_subject BLOB NOT NULL, max_questions int(11) unsigned DEFAULT 0  NOT NULL, max_updates int(11) unsigned DEFAULT 0  NOT NULL, max_connections int(11) unsigned DEFAULT 0  NOT NULL, max_user_connections int(11) unsigned DEFAULT 0  NOT NULL, PRIMARY KEY Host (Host,User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Users and global privileges';
 
14
 
 
15
 
 
16
CREATE TABLE IF NOT EXISTS func (  name char(64) binary DEFAULT '' NOT NULL, ret tinyint(1) DEFAULT '0' NOT NULL, dl char(128) DEFAULT '' NOT NULL, type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL, PRIMARY KEY (name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin   comment='User defined functions';
 
17
 
 
18
 
 
19
CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp(14), Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin   comment='Table privileges';
 
20
 
 
21
CREATE TABLE IF NOT EXISTS columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp(14), Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin   comment='Column privileges';
 
22
 
 
23
 
 
24
CREATE TABLE IF NOT EXISTS help_topic ( help_topic_id int unsigned not null, name char(64) not null, help_category_id smallint unsigned not null, description text not null, example  text not null, url char(128) not null, primary key (help_topic_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8   comment='help topics';
 
25
 
 
26
 
 
27
CREATE TABLE IF NOT EXISTS help_category ( help_category_id smallint unsigned not null, name  char(64) not null, parent_category_id smallint unsigned null, url char(128) not null, primary key (help_category_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8   comment='help categories';
 
28
 
 
29
 
 
30
CREATE TABLE IF NOT EXISTS help_relation ( help_topic_id int unsigned not null references help_topic, help_keyword_id  int unsigned not null references help_keyword, primary key (help_keyword_id, help_topic_id) ) engine=MyISAM CHARACTER SET utf8 comment='keyword-topic relation';
 
31
 
 
32
 
 
33
CREATE TABLE IF NOT EXISTS help_keyword (   help_keyword_id  int unsigned not null, name char(64) not null, primary key (help_keyword_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help keywords';
 
34
 
 
35
 
 
36
CREATE TABLE IF NOT EXISTS time_zone_name (   Name char(64) NOT NULL, Time_zone_id int unsigned NOT NULL, PRIMARY KEY Name (Name) ) engine=MyISAM CHARACTER SET utf8   comment='Time zone names';
 
37
 
 
38
 
 
39
CREATE TABLE IF NOT EXISTS time_zone (   Time_zone_id int unsigned NOT NULL auto_increment, Use_leap_seconds enum('Y','N') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY TzId (Time_zone_id) ) engine=MyISAM CHARACTER SET utf8   comment='Time zones';
 
40
 
 
41
 
 
42
CREATE TABLE IF NOT EXISTS time_zone_transition (   Time_zone_id int unsigned NOT NULL, Transition_time bigint signed NOT NULL, Transition_type_id int unsigned NOT NULL, PRIMARY KEY TzIdTranTime (Time_zone_id, Transition_time) ) engine=MyISAM CHARACTER SET utf8   comment='Time zone transitions';
 
43
 
 
44
 
 
45
CREATE TABLE IF NOT EXISTS time_zone_transition_type (   Time_zone_id int unsigned NOT NULL, Transition_type_id int unsigned NOT NULL, Offset int signed DEFAULT 0 NOT NULL, Is_DST tinyint unsigned DEFAULT 0 NOT NULL, Abbreviation char(8) DEFAULT '' NOT NULL, PRIMARY KEY TzIdTrTId (Time_zone_id, Transition_type_id) ) engine=MyISAM CHARACTER SET utf8   comment='Time zone transition types';
 
46
 
 
47
 
 
48
CREATE TABLE IF NOT EXISTS time_zone_leap_second (   Transition_time bigint signed NOT NULL, Correction int signed NOT NULL, PRIMARY KEY TranTime (Transition_time) ) engine=MyISAM CHARACTER SET utf8   comment='Leap seconds information for time zones';
 
49
 
 
50
 
 
51
CREATE TABLE IF NOT EXISTS proc ( db char(64) collate utf8_bin DEFAULT '' NOT NULL, name  char(64) DEFAULT '' NOT NULL, type  enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language  enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum('CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA' ) DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic  enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list  blob NOT NULL, returns char(64) DEFAULT '' NOT NULL, body  longblob NOT NULL, definer char(77) collate utf8_bin DEFAULT '' NOT NULL, created timestamp, modified timestamp, sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'NOT_USED', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE' ) DEFAULT '' NOT NULL, comment char(64) collate utf8_bin DEFAULT '' NOT NULL, PRIMARY KEY (db,name,type) ) engine=MyISAM character set utf8 comment='Stored Procedures';
 
52
 
 
53
 
 
54
CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin   comment='Procedure privileges';
 
55
 
 
56
# This part converts any old privilege tables to privilege tables suitable
 
57
# for current version of MySQL
 
58
 
 
59
# You can safely ignore all 'Duplicate column' and 'Unknown column' errors
 
60
# because these just mean that your tables are already up to date.
 
61
# This script is safe to run even if your tables are already up to date!
 
62
 
 
63
# On unix, you should use the mysql_fix_privilege_tables script to execute
 
64
# this sql script.
 
65
# On windows you should do 'mysql --force mysql < mysql_fix_privilege_tables.sql'
3
66
 
4
67
set storage_engine=MyISAM;
5
68
 
6
 
CREATE TABLE IF NOT EXISTS func (
7
 
  name char(64) binary DEFAULT '' NOT NULL,
8
 
  ret tinyint(1) DEFAULT '0' NOT NULL,
9
 
  dl char(128) DEFAULT '' NOT NULL,
10
 
  type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL,
11
 
  PRIMARY KEY (name)
12
 
) CHARACTER SET utf8 COLLATE utf8_bin;
13
 
 
14
69
ALTER TABLE user add File_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL;
15
70
 
 
71
# Detect whether or not we had the Grant_priv column
16
72
SET @hadGrantPriv:=0;
17
73
SELECT @hadGrantPriv:=1 FROM user WHERE Grant_priv LIKE '%';
18
74
 
29
76
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;
30
77
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;
31
78
 
 
79
# Fix privileges for old tables
32
80
UPDATE user SET Grant_priv=File_priv,References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0;
33
81
UPDATE db SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0;
34
82
UPDATE host SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0;
35
83
 
36
 
--
 
84
#
 
85
# The second alter changes ssl_type to new 4.0.2 format
 
86
# Adding columns needed by GRANT .. REQUIRE (openssl)
37
87
 
38
88
ALTER TABLE user
39
89
ADD ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci NOT NULL,
45
92
ADD x509_subject BLOB NOT NULL;
46
93
ALTER TABLE user MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') NOT NULL;
47
94
 
48
 
--
49
 
--
50
 
CREATE TABLE IF NOT EXISTS tables_priv (
51
 
  Host char(60) binary DEFAULT '' NOT NULL,
52
 
  Db char(64) binary DEFAULT '' NOT NULL,
53
 
  User char(16) binary DEFAULT '' NOT NULL,
54
 
  Table_name char(64) binary DEFAULT '' NOT NULL,
55
 
  Grantor char(77) DEFAULT '' NOT NULL,
56
 
  Timestamp timestamp(14),
57
 
  Table_priv set('Select','Insert','Update','Delete','Create',
58
 
                 'Drop','Grant','References','Index','Alter')
59
 
    COLLATE utf8_general_ci DEFAULT '' NOT NULL,
60
 
  Column_priv set('Select','Insert','Update','References')
61
 
    COLLATE utf8_general_ci DEFAULT '' NOT NULL,
62
 
  PRIMARY KEY (Host,Db,User,Table_name)
63
 
) CHARACTER SET utf8 COLLATE utf8_bin;
 
95
#
 
96
# tables_priv
 
97
#
64
98
 
65
99
ALTER TABLE tables_priv
66
100
  ADD KEY Grantor (Grantor);
84
117
    COLLATE utf8_general_ci DEFAULT '' NOT NULL,
85
118
  COMMENT='Table privileges';
86
119
 
87
 
--
88
 
--
89
 
CREATE TABLE IF NOT EXISTS columns_priv (
90
 
  Host char(60) DEFAULT '' NOT NULL,
91
 
  Db char(64) DEFAULT '' NOT NULL,
92
 
  User char(16) DEFAULT '' NOT NULL,
93
 
  Table_name char(64) DEFAULT '' NOT NULL,
94
 
  Column_name char(64) DEFAULT '' NOT NULL,
95
 
  Timestamp timestamp(14),
96
 
  Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL,
97
 
  PRIMARY KEY (Host,Db,User,Table_name,Column_name)
98
 
) CHARACTER SET utf8 COLLATE utf8_bin;
 
120
#
 
121
# columns_priv
 
122
#
99
123
 
 
124
# Name change of Type -> Column_priv from MySQL 3.22.12
100
125
ALTER TABLE columns_priv
101
126
  CHANGE Type Column_priv set('Select','Insert','Update','References')
102
127
    COLLATE utf8_general_ci DEFAULT '' NOT NULL;
117
140
  MODIFY Column_priv set('Select','Insert','Update','References')
118
141
    COLLATE utf8_general_ci DEFAULT '' NOT NULL;
119
142
 
120
 
--
121
 
--
 
143
#
 
144
#  Add the new 'type' column to the func table.
 
145
#
122
146
 
123
147
ALTER TABLE func add type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL;
124
148
 
125
 
--
126
 
--
 
149
#
 
150
#  Change the user,db and host tables to current format
 
151
#
127
152
 
128
153
# Detect whether we had Show_db_priv
129
154
SET @hadShowDbPriv:=0;
140
163
ADD Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Execute_priv,
141
164
ADD Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Repl_slave_priv;
142
165
 
 
166
# Convert privileges so that users have similar privileges as before
143
167
 
144
168
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;
145
169
 
146
170
 
 
171
#  Add fields that can be used to limit number of questions and connections
 
172
#  for some users.
147
173
 
148
174
ALTER TABLE user
149
175
ADD max_questions int(11) NOT NULL DEFAULT 0 AFTER x509_subject,
154
177
ADD max_connections int(11) unsigned NOT NULL DEFAULT 0 AFTER max_updates;
155
178
 
156
179
 
157
 
--
158
 
--
 
180
#
 
181
#  Add Create_tmp_table_priv and Lock_tables_priv to db and host
 
182
#
159
183
 
160
184
ALTER TABLE db
161
185
ADD Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
173
196
alter table user comment='Users and global privileges';
174
197
alter table func comment='User defined functions';
175
198
 
 
199
# Convert all tables to UTF-8 with binary collation
 
200
# and reset all char columns to correct width
176
201
ALTER TABLE user
177
202
  MODIFY Host char(60) NOT NULL default '',
178
203
  MODIFY User char(16) NOT NULL default '',
248
271
 
249
272
#
250
273
# Detect whether we had Create_view_priv
251
 
 
274
#
252
275
SET @hadCreateViewPriv:=0;
253
276
SELECT @hadCreateViewPriv:=1 FROM user WHERE Create_view_priv LIKE '%';
254
277
 
325
348
UPDATE host SET Create_routine_priv=Create_priv, Alter_routine_priv=Alter_priv, Execute_priv=Select_priv where @hadCreateRoutinePriv = 0;
326
349
 
327
350
#
328
 
# Add max_user_connections resource limit 
 
351
# Add max_user_connections resource limit
329
352
#
330
353
ALTER TABLE user ADD max_user_connections int(11) unsigned DEFAULT '0' NOT NULL AFTER max_connections;
331
354
 
342
365
  WHERE @hadCreateUserPriv = 0 AND
343
366
        (user.Grant_priv = 'Y' OR db.Grant_priv = 'Y');
344
367
 
345
 
--
346
 
--
347
 
CREATE TABLE IF NOT EXISTS procs_priv (
348
 
  Host char(60) binary DEFAULT '' NOT NULL,
349
 
  Db char(64) binary DEFAULT '' NOT NULL,
350
 
  User char(16) binary DEFAULT '' NOT NULL,
351
 
  Routine_name char(64) binary DEFAULT '' NOT NULL,
352
 
  Routine_type enum('FUNCTION','PROCEDURE') NOT NULL,
353
 
  Grantor char(77) DEFAULT '' NOT NULL,
354
 
  Proc_priv set('Execute','Alter Routine','Grant')
355
 
    COLLATE utf8_general_ci DEFAULT '' NOT NULL,
356
 
  Timestamp timestamp(14),
357
 
  PRIMARY KEY (Host, Db, User, Routine_name, Routine_type),
358
 
  KEY Grantor (Grantor)
359
 
) CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
 
368
#
 
369
# procs_priv
 
370
#
360
371
 
361
372
ALTER TABLE procs_priv
362
373
  ENGINE=MyISAM,
374
384
ALTER TABLE procs_priv
375
385
  MODIFY Timestamp timestamp(14) AFTER Proc_priv;
376
386
 
377
 
--
378
 
--
379
 
CREATE TABLE IF NOT EXISTS help_topic (
380
 
help_topic_id int unsigned not null,
381
 
name varchar(64) not null,
382
 
help_category_id smallint unsigned not null,
383
 
description text not null,
384
 
example text not null,
385
 
url varchar(128) not null,
386
 
primary key (help_topic_id), unique index (name)
387
 
) CHARACTER SET utf8 comment='help topics';
388
 
 
389
 
CREATE TABLE IF NOT EXISTS help_category (
390
 
help_category_id smallint unsigned not null,
391
 
name varchar(64) not null,
392
 
parent_category_id smallint unsigned null,
393
 
url varchar(128) not null,
394
 
primary key (help_category_id),
395
 
unique index (name)
396
 
) CHARACTER SET utf8 comment='help categories';
397
 
 
398
 
CREATE TABLE IF NOT EXISTS help_relation (
399
 
help_topic_id int unsigned not null references help_topic,
400
 
help_keyword_id  int unsigned not null references help_keyword,
401
 
primary key (help_keyword_id, help_topic_id)
402
 
) CHARACTER SET utf8 comment='keyword-topic relation';
403
 
 
404
 
CREATE TABLE IF NOT EXISTS help_keyword (
405
 
help_keyword_id int unsigned not null,
406
 
name varchar(64) not null,
407
 
primary key (help_keyword_id),
408
 
unique index (name)
409
 
) CHARACTER SET utf8 comment='help keywords';
410
 
 
411
 
#
412
 
# Create missing time zone related tables
413
 
#
414
 
 
415
 
CREATE TABLE IF NOT EXISTS time_zone_name (
416
 
Name char(64) NOT NULL,   
417
 
Time_zone_id int  unsigned NOT NULL,
418
 
PRIMARY KEY Name (Name) 
419
 
) CHARACTER SET utf8 comment='Time zone names';
420
 
 
421
 
CREATE TABLE IF NOT EXISTS time_zone (
422
 
Time_zone_id int unsigned NOT NULL auto_increment,
423
 
Use_leap_seconds  enum('Y','N') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
424
 
PRIMARY KEY TzId (Time_zone_id) 
425
 
) CHARACTER SET utf8 comment='Time zones';
426
 
ALTER TABLE time_zone
427
 
  MODIFY Use_leap_seconds enum('Y','N') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
428
 
 
429
 
CREATE TABLE IF NOT EXISTS time_zone_transition (
430
 
Time_zone_id int unsigned NOT NULL,
431
 
Transition_time bigint signed NOT NULL,   
432
 
Transition_type_id int unsigned NOT NULL,
433
 
PRIMARY KEY TzIdTranTime (Time_zone_id, Transition_time) 
434
 
) CHARACTER SET utf8 comment='Time zone transitions';
435
 
 
436
 
CREATE TABLE IF NOT EXISTS time_zone_transition_type (
437
 
Time_zone_id int unsigned NOT NULL,
438
 
Transition_type_id int unsigned NOT NULL,
439
 
Offset int signed DEFAULT 0 NOT NULL,
440
 
Is_DST tinyint unsigned DEFAULT 0 NOT NULL,
441
 
Abbreviation char(8) DEFAULT '' NOT NULL,
442
 
PRIMARY KEY TzIdTrTId (Time_zone_id, Transition_type_id) 
443
 
) CHARACTER SET utf8 comment='Time zone transition types';
444
 
 
445
 
CREATE TABLE IF NOT EXISTS time_zone_leap_second (
446
 
Transition_time bigint signed NOT NULL,
447
 
Correction int signed NOT NULL,   
448
 
PRIMARY KEY TranTime (Transition_time) 
449
 
) CHARACTER SET utf8 comment='Leap seconds information for time zones';
450
 
 
451
 
 
452
 
#
453
 
# Create proc table if it does not exists
454
 
#
455
 
 
456
 
CREATE TABLE IF NOT EXISTS proc (
457
 
  db                char(64) collate utf8_bin DEFAULT '' NOT NULL,
458
 
  name              char(64) DEFAULT '' NOT NULL,
459
 
  type              enum('FUNCTION','PROCEDURE') NOT NULL,
460
 
  specific_name     char(64) DEFAULT '' NOT NULL,
461
 
  language          enum('SQL') DEFAULT 'SQL' NOT NULL,
462
 
  sql_data_access   enum('CONTAINS_SQL',
463
 
                         'NO_SQL',
464
 
                         'READS_SQL_DATA',
465
 
                         'MODIFIES_SQL_DATA'
466
 
                    ) DEFAULT 'CONTAINS_SQL' NOT NULL,
467
 
  is_deterministic  enum('YES','NO') DEFAULT 'NO' NOT NULL,
468
 
  security_type     enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL,
469
 
  param_list        blob DEFAULT '' NOT NULL,
470
 
  returns           char(64) DEFAULT '' NOT NULL,
471
 
  body              longblob DEFAULT '' NOT NULL,
472
 
  definer           char(77) collate utf8_bin DEFAULT '' NOT NULL,
473
 
  created           timestamp,
474
 
  modified          timestamp,
475
 
  sql_mode          set(
476
 
                        'REAL_AS_FLOAT',
477
 
                        'PIPES_AS_CONCAT',
478
 
                        'ANSI_QUOTES',
479
 
                        'IGNORE_SPACE',
480
 
                        'NOT_USED',
481
 
                        'ONLY_FULL_GROUP_BY',
482
 
                        'NO_UNSIGNED_SUBTRACTION',
483
 
                        'NO_DIR_IN_CREATE',
484
 
                        'POSTGRESQL',
485
 
                        'ORACLE',
486
 
                        'MSSQL',
487
 
                        'DB2',
488
 
                        'MAXDB',
489
 
                        'NO_KEY_OPTIONS',
490
 
                        'NO_TABLE_OPTIONS',
491
 
                        'NO_FIELD_OPTIONS',
492
 
                        'MYSQL323',
493
 
                        'MYSQL40',
494
 
                        'ANSI',
495
 
                        'NO_AUTO_VALUE_ON_ZERO',
496
 
                        'NO_BACKSLASH_ESCAPES',
497
 
                        'STRICT_TRANS_TABLES',
498
 
                        'STRICT_ALL_TABLES',
499
 
                        'NO_ZERO_IN_DATE',
500
 
                        'NO_ZERO_DATE',
501
 
                        'INVALID_DATES',
502
 
                        'ERROR_FOR_DIVISION_BY_ZERO',
503
 
                        'TRADITIONAL',
504
 
                        'NO_AUTO_CREATE_USER',
505
 
                        'HIGH_NOT_PRECEDENCE'
506
 
                    ) DEFAULT '' NOT NULL,
507
 
  comment           char(64) collate utf8_bin DEFAULT '' NOT NULL,
508
 
  PRIMARY KEY (db,name,type)
509
 
) engine=MyISAM
510
 
  character set utf8
511
 
  comment='Stored Procedures';
 
387
#
 
388
# proc
 
389
#
512
390
 
513
391
# Correct the name fields to not binary, and expand sql_data_access
514
392
ALTER TABLE proc MODIFY name char(64) DEFAULT '' NOT NULL,