2014-02-17 11:00:51 +01:00
-- Copyright (C) 2003, 2013 Oracle and/or its affiliates.
2023-06-05 10:42:04 +03:00
-- Copyright (C) 2010, 2023, 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
2019-05-11 21:29:06 +03:00
-- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA
2010-04-14 20:40:04 +04:00
2015-11-03 11:55:30 -05:00
# This part converts any old privilege tables to privilege tables suitable
2023-06-05 10:42:04 +03:00
# for current version of MariaDB
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 = ' ' ;
2023-10-20 22:27:14 -04:00
set sql_safe_updates = ' OFF ' ;
2020-01-13 21:07:04 +02:00
set default_storage_engine = Aria ;
2015-11-04 15:00:34 -05:00
set enforce_storage_engine = NULL ;
2022-11-28 21:20:23 +00:00
set alter_algorithm = ' DEFAULT ' ;
2023-06-05 10:42:04 +03:00
set use_stat_tables = ' NEVER ' ;
2005-04-16 04:12:30 +03:00
2022-06-19 22:42:22 +03:00
--
-- Upgrade mysql.column_stats table early because its quite noisy otherwise
--
ALTER TABLE column_stats
modify min_value varbinary ( 255 ) DEFAULT NULL ,
modify max_value varbinary ( 255 ) DEFAULT NULL ,
modify hist_type enum ( ' SINGLE_PREC_HB ' , ' DOUBLE_PREC_HB ' , ' JSON_HB ' ) ,
modify histogram longblob ,
ENGINE = Aria transactional = 0 ;
2018-11-24 14:13:41 +01:00
set @ have_innodb = ( select count ( engine ) from information_schema . engines where engine = ' INNODB ' and support ! = ' NO ' ) ;
2022-03-29 16:16:21 +03:00
# MDEV-21873: 10.2 to 10.3 upgrade doesn't remove semi-sync reference from
# mysql.plugin table.
# As per suggested fix, check INFORMATION_SCHEMA.PLUGINS
# and if semisync plugins aren't there, delete them from mysql.plugin.
DELETE FROM mysql . plugin WHERE name = " rpl_semi_sync_master " AND NOT EXISTS ( SELECT * FROM INFORMATION_SCHEMA . PLUGINS WHERE PLUGIN_NAME = " rpl_semi_sync_master " ) ;
DELETE FROM mysql . plugin WHERE name = " rpl_semi_sync_slave " AND NOT EXISTS ( SELECT * FROM INFORMATION_SCHEMA . PLUGINS WHERE PLUGIN_NAME = " rpl_semi_sync_slave " ) ;
2020-11-18 16:04:57 +01: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 ;
2023-11-02 14:16:09 +04:00
ALTER TABLE servers ENGINE = Aria transactional = 1 ,
CONVERT TO CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci ;
2020-11-18 16:04:57 +01:00
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 ;
2023-11-02 14:16:09 +04:00
ALTER TABLE event ENGINE = Aria transactional = 1 ,
DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci ;
2020-11-18 16:04:57 +01:00
ALTER TABLE proxies_priv ENGINE = Aria transactional = 1 ;
-- The following 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 index_stats ENGINE = Aria transactional = 0 ;
2022-10-21 15:43:17 +05:30
ALTER TABLE user add File_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_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 ;
2019-09-13 20:03:43 +04:00
SELECT @ hadGrantPriv : = 1 FROM user WHERE Grant_priv IS NOT NULL ;
2015-11-03 11:55:30 -05:00
2022-10-21 15:43:17 +05:30
ALTER TABLE user add Grant_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
add References_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
add Index_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
add Alter_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ;
ALTER TABLE db add Grant_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
add References_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
add Index_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
add Alter_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_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
2020-11-18 16:04:57 +01:00
MODIFY Host char ( 255 ) NOT NULL default ' ' ,
2015-11-03 11:55:30 -05:00
MODIFY Db char ( 64 ) NOT NULL default ' ' ,
2020-11-18 16:04:57 +01:00
MODIFY User char ( 128 ) binary NOT NULL default ' ' ,
2015-11-03 11:55:30 -05:00
MODIFY Table_name char ( 64 ) NOT NULL default ' ' ,
2022-10-21 15:43:17 +05:30
MODIFY Grantor varchar ( 384 ) COLLATE utf8mb3_bin NOT NULL default ' ' ,
2018-08-02 17:59:11 +03:00
ENGINE = Aria ,
2022-10-21 15:43:17 +05:30
CONVERT TO CHARACTER SET utf8mb3 COLLATE utf8mb3_bin ;
2015-11-03 11:55:30 -05:00
ALTER TABLE tables_priv
MODIFY Column_priv set ( ' Select ' , ' Insert ' , ' Update ' , ' References ' )
2022-10-21 15:43:17 +05:30
COLLATE utf8mb3_general_ci DEFAULT ' ' NOT NULL ,
2015-11-03 11:55:30 -05:00
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 ' )
2022-10-21 15:43:17 +05:30
COLLATE utf8mb3_general_ci DEFAULT ' ' NOT NULL ,
2015-11-03 11:55:30 -05:00
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 ' )
2022-10-21 15:43:17 +05:30
COLLATE utf8mb3_general_ci DEFAULT ' ' NOT NULL ;
2015-11-03 11:55:30 -05:00
ALTER TABLE columns_priv
2020-11-18 16:04:57 +01:00
MODIFY Host char ( 255 ) NOT NULL default ' ' ,
2015-11-03 11:55:30 -05:00
MODIFY Db char ( 64 ) NOT NULL default ' ' ,
2020-11-18 16:04:57 +01:00
MODIFY User char ( 128 ) 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 ,
2022-10-21 15:43:17 +05:30
CONVERT TO CHARACTER SET utf8mb3 COLLATE utf8mb3_bin ,
2015-11-03 11:55:30 -05:00
COMMENT = ' Column privileges ' ;
ALTER TABLE columns_priv
MODIFY Column_priv set ( ' Select ' , ' Insert ' , ' Update ' , ' References ' )
2022-10-21 15:43:17 +05:30
COLLATE utf8mb3_general_ci DEFAULT ' ' NOT NULL ;
2015-11-03 11:55:30 -05:00
#
# Add the new 'type' column to the func table.
#
2022-10-21 15:43:17 +05:30
ALTER TABLE func add type enum ( ' function ' , ' aggregate ' ) COLLATE utf8mb3_general_ci NOT NULL ;
2015-11-03 11:55:30 -05:00
#
# Change the user,db and host tables to current format
#
# Detect whether we had Show_db_priv
SET @ hadShowDbPriv : = 0 ;
2019-09-13 20:03:43 +04:00
SELECT @ hadShowDbPriv : = 1 FROM user WHERE Show_db_priv IS NOT NULL ;
2015-11-03 11:55:30 -05:00
ALTER TABLE user
2022-10-21 15:43:17 +05:30
ADD Show_db_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Alter_priv ,
ADD Super_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Show_db_priv ,
ADD Create_tmp_table_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Super_priv ,
ADD Lock_tables_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Create_tmp_table_priv ,
ADD Execute_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Lock_tables_priv ,
ADD Repl_slave_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Execute_priv ,
ADD Repl_client_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Repl_slave_priv ;
2015-11-03 11:55:30 -05:00
# 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
2022-10-21 15:43:17 +05:30
ADD Create_tmp_table_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
ADD Lock_tables_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ;
2015-11-03 11:55:30 -05:00
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
2020-11-18 16:04:57 +01:00
MODIFY Host char ( 255 ) NOT NULL default ' ' ,
MODIFY User char ( 128 ) binary NOT NULL default ' ' ,
2022-10-21 15:43:17 +05:30
ENGINE = Aria , CONVERT TO CHARACTER SET utf8mb3 COLLATE utf8mb3_bin ;
2016-12-12 02:57:07 +02:00
2023-11-02 14:16:09 +04:00
ALTER TABLE plugin
MODIFY name varchar ( 64 ) COLLATE utf8mb3_general_ci NOT NULL DEFAULT ' ' ,
MODIFY dl varchar ( 128 ) COLLATE utf8mb3_general_ci NOT NULL DEFAULT ' ' ,
CONVERT TO CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci ;
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 ;
2020-02-27 01:53:46 +02:00
# In MySQL the Unix socket authentication plugin has a different name. Thus the
# references to it need to be renamed in the user table. Thanks to the WHERE
# clauses this applies only to MySQL->MariaDB upgrades and nothing else.
UPDATE user
SET plugin = ' unix_socket ' WHERE plugin = ' auth_socket ' ;
DELETE FROM plugin
WHERE name = ' auth_socket ' ;
2023-08-31 13:14:03 +10:00
# Delete plugins that are now inbuilt but might not have been before (MDEV-32043)
DELETE plugin
FROM information_schema . PLUGINS is_p
JOIN plugin ON plugin . name = is_p . PLUGIN_NAME
WHERE is_p . PLUGIN_LIBRARY IS NULL ;
2020-02-27 01:53:46 +02:00
2015-11-03 11:55:30 -05:00
ALTER TABLE user
MODIFY Password char ( 41 ) character set latin1 collate latin1_bin NOT NULL default ' ' ,
2022-10-21 15:43:17 +05:30
MODIFY Select_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Insert_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Update_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Delete_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Create_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Drop_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Reload_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Shutdown_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Process_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY File_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Grant_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY References_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Index_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Alter_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Show_db_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Super_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Create_tmp_table_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Lock_tables_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Execute_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Repl_slave_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Repl_client_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY ssl_type enum ( ' ' , ' ANY ' , ' X509 ' , ' SPECIFIED ' ) COLLATE utf8mb3_general_ci DEFAULT ' ' NOT NULL ;
2015-11-03 11:55:30 -05:00
ALTER TABLE db
2020-11-18 16:04:57 +01:00
MODIFY Host char ( 255 ) NOT NULL default ' ' ,
2015-11-03 11:55:30 -05:00
MODIFY Db char ( 64 ) NOT NULL default ' ' ,
2020-11-18 16:04:57 +01:00
MODIFY User char ( 128 ) binary NOT NULL default ' ' ,
2022-10-21 15:43:17 +05:30
ENGINE = Aria , CONVERT TO CHARACTER SET utf8mb3 COLLATE utf8mb3_bin ;
2015-11-03 11:55:30 -05:00
ALTER TABLE db
2022-10-21 15:43:17 +05:30
MODIFY Select_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Insert_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Update_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Delete_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Create_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Drop_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Grant_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY References_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Index_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Alter_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Create_tmp_table_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Lock_tables_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ;
2015-11-03 11:55:30 -05:00
ALTER TABLE func
2022-10-21 15:43:17 +05:30
ENGINE = Aria , CONVERT TO CHARACTER SET utf8mb3 COLLATE utf8mb3_bin ;
2015-11-03 11:55:30 -05:00
ALTER TABLE func
2022-10-21 15:43:17 +05:30
MODIFY type enum ( ' function ' , ' aggregate ' ) COLLATE utf8mb3_general_ci NOT NULL ;
2015-11-03 11:55:30 -05:00
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 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 ;
2022-09-26 19:21:24 +02:00
SET @ old_log_state = @ @ global . log_slow_query ;
SET GLOBAL log_slow_query = ' 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
2023-10-17 16:04:21 +03:00
ADD COLUMN rows_affected BIGINT UNSIGNED 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 ,
2023-07-13 13:39:54 +02:00
MODIFY rows_sent BIGINT UNSIGNED NOT NULL ,
MODIFY rows_examined BIGINT UNSIGNED NOT NULL ,
2010-02-26 09:22:48 -03:00
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 ;
2022-09-26 19:21:24 +02:00
SET GLOBAL log_slow_query = @ old_log_state ;
2009-03-11 17:30:56 -03:00
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 ;
2019-09-13 20:03:43 +04:00
SELECT @ hadCreateViewPriv : = 1 FROM user WHERE Create_view_priv IS NOT NULL ;
2015-11-03 11:55:30 -05:00
#
# Create VIEWs privileges (v5.0)
#
2022-10-21 15:43:17 +05:30
ALTER TABLE db ADD Create_view_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Lock_tables_priv ;
ALTER TABLE db MODIFY Create_view_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Lock_tables_priv ;
2015-11-03 11:55:30 -05:00
2022-10-21 15:43:17 +05:30
ALTER TABLE user ADD Create_view_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Repl_client_priv ;
ALTER TABLE user MODIFY Create_view_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Repl_client_priv ;
2015-11-03 11:55:30 -05:00
#
# Show VIEWs privileges (v5.0)
#
2022-10-21 15:43:17 +05:30
ALTER TABLE db ADD Show_view_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Create_view_priv ;
ALTER TABLE db MODIFY Show_view_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Create_view_priv ;
2015-11-03 11:55:30 -05:00
2022-10-21 15:43:17 +05:30
ALTER TABLE user ADD Show_view_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Create_view_priv ;
ALTER TABLE user MODIFY Show_view_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Create_view_priv ;
2015-11-03 11:55:30 -05:00
#
# 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 ;
2019-09-13 20:03:43 +04:00
SELECT @ hadCreateRoutinePriv : = 1 FROM user WHERE Create_routine_priv IS NOT NULL ;
2015-11-03 11:55:30 -05:00
#
# Create PROCEDUREs privileges (v5.0)
#
2022-10-21 15:43:17 +05:30
ALTER TABLE db ADD Create_routine_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Show_view_priv ;
ALTER TABLE db MODIFY Create_routine_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Show_view_priv ;
2015-11-03 11:55:30 -05:00
2022-10-21 15:43:17 +05:30
ALTER TABLE user ADD Create_routine_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Show_view_priv ;
ALTER TABLE user MODIFY Create_routine_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Show_view_priv ;
2015-11-03 11:55:30 -05:00
#
# Alter PROCEDUREs privileges (v5.0)
#
2022-10-21 15:43:17 +05:30
ALTER TABLE db ADD Alter_routine_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Create_routine_priv ;
ALTER TABLE db MODIFY Alter_routine_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Create_routine_priv ;
2015-11-03 11:55:30 -05:00
2022-10-21 15:43:17 +05:30
ALTER TABLE user ADD Alter_routine_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Create_routine_priv ;
ALTER TABLE user MODIFY Alter_routine_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Create_routine_priv ;
2015-11-03 11:55:30 -05:00
2022-10-21 15:43:17 +05:30
ALTER TABLE db ADD Execute_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Alter_routine_priv ;
ALTER TABLE db MODIFY Execute_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Alter_routine_priv ;
2015-11-03 11:55:30 -05:00
#
# 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 ;
2019-09-13 20:03:43 +04:00
SELECT @ hadCreateUserPriv : = 1 FROM user WHERE Create_user_priv IS NOT NULL ;
2015-11-03 11:55:30 -05:00
2022-10-21 15:43:17 +05:30
ALTER TABLE user ADD Create_user_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Alter_routine_priv ;
ALTER TABLE user MODIFY Create_user_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Alter_routine_priv ;
2015-11-03 11:55:30 -05:00
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 ,
2022-10-21 15:43:17 +05:30
CONVERT TO CHARACTER SET utf8mb3 COLLATE utf8mb3_bin ;
2015-11-03 11:55:30 -05:00
ALTER TABLE procs_priv
2023-09-04 13:04:06 +02:00
MODIFY Proc_priv set ( ' Execute ' , ' Alter Routine ' , ' Grant ' , ' Show Create Routine ' )
2022-10-21 15:43:17 +05:30
COLLATE utf8mb3_general_ci DEFAULT ' ' NOT NULL ;
2015-11-03 11:55:30 -05:00
ALTER IGNORE TABLE procs_priv
MODIFY Routine_name char ( 64 )
2022-10-21 15:43:17 +05:30
COLLATE utf8mb3_general_ci DEFAULT ' ' NOT NULL ;
2015-11-03 11:55:30 -05:00
ALTER TABLE procs_priv
ADD Routine_type enum ( ' FUNCTION ' , ' PROCEDURE ' )
2022-10-21 15:43:17 +05:30
COLLATE utf8mb3_general_ci NOT NULL AFTER Routine_name ;
2015-11-03 11:55:30 -05:00
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 ' ,
2018-11-23 19:04:42 +04:00
' SIMULTANEOUS_ASSIGNMENT ' ,
' TIME_ROUND_FRACTIONAL '
2005-08-23 16:37:21 -07:00
) DEFAULT ' ' NOT NULL ,
2023-11-02 14:16:09 +04:00
DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci ;
2005-07-08 16:33:15 +02:00
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
2023-11-02 14:16:09 +04:00
ALTER TABLE proc CONVERT TO CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci ,
2018-10-27 20:46:18 +02:00
MODIFY db char ( 64 ) binary DEFAULT ' ' NOT NULL ,
2020-11-18 16:04:57 +01:00
MODIFY definer varchar ( 384 ) binary DEFAULT ' ' NOT NULL ,
2018-10-27 20:46:18 +02:00
MODIFY comment text binary NOT NULL ;
2015-11-03 11:55:30 -05:00
ALTER TABLE proc ADD character_set_client
2022-10-21 15:43:17 +05:30
char ( 32 ) collate utf8mb3_bin DEFAULT NULL
2015-11-03 11:55:30 -05:00
AFTER comment ;
ALTER TABLE proc MODIFY character_set_client
2022-10-21 15:43:17 +05:30
char ( 32 ) collate utf8mb3_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
2023-06-27 17:43:31 +03:00
char ( 64 ) collate utf8mb3_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
AFTER character_set_client ;
ALTER TABLE proc MODIFY collation_connection
2023-06-27 17:43:31 +03:00
char ( 64 ) collate utf8mb3_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
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
2023-06-27 17:43:31 +03:00
char ( 64 ) collate utf8mb3_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
AFTER collation_connection ;
ALTER TABLE proc MODIFY db_collation
2023-06-27 17:43:31 +03:00
char ( 64 ) collate utf8mb3_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
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
2022-10-21 15:43:17 +05:30
text collate utf8mb3_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 ;
2021-10-15 23:20:48 +00:00
# Update definer of Add/DropGeometryColumn procedures to 'mariadb.sys'
# To consider the scenarios in MDEV-23102, only update the definer when it's 'root'
UPDATE proc SET Definer = ' mariadb.sys@localhost ' WHERE Definer = ' root@localhost ' AND Name = ' AddGeometryColumn ' ;
UPDATE proc SET Definer = ' mariadb.sys@localhost ' WHERE Definer = ' root@localhost ' AND Name = ' DropGeometryColumn ' ;
2017-12-12 12:09:52 +05:30
2015-11-03 11:55:30 -05:00
#
# EVENT privilege
#
SET @ hadEventPriv : = 0 ;
2019-09-13 20:03:43 +04:00
SELECT @ hadEventPriv : = 1 FROM user WHERE Event_priv IS NOT NULL ;
2015-11-03 11:55:30 -05:00
2023-11-02 14:16:09 +04:00
ALTER TABLE user ADD Event_priv enum ( ' N ' , ' Y ' ) character set utf8mb3 COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Create_user_priv ;
ALTER TABLE user MODIFY Event_priv enum ( ' N ' , ' Y ' ) character set utf8mb3 COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Create_user_priv ;
2015-11-03 11:55:30 -05:00
UPDATE user SET Event_priv = Super_priv WHERE @ hadEventPriv = 0 ;
2023-11-02 14:16:09 +04:00
ALTER TABLE db ADD Event_priv enum ( ' N ' , ' Y ' ) character set utf8mb3 COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ;
ALTER TABLE db MODIFY Event_priv enum ( ' N ' , ' Y ' ) character set utf8mb3 COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ;
2015-11-03 11:55:30 -05:00
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 ' ,
2018-11-23 19:04:42 +04:00
' SIMULTANEOUS_ASSIGNMENT ' ,
' TIME_ROUND_FRACTIONAL '
2006-01-31 23:29:03 +01:00
) DEFAULT ' ' NOT NULL AFTER on_completion ;
2023-11-02 14:16:09 +04:00
ALTER TABLE event MODIFY name char ( 64 ) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL default ' ' ;
2022-10-21 15:43:17 +05:30
ALTER TABLE event MODIFY db CHAR ( 64 ) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NOT NULL DEFAULT ' ' ;
2023-11-02 14:16:09 +04:00
ALTER TABLE event MODIFY interval_field
enum ( ' YEAR ' , ' QUARTER ' , ' MONTH ' , ' DAY ' , ' HOUR ' ,
' MINUTE ' , ' WEEK ' , ' SECOND ' , ' MICROSECOND ' ,
' YEAR_MONTH ' , ' DAY_HOUR ' , ' DAY_MINUTE ' ,
' DAY_SECOND ' , ' HOUR_MINUTE ' , ' HOUR_SECOND ' ,
' MINUTE_SECOND ' , ' DAY_MICROSECOND ' , ' HOUR_MICROSECOND ' ,
' MINUTE_MICROSECOND ' , ' SECOND_MICROSECOND '
) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL ;
2022-10-21 15:43:17 +05:30
ALTER TABLE event MODIFY comment CHAR ( 64 ) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NOT NULL DEFAULT ' ' ;
2023-11-02 14:16:09 +04:00
ALTER TABLE event MODIFY on_completion enum ( ' DROP ' , ' PRESERVE ' )
CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT ' DROP ' ;
2015-11-03 11:55:30 -05:00
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 ' ;
2023-11-02 14:16:09 +04:00
ALTER TABLE event ADD COLUMN time_zone char ( 64 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci
2015-11-03 11:55:30 -05:00
NOT NULL DEFAULT ' SYSTEM ' AFTER originator ;
ALTER TABLE event ADD character_set_client
2022-10-21 15:43:17 +05:30
char ( 32 ) collate utf8mb3_bin DEFAULT NULL
2015-11-03 11:55:30 -05:00
AFTER time_zone ;
ALTER TABLE event MODIFY character_set_client
2022-10-21 15:43:17 +05:30
char ( 32 ) collate utf8mb3_bin DEFAULT NULL ;
2015-11-03 11:55:30 -05:00
ALTER TABLE event ADD collation_connection
2023-06-27 17:43:31 +03:00
char ( 64 ) collate utf8mb3_bin DEFAULT NULL
2015-11-03 11:55:30 -05:00
AFTER character_set_client ;
ALTER TABLE event MODIFY collation_connection
2023-06-27 17:43:31 +03:00
char ( 64 ) collate utf8mb3_bin DEFAULT NULL ;
2015-11-03 11:55:30 -05:00
ALTER TABLE event ADD db_collation
2023-06-27 17:43:31 +03:00
char ( 64 ) collate utf8mb3_bin DEFAULT NULL
2015-11-03 11:55:30 -05:00
AFTER collation_connection ;
ALTER TABLE event MODIFY db_collation
2023-06-27 17:43:31 +03:00
char ( 64 ) collate utf8mb3_bin DEFAULT NULL ;
2015-11-03 11:55:30 -05:00
ALTER TABLE event ADD body_utf8 longblob DEFAULT NULL
AFTER db_collation ;
ALTER TABLE event MODIFY body_utf8 longblob DEFAULT NULL ;
2022-10-21 15:43:17 +05:30
alter table event MODIFY definer varchar ( 384 ) collate utf8mb3_bin NOT NULL DEFAULT ' ' ;
2021-05-20 11:42:00 +02:00
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 ;
2019-09-13 20:03:43 +04:00
SELECT @ hadTriggerPriv : = 1 FROM user WHERE Trigger_priv IS NOT NULL ;
2015-11-03 11:55:30 -05:00
2022-10-21 15:43:17 +05:30
ALTER TABLE user ADD Trigger_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Event_priv ;
ALTER TABLE user MODIFY Trigger_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Event_priv ;
2015-11-03 11:55:30 -05:00
2022-10-21 15:43:17 +05:30
ALTER TABLE db ADD Trigger_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ;
ALTER TABLE db MODIFY Trigger_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL ;
2015-11-03 11:55:30 -05:00
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 ;
2019-09-13 20:03:43 +04:00
SELECT @ hadCreateTablespacePriv : = 1 FROM user WHERE Create_tablespace_priv IS NOT NULL ;
2009-10-10 00:01:10 +04:00
2022-10-21 15:43:17 +05:30
ALTER TABLE user ADD Create_tablespace_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Trigger_priv ;
ALTER TABLE user MODIFY Create_tablespace_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER Trigger_priv ;
2009-10-10 00:01:10 +04:00
UPDATE user SET Create_tablespace_priv = Super_priv WHERE @ hadCreateTablespacePriv = 0 ;
2018-02-07 02:39:40 +02:00
#
# System versioning
#
2022-10-21 15:43:17 +05:30
ALTER TABLE user change Truncate_versioning_priv Delete_history_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci NOT NULL DEFAULT ' N ' ;
ALTER TABLE db change Truncate_versioning_priv Delete_history_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_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 ;
2019-09-13 20:03:43 +04:00
SELECT @ had_user_delete_history_priv : = 1 FROM user WHERE Delete_history_priv IS NOT NULL ;
2018-02-07 02:39:40 +02:00
2024-02-29 18:16:06 +01:00
SET @ had_show_create_routine : = 0 ;
SELECT @ had_show_create_routine : = 1 FROM db WHERE Show_create_routine_priv IS NOT NULL ;
2022-10-21 15:43:17 +05:30
ALTER TABLE user add Delete_history_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci NOT NULL DEFAULT ' N ' after Create_tablespace_priv ;
ALTER TABLE user modify Delete_history_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci NOT NULL DEFAULT ' N ' ;
ALTER TABLE db add Delete_history_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci NOT NULL DEFAULT ' N ' after Trigger_priv ;
ALTER TABLE db modify Delete_history_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_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 ;
2023-09-04 13:04:06 +02:00
ALTER TABLE db ADD Show_create_routine_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci NOT NULL DEFAULT ' N ' AFTER Delete_history_priv ;
ALTER TABLE db MODIFY Show_create_routine_priv enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci NOT NULL DEFAULT ' N ' ;
2024-02-29 18:16:06 +01:00
UPDATE db SET Show_create_routine_priv = ' Y ' WHERE @ had_show_create_routine = 0
AND Drop_priv = ' Y ' AND Index_priv = ' Y ' AND Alter_priv = ' Y '
AND Event_priv = ' Y ' AND Select_priv = ' Y ' AND Insert_priv = ' Y '
AND Update_priv = ' Y ' AND Delete_priv = ' Y ' AND Create_priv = ' Y '
AND Execute_priv = ' Y ' AND Trigger_priv = ' Y ' AND Show_view_priv = ' Y '
AND References_priv = ' Y ' AND Lock_tables_priv = ' Y ' AND Create_view_priv = ' Y '
AND Alter_routine_priv = ' Y ' AND Create_routine_priv = ' Y '
AND Delete_history_priv = ' Y ' AND Create_tmp_table_priv = ' Y ' ;
2018-02-07 02:39:40 +02:00
MDEV-23201: mysql_upgrade order mysql.user for 5.7 cross-upgrade
As MariaDB tables are expected in a fixed order, the cross upgrade
previously placed roles, default_role and max_statement_time after
now unused mysql-5.7 columns.
Test:
$ cp -a /usr/local/mysql-5.7.31/data/ /tmp/m57data
$ sql/mysqld --no-defaults --skip-networking --datadir=/tmp/m57data --socket=/tmp/${PWD##*/}.sock --verbose --lc-messages-dir=$PWD/sql/share
2020-10-02 11:02:05 140135193212864 [Note] sql/mysqld (mysqld 10.2.34-MariaDB) starting as process 1457667 ...
2020-10-02 11:02:05 140135193212864 [Note] InnoDB: Mutexes and rw_locks use GCC atomic built
$ client/mysql_upgrade --no-defaults -u root -pbob -S /tmp/build-mariadb-server-10.2.sock
MySQL upgrade detected
Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.columns_priv OK
mysql.db OK
mysql.engine_cost OK
mysql.event OK
mysql.func OK
mysql.gtid_executed OK
mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.ndb_binlog_index OK
mysql.plugin OK
mysql.proc OK
mysql.procs_priv OK
mysql.proxies_priv OK
mysql.server_cost OK
mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
Upgrading from a version before MariaDB-10.1
Phase 2/7: Installing used storage engines
Result:
| user | CREATE TABLE `user` (
`Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
`User` char(80) COLLATE utf8_bin NOT NULL DEFAULT '',
`Password` char(41) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
`Select_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Insert_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Update_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Delete_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Create_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Drop_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Reload_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Shutdown_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Process_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`File_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Grant_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`References_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Index_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Alter_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Show_db_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Super_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Create_tmp_table_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Lock_tables_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Execute_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Repl_slave_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Repl_client_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Create_view_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Show_view_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Create_routine_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Alter_routine_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Create_user_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Event_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Trigger_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Create_tablespace_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`ssl_type` enum('','ANY','X509','SPECIFIED') CHARACTER SET utf8 NOT NULL DEFAULT '',
`ssl_cipher` blob NOT NULL,
`x509_issuer` blob NOT NULL,
`x509_subject` blob NOT NULL,
`max_questions` int(11) unsigned NOT NULL DEFAULT 0,
`max_updates` int(11) unsigned NOT NULL DEFAULT 0,
`max_connections` int(11) unsigned NOT NULL DEFAULT 0,
`max_user_connections` int(11) NOT NULL DEFAULT 0,
`plugin` char(64) CHARACTER SET latin1 NOT NULL DEFAULT '',
`authentication_string` text COLLATE utf8_bin NOT NULL,
`password_expired` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`is_role` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`default_role` char(80) COLLATE utf8_bin NOT NULL DEFAULT '',
`max_statement_time` decimal(12,6) NOT NULL DEFAULT 0.000000,
`password_last_changed` timestamp NULL DEFAULT NULL,
`password_lifetime` smallint(5) unsigned DEFAULT NULL,
`account_locked` enum('N','Y') COLLATE utf8_bin NOT NULL DEFAULT 'N',
PRIMARY KEY (`Host`,`User`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Users and global privileges' |
MariaDB [(none)]> CREATE ROLE `aRole`;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> SET ROLE `aRole`;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> SET ROLE `aRole`;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> SELECT `User`, `is_role` FROM `mysql`.`user`;
+---------------+---------+
| User | is_role |
+---------------+---------+
| root | N |
| mysql.session | N |
| mysql.sys | N |
| dan | N |
| aRole | Y |
+---------------+---------+
5 rows in set (0.00 sec)
Reviewer: Anel Husakovic
2020-10-02 11:09:01 +10:00
ALTER TABLE user ADD plugin char ( 64 ) CHARACTER SET latin1 DEFAULT ' ' NOT NULL AFTER max_user_connections ,
ADD authentication_string TEXT NOT NULL AFTER plugin ;
2020-04-21 18:40:15 +02:00
ALTER TABLE user CHANGE auth_string authentication_string TEXT NOT NULL ;
2020-11-05 13:37:35 +11:00
2022-10-21 15:43:17 +05:30
ALTER TABLE user ADD password_expired ENUM ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER authentication_string ;
2022-06-12 22:01:56 +02:00
ALTER TABLE user ADD password_last_changed timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP after password_expired ;
2019-01-16 19:44:30 +02:00
ALTER TABLE user ADD password_lifetime smallint unsigned DEFAULT NULL after password_last_changed ;
2022-10-21 15:43:17 +05:30
ALTER TABLE user ADD account_locked enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL after password_lifetime ;
ALTER TABLE user ADD is_role enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER account_locked ;
2020-11-18 16:04:57 +01:00
ALTER TABLE user ADD default_role char ( 128 ) binary DEFAULT ' ' NOT NULL AFTER is_role ;
MDEV-23201: mysql_upgrade order mysql.user for 5.7 cross-upgrade
As MariaDB tables are expected in a fixed order, the cross upgrade
previously placed roles, default_role and max_statement_time after
now unused mysql-5.7 columns.
Test:
$ cp -a /usr/local/mysql-5.7.31/data/ /tmp/m57data
$ sql/mysqld --no-defaults --skip-networking --datadir=/tmp/m57data --socket=/tmp/${PWD##*/}.sock --verbose --lc-messages-dir=$PWD/sql/share
2020-10-02 11:02:05 140135193212864 [Note] sql/mysqld (mysqld 10.2.34-MariaDB) starting as process 1457667 ...
2020-10-02 11:02:05 140135193212864 [Note] InnoDB: Mutexes and rw_locks use GCC atomic built
$ client/mysql_upgrade --no-defaults -u root -pbob -S /tmp/build-mariadb-server-10.2.sock
MySQL upgrade detected
Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.columns_priv OK
mysql.db OK
mysql.engine_cost OK
mysql.event OK
mysql.func OK
mysql.gtid_executed OK
mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.ndb_binlog_index OK
mysql.plugin OK
mysql.proc OK
mysql.procs_priv OK
mysql.proxies_priv OK
mysql.server_cost OK
mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
Upgrading from a version before MariaDB-10.1
Phase 2/7: Installing used storage engines
Result:
| user | CREATE TABLE `user` (
`Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
`User` char(80) COLLATE utf8_bin NOT NULL DEFAULT '',
`Password` char(41) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
`Select_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Insert_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Update_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Delete_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Create_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Drop_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Reload_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Shutdown_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Process_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`File_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Grant_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`References_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Index_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Alter_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Show_db_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Super_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Create_tmp_table_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Lock_tables_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Execute_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Repl_slave_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Repl_client_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Create_view_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Show_view_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Create_routine_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Alter_routine_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Create_user_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Event_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Trigger_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Create_tablespace_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`ssl_type` enum('','ANY','X509','SPECIFIED') CHARACTER SET utf8 NOT NULL DEFAULT '',
`ssl_cipher` blob NOT NULL,
`x509_issuer` blob NOT NULL,
`x509_subject` blob NOT NULL,
`max_questions` int(11) unsigned NOT NULL DEFAULT 0,
`max_updates` int(11) unsigned NOT NULL DEFAULT 0,
`max_connections` int(11) unsigned NOT NULL DEFAULT 0,
`max_user_connections` int(11) NOT NULL DEFAULT 0,
`plugin` char(64) CHARACTER SET latin1 NOT NULL DEFAULT '',
`authentication_string` text COLLATE utf8_bin NOT NULL,
`password_expired` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`is_role` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`default_role` char(80) COLLATE utf8_bin NOT NULL DEFAULT '',
`max_statement_time` decimal(12,6) NOT NULL DEFAULT 0.000000,
`password_last_changed` timestamp NULL DEFAULT NULL,
`password_lifetime` smallint(5) unsigned DEFAULT NULL,
`account_locked` enum('N','Y') COLLATE utf8_bin NOT NULL DEFAULT 'N',
PRIMARY KEY (`Host`,`User`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Users and global privileges' |
MariaDB [(none)]> CREATE ROLE `aRole`;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> SET ROLE `aRole`;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> SET ROLE `aRole`;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> SELECT `User`, `is_role` FROM `mysql`.`user`;
+---------------+---------+
| User | is_role |
+---------------+---------+
| root | N |
| mysql.session | N |
| mysql.sys | N |
| dan | N |
| aRole | Y |
+---------------+---------+
5 rows in set (0.00 sec)
Reviewer: Anel Husakovic
2020-10-02 11:09:01 +10:00
ALTER TABLE user ADD max_statement_time decimal ( 12 , 6 ) DEFAULT 0 NOT NULL AFTER default_role ;
2020-11-05 13:37:35 +11:00
2022-10-21 15:43:17 +05:30
-- Somewhere above, we ran ALTER TABLE user .... CONVERT TO CHARACTER SET utf8mb3 COLLATE utf8mb3_bin.
-- we want password_expired column to have collation utf8mb3_general_ci.
2020-11-05 13:37:35 +11:00
-- Order columns correctly that were not ordered until MDEV-23201 (ff8ffef3e1915d7a9caa07d9461cd8d47c4baf98)
ALTER TABLE user MODIFY plugin char ( 64 ) CHARACTER SET latin1 DEFAULT ' ' NOT NULL AFTER max_user_connections ,
MODIFY authentication_string TEXT NOT NULL AFTER plugin ,
2022-10-21 15:43:17 +05:30
MODIFY password_expired ENUM ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER authentication_string ,
MODIFY is_role enum ( ' N ' , ' Y ' ) COLLATE utf8mb3_general_ci DEFAULT ' N ' NOT NULL AFTER password_expired ,
2020-11-05 13:37:35 +11:00
MODIFY default_role char ( 80 ) binary DEFAULT ' ' NOT NULL AFTER is_role ,
MODIFY max_statement_time decimal ( 12 , 6 ) DEFAULT 0 NOT NULL AFTER default_role ,
-- MDEV-24122 formerly mysql5.7 users may have the following columns password_last_changed,
-- password_lifetime and account_locked. Ensure they are beyond the end of the user columns
-- used by MariaDB. MariaDB-10.4 will use these in the creation of mysql.global_priv.
-- password_last_changed has a DEFAULT/ON UPDATE of CURRENT_TIMESTAMP to keep track of
-- time until 10.4 added.
2022-06-12 22:01:56 +02:00
MODIFY IF EXISTS password_last_changed timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP AFTER max_statement_time ,
2020-11-05 13:37:35 +11:00
MODIFY IF EXISTS password_lifetime smallint unsigned DEFAULT NULL AFTER password_last_changed ,
2022-10-21 15:43:17 +05:30
MODIFY IF EXISTS account_locked enum ( ' N ' , ' Y ' ) CHARACTER SET utf8mb3 DEFAULT ' N ' NOT NULL after password_lifetime ;
2010-08-09 11:32:50 +03:00
2014-08-01 14:18:28 +05:30
-- Checking for any duplicate hostname and username combination are exists.
-- If exits we will throw error.
DELIMITER / /
2018-11-24 14:13:41 +01:00
BEGIN NOT ATOMIC
2014-08-01 14:18:28 +05:30
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 ;
-- Get warnings (if any)
SHOW WARNINGS ;
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
2019-03-13 12:42:42 +01:00
DELIMITER / /
if @ have_innodb then
# fix bad data when upgrading from unfixed InnoDB (MDEV-13360)
delete from innodb_index_stats where length ( table_name ) > 64 ;
delete from innodb_table_stats where length ( table_name ) > 64 ;
# update table_name and timestamp fields in the innodb stat tables
alter table innodb_index_stats modify last_update timestamp not null default current_timestamp on update current_timestamp , modify table_name varchar ( 199 ) ;
alter table innodb_table_stats modify last_update timestamp not null default current_timestamp on update current_timestamp , modify table_name varchar ( 199 ) ;
alter table innodb_index_stats drop foreign key if exists innodb_index_stats_ibfk_1 ;
end if / /
DELIMITER ;
2014-08-05 14:37:05 +02:00
2024-03-21 14:48:06 +11:00
# MDEV-4332 longer user names, extended by MDEV-24312 to longer again.
2020-11-18 16:04:57 +01:00
alter table user modify User char ( 128 ) binary not null default ' ' ;
alter table db modify User char ( 128 ) binary not null default ' ' ;
alter table tables_priv modify User char ( 128 ) binary not null default ' ' ;
alter table columns_priv modify User char ( 128 ) binary not null default ' ' ;
2024-03-21 14:48:06 +11:00
alter table procs_priv modify User char ( 128 ) binary not null default ' ' , modify Host char ( 255 ) binary DEFAULT ' ' ;
2022-10-21 15:43:17 +05:30
alter table proc modify definer varchar ( 384 ) collate utf8mb3_bin not null default ' ' ;
2024-03-21 14:48:06 +11:00
alter table proxies_priv modify User char ( 128 ) COLLATE utf8mb3_bin not null default ' ' , modify Host char ( 255 ) binary DEFAULT ' ' ;
2022-10-21 15:43:17 +05:30
alter table proxies_priv modify Proxied_user char ( 128 ) COLLATE utf8mb3_bin not null default ' ' ;
alter table proxies_priv modify Grantor varchar ( 384 ) COLLATE utf8mb3_bin not null default ' ' ;
2020-11-18 16:04:57 +01:00
alter table servers modify Username char ( 128 ) not null default ' ' ;
2022-10-21 15:43:17 +05:30
alter table procs_priv modify Grantor varchar ( 384 ) COLLATE utf8mb3_bin not null default ' ' ;
alter table tables_priv modify Grantor varchar ( 384 ) COLLATE utf8mb3_bin not null default ' ' ;
2024-03-21 14:48:06 +11:00
# MDEV-33726 longer names from MDEV-24312 extension
alter table if exists global_priv modify Host char ( 255 ) binary DEFAULT ' ' , modify User char ( 128 ) binary not null default ' ' ;
alter table if exists roles_mapping modify Host char ( 255 ) binary not null DEFAULT ' ' , modify User char ( 128 ) binary 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 ;
2018-11-24 14:13:41 +01:00
DELIMITER / /
2019-02-13 18:08:47 +01:00
IF ' BASE TABLE ' = ( select table_type from information_schema . tables where table_schema = database ( ) and table_name = ' user ' ) THEN
2022-10-21 15:43:17 +05:30
CREATE TABLE IF NOT EXISTS global_priv ( Host char ( 255 ) binary DEFAULT ' ' , User char ( 128 ) binary DEFAULT ' ' , Priv JSON NOT NULL DEFAULT ' {} ' CHECK ( JSON_VALID ( Priv ) ) , PRIMARY KEY Host ( Host , User ) ) engine = Aria transactional = 1 CHARACTER SET utf8mb3 COLLATE utf8mb3_bin comment = ' Users and global privileges '
2018-11-24 14:13:41 +01:00
SELECT Host , User , JSON_COMPACT ( JSON_OBJECT ( ' access ' ,
1 * ( ' Y ' = Select_priv ) +
2 * ( ' Y ' = Insert_priv ) +
4 * ( ' Y ' = Update_priv ) +
8 * ( ' Y ' = Delete_priv ) +
16 * ( ' Y ' = Create_priv ) +
32 * ( ' Y ' = Drop_priv ) +
64 * ( ' Y ' = Reload_priv ) +
128 * ( ' Y ' = Shutdown_priv ) +
256 * ( ' Y ' = Process_priv ) +
512 * ( ' Y ' = File_priv ) +
1024 * ( ' Y ' = Grant_priv ) +
2048 * ( ' Y ' = References_priv ) +
4096 * ( ' Y ' = Index_priv ) +
8192 * ( ' Y ' = Alter_priv ) +
16384 * ( ' Y ' = Show_db_priv ) +
32768 * ( ' Y ' = Super_priv ) +
65536 * ( ' Y ' = Create_tmp_table_priv ) +
131072 * ( ' Y ' = Lock_tables_priv ) +
262144 * ( ' Y ' = Execute_priv ) +
524288 * ( ' Y ' = Repl_slave_priv ) +
1048576 * ( ' Y ' = Repl_client_priv ) +
2097152 * ( ' Y ' = Create_view_priv ) +
4194304 * ( ' Y ' = Show_view_priv ) +
8388608 * ( ' Y ' = Create_routine_priv ) +
16777216 * ( ' Y ' = Alter_routine_priv ) +
33554432 * ( ' Y ' = Create_user_priv ) +
67108864 * ( ' Y ' = Event_priv ) +
134217728 * ( ' Y ' = Trigger_priv ) +
268435456 * ( ' Y ' = Create_tablespace_priv ) +
536870912 * ( ' Y ' = Delete_history_priv ) ,
' ssl_type ' , ssl_type - 1 ,
' ssl_cipher ' , ssl_cipher ,
' x509_issuer ' , x509_issuer ,
' x509_subject ' , x509_subject ,
' max_questions ' , max_questions ,
' max_updates ' , max_updates ,
' max_connections ' , max_connections ,
' max_user_connections ' , max_user_connections ,
' max_statement_time ' , max_statement_time ,
' plugin ' , if ( plugin > ' ' , plugin , if ( length ( password ) = 16 , ' mysql_old_password ' , ' mysql_native_password ' ) ) ,
2019-01-09 20:24:34 +01:00
' authentication_string ' , if ( plugin > ' ' and authentication_string > ' ' , authentication_string , password ) ,
2021-08-16 08:40:56 +10:00
' password_last_changed ' , if ( password_expired = ' Y ' , 0 , if ( password_last_changed , UNIX_TIMESTAMP ( password_last_changed ) , UNIX_TIMESTAMP ( ) ) ) ,
2019-01-16 19:44:30 +02:00
' password_lifetime ' , ifnull ( password_lifetime , - 1 ) ,
2019-02-13 20:02:42 +01:00
' account_locked ' , ' Y ' = account_locked ,
2018-11-24 14:13:41 +01:00
' default_role ' , default_role ,
' is_role ' , ' Y ' = is_role ) ) as Priv
FROM user ;
DROP TABLE user ;
END IF / /
2020-02-19 17:50:30 +01:00
2021-03-08 17:51:33 +02:00
IF 1 = ( SELECT count ( * ) FROM information_schema . VIEWS WHERE TABLE_CATALOG = ' def ' and TABLE_SCHEMA = ' mysql ' and TABLE_NAME = ' user ' and ( DEFINER = ' root@localhost ' or ( DEFINER = ' mariadb.sys@localhost ' and VIEW_DEFINITION LIKE " %'N' AS `password_expired`% " ) ) ) THEN
2020-02-19 17:50:30 +01:00
DROP VIEW IF EXISTS mysql . user ;
END IF / /
2018-11-24 14:13:41 +01:00
DELIMITER ;
MDEV-22683: Ensure system tables are correctly upgraded in MariaDB 10.4
Running mysql_upgrade should end up with the exact same system tables as fresh
installations have after running mysql_install_db. To ensure the upgrade is
correct and complete:
- Remove the redundant modification of thread_id`. On 5.5 version, the
`general_log` table was created as `CREATE TABLE IF NOT EXISTS general_log
(..., thread_id INTEGER NOT NULL, ...)`, and starting from 10.0+, the table is
created as `CREATE TABLE IF NOT EXISTS general_log (..., thread_id BIGINT(21)
UNSIGNED NOT NULL, ...)`, but mysql_upgrade is not properly upgrading the
table. It modifies the `thread_id` twice in one query, which could leave the
table not modified and lead to other potential error when upgrading from
MariaDB 5.5 or older.
- Update `servers` to ensure `Host` and `User` has correct data type if
upgrading from 10.1 or older. On versions 10.0 and 10.1, the `servers` table
was created as `CREATE TABLE IF NOT EXISTS servers (..., Host char(64) NOT
NULL DEFAULT , ..., Owner char(64) NOT NULL DEFAULT , ...)`, and starting
from 10.2, the table is created as `CREATE TABLE IF NOT EXISTS servers (...,
Host varchar(2048) NOT NULL DEFAULT , ..., Owner varchar(512) NOT NULL
DEFAULT , ...)`.
All new code of the whole pull request, including one or several files that
are either new files or modified ones, are contributed under the BSD-new license.
I am contributing on behalf of my employer Amazon Web Services, Inc.
2023-03-01 20:46:18 +00:00
# MDEV-22683 - upgrade Host and Owner of servers
ALTER TABLE servers
MODIFY Host varchar ( 2048 ) NOT NULL DEFAULT ' ' ,
MODIFY Owner varchar ( 512 ) NOT NULL DEFAULT ' ' ;
2024-08-07 17:27:15 +10:00
# MDEV-34716 Fix mysql.servers socket max length too short
ALTER TABLE servers
MODIFY Socket char ( 108 ) NOT NULL DEFAULT ' ' ;
2024-09-05 16:12:35 +10:00
# MDEV-34716 Allow arbitrary options in CREATE SERVER
ALTER TABLE servers
ADD Options JSON NOT NULL DEFAULT ' {} ' CHECK ( JSON_VALID ( Options ) ) ;
# Ensure the collation is utf8mb4_bin (default for JSON)
ALTER TABLE servers
MODIFY Options JSON NOT NULL DEFAULT ' {} ' CHECK ( JSON_VALID ( Options ) ) ;