2014-02-17 11:00:51 +01:00
-- Copyright (C) 2003, 2013 Oracle and/or its affiliates.
2018-07-14 13:48:50 +02:00
-- Copyright (C) 2010, 2018 MariaDB Corporation
2010-04-14 20:40:04 +04:00
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; version 2 of the License.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2015-11-03 11:55:30 -05:00
# This part converts any old privilege tables to privilege tables suitable
# for current version of MySQL
2003-08-27 22:30:50 +03:00
2007-02-26 14:48:41 +01:00
# You can safely ignore all 'Duplicate column' and 'Unknown column' errors
2006-11-21 22:32:58 +02:00
# 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!
2003-08-27 22:30:50 +03:00
2013-06-16 21:26:40 +03:00
# Warning message(s) produced for a statement can be printed by explicitly
# adding a 'SHOW WARNINGS' after the statement.
2007-01-02 09:42:13 -08:00
set sql_mode = ' ' ;
2018-08-02 17:59:11 +03:00
set storage_engine = Aria ;
2015-11-04 15:00:34 -05:00
set enforce_storage_engine = NULL ;
2005-04-16 04:12:30 +03:00
2018-07-14 13:48:50 +02:00
ALTER TABLE user add File_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ;
2015-11-03 11:55:30 -05:00
# Detect whether or not we had the Grant_priv column
SET @ hadGrantPriv : = 0 ;
SELECT @ hadGrantPriv : = 1 FROM user WHERE Grant_priv LIKE ' % ' ;
2018-07-14 13:48:50 +02:00
ALTER TABLE user add Grant_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
add References_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
add Index_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
add Alter_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ;
ALTER TABLE db add Grant_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
add References_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
add Index_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
add Alter_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ;
2015-11-03 11:55:30 -05:00
# 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 ;
#
# The second alter changes ssl_type to new 4.0.2 format
# Adding columns needed by GRANT .. REQUIRE (openssl)
ALTER TABLE user
2018-07-14 13:48:50 +02:00
ADD ssl_type enum ( ' ' , ' ANY ' , ' X509 ' , ' SPECIFIED ' ) DEFAULT ' ' NOT NULL ,
2015-11-03 11:55:30 -05:00
ADD ssl_cipher BLOB NOT NULL ,
ADD x509_issuer BLOB NOT NULL ,
ADD x509_subject BLOB NOT NULL ;
2018-07-14 13:48:50 +02:00
ALTER TABLE user MODIFY ssl_type enum ( ' ' , ' ANY ' , ' X509 ' , ' SPECIFIED ' ) DEFAULT ' ' NOT NULL ;
2015-11-03 11:55:30 -05:00
#
# 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 ' ' ,
2018-07-14 13:48:50 +02:00
MODIFY User char ( 80 ) binary NOT NULL default ' ' ,
2015-11-03 11:55:30 -05:00
MODIFY Table_name char ( 64 ) NOT NULL default ' ' ,
2018-07-14 13:48:50 +02:00
MODIFY Grantor char ( 141 ) COLLATE utf8_bin NOT NULL default ' ' ,
2018-08-02 17:59:11 +03:00
ENGINE = Aria ,
2015-11-03 11:55:30 -05:00
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 ' ,
2017-09-08 10:22:24 +03:00
' Create View ' , ' Show view ' , ' Trigger ' , ' Delete versioning rows ' )
2015-11-03 11:55:30 -05:00
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 ' ' ,
2018-07-14 13:48:50 +02:00
MODIFY User char ( 80 ) binary NOT NULL default ' ' ,
2015-11-03 11:55:30 -05:00
MODIFY Table_name char ( 64 ) NOT NULL default ' ' ,
MODIFY Column_name char ( 64 ) NOT NULL default ' ' ,
2018-08-02 17:59:11 +03:00
ENGINE = Aria ,
2015-11-03 11:55:30 -05:00
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 user change max_questions max_questions int ( 11 ) unsigned DEFAULT 0 NOT NULL ;
alter table db comment = ' 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 ' ' ,
2018-07-14 13:48:50 +02:00
MODIFY User char ( 80 ) binary NOT NULL default ' ' ,
2018-08-02 17:59:11 +03:00
ENGINE = Aria , CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin ;
2016-12-12 02:57:07 +02:00
# In MySQL 5.7.6 the Password column is removed. Recreate it to preserve the number
# of columns MariaDB expects in the user table.
ALTER TABLE user
ADD Password char ( 41 ) character set latin1 collate latin1_bin NOT NULL default ' ' AFTER User ;
2015-11-03 11:55:30 -05:00
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 ' ' ,
2018-07-14 13:48:50 +02:00
MODIFY User char ( 80 ) binary NOT NULL default ' ' ,
2018-08-02 17:59:11 +03:00
ENGINE = Aria , CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin ;
2015-11-03 11:55:30 -05:00
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 func
2018-08-02 17:59:11 +03:00
ENGINE = Aria , CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin ;
2015-11-03 11:55:30 -05:00
ALTER TABLE func
MODIFY type enum ( ' function ' , ' aggregate ' ) COLLATE utf8_general_ci NOT NULL ;
2009-03-11 17:30:56 -03:00
#
# Modify log tables.
#
2015-11-03 11:55:30 -05:00
2009-03-11 17:30:56 -03:00
SET @ old_log_state = @ @ global . general_log ;
SET GLOBAL general_log = ' OFF ' ;
2010-02-26 09:22:48 -03:00
ALTER TABLE general_log
2013-06-16 21:26:40 +03:00
MODIFY event_time TIMESTAMP ( 6 ) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
2010-02-26 09:22:48 -03:00
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 ,
2013-06-16 21:26:40 +03:00
MODIFY argument MEDIUMTEXT NOT NULL ,
MODIFY thread_id BIGINT ( 21 ) UNSIGNED NOT NULL ;
2009-03-11 17:30:56 -03:00
SET GLOBAL general_log = @ old_log_state ;
SET @ old_log_state = @ @ global . slow_query_log ;
SET GLOBAL slow_query_log = ' OFF ' ;
2010-02-26 09:22:48 -03:00
ALTER TABLE slow_log
2013-06-16 21:26:40 +03:00
ADD COLUMN thread_id BIGINT ( 21 ) UNSIGNED NOT NULL AFTER sql_text ;
2014-11-30 21:13:41 -05:00
ALTER TABLE slow_log
ADD COLUMN rows_affected INTEGER NOT NULL AFTER thread_id ;
2013-06-16 21:26:40 +03:00
ALTER TABLE slow_log
MODIFY start_time TIMESTAMP ( 6 ) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
2010-02-26 09:22:48 -03:00
MODIFY user_host MEDIUMTEXT NOT NULL ,
2011-05-19 19:19:44 +02:00
MODIFY query_time TIME ( 6 ) NOT NULL ,
MODIFY lock_time TIME ( 6 ) NOT NULL ,
2010-02-26 09:22:48 -03:00
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 ,
2013-06-16 21:26:40 +03:00
MODIFY sql_text MEDIUMTEXT NOT NULL ,
MODIFY thread_id BIGINT ( 21 ) UNSIGNED NOT NULL ;
2009-03-11 17:30:56 -03:00
SET GLOBAL slow_query_log = @ old_log_state ;
2009-10-12 20:15:10 +02:00
ALTER TABLE plugin
MODIFY name varchar ( 64 ) COLLATE utf8_general_ci NOT NULL DEFAULT ' ' ,
MODIFY dl varchar ( 128 ) COLLATE utf8_general_ci NOT NULL DEFAULT ' ' ,
CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci ;
2004-09-11 18:46:06 +03:00
#
2015-11-03 11:55:30 -05:00
# 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 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 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 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 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 ;
#
# 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 ;
#
# Add max_user_connections resource limit
# this is signed in MariaDB so that if one sets it's to -1 then the user
# can't connect anymore.
2004-12-29 20:30:37 +03:00
#
2011-09-26 20:26:47 +03:00
ALTER TABLE user ADD max_user_connections int ( 11 ) DEFAULT ' 0 ' NOT NULL AFTER max_connections ;
ALTER TABLE user MODIFY max_user_connections int ( 11 ) DEFAULT ' 0 ' NOT NULL AFTER max_connections ;
2004-12-29 20:30:37 +03:00
2015-11-03 11:55:30 -05:00
#
# 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 ' ) ;
2007-02-26 11:49:24 +01:00
#
# procs_priv
#
2015-11-03 11:55:30 -05:00
ALTER TABLE procs_priv
2018-08-02 17:59:11 +03:00
ENGINE = Aria ,
2015-11-03 11:55:30 -05:00
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 ;
2006-11-29 12:04:29 +01:00
ALTER TABLE procs_priv
2013-06-16 21:26:40 +03:00
MODIFY Timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP AFTER Proc_priv ;
2006-11-29 12:04:29 +01:00
2007-02-26 11:49:24 +01:00
#
# proc
#
2004-03-23 12:04:40 +01:00
2004-10-14 18:07:09 +02:00
# Correct the name fields to not binary, and expand sql_data_access
2015-11-03 11:55:30 -05:00
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
2005-03-08 17:40:43 -08:00
set ( ' REAL_AS_FLOAT ' ,
' PIPES_AS_CONCAT ' ,
' ANSI_QUOTES ' ,
' IGNORE_SPACE ' ,
2010-04-08 14:10:05 +02:00
' IGNORE_BAD_TABLE_OPTIONS ' ,
2005-03-08 17:40:43 -08:00
' 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 ' ,
2008-02-07 08:47:39 -02:00
' HIGH_NOT_PRECEDENCE ' ,
' NO_ENGINE_SUBSTITUTION ' ,
2017-10-13 15:55:42 +02:00
' PAD_CHAR_TO_FULL_LENGTH ' ,
2018-01-29 16:53:39 +01:00
' EMPTY_STRING_IS_NULL ' ,
' SIMULTANEOUS_ASSIGNMENT '
2005-08-23 16:37:21 -07:00
) DEFAULT ' ' NOT NULL ,
2005-07-08 16:33:15 +02:00
DEFAULT CHARACTER SET utf8 ;
2015-11-03 11:55:30 -05:00
# Correct the character set and collation
2005-07-08 16:33:15 +02:00
# Reset some fields after the conversion
2018-10-19 20:18:34 +02:00
ALTER TABLE proc CONVERT TO CHARACTER SET utf8 ,
2018-10-27 20:46:18 +02:00
MODIFY db char ( 64 ) binary DEFAULT ' ' NOT NULL ,
MODIFY definer char ( 141 ) binary DEFAULT ' ' NOT NULL ,
MODIFY comment text binary NOT NULL ;
2015-11-03 11:55:30 -05:00
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 ;
Patch for the following bugs:
- BUG#11986: Stored routines and triggers can fail if the code
has a non-ascii symbol
- BUG#16291: mysqldump corrupts string-constants with non-ascii-chars
- BUG#19443: INFORMATION_SCHEMA does not support charsets properly
- BUG#21249: Character set of SP-var can be ignored
- BUG#25212: Character set of string constant is ignored (stored routines)
- BUG#25221: Character set of string constant is ignored (triggers)
There were a few general problems that caused these bugs:
1. Character set information of the original (definition) query for views,
triggers, stored routines and events was lost.
2. mysqldump output query in client character set, which can be
inappropriate to encode definition-query.
3. INFORMATION_SCHEMA used strings with mixed encodings to display object
definition;
1. No query-definition-character set.
In order to compile query into execution code, some extra data (such as
environment variables or the database character set) is used. The problem
here was that this context was not preserved. So, on the next load it can
differ from the original one, thus the result will be different.
The context contains the following data:
- client character set;
- connection collation (character set and collation);
- collation of the owner database;
The fix is to store this context and use it each time we parse (compile)
and execute the object (stored routine, trigger, ...).
2. Wrong mysqldump-output.
The original query can contain several encodings (by means of character set
introducers). The problem here was that we tried to convert original query
to the mysqldump-client character set.
Moreover, we stored queries in different character sets for different
objects (views, for one, used UTF8, triggers used original character set).
The solution is
- to store definition queries in the original character set;
- to change SHOW CREATE statement to output definition query in the
binary character set (i.e. without any conversion);
- introduce SHOW CREATE TRIGGER statement;
- to dump special statements to switch the context to the original one
before dumping and restore it afterwards.
Note, in order to preserve the database collation at the creation time,
additional ALTER DATABASE might be used (to temporary switch the database
collation back to the original value). In this case, ALTER DATABASE
privilege will be required. This is a backward-incompatible change.
3. INFORMATION_SCHEMA showed non-UTF8 strings
The fix is to generate UTF8-query during the parsing, store it in the object
and show it in the INFORMATION_SCHEMA.
Basically, the idea is to create a copy of the original query convert it to
UTF8. Character set introducers are removed and all text literals are
converted to UTF8.
This UTF8 query is intended to provide user-readable output. It must not be
used to recreate the object. Specialized SHOW CREATE statements should be
used for this.
The reason for this limitation is the following: the original query can
contain symbols from several character sets (by means of character set
introducers).
Example:
- original query:
CREATE VIEW v1 AS SELECT _cp1251 'Hello' AS c1;
- UTF8 query (for INFORMATION_SCHEMA):
CREATE VIEW v1 AS SELECT 'Hello' AS c1;
client/mysqldump.c:
Set original character set and collation before dumping definition query.
include/my_sys.h:
Move out-parameter to the end of list.
mysql-test/lib/mtr_report.pl:
Ignore server-warnings during the test case.
mysql-test/r/create.result:
Update result file.
mysql-test/r/ctype_cp932_binlog_stm.result:
Update result file.
mysql-test/r/events.result:
Update result file.
mysql-test/r/events_bugs.result:
Update result file.
mysql-test/r/events_grant.result:
Update result file.
mysql-test/r/func_in.result:
Update result file.
mysql-test/r/gis.result:
Update result file.
mysql-test/r/grant.result:
Update result file.
mysql-test/r/information_schema.result:
Update result file.
mysql-test/r/information_schema_db.result:
Update result file.
mysql-test/r/lowercase_view.result:
Update result file.
mysql-test/r/mysqldump.result:
Update result file.
mysql-test/r/ndb_sp.result:
Update result file.
mysql-test/r/ps.result:
Update result file.
mysql-test/r/rpl_replicate_do.result:
Update result file.
mysql-test/r/rpl_sp.result:
Update result file.
mysql-test/r/rpl_trigger.result:
Update result file.
mysql-test/r/rpl_view.result:
Update result file.
mysql-test/r/show_check.result:
Update result file.
mysql-test/r/skip_grants.result:
Update result file.
mysql-test/r/sp-destruct.result:
Update result file.
mysql-test/r/sp-error.result:
Update result file.
mysql-test/r/sp-security.result:
Update result file.
mysql-test/r/sp.result:
Update result file.
mysql-test/r/sql_mode.result:
Update result file.
mysql-test/r/system_mysql_db.result:
Update result file.
mysql-test/r/temp_table.result:
Update result file.
mysql-test/r/trigger-compat.result:
Update result file.
mysql-test/r/trigger-grant.result:
Update result file.
mysql-test/r/trigger.result:
Update result file.
mysql-test/r/view.result:
Update result file.
mysql-test/r/view_grant.result:
Update result file.
mysql-test/t/events.test:
Update test case (new columns added).
mysql-test/t/information_schema.test:
Update test case (new columns added).
mysql-test/t/show_check.test:
Test case for SHOW CREATE TRIGGER in prepared statements and
stored routines.
mysql-test/t/sp-destruct.test:
Update test case (new columns added).
mysql-test/t/sp.test:
Update test case (new columns added).
mysql-test/t/view.test:
Update test.
mysys/charset.c:
Move out-parameter to the end of list.
scripts/mysql_system_tables.sql:
Add new columns to mysql.proc and mysql.event.
scripts/mysql_system_tables_fix.sql:
Add new columns to mysql.proc and mysql.event.
sql/event_data_objects.cc:
Support new attributes for events.
sql/event_data_objects.h:
Support new attributes for events.
sql/event_db_repository.cc:
Support new attributes for events.
sql/event_db_repository.h:
Support new attributes for events.
sql/events.cc:
Add new columns to SHOW CREATE event resultset.
sql/mysql_priv.h:
1. Introduce Object_creation_ctx;
2. Introduce SHOW CREATE TRIGGER;
3. Introduce auxilary functions.
sql/sp.cc:
Add support for new store routines attributes.
sql/sp_head.cc:
Add support for new store routines attributes.
sql/sp_head.h:
Add support for new store routines attributes.
sql/sql_lex.cc:
Generate UTF8-body on parsing/lexing.
sql/sql_lex.h:
1. Generate UTF8-body on parsing/lexing.
2. Introduce SHOW CREATE TRIGGER.
sql/sql_parse.cc:
Introduce SHOW CREATE TRIGGER.
sql/sql_partition.cc:
Update parse_sql().
sql/sql_prepare.cc:
Update parse_sql().
sql/sql_show.cc:
Support new attributes for views
sql/sql_trigger.cc:
Support new attributes for views
sql/sql_trigger.h:
Support new attributes for views
sql/sql_view.cc:
Support new attributes for views
sql/sql_yacc.yy:
1. Add SHOW CREATE TRIGGER statement.
2. Generate UTF8-body for views, stored routines, triggers and events.
sql/table.cc:
Introduce Object_creation_ctx.
sql/table.h:
Introduce Object_creation_ctx.
sql/share/errmsg.txt:
Add new errors.
mysql-test/include/ddl_i18n.check_events.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_sp.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_triggers.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_views.inc:
Aux file for test suite.
mysql-test/include/have_cp1251.inc:
Aux file for test suite.
mysql-test/include/have_cp866.inc:
Aux file for test suite.
mysql-test/include/have_koi8r.inc:
Aux file for test suite.
mysql-test/include/have_utf8.inc:
Aux file for test suite.
mysql-test/r/ddl_i18n_koi8r.result:
Result file.
mysql-test/r/ddl_i18n_utf8.result:
Result file.
mysql-test/r/have_cp1251.require:
Aux file for test suite.
mysql-test/r/have_cp866.require:
Aux file for test suite.
mysql-test/r/have_koi8r.require:
Aux file for test suite.
mysql-test/r/have_utf8.require:
Aux file for test suite.
mysql-test/t/ddl_i18n_koi8r.test:
Complete koi8r test case for the CS patch.
mysql-test/t/ddl_i18n_utf8.test:
Complete utf8 test case for the CS patch.
2007-06-28 21:34:54 +04:00
2017-08-18 23:36:42 +04:00
ALTER TABLE proc MODIFY type enum ( ' FUNCTION ' ,
' PROCEDURE ' ,
' PACKAGE ' ,
' PACKAGE BODY ' ) NOT NULL ;
ALTER TABLE procs_priv MODIFY Routine_type enum ( ' FUNCTION ' ,
' PROCEDURE ' ,
' PACKAGE ' ,
' PACKAGE BODY ' ) NOT NULL ;
2009-12-03 17:15:47 +01:00
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 ;
Patch for the following bugs:
- BUG#11986: Stored routines and triggers can fail if the code
has a non-ascii symbol
- BUG#16291: mysqldump corrupts string-constants with non-ascii-chars
- BUG#19443: INFORMATION_SCHEMA does not support charsets properly
- BUG#21249: Character set of SP-var can be ignored
- BUG#25212: Character set of string constant is ignored (stored routines)
- BUG#25221: Character set of string constant is ignored (triggers)
There were a few general problems that caused these bugs:
1. Character set information of the original (definition) query for views,
triggers, stored routines and events was lost.
2. mysqldump output query in client character set, which can be
inappropriate to encode definition-query.
3. INFORMATION_SCHEMA used strings with mixed encodings to display object
definition;
1. No query-definition-character set.
In order to compile query into execution code, some extra data (such as
environment variables or the database character set) is used. The problem
here was that this context was not preserved. So, on the next load it can
differ from the original one, thus the result will be different.
The context contains the following data:
- client character set;
- connection collation (character set and collation);
- collation of the owner database;
The fix is to store this context and use it each time we parse (compile)
and execute the object (stored routine, trigger, ...).
2. Wrong mysqldump-output.
The original query can contain several encodings (by means of character set
introducers). The problem here was that we tried to convert original query
to the mysqldump-client character set.
Moreover, we stored queries in different character sets for different
objects (views, for one, used UTF8, triggers used original character set).
The solution is
- to store definition queries in the original character set;
- to change SHOW CREATE statement to output definition query in the
binary character set (i.e. without any conversion);
- introduce SHOW CREATE TRIGGER statement;
- to dump special statements to switch the context to the original one
before dumping and restore it afterwards.
Note, in order to preserve the database collation at the creation time,
additional ALTER DATABASE might be used (to temporary switch the database
collation back to the original value). In this case, ALTER DATABASE
privilege will be required. This is a backward-incompatible change.
3. INFORMATION_SCHEMA showed non-UTF8 strings
The fix is to generate UTF8-query during the parsing, store it in the object
and show it in the INFORMATION_SCHEMA.
Basically, the idea is to create a copy of the original query convert it to
UTF8. Character set introducers are removed and all text literals are
converted to UTF8.
This UTF8 query is intended to provide user-readable output. It must not be
used to recreate the object. Specialized SHOW CREATE statements should be
used for this.
The reason for this limitation is the following: the original query can
contain symbols from several character sets (by means of character set
introducers).
Example:
- original query:
CREATE VIEW v1 AS SELECT _cp1251 'Hello' AS c1;
- UTF8 query (for INFORMATION_SCHEMA):
CREATE VIEW v1 AS SELECT 'Hello' AS c1;
client/mysqldump.c:
Set original character set and collation before dumping definition query.
include/my_sys.h:
Move out-parameter to the end of list.
mysql-test/lib/mtr_report.pl:
Ignore server-warnings during the test case.
mysql-test/r/create.result:
Update result file.
mysql-test/r/ctype_cp932_binlog_stm.result:
Update result file.
mysql-test/r/events.result:
Update result file.
mysql-test/r/events_bugs.result:
Update result file.
mysql-test/r/events_grant.result:
Update result file.
mysql-test/r/func_in.result:
Update result file.
mysql-test/r/gis.result:
Update result file.
mysql-test/r/grant.result:
Update result file.
mysql-test/r/information_schema.result:
Update result file.
mysql-test/r/information_schema_db.result:
Update result file.
mysql-test/r/lowercase_view.result:
Update result file.
mysql-test/r/mysqldump.result:
Update result file.
mysql-test/r/ndb_sp.result:
Update result file.
mysql-test/r/ps.result:
Update result file.
mysql-test/r/rpl_replicate_do.result:
Update result file.
mysql-test/r/rpl_sp.result:
Update result file.
mysql-test/r/rpl_trigger.result:
Update result file.
mysql-test/r/rpl_view.result:
Update result file.
mysql-test/r/show_check.result:
Update result file.
mysql-test/r/skip_grants.result:
Update result file.
mysql-test/r/sp-destruct.result:
Update result file.
mysql-test/r/sp-error.result:
Update result file.
mysql-test/r/sp-security.result:
Update result file.
mysql-test/r/sp.result:
Update result file.
mysql-test/r/sql_mode.result:
Update result file.
mysql-test/r/system_mysql_db.result:
Update result file.
mysql-test/r/temp_table.result:
Update result file.
mysql-test/r/trigger-compat.result:
Update result file.
mysql-test/r/trigger-grant.result:
Update result file.
mysql-test/r/trigger.result:
Update result file.
mysql-test/r/view.result:
Update result file.
mysql-test/r/view_grant.result:
Update result file.
mysql-test/t/events.test:
Update test case (new columns added).
mysql-test/t/information_schema.test:
Update test case (new columns added).
mysql-test/t/show_check.test:
Test case for SHOW CREATE TRIGGER in prepared statements and
stored routines.
mysql-test/t/sp-destruct.test:
Update test case (new columns added).
mysql-test/t/sp.test:
Update test case (new columns added).
mysql-test/t/view.test:
Update test.
mysys/charset.c:
Move out-parameter to the end of list.
scripts/mysql_system_tables.sql:
Add new columns to mysql.proc and mysql.event.
scripts/mysql_system_tables_fix.sql:
Add new columns to mysql.proc and mysql.event.
sql/event_data_objects.cc:
Support new attributes for events.
sql/event_data_objects.h:
Support new attributes for events.
sql/event_db_repository.cc:
Support new attributes for events.
sql/event_db_repository.h:
Support new attributes for events.
sql/events.cc:
Add new columns to SHOW CREATE event resultset.
sql/mysql_priv.h:
1. Introduce Object_creation_ctx;
2. Introduce SHOW CREATE TRIGGER;
3. Introduce auxilary functions.
sql/sp.cc:
Add support for new store routines attributes.
sql/sp_head.cc:
Add support for new store routines attributes.
sql/sp_head.h:
Add support for new store routines attributes.
sql/sql_lex.cc:
Generate UTF8-body on parsing/lexing.
sql/sql_lex.h:
1. Generate UTF8-body on parsing/lexing.
2. Introduce SHOW CREATE TRIGGER.
sql/sql_parse.cc:
Introduce SHOW CREATE TRIGGER.
sql/sql_partition.cc:
Update parse_sql().
sql/sql_prepare.cc:
Update parse_sql().
sql/sql_show.cc:
Support new attributes for views
sql/sql_trigger.cc:
Support new attributes for views
sql/sql_trigger.h:
Support new attributes for views
sql/sql_view.cc:
Support new attributes for views
sql/sql_yacc.yy:
1. Add SHOW CREATE TRIGGER statement.
2. Generate UTF8-body for views, stored routines, triggers and events.
sql/table.cc:
Introduce Object_creation_ctx.
sql/table.h:
Introduce Object_creation_ctx.
sql/share/errmsg.txt:
Add new errors.
mysql-test/include/ddl_i18n.check_events.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_sp.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_triggers.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_views.inc:
Aux file for test suite.
mysql-test/include/have_cp1251.inc:
Aux file for test suite.
mysql-test/include/have_cp866.inc:
Aux file for test suite.
mysql-test/include/have_koi8r.inc:
Aux file for test suite.
mysql-test/include/have_utf8.inc:
Aux file for test suite.
mysql-test/r/ddl_i18n_koi8r.result:
Result file.
mysql-test/r/ddl_i18n_utf8.result:
Result file.
mysql-test/r/have_cp1251.require:
Aux file for test suite.
mysql-test/r/have_cp866.require:
Aux file for test suite.
mysql-test/r/have_koi8r.require:
Aux file for test suite.
mysql-test/r/have_utf8.require:
Aux file for test suite.
mysql-test/t/ddl_i18n_koi8r.test:
Complete koi8r test case for the CS patch.
mysql-test/t/ddl_i18n_utf8.test:
Complete utf8 test case for the CS patch.
2007-06-28 21:34:54 +04:00
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 ;
2009-12-03 17:15:47 +01:00
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 ;
Patch for the following bugs:
- BUG#11986: Stored routines and triggers can fail if the code
has a non-ascii symbol
- BUG#16291: mysqldump corrupts string-constants with non-ascii-chars
- BUG#19443: INFORMATION_SCHEMA does not support charsets properly
- BUG#21249: Character set of SP-var can be ignored
- BUG#25212: Character set of string constant is ignored (stored routines)
- BUG#25221: Character set of string constant is ignored (triggers)
There were a few general problems that caused these bugs:
1. Character set information of the original (definition) query for views,
triggers, stored routines and events was lost.
2. mysqldump output query in client character set, which can be
inappropriate to encode definition-query.
3. INFORMATION_SCHEMA used strings with mixed encodings to display object
definition;
1. No query-definition-character set.
In order to compile query into execution code, some extra data (such as
environment variables or the database character set) is used. The problem
here was that this context was not preserved. So, on the next load it can
differ from the original one, thus the result will be different.
The context contains the following data:
- client character set;
- connection collation (character set and collation);
- collation of the owner database;
The fix is to store this context and use it each time we parse (compile)
and execute the object (stored routine, trigger, ...).
2. Wrong mysqldump-output.
The original query can contain several encodings (by means of character set
introducers). The problem here was that we tried to convert original query
to the mysqldump-client character set.
Moreover, we stored queries in different character sets for different
objects (views, for one, used UTF8, triggers used original character set).
The solution is
- to store definition queries in the original character set;
- to change SHOW CREATE statement to output definition query in the
binary character set (i.e. without any conversion);
- introduce SHOW CREATE TRIGGER statement;
- to dump special statements to switch the context to the original one
before dumping and restore it afterwards.
Note, in order to preserve the database collation at the creation time,
additional ALTER DATABASE might be used (to temporary switch the database
collation back to the original value). In this case, ALTER DATABASE
privilege will be required. This is a backward-incompatible change.
3. INFORMATION_SCHEMA showed non-UTF8 strings
The fix is to generate UTF8-query during the parsing, store it in the object
and show it in the INFORMATION_SCHEMA.
Basically, the idea is to create a copy of the original query convert it to
UTF8. Character set introducers are removed and all text literals are
converted to UTF8.
This UTF8 query is intended to provide user-readable output. It must not be
used to recreate the object. Specialized SHOW CREATE statements should be
used for this.
The reason for this limitation is the following: the original query can
contain symbols from several character sets (by means of character set
introducers).
Example:
- original query:
CREATE VIEW v1 AS SELECT _cp1251 'Hello' AS c1;
- UTF8 query (for INFORMATION_SCHEMA):
CREATE VIEW v1 AS SELECT 'Hello' AS c1;
client/mysqldump.c:
Set original character set and collation before dumping definition query.
include/my_sys.h:
Move out-parameter to the end of list.
mysql-test/lib/mtr_report.pl:
Ignore server-warnings during the test case.
mysql-test/r/create.result:
Update result file.
mysql-test/r/ctype_cp932_binlog_stm.result:
Update result file.
mysql-test/r/events.result:
Update result file.
mysql-test/r/events_bugs.result:
Update result file.
mysql-test/r/events_grant.result:
Update result file.
mysql-test/r/func_in.result:
Update result file.
mysql-test/r/gis.result:
Update result file.
mysql-test/r/grant.result:
Update result file.
mysql-test/r/information_schema.result:
Update result file.
mysql-test/r/information_schema_db.result:
Update result file.
mysql-test/r/lowercase_view.result:
Update result file.
mysql-test/r/mysqldump.result:
Update result file.
mysql-test/r/ndb_sp.result:
Update result file.
mysql-test/r/ps.result:
Update result file.
mysql-test/r/rpl_replicate_do.result:
Update result file.
mysql-test/r/rpl_sp.result:
Update result file.
mysql-test/r/rpl_trigger.result:
Update result file.
mysql-test/r/rpl_view.result:
Update result file.
mysql-test/r/show_check.result:
Update result file.
mysql-test/r/skip_grants.result:
Update result file.
mysql-test/r/sp-destruct.result:
Update result file.
mysql-test/r/sp-error.result:
Update result file.
mysql-test/r/sp-security.result:
Update result file.
mysql-test/r/sp.result:
Update result file.
mysql-test/r/sql_mode.result:
Update result file.
mysql-test/r/system_mysql_db.result:
Update result file.
mysql-test/r/temp_table.result:
Update result file.
mysql-test/r/trigger-compat.result:
Update result file.
mysql-test/r/trigger-grant.result:
Update result file.
mysql-test/r/trigger.result:
Update result file.
mysql-test/r/view.result:
Update result file.
mysql-test/r/view_grant.result:
Update result file.
mysql-test/t/events.test:
Update test case (new columns added).
mysql-test/t/information_schema.test:
Update test case (new columns added).
mysql-test/t/show_check.test:
Test case for SHOW CREATE TRIGGER in prepared statements and
stored routines.
mysql-test/t/sp-destruct.test:
Update test case (new columns added).
mysql-test/t/sp.test:
Update test case (new columns added).
mysql-test/t/view.test:
Update test.
mysys/charset.c:
Move out-parameter to the end of list.
scripts/mysql_system_tables.sql:
Add new columns to mysql.proc and mysql.event.
scripts/mysql_system_tables_fix.sql:
Add new columns to mysql.proc and mysql.event.
sql/event_data_objects.cc:
Support new attributes for events.
sql/event_data_objects.h:
Support new attributes for events.
sql/event_db_repository.cc:
Support new attributes for events.
sql/event_db_repository.h:
Support new attributes for events.
sql/events.cc:
Add new columns to SHOW CREATE event resultset.
sql/mysql_priv.h:
1. Introduce Object_creation_ctx;
2. Introduce SHOW CREATE TRIGGER;
3. Introduce auxilary functions.
sql/sp.cc:
Add support for new store routines attributes.
sql/sp_head.cc:
Add support for new store routines attributes.
sql/sp_head.h:
Add support for new store routines attributes.
sql/sql_lex.cc:
Generate UTF8-body on parsing/lexing.
sql/sql_lex.h:
1. Generate UTF8-body on parsing/lexing.
2. Introduce SHOW CREATE TRIGGER.
sql/sql_parse.cc:
Introduce SHOW CREATE TRIGGER.
sql/sql_partition.cc:
Update parse_sql().
sql/sql_prepare.cc:
Update parse_sql().
sql/sql_show.cc:
Support new attributes for views
sql/sql_trigger.cc:
Support new attributes for views
sql/sql_trigger.h:
Support new attributes for views
sql/sql_view.cc:
Support new attributes for views
sql/sql_yacc.yy:
1. Add SHOW CREATE TRIGGER statement.
2. Generate UTF8-body for views, stored routines, triggers and events.
sql/table.cc:
Introduce Object_creation_ctx.
sql/table.h:
Introduce Object_creation_ctx.
sql/share/errmsg.txt:
Add new errors.
mysql-test/include/ddl_i18n.check_events.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_sp.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_triggers.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_views.inc:
Aux file for test suite.
mysql-test/include/have_cp1251.inc:
Aux file for test suite.
mysql-test/include/have_cp866.inc:
Aux file for test suite.
mysql-test/include/have_koi8r.inc:
Aux file for test suite.
mysql-test/include/have_utf8.inc:
Aux file for test suite.
mysql-test/r/ddl_i18n_koi8r.result:
Result file.
mysql-test/r/ddl_i18n_utf8.result:
Result file.
mysql-test/r/have_cp1251.require:
Aux file for test suite.
mysql-test/r/have_cp866.require:
Aux file for test suite.
mysql-test/r/have_koi8r.require:
Aux file for test suite.
mysql-test/r/have_utf8.require:
Aux file for test suite.
mysql-test/t/ddl_i18n_koi8r.test:
Complete koi8r test case for the CS patch.
mysql-test/t/ddl_i18n_utf8.test:
Complete utf8 test case for the CS patch.
2007-06-28 21:34:54 +04:00
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 ;
2009-12-03 17:15:47 +01:00
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 ;
Patch for the following bugs:
- BUG#11986: Stored routines and triggers can fail if the code
has a non-ascii symbol
- BUG#16291: mysqldump corrupts string-constants with non-ascii-chars
- BUG#19443: INFORMATION_SCHEMA does not support charsets properly
- BUG#21249: Character set of SP-var can be ignored
- BUG#25212: Character set of string constant is ignored (stored routines)
- BUG#25221: Character set of string constant is ignored (triggers)
There were a few general problems that caused these bugs:
1. Character set information of the original (definition) query for views,
triggers, stored routines and events was lost.
2. mysqldump output query in client character set, which can be
inappropriate to encode definition-query.
3. INFORMATION_SCHEMA used strings with mixed encodings to display object
definition;
1. No query-definition-character set.
In order to compile query into execution code, some extra data (such as
environment variables or the database character set) is used. The problem
here was that this context was not preserved. So, on the next load it can
differ from the original one, thus the result will be different.
The context contains the following data:
- client character set;
- connection collation (character set and collation);
- collation of the owner database;
The fix is to store this context and use it each time we parse (compile)
and execute the object (stored routine, trigger, ...).
2. Wrong mysqldump-output.
The original query can contain several encodings (by means of character set
introducers). The problem here was that we tried to convert original query
to the mysqldump-client character set.
Moreover, we stored queries in different character sets for different
objects (views, for one, used UTF8, triggers used original character set).
The solution is
- to store definition queries in the original character set;
- to change SHOW CREATE statement to output definition query in the
binary character set (i.e. without any conversion);
- introduce SHOW CREATE TRIGGER statement;
- to dump special statements to switch the context to the original one
before dumping and restore it afterwards.
Note, in order to preserve the database collation at the creation time,
additional ALTER DATABASE might be used (to temporary switch the database
collation back to the original value). In this case, ALTER DATABASE
privilege will be required. This is a backward-incompatible change.
3. INFORMATION_SCHEMA showed non-UTF8 strings
The fix is to generate UTF8-query during the parsing, store it in the object
and show it in the INFORMATION_SCHEMA.
Basically, the idea is to create a copy of the original query convert it to
UTF8. Character set introducers are removed and all text literals are
converted to UTF8.
This UTF8 query is intended to provide user-readable output. It must not be
used to recreate the object. Specialized SHOW CREATE statements should be
used for this.
The reason for this limitation is the following: the original query can
contain symbols from several character sets (by means of character set
introducers).
Example:
- original query:
CREATE VIEW v1 AS SELECT _cp1251 'Hello' AS c1;
- UTF8 query (for INFORMATION_SCHEMA):
CREATE VIEW v1 AS SELECT 'Hello' AS c1;
client/mysqldump.c:
Set original character set and collation before dumping definition query.
include/my_sys.h:
Move out-parameter to the end of list.
mysql-test/lib/mtr_report.pl:
Ignore server-warnings during the test case.
mysql-test/r/create.result:
Update result file.
mysql-test/r/ctype_cp932_binlog_stm.result:
Update result file.
mysql-test/r/events.result:
Update result file.
mysql-test/r/events_bugs.result:
Update result file.
mysql-test/r/events_grant.result:
Update result file.
mysql-test/r/func_in.result:
Update result file.
mysql-test/r/gis.result:
Update result file.
mysql-test/r/grant.result:
Update result file.
mysql-test/r/information_schema.result:
Update result file.
mysql-test/r/information_schema_db.result:
Update result file.
mysql-test/r/lowercase_view.result:
Update result file.
mysql-test/r/mysqldump.result:
Update result file.
mysql-test/r/ndb_sp.result:
Update result file.
mysql-test/r/ps.result:
Update result file.
mysql-test/r/rpl_replicate_do.result:
Update result file.
mysql-test/r/rpl_sp.result:
Update result file.
mysql-test/r/rpl_trigger.result:
Update result file.
mysql-test/r/rpl_view.result:
Update result file.
mysql-test/r/show_check.result:
Update result file.
mysql-test/r/skip_grants.result:
Update result file.
mysql-test/r/sp-destruct.result:
Update result file.
mysql-test/r/sp-error.result:
Update result file.
mysql-test/r/sp-security.result:
Update result file.
mysql-test/r/sp.result:
Update result file.
mysql-test/r/sql_mode.result:
Update result file.
mysql-test/r/system_mysql_db.result:
Update result file.
mysql-test/r/temp_table.result:
Update result file.
mysql-test/r/trigger-compat.result:
Update result file.
mysql-test/r/trigger-grant.result:
Update result file.
mysql-test/r/trigger.result:
Update result file.
mysql-test/r/view.result:
Update result file.
mysql-test/r/view_grant.result:
Update result file.
mysql-test/t/events.test:
Update test case (new columns added).
mysql-test/t/information_schema.test:
Update test case (new columns added).
mysql-test/t/show_check.test:
Test case for SHOW CREATE TRIGGER in prepared statements and
stored routines.
mysql-test/t/sp-destruct.test:
Update test case (new columns added).
mysql-test/t/sp.test:
Update test case (new columns added).
mysql-test/t/view.test:
Update test.
mysys/charset.c:
Move out-parameter to the end of list.
scripts/mysql_system_tables.sql:
Add new columns to mysql.proc and mysql.event.
scripts/mysql_system_tables_fix.sql:
Add new columns to mysql.proc and mysql.event.
sql/event_data_objects.cc:
Support new attributes for events.
sql/event_data_objects.h:
Support new attributes for events.
sql/event_db_repository.cc:
Support new attributes for events.
sql/event_db_repository.h:
Support new attributes for events.
sql/events.cc:
Add new columns to SHOW CREATE event resultset.
sql/mysql_priv.h:
1. Introduce Object_creation_ctx;
2. Introduce SHOW CREATE TRIGGER;
3. Introduce auxilary functions.
sql/sp.cc:
Add support for new store routines attributes.
sql/sp_head.cc:
Add support for new store routines attributes.
sql/sp_head.h:
Add support for new store routines attributes.
sql/sql_lex.cc:
Generate UTF8-body on parsing/lexing.
sql/sql_lex.h:
1. Generate UTF8-body on parsing/lexing.
2. Introduce SHOW CREATE TRIGGER.
sql/sql_parse.cc:
Introduce SHOW CREATE TRIGGER.
sql/sql_partition.cc:
Update parse_sql().
sql/sql_prepare.cc:
Update parse_sql().
sql/sql_show.cc:
Support new attributes for views
sql/sql_trigger.cc:
Support new attributes for views
sql/sql_trigger.h:
Support new attributes for views
sql/sql_view.cc:
Support new attributes for views
sql/sql_yacc.yy:
1. Add SHOW CREATE TRIGGER statement.
2. Generate UTF8-body for views, stored routines, triggers and events.
sql/table.cc:
Introduce Object_creation_ctx.
sql/table.h:
Introduce Object_creation_ctx.
sql/share/errmsg.txt:
Add new errors.
mysql-test/include/ddl_i18n.check_events.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_sp.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_triggers.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_views.inc:
Aux file for test suite.
mysql-test/include/have_cp1251.inc:
Aux file for test suite.
mysql-test/include/have_cp866.inc:
Aux file for test suite.
mysql-test/include/have_koi8r.inc:
Aux file for test suite.
mysql-test/include/have_utf8.inc:
Aux file for test suite.
mysql-test/r/ddl_i18n_koi8r.result:
Result file.
mysql-test/r/ddl_i18n_utf8.result:
Result file.
mysql-test/r/have_cp1251.require:
Aux file for test suite.
mysql-test/r/have_cp866.require:
Aux file for test suite.
mysql-test/r/have_koi8r.require:
Aux file for test suite.
mysql-test/r/have_utf8.require:
Aux file for test suite.
mysql-test/t/ddl_i18n_koi8r.test:
Complete koi8r test case for the CS patch.
mysql-test/t/ddl_i18n_utf8.test:
Complete utf8 test case for the CS patch.
2007-06-28 21:34:54 +04:00
ALTER TABLE proc ADD body_utf8 longblob DEFAULT NULL
AFTER db_collation ;
ALTER TABLE proc MODIFY body_utf8 longblob DEFAULT NULL ;
2009-10-09 17:35:07 +02:00
# Change comment from char(64) to text
ALTER TABLE proc MODIFY comment
text collate utf8_bin NOT NULL ;
Patch for the following bugs:
- BUG#11986: Stored routines and triggers can fail if the code
has a non-ascii symbol
- BUG#16291: mysqldump corrupts string-constants with non-ascii-chars
- BUG#19443: INFORMATION_SCHEMA does not support charsets properly
- BUG#21249: Character set of SP-var can be ignored
- BUG#25212: Character set of string constant is ignored (stored routines)
- BUG#25221: Character set of string constant is ignored (triggers)
There were a few general problems that caused these bugs:
1. Character set information of the original (definition) query for views,
triggers, stored routines and events was lost.
2. mysqldump output query in client character set, which can be
inappropriate to encode definition-query.
3. INFORMATION_SCHEMA used strings with mixed encodings to display object
definition;
1. No query-definition-character set.
In order to compile query into execution code, some extra data (such as
environment variables or the database character set) is used. The problem
here was that this context was not preserved. So, on the next load it can
differ from the original one, thus the result will be different.
The context contains the following data:
- client character set;
- connection collation (character set and collation);
- collation of the owner database;
The fix is to store this context and use it each time we parse (compile)
and execute the object (stored routine, trigger, ...).
2. Wrong mysqldump-output.
The original query can contain several encodings (by means of character set
introducers). The problem here was that we tried to convert original query
to the mysqldump-client character set.
Moreover, we stored queries in different character sets for different
objects (views, for one, used UTF8, triggers used original character set).
The solution is
- to store definition queries in the original character set;
- to change SHOW CREATE statement to output definition query in the
binary character set (i.e. without any conversion);
- introduce SHOW CREATE TRIGGER statement;
- to dump special statements to switch the context to the original one
before dumping and restore it afterwards.
Note, in order to preserve the database collation at the creation time,
additional ALTER DATABASE might be used (to temporary switch the database
collation back to the original value). In this case, ALTER DATABASE
privilege will be required. This is a backward-incompatible change.
3. INFORMATION_SCHEMA showed non-UTF8 strings
The fix is to generate UTF8-query during the parsing, store it in the object
and show it in the INFORMATION_SCHEMA.
Basically, the idea is to create a copy of the original query convert it to
UTF8. Character set introducers are removed and all text literals are
converted to UTF8.
This UTF8 query is intended to provide user-readable output. It must not be
used to recreate the object. Specialized SHOW CREATE statements should be
used for this.
The reason for this limitation is the following: the original query can
contain symbols from several character sets (by means of character set
introducers).
Example:
- original query:
CREATE VIEW v1 AS SELECT _cp1251 'Hello' AS c1;
- UTF8 query (for INFORMATION_SCHEMA):
CREATE VIEW v1 AS SELECT 'Hello' AS c1;
client/mysqldump.c:
Set original character set and collation before dumping definition query.
include/my_sys.h:
Move out-parameter to the end of list.
mysql-test/lib/mtr_report.pl:
Ignore server-warnings during the test case.
mysql-test/r/create.result:
Update result file.
mysql-test/r/ctype_cp932_binlog_stm.result:
Update result file.
mysql-test/r/events.result:
Update result file.
mysql-test/r/events_bugs.result:
Update result file.
mysql-test/r/events_grant.result:
Update result file.
mysql-test/r/func_in.result:
Update result file.
mysql-test/r/gis.result:
Update result file.
mysql-test/r/grant.result:
Update result file.
mysql-test/r/information_schema.result:
Update result file.
mysql-test/r/information_schema_db.result:
Update result file.
mysql-test/r/lowercase_view.result:
Update result file.
mysql-test/r/mysqldump.result:
Update result file.
mysql-test/r/ndb_sp.result:
Update result file.
mysql-test/r/ps.result:
Update result file.
mysql-test/r/rpl_replicate_do.result:
Update result file.
mysql-test/r/rpl_sp.result:
Update result file.
mysql-test/r/rpl_trigger.result:
Update result file.
mysql-test/r/rpl_view.result:
Update result file.
mysql-test/r/show_check.result:
Update result file.
mysql-test/r/skip_grants.result:
Update result file.
mysql-test/r/sp-destruct.result:
Update result file.
mysql-test/r/sp-error.result:
Update result file.
mysql-test/r/sp-security.result:
Update result file.
mysql-test/r/sp.result:
Update result file.
mysql-test/r/sql_mode.result:
Update result file.
mysql-test/r/system_mysql_db.result:
Update result file.
mysql-test/r/temp_table.result:
Update result file.
mysql-test/r/trigger-compat.result:
Update result file.
mysql-test/r/trigger-grant.result:
Update result file.
mysql-test/r/trigger.result:
Update result file.
mysql-test/r/view.result:
Update result file.
mysql-test/r/view_grant.result:
Update result file.
mysql-test/t/events.test:
Update test case (new columns added).
mysql-test/t/information_schema.test:
Update test case (new columns added).
mysql-test/t/show_check.test:
Test case for SHOW CREATE TRIGGER in prepared statements and
stored routines.
mysql-test/t/sp-destruct.test:
Update test case (new columns added).
mysql-test/t/sp.test:
Update test case (new columns added).
mysql-test/t/view.test:
Update test.
mysys/charset.c:
Move out-parameter to the end of list.
scripts/mysql_system_tables.sql:
Add new columns to mysql.proc and mysql.event.
scripts/mysql_system_tables_fix.sql:
Add new columns to mysql.proc and mysql.event.
sql/event_data_objects.cc:
Support new attributes for events.
sql/event_data_objects.h:
Support new attributes for events.
sql/event_db_repository.cc:
Support new attributes for events.
sql/event_db_repository.h:
Support new attributes for events.
sql/events.cc:
Add new columns to SHOW CREATE event resultset.
sql/mysql_priv.h:
1. Introduce Object_creation_ctx;
2. Introduce SHOW CREATE TRIGGER;
3. Introduce auxilary functions.
sql/sp.cc:
Add support for new store routines attributes.
sql/sp_head.cc:
Add support for new store routines attributes.
sql/sp_head.h:
Add support for new store routines attributes.
sql/sql_lex.cc:
Generate UTF8-body on parsing/lexing.
sql/sql_lex.h:
1. Generate UTF8-body on parsing/lexing.
2. Introduce SHOW CREATE TRIGGER.
sql/sql_parse.cc:
Introduce SHOW CREATE TRIGGER.
sql/sql_partition.cc:
Update parse_sql().
sql/sql_prepare.cc:
Update parse_sql().
sql/sql_show.cc:
Support new attributes for views
sql/sql_trigger.cc:
Support new attributes for views
sql/sql_trigger.h:
Support new attributes for views
sql/sql_view.cc:
Support new attributes for views
sql/sql_yacc.yy:
1. Add SHOW CREATE TRIGGER statement.
2. Generate UTF8-body for views, stored routines, triggers and events.
sql/table.cc:
Introduce Object_creation_ctx.
sql/table.h:
Introduce Object_creation_ctx.
sql/share/errmsg.txt:
Add new errors.
mysql-test/include/ddl_i18n.check_events.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_sp.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_triggers.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_views.inc:
Aux file for test suite.
mysql-test/include/have_cp1251.inc:
Aux file for test suite.
mysql-test/include/have_cp866.inc:
Aux file for test suite.
mysql-test/include/have_koi8r.inc:
Aux file for test suite.
mysql-test/include/have_utf8.inc:
Aux file for test suite.
mysql-test/r/ddl_i18n_koi8r.result:
Result file.
mysql-test/r/ddl_i18n_utf8.result:
Result file.
mysql-test/r/have_cp1251.require:
Aux file for test suite.
mysql-test/r/have_cp866.require:
Aux file for test suite.
mysql-test/r/have_koi8r.require:
Aux file for test suite.
mysql-test/r/have_utf8.require:
Aux file for test suite.
mysql-test/t/ddl_i18n_koi8r.test:
Complete koi8r test case for the CS patch.
mysql-test/t/ddl_i18n_utf8.test:
Complete utf8 test case for the CS patch.
2007-06-28 21:34:54 +04:00
2017-12-12 12:09:52 +05:30
# MDEV-7773: Stored Aggregate Functions
ALTER TABLE proc ADD aggregate enum ( ' NONE ' , ' GROUP ' ) DEFAULT ' NONE ' NOT NULL
AFTER body_utf8 ;
2015-11-03 11:55:30 -05:00
#
# EVENT privilege
#
SET @ hadEventPriv : = 0 ;
SELECT @ hadEventPriv : = 1 FROM user WHERE Event_priv LIKE ' % ' ;
2018-07-14 13:48:50 +02:00
ALTER TABLE user ADD Event_priv enum ( ' N ' , ' Y ' ) character set utf8 DEFAULT ' N ' NOT NULL AFTER Create_user_priv ;
2015-11-03 11:55:30 -05:00
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 ;
2018-07-14 13:48:50 +02:00
ALTER TABLE db ADD Event_priv enum ( ' N ' , ' Y ' ) character set utf8 DEFAULT ' N ' NOT NULL ;
2015-11-03 11:55:30 -05:00
ALTER TABLE db MODIFY Event_priv enum ( ' N ' , ' Y ' ) character set utf8 DEFAULT ' N ' NOT NULL ;
2007-03-21 19:20:44 +03:00
#
# EVENT table
#
2018-07-14 13:48:50 +02:00
ALTER TABLE event DROP PRIMARY KEY , ADD PRIMARY KEY ( db , name ) ;
2015-11-03 11:55:30 -05:00
# Add sql_mode column just in case.
ALTER TABLE event ADD sql_mode set ( ' IGNORE_BAD_TABLE_OPTIONS ' ) AFTER on_completion ;
2008-04-04 13:46:05 -03:00
# Update list of sql_mode values.
ALTER TABLE event MODIFY sql_mode
2006-01-31 16:01:27 +01:00
set ( ' REAL_AS_FLOAT ' ,
' PIPES_AS_CONCAT ' ,
' ANSI_QUOTES ' ,
' IGNORE_SPACE ' ,
2010-04-08 14:10:05 +02:00
' IGNORE_BAD_TABLE_OPTIONS ' ,
2006-01-31 16:01:27 +01:00
' 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 ' ,
2008-02-07 08:47:39 -02:00
' HIGH_NOT_PRECEDENCE ' ,
' NO_ENGINE_SUBSTITUTION ' ,
2017-10-13 15:55:42 +02:00
' PAD_CHAR_TO_FULL_LENGTH ' ,
2018-01-29 16:53:39 +01:00
' EMPTY_STRING_IS_NULL ' ,
' SIMULTANEOUS_ASSIGNMENT '
2006-01-31 23:29:03 +01:00
) DEFAULT ' ' NOT NULL AFTER on_completion ;
2015-11-03 11:55:30 -05:00
ALTER TABLE event MODIFY name char ( 64 ) CHARACTER SET utf8 NOT NULL default ' ' ;
ALTER TABLE event ADD COLUMN originator INT UNSIGNED NOT NULL AFTER comment ;
2018-07-14 13:48:50 +02:00
ALTER TABLE event MODIFY COLUMN originator INT UNSIGNED NOT NULL ;
2015-11-03 11:55:30 -05:00
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 ;
2015-10-15 12:11:17 +03:00
# Enable event scheduler if the event table was not up to date before.
set global event_scheduler = original ;
2015-11-03 11:55:30 -05:00
#
# 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 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 ;
2006-02-25 21:54:34 +02:00
2009-10-10 00:01:10 +04:00
#
# user.Create_tablespace_priv
#
SET @ hadCreateTablespacePriv : = 0 ;
SELECT @ hadCreateTablespacePriv : = 1 FROM user WHERE Create_tablespace_priv LIKE ' % ' ;
ALTER TABLE user ADD Create_tablespace_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Trigger_priv ;
ALTER TABLE user MODIFY Create_tablespace_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Trigger_priv ;
UPDATE user SET Create_tablespace_priv = Super_priv WHERE @ hadCreateTablespacePriv = 0 ;
2018-02-07 02:39:40 +02:00
#
# System versioning
#
2018-02-12 16:26:11 +01:00
ALTER TABLE user change Truncate_versioning_priv Delete_history_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci NOT NULL DEFAULT ' N ' ;
ALTER TABLE db change Truncate_versioning_priv Delete_history_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci NOT NULL DEFAULT ' N ' ;
2018-02-07 02:39:40 +02:00
2018-02-12 16:26:11 +01:00
SET @ had_user_delete_history_priv : = 0 ;
SELECT @ had_user_delete_history_priv : = 1 FROM user WHERE Delete_history_priv LIKE ' % ' ;
2018-02-07 02:39:40 +02:00
2018-02-12 16:26:11 +01:00
ALTER TABLE user add Delete_history_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci NOT NULL DEFAULT ' N ' after Create_tablespace_priv ;
ALTER TABLE user modify Delete_history_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci NOT NULL DEFAULT ' N ' ;
ALTER TABLE db add Delete_history_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci NOT NULL DEFAULT ' N ' after Trigger_priv ;
ALTER TABLE db modify Delete_history_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci NOT NULL DEFAULT ' N ' ;
2018-02-07 02:39:40 +02:00
2018-02-12 16:26:11 +01:00
UPDATE user SET Delete_history_priv = Super_priv WHERE @ had_user_delete_history_priv = 0 ;
2018-02-07 02:39:40 +02:00
2018-07-14 13:48:50 +02:00
ALTER TABLE user ADD plugin char ( 64 ) CHARACTER SET latin1 DEFAULT ' ' NOT NULL ,
ADD authentication_string TEXT NOT NULL ;
ALTER TABLE user MODIFY plugin char ( 64 ) CHARACTER SET latin1 DEFAULT ' ' NOT NULL ,
MODIFY authentication_string TEXT NOT NULL ;
2013-06-16 21:26:40 +03:00
ALTER TABLE user ADD password_expired ENUM ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ;
2013-11-13 22:58:10 +01:00
ALTER TABLE user ADD is_role enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ;
2014-05-30 17:54:13 +03:00
ALTER TABLE user ADD default_role char ( 80 ) binary DEFAULT ' ' NOT NULL ;
2014-10-07 11:37:36 +03:00
ALTER TABLE user ADD max_statement_time decimal ( 12 , 6 ) DEFAULT 0 NOT NULL ;
2013-07-04 17:01:36 +04:00
-- Somewhere above, we ran ALTER TABLE user .... CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin.
-- we want password_expired column to have collation utf8_general_ci.
ALTER TABLE user MODIFY password_expired ENUM ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ;
2013-11-13 22:58:10 +01:00
ALTER TABLE user MODIFY is_role enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ;
2010-08-09 11:32:50 +03:00
2010-11-19 16:35:04 +02:00
-- Need to pre-fill mysql.proxies_priv with access for root even when upgrading from
-- older versions
CREATE TEMPORARY TABLE tmp_proxies_priv LIKE proxies_priv ;
INSERT INTO tmp_proxies_priv VALUES ( ' localhost ' , ' root ' , ' ' , ' ' , TRUE , ' ' , now ( ) ) ;
INSERT INTO proxies_priv SELECT * FROM tmp_proxies_priv WHERE @ had_proxies_priv_table = 0 ;
DROP TABLE tmp_proxies_priv ;
2014-08-01 14:18:28 +05:30
-- Checking for any duplicate hostname and username combination are exists.
-- If exits we will throw error.
DROP PROCEDURE IF EXISTS mysql . count_duplicate_host_names ;
DELIMITER / /
CREATE PROCEDURE mysql . count_duplicate_host_names ( )
BEGIN
SET @ duplicate_hosts = ( SELECT count ( * ) FROM mysql . user GROUP BY user , lower ( host ) HAVING count ( * ) > 1 LIMIT 1 ) ;
IF @ duplicate_hosts > 1 THEN
SIGNAL SQLSTATE ' 45000 ' SET MESSAGE_TEXT = ' Multiple accounts exist for @user_name, @host_name that differ only in Host lettercase; remove all except one of them ' ;
END IF ;
END / /
DELIMITER ;
CALL mysql . count_duplicate_host_names ( ) ;
-- Get warnings (if any)
SHOW WARNINGS ;
DROP PROCEDURE mysql . count_duplicate_host_names ;
2013-10-31 23:02:44 +05:30
# Convering the host name to lower case for existing users
UPDATE user SET host = LOWER ( host ) WHERE LOWER ( host ) < > host ;
2010-08-09 11:32:50 +03:00
2017-07-20 15:08:24 +02:00
# fix bad data when upgrading from unfixed InnoDB (MDEV-13360)
set @ str = " delete from innodb_index_stats where length(table_name) > 64 " ;
set @ str = if ( @ have_innodb < > 0 , @ str , " set @dummy = 0 " ) ;
prepare stmt from @ str ;
execute stmt ;
set @ str = replace ( @ str , " innodb_index_stats " , " innodb_table_stats " ) ;
prepare stmt from @ str ;
execute stmt ;
MDEV-14637: Fix hang due to persistent statistics
Similar to the tables SYS_FOREIGN and SYS_FOREIGN_COLS,
the tables mysql.innodb_table_stats and mysql.innodb_index_stats
are updated by the InnoDB internal SQL parser, which fails to
enforce the size limits of the data. Due to this, it is possible
for InnoDB to hang when there are persistent statistics defined on
partitioned tables where the total length of table name,
partition name and subpartition name exceeds the incorrectly
defined limit VARCHAR(64). That column should have been defined
as VARCHAR(199).
btr_node_ptr_max_size(): Interpret the VARCHAR(64) as VARCHAR(199),
to prevent a hang in the case that the upgrade script has not been
run.
dict_table_schema_check(): Ignore difference in the length of the
table_name column.
ha_innobase::max_supported_key_length(): For innodb_page_size=4k,
return a larger value so that the table mysql.innodb_index_stats
can be created. This could allow "impossible" tables to be created,
such that it is not possible to insert anything into a secondary
index when both the secondary key and the primary key are long,
but this is the easiest and most consistent way. The Oracle fix
would only ignore the maximum length violation for the two
statistics tables.
os_file_get_status_posix(), os_file_get_status_win32(): Handle
ENAMETOOLONG as well.
This patch is based on the following change in MySQL 5.7.23.
Not all changes were applied, and our variant allows persistent
statistics to work without hangs even if the table definitions
were not upgraded.
From fdbdce701ab8145ae234c9d401109dff4e4106cb Mon Sep 17 00:00:00 2001
From: Aditya A <aditya.a@oracle.com>
Date: Thu, 17 May 2018 16:11:43 +0530
Subject: [PATCH] Bug #26390736 THE FIELD TABLE_NAME (VARCHAR(64)) FROM
MYSQL.INNODB_TABLE_STATS CAN OVERFLOW.
In mysql.innodb_index_stats and mysql.innodb_table_stats
tables the table name column didn't take into consideration
partition names which can be more than varchar(64).
2018-08-02 17:35:24 +03:00
# update table_name and timestamp fields in the innodb stat tables
set @ str = " alter table mysql.innodb_index_stats modify last_update timestamp not null default current_timestamp on update current_timestamp, modify table_name varchar(199) " ;
2014-08-05 14:39:00 +02:00
set @ str = if ( @ have_innodb < > 0 , @ str , " set @dummy = 0 " ) ;
2014-11-03 21:45:06 +04:00
prepare stmt from @ str ;
execute stmt ;
MDEV-14637: Fix hang due to persistent statistics
Similar to the tables SYS_FOREIGN and SYS_FOREIGN_COLS,
the tables mysql.innodb_table_stats and mysql.innodb_index_stats
are updated by the InnoDB internal SQL parser, which fails to
enforce the size limits of the data. Due to this, it is possible
for InnoDB to hang when there are persistent statistics defined on
partitioned tables where the total length of table name,
partition name and subpartition name exceeds the incorrectly
defined limit VARCHAR(64). That column should have been defined
as VARCHAR(199).
btr_node_ptr_max_size(): Interpret the VARCHAR(64) as VARCHAR(199),
to prevent a hang in the case that the upgrade script has not been
run.
dict_table_schema_check(): Ignore difference in the length of the
table_name column.
ha_innobase::max_supported_key_length(): For innodb_page_size=4k,
return a larger value so that the table mysql.innodb_index_stats
can be created. This could allow "impossible" tables to be created,
such that it is not possible to insert anything into a secondary
index when both the secondary key and the primary key are long,
but this is the easiest and most consistent way. The Oracle fix
would only ignore the maximum length violation for the two
statistics tables.
os_file_get_status_posix(), os_file_get_status_win32(): Handle
ENAMETOOLONG as well.
This patch is based on the following change in MySQL 5.7.23.
Not all changes were applied, and our variant allows persistent
statistics to work without hangs even if the table definitions
were not upgraded.
From fdbdce701ab8145ae234c9d401109dff4e4106cb Mon Sep 17 00:00:00 2001
From: Aditya A <aditya.a@oracle.com>
Date: Thu, 17 May 2018 16:11:43 +0530
Subject: [PATCH] Bug #26390736 THE FIELD TABLE_NAME (VARCHAR(64)) FROM
MYSQL.INNODB_TABLE_STATS CAN OVERFLOW.
In mysql.innodb_index_stats and mysql.innodb_table_stats
tables the table name column didn't take into consideration
partition names which can be more than varchar(64).
2018-08-02 17:35:24 +03:00
set @ str = " alter table mysql.innodb_table_stats modify last_update timestamp not null default current_timestamp on update current_timestamp, modify table_name varchar(199) " ;
2014-11-03 21:45:06 +04:00
set @ str = if ( @ have_innodb < > 0 , @ str , " set @dummy = 0 " ) ;
2014-08-05 14:39:00 +02:00
prepare stmt from @ str ;
execute stmt ;
set @ str = replace ( @ str , " innodb_index_stats " , " innodb_table_stats " ) ;
prepare stmt from @ str ;
execute stmt ;
2014-08-05 14:37:05 +02:00
SET @ innodb_index_stats_fk = ( select count ( * ) from information_schema . referential_constraints where constraint_schema = ' mysql ' and table_name = ' innodb_index_stats ' and referenced_table_name = ' innodb_table_stats ' and constraint_name = ' innodb_index_stats_ibfk_1 ' ) ;
SET @ str = IF ( @ innodb_index_stats_fk > 0 and @ have_innodb > 0 , " ALTER TABLE mysql.innodb_index_stats DROP FOREIGN KEY `innodb_index_stats_ibfk_1` " , " SET @dummy = 0 " ) ;
PREPARE stmt FROM @ str ;
EXECUTE stmt ;
DROP PREPARE stmt ;
2013-11-03 16:31:52 +01:00
# MDEV-4332 longer user names
2013-11-13 22:58:10 +01:00
alter table user modify User char ( 80 ) binary not null default ' ' ;
alter table db modify User char ( 80 ) binary not null default ' ' ;
alter table tables_priv modify User char ( 80 ) binary not null default ' ' ;
alter table columns_priv modify User char ( 80 ) binary not null default ' ' ;
alter table procs_priv modify User char ( 80 ) binary not null default ' ' ;
alter table proc modify definer char ( 141 ) collate utf8_bin not null default ' ' ;
alter table event modify definer char ( 141 ) collate utf8_bin not null default ' ' ;
alter table proxies_priv modify User char ( 80 ) COLLATE utf8_bin not null default ' ' ;
alter table proxies_priv modify Proxied_user char ( 80 ) COLLATE utf8_bin not null default ' ' ;
alter table proxies_priv modify Grantor char ( 141 ) COLLATE utf8_bin not null default ' ' ;
alter table servers modify Username char ( 80 ) not null default ' ' ;
alter table procs_priv modify Grantor char ( 141 ) COLLATE utf8_bin not null default ' ' ;
alter table tables_priv modify Grantor char ( 141 ) COLLATE utf8_bin not null default ' ' ;
2010-08-09 11:32:50 +03:00
2015-11-03 11:55:30 -05:00
# Activate the new, possible modified privilege tables
2006-02-24 18:34:15 +02:00
# This should not be needed, but gives us some extra testing that the above
# changes was correct
flush privileges ;
2012-08-14 17:23:34 +03:00
2014-11-18 22:25:52 +01:00
--
-- Upgrade help tables
--
ALTER TABLE help_category MODIFY url TEXT NOT NULL ;
ALTER TABLE help_topic MODIFY url TEXT NOT NULL ;
2015-11-09 17:58:35 +03:00
# MDEV-7383 - varbinary on mix/max of column_stats
alter table column_stats modify min_value varbinary ( 255 ) DEFAULT NULL , modify max_value varbinary ( 255 ) DEFAULT NULL ;
2018-08-02 17:59:11 +03:00
--
-- Ensure that all tables are of type Aria and transactional
--
ALTER TABLE user ENGINE = Aria transactional = 1 ;
ALTER TABLE db ENGINE = Aria transactional = 1 ;
ALTER TABLE func ENGINE = Aria transactional = 1 ;
ALTER TABLE procs_priv ENGINE = Aria transactional = 1 ;
ALTER TABLE tables_priv ENGINE = Aria transactional = 1 ;
ALTER TABLE columns_priv ENGINE = Aria transactional = 1 ;
ALTER TABLE roles_mapping ENGINE = Aria transactional = 1 ;
ALTER TABLE plugin ENGINE = Aria transactional = 1 ;
ALTER TABLE servers ENGINE = Aria transactional = 1 ;
ALTER TABLE time_zone_name ENGINE = Aria transactional = 1 ;
ALTER TABLE time_zone ENGINE = Aria transactional = 1 ;
ALTER TABLE time_zone_transition ENGINE = Aria transactional = 1 ;
ALTER TABLE time_zone_transition_type ENGINE = Aria transactional = 1 ;
ALTER TABLE time_zone_leap_second ENGINE = Aria transactional = 1 ;
ALTER TABLE proc ENGINE = Aria transactional = 1 ;
ALTER TABLE event ENGINE = Aria transactional = 1 ;
ALTER TABLE proxies_priv ENGINE = Aria transactional = 1 ;
-- The folloing tables doesn't have to be transactional
ALTER TABLE help_topic ENGINE = Aria transactional = 0 ;
ALTER TABLE help_category ENGINE = Aria transactional = 0 ;
ALTER TABLE help_relation ENGINE = Aria transactional = 0 ;
ALTER TABLE help_keyword ENGINE = Aria transactional = 0 ;
ALTER TABLE table_stats ENGINE = Aria transactional = 0 ;
ALTER TABLE column_stats ENGINE = Aria transactional = 0 ;
ALTER TABLE index_stats ENGINE = Aria transactional = 0 ;