mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 13:32:33 +01:00
a8a757c6bb
and collateral changes. * introduce my_hrtime_t, my_timediff_t, and conversion macros * inroduce TIME_RESULT, but it can only be returned from Item::cmp_type(), never from Item::result_type() * pack_time/unpack_time function for "packed" representation of MYSQL_TIME in a longlong that can be compared * ADDTIME()/SUBTIME()/+- INTERVAL now work with TIME values * numbers aren't quoted in EXPLAIN EXTENDED * new column I_S.COLUMNS.DATETIME_PRECISION * date/time values are compares to anything as date/time, not as strings or numbers. * old timestamp(X) is no longer supported * MYSQL_TIME to string conversion functions take precision as an argument * unified the warnings from Field_timestamp/datetime/time/date/newdate store methods * Field_timestamp_hires, Field_datetime_hires, Field_time_hires * Field_temporal * Lazy_string class to pass a value (string, number, time) polymorphically down the stack * make_truncated_value_warning and Field::set_datetime_warning use Lazy_string as an argument, removed char*/int/double variants * removed Field::can_be_compared_as_longlong(). Use Field::cmp_type() == INT_RESULT instead * introduced Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong() * in many cases date/time types are treated like other types, not as special cases * greatly simplified Arg_comparator (regarding date/time/year code) * SEC_TO_TIME is real function, not integer. * microsecond precision in NOW, CURTIME, etc * Item_temporal. All items derived from it only provide get_date, but no val* methods * replication of NOW(6) * Protocol::store(time) now takes the precision as an argument * @@TIMESTAMP is a double client/mysqlbinlog.cc: remove unneded casts include/my_sys.h: introduce my_hrtime_t, my_timediff_t, and conversion macros include/my_time.h: pack_time/unpack_time, etc. convenience functions to work with MYSQL_TIME::second_part libmysql/libmysql.c: str_to_time() is gone. str_to_datetime() does it now. my_TIME_to_str() takes the precision as an argument mysql-test/include/ps_conv.inc: time is not equal to datetime anymore mysql-test/r/distinct.result: a test for an old MySQL bug mysql-test/r/explain.result: numbers aren't quoted in EXPLAIN EXTENDED mysql-test/r/func_default.result: numbers aren't quoted in EXPLAIN EXTENDED mysql-test/r/func_sapdb.result: when decimals=NOT_FIXED_DEC it means "not fixed" indeed mysql-test/r/func_test.result: numbers aren't quoted in EXPLAIN EXTENDED mysql-test/r/func_time.result: ADDTIME()/SUBTIME()/+- INTERVAL now work with TIME values mysql-test/r/having.result: numbers aren't quoted in EXPLAIN EXTENDED mysql-test/r/information_schema.result: new column I_S.COLUMNS.DATETIME_PRECISION mysql-test/r/join_outer.result: numbers aren't quoted in EXPLAIN EXTENDED mysql-test/r/metadata.result: TIMESTAMP no longer has zerofill flag mysql-test/r/range.result: invalid datetime is not compared with as a string mysql-test/r/select.result: NO_ZERO_IN_DATE, etc only affect storage - according to the manual numbers aren't quoted in EXPLAIN EXTENDED mysql-test/r/subselect.result: numbers aren't quoted in EXPLAIN EXTENDED mysql-test/r/sysdate_is_now.result: when decimals=NOT_FIXED_DEC it means "not fixed" indeed mysql-test/r/type_blob.result: TIMESTAMP(N) is not deprecated mysql-test/r/type_timestamp.result: old TIMESTAMP(X) semantics is not supported anymore mysql-test/r/union.result: numbers aren't quoted in EXPLAIN EXTENDED mysql-test/r/varbinary.result: numbers aren't quoted in EXPLAIN EXTENDED mysql-test/t/distinct.test: test for an old MySQL bug mysql-test/t/func_time.test: +- INTERVAL now works with TIME values mysql-test/t/select.test: typo mysql-test/t/subselect.test: only one error per statement, please mysql-test/t/system_mysql_db_fix40123.test: old timestamp(X) is no longer supported mysql-test/t/system_mysql_db_fix50030.test: old timestamp(X) is no longer supported mysql-test/t/system_mysql_db_fix50117.test: old timestamp(X) is no longer supported mysql-test/t/type_blob.test: old timestamp(X) is no longer supported mysql-test/t/type_timestamp.test: old timestamp(X) is no longer supported mysys/my_getsystime.c: functions to get the time with microsecond precision mysys/my_init.c: move the my_getsystime.c initialization code to my_getsystime.c mysys/my_static.c: no need to make these variables extern mysys/my_static.h: no need to make these variables extern scripts/mysql_system_tables.sql: old timestamp(X) is no longer supported scripts/mysql_system_tables_fix.sql: old timestamp(X) is no longer supported scripts/mysqlhotcopy.sh: old timestamp(X) is no longer supported sql-common/my_time.c: * call str_to_time from str_to_datetime, as appropriate * date/time to string conversions take precision as an argument * number_to_time() * TIME_to_double() * pack_time() and unpack_time() sql/event_data_objects.cc: cast is not needed my_datetime_to_str() takes precision as an argument sql/event_db_repository.cc: avoid dangerous downcast (because the pointer is not always Field_timestamp, see events_1.test) sql/event_queue.cc: avoid silly double-work for cond_wait (having an endpoint of wait, subtract the current time to get the timeout, and use set_timespec() macro to fill in struct timespec, by adding the current time to the timeout) sql/field.cc: * remove virtual Field::get_time(), everyone should use only Field::get_date() * remove lots of #ifdef WORDS_BIGENDIAN * unified the warnings from Field_timestamp/datetime/time/date/newdate store methods * Field_timestamp_hires, Field_datetime_hires, Field_time_hires * Field_temporal * make_truncated_value_warning and Field::set_datetime_warning use Lazy_string as an argument, removed char*/int/double variants sql/field.h: * remove virtual Field::get_time(), everyone should use only Field::get_date() * remove lots of #ifdef WORDS_BIGENDIAN * unified the warnings from Field_timestamp/datetime/time/date/newdate store methods * Field_timestamp_hires, Field_datetime_hires, Field_time_hires * Field_temporal * make_truncated_value_warning and Field::set_datetime_warning use Lazy_string as an argument, removed char*/int/double variants * removed Field::can_be_compared_as_longlong(). Use Field::cmp_type() == INT_RESULT instead sql/filesort.cc: TIME_RESULT, cmp_time() sql/item.cc: * numbers aren't quoted in EXPLAIN EXTENDED * Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong() * virtual Item::get_time() is gone * Item_param::field_type() is set correctly * Item_datetime, for a datetime constant * time to anything is compared as a time * Item_cache::print() prints the value is available * bug fixed in Item_cache_int::val_str() sql/item.h: * Item::print_value(), to be used from Item_xxx::print() when needed * Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong() * virtual Item::get_time() is gone * Item_datetime, for a datetime constant * better default for cast_to_int_type() * Item_cache objects now *always* have the field_type() set sql/item_cmpfunc.cc: * get_year_value, get_time_value are gone. get_datetime_value does it all * get_value_a_func, get_value_b_func are gone * can_compare_as_dates() is gone too, TIME_RESULT is used instead * cmp_type() instead or result_type() when doing a comparison * compare_datetime and compate_e_datetime in the comparator_matrix, is_nulls_eq is gone * Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong() sql/item_cmpfunc.h: greatly simplified Arg_comparator sql/item_create.cc: * fix a bug in error messages in CAST sql/item_func.cc: Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong() mention all possibitiles in switch over Item_result values, or use default: sql/item_row.h: overwrite the default cmp_type() for Item_row, as no MYSQL_TYPE_xxx value corresponds to ROW_RESULT sql/item_timefunc.cc: rewrite make_datetime to support precision argument SEC_TO_TIME is real function, not integer. many functions that returned temporal values had duplicate code in val_* methods, some of them did not have get_date() which resulted in unnecessary date->str->date conversions. Now they all are derived from Item_temporal_func and *only* provide get_date, not val* methods. many fixes to set decimals (datetime precision) correctly. sql/item_timefunc.h: SEC_TO_TIME is real function, not integer. many functions that returned temporal values had duplicate code in val_* methods, some of them did not have get_date() which resulted in unnecessary date->str->date conversions. Now they all are derived from Item_temporal_func and *only* provide get_date, not val* methods. many fixes to set decimals (datetime precision) correctly. sql/log_event.cc: replication of NOW(6) sql/log_event.h: replication of NOW(6) sql/mysql_priv.h: Lazy_string class to pass a value (string, number, time) polymorphically down the stack. make_truncated_value_warning() that uses it. sql/mysqld.cc: datetime in Arg_comparator::comparator_matrix sql/opt_range.cc: cleanup: don't disable warnings before calling save_in_field_no_warnings() sql/protocol.cc: Protocol::store(time) now takes the precision as an argument sql/protocol.h: Protocol::store(time) now takes the precision as an argument sql/rpl_rli.cc: small cleanup sql/set_var.cc: SET TIMESTAMP=double sql/set_var.h: @@TIMESTAMP is a double sql/share/errmsg.txt: precision and scale are unsigned sql/slave.cc: replication of NOW(6) sql/sp_head.cc: cleanup sql/sql_class.cc: support for NOW(6) sql/sql_class.h: support for NOW(6) sql/sql_insert.cc: support for NOW(6) sql/sql_select.cc: use item->cmp_type(). move a comment where it belongs sql/sql_show.cc: new column I_S.COLUMNS.DATETIME_PRECISION sql/sql_yacc.yy: TIME(X), DATETIME(X), cast, NOW(X), CURTIME(X), etc sql/time.cc: fix date_add_interval() to support MYSQL_TIMESTAMP_TIME argument storage/myisam/ha_myisam.cc: TIMESTAMP no longer carries ZEROFIELD flag, still we keep MYI file compatible. strings/my_vsnprintf.c: warnings tests/mysql_client_test.c: old timestamp(X) does not work anymore datetime is no longer equal to time
593 lines
27 KiB
SQL
593 lines
27 KiB
SQL
# This part converts any old privilege tables to privilege tables suitable
|
|
# for current version of MySQL
|
|
|
|
# You can safely ignore all 'Duplicate column' and 'Unknown column' errors
|
|
# because these just mean that your tables are already up to date.
|
|
# This script is safe to run even if your tables are already up to date!
|
|
|
|
# On unix, you should use the mysql_fix_privilege_tables script to execute
|
|
# this sql script.
|
|
# On windows you should do 'mysql --force mysql < mysql_fix_privilege_tables.sql'
|
|
|
|
set sql_mode='';
|
|
set storage_engine=MyISAM;
|
|
|
|
ALTER TABLE user add File_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL;
|
|
|
|
# Detect whether or not we had the Grant_priv column
|
|
SET @hadGrantPriv:=0;
|
|
SELECT @hadGrantPriv:=1 FROM user WHERE Grant_priv LIKE '%';
|
|
|
|
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;
|
|
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;
|
|
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;
|
|
|
|
# Fix privileges for old tables
|
|
UPDATE user SET Grant_priv=File_priv,References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0;
|
|
UPDATE db SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0;
|
|
UPDATE host SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0;
|
|
|
|
#
|
|
# The second alter changes ssl_type to new 4.0.2 format
|
|
# Adding columns needed by GRANT .. REQUIRE (openssl)
|
|
|
|
ALTER TABLE user
|
|
ADD ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci NOT NULL,
|
|
ADD ssl_cipher BLOB NOT NULL,
|
|
ADD x509_issuer BLOB NOT NULL,
|
|
ADD x509_subject BLOB NOT NULL;
|
|
ALTER TABLE user MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') NOT NULL;
|
|
|
|
#
|
|
# tables_priv
|
|
#
|
|
ALTER TABLE tables_priv
|
|
ADD KEY Grantor (Grantor);
|
|
|
|
ALTER TABLE tables_priv
|
|
MODIFY Host char(60) NOT NULL default '',
|
|
MODIFY Db char(64) NOT NULL default '',
|
|
MODIFY User char(16) NOT NULL default '',
|
|
MODIFY Table_name char(64) NOT NULL default '',
|
|
MODIFY Grantor char(77) NOT NULL default '',
|
|
ENGINE=MyISAM,
|
|
CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
|
|
|
|
ALTER TABLE tables_priv
|
|
MODIFY Column_priv set('Select','Insert','Update','References')
|
|
COLLATE utf8_general_ci DEFAULT '' NOT NULL,
|
|
MODIFY Table_priv set('Select','Insert','Update','Delete','Create',
|
|
'Drop','Grant','References','Index','Alter',
|
|
'Create View','Show view','Trigger')
|
|
COLLATE utf8_general_ci DEFAULT '' NOT NULL,
|
|
COMMENT='Table privileges';
|
|
|
|
#
|
|
# columns_priv
|
|
#
|
|
#
|
|
# Name change of Type -> Column_priv from MySQL 3.22.12
|
|
#
|
|
ALTER TABLE columns_priv
|
|
CHANGE Type Column_priv set('Select','Insert','Update','References')
|
|
COLLATE utf8_general_ci DEFAULT '' NOT NULL;
|
|
|
|
ALTER TABLE columns_priv
|
|
MODIFY Host char(60) NOT NULL default '',
|
|
MODIFY Db char(64) NOT NULL default '',
|
|
MODIFY User char(16) NOT NULL default '',
|
|
MODIFY Table_name char(64) NOT NULL default '',
|
|
MODIFY Column_name char(64) NOT NULL default '',
|
|
ENGINE=MyISAM,
|
|
CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin,
|
|
COMMENT='Column privileges';
|
|
|
|
ALTER TABLE columns_priv
|
|
MODIFY Column_priv set('Select','Insert','Update','References')
|
|
COLLATE utf8_general_ci DEFAULT '' NOT NULL;
|
|
|
|
#
|
|
# Add the new 'type' column to the func table.
|
|
#
|
|
|
|
ALTER TABLE func add type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL;
|
|
|
|
#
|
|
# Change the user,db and host tables to current format
|
|
#
|
|
|
|
# Detect whether we had Show_db_priv
|
|
SET @hadShowDbPriv:=0;
|
|
SELECT @hadShowDbPriv:=1 FROM user WHERE Show_db_priv LIKE '%';
|
|
|
|
ALTER TABLE user
|
|
ADD Show_db_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_priv,
|
|
ADD Super_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_db_priv,
|
|
ADD Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Super_priv,
|
|
ADD Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_tmp_table_priv,
|
|
ADD Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv,
|
|
ADD Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Execute_priv,
|
|
ADD Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Repl_slave_priv;
|
|
|
|
# Convert privileges so that users have similar privileges as before
|
|
|
|
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;
|
|
|
|
|
|
# Add fields that can be used to limit number of questions and connections
|
|
# for some users.
|
|
|
|
ALTER TABLE user
|
|
ADD max_questions int(11) NOT NULL DEFAULT 0 AFTER x509_subject,
|
|
ADD max_updates int(11) unsigned NOT NULL DEFAULT 0 AFTER max_questions,
|
|
ADD max_connections int(11) unsigned NOT NULL DEFAULT 0 AFTER max_updates;
|
|
|
|
|
|
#
|
|
# Add Create_tmp_table_priv and Lock_tables_priv to db and host
|
|
#
|
|
|
|
ALTER TABLE db
|
|
ADD Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
ADD Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
|
|
ALTER TABLE host
|
|
ADD Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,
|
|
ADD Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL;
|
|
|
|
alter table user change max_questions max_questions int(11) unsigned DEFAULT 0 NOT NULL;
|
|
|
|
|
|
alter table db comment='Database privileges';
|
|
alter table host comment='Host privileges; Merged with database privileges';
|
|
alter table user comment='Users and global privileges';
|
|
alter table func comment='User defined functions';
|
|
|
|
# Convert all tables to UTF-8 with binary collation
|
|
# and reset all char columns to correct width
|
|
ALTER TABLE user
|
|
MODIFY Host char(60) NOT NULL default '',
|
|
MODIFY User char(16) NOT NULL default '',
|
|
ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
|
|
ALTER TABLE user
|
|
MODIFY Password char(41) character set latin1 collate latin1_bin NOT NULL default '',
|
|
MODIFY Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Reload_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Shutdown_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Process_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY File_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Show_db_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Super_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci DEFAULT '' NOT NULL;
|
|
|
|
ALTER TABLE db
|
|
MODIFY Host char(60) NOT NULL default '',
|
|
MODIFY Db char(64) NOT NULL default '',
|
|
MODIFY User char(16) NOT NULL default '',
|
|
ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
|
|
ALTER TABLE db
|
|
MODIFY Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
|
|
|
|
ALTER TABLE host
|
|
MODIFY Host char(60) NOT NULL default '',
|
|
MODIFY Db char(64) NOT NULL default '',
|
|
ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
|
|
ALTER TABLE host
|
|
MODIFY Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
|
|
MODIFY Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
|
|
|
|
ALTER TABLE func
|
|
ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
|
|
ALTER TABLE func
|
|
MODIFY type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL;
|
|
|
|
#
|
|
# Modify log tables.
|
|
#
|
|
|
|
SET @old_log_state = @@global.general_log;
|
|
SET GLOBAL general_log = 'OFF';
|
|
ALTER TABLE general_log
|
|
MODIFY event_time TIMESTAMP NOT NULL,
|
|
MODIFY user_host MEDIUMTEXT NOT NULL,
|
|
MODIFY thread_id INTEGER NOT NULL,
|
|
MODIFY server_id INTEGER UNSIGNED NOT NULL,
|
|
MODIFY command_type VARCHAR(64) NOT NULL,
|
|
MODIFY argument MEDIUMTEXT NOT NULL;
|
|
SET GLOBAL general_log = @old_log_state;
|
|
|
|
SET @old_log_state = @@global.slow_query_log;
|
|
SET GLOBAL slow_query_log = 'OFF';
|
|
ALTER TABLE slow_log
|
|
MODIFY start_time TIMESTAMP NOT NULL,
|
|
MODIFY user_host MEDIUMTEXT NOT NULL,
|
|
MODIFY query_time TIME NOT NULL,
|
|
MODIFY lock_time TIME NOT NULL,
|
|
MODIFY rows_sent INTEGER NOT NULL,
|
|
MODIFY rows_examined INTEGER NOT NULL,
|
|
MODIFY db VARCHAR(512) NOT NULL,
|
|
MODIFY last_insert_id INTEGER NOT NULL,
|
|
MODIFY insert_id INTEGER NOT NULL,
|
|
MODIFY server_id INTEGER UNSIGNED NOT NULL,
|
|
MODIFY sql_text MEDIUMTEXT NOT NULL;
|
|
SET GLOBAL slow_query_log = @old_log_state;
|
|
|
|
#
|
|
# Detect whether we had Create_view_priv
|
|
#
|
|
SET @hadCreateViewPriv:=0;
|
|
SELECT @hadCreateViewPriv:=1 FROM user WHERE Create_view_priv LIKE '%';
|
|
|
|
#
|
|
# Create VIEWs privileges (v5.0)
|
|
#
|
|
ALTER TABLE db ADD Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv;
|
|
ALTER TABLE db MODIFY Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv;
|
|
|
|
ALTER TABLE host ADD Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv;
|
|
ALTER TABLE host MODIFY Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv;
|
|
|
|
ALTER TABLE user ADD Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Repl_client_priv;
|
|
ALTER TABLE user MODIFY Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Repl_client_priv;
|
|
|
|
#
|
|
# Show VIEWs privileges (v5.0)
|
|
#
|
|
ALTER TABLE db ADD Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv;
|
|
ALTER TABLE db MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv;
|
|
|
|
ALTER TABLE host ADD Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv;
|
|
ALTER TABLE host MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv;
|
|
|
|
ALTER TABLE user ADD Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv;
|
|
ALTER TABLE user MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv;
|
|
|
|
#
|
|
# Assign create/show view privileges to people who have create provileges
|
|
#
|
|
UPDATE user SET Create_view_priv=Create_priv, Show_view_priv=Create_priv where user<>"" AND @hadCreateViewPriv = 0;
|
|
|
|
#
|
|
#
|
|
#
|
|
SET @hadCreateRoutinePriv:=0;
|
|
SELECT @hadCreateRoutinePriv:=1 FROM user WHERE Create_routine_priv LIKE '%';
|
|
|
|
#
|
|
# Create PROCEDUREs privileges (v5.0)
|
|
#
|
|
ALTER TABLE db ADD Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv;
|
|
ALTER TABLE db MODIFY Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv;
|
|
|
|
ALTER TABLE host ADD Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv;
|
|
ALTER TABLE host MODIFY Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv;
|
|
|
|
ALTER TABLE user ADD Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv;
|
|
ALTER TABLE user MODIFY Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv;
|
|
|
|
#
|
|
# Alter PROCEDUREs privileges (v5.0)
|
|
#
|
|
ALTER TABLE db ADD Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv;
|
|
ALTER TABLE db MODIFY Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv;
|
|
|
|
ALTER TABLE host ADD Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv;
|
|
ALTER TABLE host MODIFY Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv;
|
|
|
|
ALTER TABLE user ADD Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv;
|
|
ALTER TABLE user MODIFY Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv;
|
|
|
|
ALTER TABLE db ADD Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv;
|
|
ALTER TABLE db MODIFY Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv;
|
|
|
|
ALTER TABLE host ADD Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv;
|
|
ALTER TABLE host MODIFY Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv;
|
|
|
|
#
|
|
# Assign create/alter routine privileges to people who have create privileges
|
|
#
|
|
UPDATE user SET Create_routine_priv=Create_priv, Alter_routine_priv=Alter_priv where user<>"" AND @hadCreateRoutinePriv = 0;
|
|
UPDATE db SET Create_routine_priv=Create_priv, Alter_routine_priv=Alter_priv, Execute_priv=Select_priv where user<>"" AND @hadCreateRoutinePriv = 0;
|
|
UPDATE host SET Create_routine_priv=Create_priv, Alter_routine_priv=Alter_priv, Execute_priv=Select_priv where @hadCreateRoutinePriv = 0;
|
|
|
|
#
|
|
# Add max_user_connections resource limit
|
|
#
|
|
ALTER TABLE user ADD max_user_connections int(11) unsigned DEFAULT '0' NOT NULL AFTER max_connections;
|
|
|
|
#
|
|
# user.Create_user_priv
|
|
#
|
|
|
|
SET @hadCreateUserPriv:=0;
|
|
SELECT @hadCreateUserPriv:=1 FROM user WHERE Create_user_priv LIKE '%';
|
|
|
|
ALTER TABLE user ADD Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv;
|
|
ALTER TABLE user MODIFY Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv;
|
|
UPDATE user LEFT JOIN db USING (Host,User) SET Create_user_priv='Y'
|
|
WHERE @hadCreateUserPriv = 0 AND
|
|
(user.Grant_priv = 'Y' OR db.Grant_priv = 'Y');
|
|
|
|
#
|
|
# procs_priv
|
|
#
|
|
|
|
ALTER TABLE procs_priv
|
|
ENGINE=MyISAM,
|
|
CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
|
|
|
|
ALTER TABLE procs_priv
|
|
MODIFY Proc_priv set('Execute','Alter Routine','Grant')
|
|
COLLATE utf8_general_ci DEFAULT '' NOT NULL;
|
|
|
|
ALTER IGNORE TABLE procs_priv
|
|
MODIFY Routine_name char(64)
|
|
COLLATE utf8_general_ci DEFAULT '' NOT NULL;
|
|
|
|
ALTER TABLE procs_priv
|
|
ADD Routine_type enum('FUNCTION','PROCEDURE')
|
|
COLLATE utf8_general_ci NOT NULL AFTER Routine_name;
|
|
|
|
ALTER TABLE procs_priv
|
|
MODIFY Timestamp timestamp AFTER Proc_priv;
|
|
|
|
#
|
|
# proc
|
|
#
|
|
|
|
# Correct the name fields to not binary, and expand sql_data_access
|
|
ALTER TABLE proc MODIFY name char(64) DEFAULT '' NOT NULL,
|
|
MODIFY specific_name char(64) DEFAULT '' NOT NULL,
|
|
MODIFY sql_data_access
|
|
enum('CONTAINS_SQL',
|
|
'NO_SQL',
|
|
'READS_SQL_DATA',
|
|
'MODIFIES_SQL_DATA'
|
|
) DEFAULT 'CONTAINS_SQL' NOT NULL,
|
|
MODIFY body longblob NOT NULL,
|
|
MODIFY returns longblob NOT NULL,
|
|
MODIFY 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',
|
|
'NO_ENGINE_SUBSTITUTION',
|
|
'PAD_CHAR_TO_FULL_LENGTH'
|
|
) DEFAULT '' NOT NULL,
|
|
DEFAULT CHARACTER SET utf8;
|
|
|
|
# Correct the character set and collation
|
|
ALTER TABLE proc CONVERT TO CHARACTER SET utf8;
|
|
# Reset some fields after the conversion
|
|
ALTER TABLE proc MODIFY db
|
|
char(64) collate utf8_bin DEFAULT '' NOT NULL,
|
|
MODIFY definer
|
|
char(77) collate utf8_bin DEFAULT '' NOT NULL,
|
|
MODIFY comment
|
|
char(64) collate utf8_bin DEFAULT '' NOT NULL;
|
|
|
|
ALTER TABLE proc ADD character_set_client
|
|
char(32) collate utf8_bin DEFAULT NULL
|
|
AFTER comment;
|
|
ALTER TABLE proc MODIFY character_set_client
|
|
char(32) collate utf8_bin DEFAULT NULL;
|
|
|
|
SELECT CASE WHEN COUNT(*) > 0 THEN
|
|
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.")
|
|
ELSE NULL
|
|
END
|
|
AS value FROM proc WHERE character_set_client IS NULL;
|
|
|
|
UPDATE proc SET character_set_client = @@character_set_client
|
|
WHERE character_set_client IS NULL;
|
|
|
|
ALTER TABLE proc ADD collation_connection
|
|
char(32) collate utf8_bin DEFAULT NULL
|
|
AFTER character_set_client;
|
|
ALTER TABLE proc MODIFY collation_connection
|
|
char(32) collate utf8_bin DEFAULT NULL;
|
|
|
|
SELECT CASE WHEN COUNT(*) > 0 THEN
|
|
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.")
|
|
ELSE NULL
|
|
END
|
|
AS value FROM proc WHERE collation_connection IS NULL;
|
|
|
|
UPDATE proc SET collation_connection = @@collation_connection
|
|
WHERE collation_connection IS NULL;
|
|
|
|
ALTER TABLE proc ADD db_collation
|
|
char(32) collate utf8_bin DEFAULT NULL
|
|
AFTER collation_connection;
|
|
ALTER TABLE proc MODIFY db_collation
|
|
char(32) collate utf8_bin DEFAULT NULL;
|
|
|
|
SELECT CASE WHEN COUNT(*) > 0 THEN
|
|
CONCAT ("WARNING: NULL values of the 'db_collation' column ('mysql.proc' table) have been updated with default values. Please verify if necessary.")
|
|
ELSE NULL
|
|
END
|
|
AS value FROM proc WHERE db_collation IS NULL;
|
|
|
|
UPDATE proc AS p SET db_collation =
|
|
( SELECT DEFAULT_COLLATION_NAME
|
|
FROM INFORMATION_SCHEMA.SCHEMATA
|
|
WHERE SCHEMA_NAME = p.db)
|
|
WHERE db_collation IS NULL;
|
|
|
|
ALTER TABLE proc ADD body_utf8 longblob DEFAULT NULL
|
|
AFTER db_collation;
|
|
ALTER TABLE proc MODIFY body_utf8 longblob DEFAULT NULL;
|
|
|
|
|
|
#
|
|
# EVENT privilege
|
|
#
|
|
SET @hadEventPriv := 0;
|
|
SELECT @hadEventPriv :=1 FROM user WHERE Event_priv LIKE '%';
|
|
|
|
ALTER TABLE user add Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL AFTER Create_user_priv;
|
|
ALTER TABLE user MODIFY Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL AFTER Create_user_priv;
|
|
|
|
UPDATE user SET Event_priv=Super_priv WHERE @hadEventPriv = 0;
|
|
|
|
ALTER TABLE db add Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL;
|
|
ALTER TABLE db MODIFY Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL;
|
|
|
|
#
|
|
# EVENT table
|
|
#
|
|
ALTER TABLE event DROP PRIMARY KEY;
|
|
ALTER TABLE event ADD PRIMARY KEY(db, name);
|
|
# Add sql_mode column just in case.
|
|
ALTER TABLE event ADD sql_mode set ('NOT_USED') AFTER on_completion;
|
|
# Update list of sql_mode values.
|
|
ALTER TABLE event MODIFY 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',
|
|
'NO_ENGINE_SUBSTITUTION',
|
|
'PAD_CHAR_TO_FULL_LENGTH'
|
|
) DEFAULT '' NOT NULL AFTER on_completion;
|
|
ALTER TABLE event MODIFY name char(64) CHARACTER SET utf8 NOT NULL default '';
|
|
|
|
ALTER TABLE event MODIFY COLUMN originator INT UNSIGNED NOT NULL;
|
|
ALTER TABLE event ADD COLUMN originator INT UNSIGNED NOT NULL AFTER comment;
|
|
|
|
ALTER TABLE event MODIFY COLUMN status ENUM('ENABLED','DISABLED','SLAVESIDE_DISABLED') NOT NULL default 'ENABLED';
|
|
|
|
ALTER TABLE event ADD COLUMN time_zone char(64) CHARACTER SET latin1
|
|
NOT NULL DEFAULT 'SYSTEM' AFTER originator;
|
|
|
|
ALTER TABLE event ADD character_set_client
|
|
char(32) collate utf8_bin DEFAULT NULL
|
|
AFTER time_zone;
|
|
ALTER TABLE event MODIFY character_set_client
|
|
char(32) collate utf8_bin DEFAULT NULL;
|
|
|
|
ALTER TABLE event ADD collation_connection
|
|
char(32) collate utf8_bin DEFAULT NULL
|
|
AFTER character_set_client;
|
|
ALTER TABLE event MODIFY collation_connection
|
|
char(32) collate utf8_bin DEFAULT NULL;
|
|
|
|
ALTER TABLE event ADD db_collation
|
|
char(32) collate utf8_bin DEFAULT NULL
|
|
AFTER collation_connection;
|
|
ALTER TABLE event MODIFY db_collation
|
|
char(32) collate utf8_bin DEFAULT NULL;
|
|
|
|
ALTER TABLE event ADD body_utf8 longblob DEFAULT NULL
|
|
AFTER db_collation;
|
|
ALTER TABLE event MODIFY body_utf8 longblob DEFAULT NULL;
|
|
|
|
|
|
#
|
|
# TRIGGER privilege
|
|
#
|
|
|
|
SET @hadTriggerPriv := 0;
|
|
SELECT @hadTriggerPriv :=1 FROM user WHERE Trigger_priv LIKE '%';
|
|
|
|
ALTER TABLE user ADD Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Event_priv;
|
|
ALTER TABLE user MODIFY Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Event_priv;
|
|
|
|
ALTER TABLE host ADD Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
|
|
ALTER TABLE host MODIFY Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
|
|
|
|
ALTER TABLE db ADD Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
|
|
ALTER TABLE db MODIFY Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
|
|
|
|
UPDATE user SET Trigger_priv=Super_priv WHERE @hadTriggerPriv = 0;
|
|
|
|
# Activate the new, possible modified privilege tables
|
|
# This should not be needed, but gives us some extra testing that the above
|
|
# changes was correct
|
|
|
|
flush privileges;
|