2011-11-03 19:17:05 +01:00
-- Copyright (C) 2003, 2011 Oracle and/or its affiliates.
2013-06-16 20:26:40 +02:00
-- Copyright (C) 2010-2013 Monty Program Ab & SkySQL Ab
2010-04-14 18:40:04 +02:00
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; version 2 of the License.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2007-02-26 11:49:24 +01:00
# This part converts any old privilege tables to privilege tables suitable
# for current version of MySQL
2003-08-27 21:30:50 +02:00
2007-02-26 14:48:41 +01:00
# You can safely ignore all 'Duplicate column' and 'Unknown column' errors
2006-11-21 21:32:58 +01: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 21:30:50 +02:00
2013-06-16 20:26:40 +02:00
# Warning message(s) produced for a statement can be printed by explicitly
# adding a 'SHOW WARNINGS' after the statement.
2007-01-02 18:42:13 +01:00
set sql_mode = ' ' ;
2005-04-18 23:01:18 +02:00
set storage_engine = MyISAM ;
2005-04-16 03:12:30 +02:00
2005-02-11 05:25:14 +01:00
ALTER TABLE user add File_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci NOT NULL ;
2006-11-21 21:32:58 +01:00
# Detect whether or not we had the Grant_priv column
2003-06-04 17:28:51 +02:00
SET @ hadGrantPriv : = 0 ;
SELECT @ hadGrantPriv : = 1 FROM user WHERE Grant_priv LIKE ' % ' ;
2005-02-11 05:25:14 +01:00
ALTER TABLE user add Grant_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci NOT NULL , add References_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci NOT NULL , add Index_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci NOT NULL , add Alter_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci NOT NULL ;
ALTER TABLE host add Grant_priv enum ( ' N ' , ' Y ' ) NOT NULL , add References_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci NOT NULL , add Index_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci NOT NULL , add Alter_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci NOT NULL ;
ALTER TABLE db add Grant_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci NOT NULL , add References_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci NOT NULL , add Index_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci NOT NULL , add Alter_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci NOT NULL ;
2003-06-04 17:28:51 +02:00
2006-11-21 21:32:58 +01:00
# Fix privileges for old tables
2003-06-04 17:28:51 +02:00
UPDATE user SET Grant_priv = File_priv , References_priv = Create_priv , Index_priv = Create_priv , Alter_priv = Create_priv WHERE @ hadGrantPriv = 0 ;
UPDATE db SET References_priv = Create_priv , Index_priv = Create_priv , Alter_priv = Create_priv WHERE @ hadGrantPriv = 0 ;
UPDATE host SET References_priv = Create_priv , Index_priv = Create_priv , Alter_priv = Create_priv WHERE @ hadGrantPriv = 0 ;
2006-11-21 21:32:58 +01:00
#
# The second alter changes ssl_type to new 4.0.2 format
2007-02-26 14:49:41 +01:00
# Adding columns needed by GRANT .. REQUIRE (openssl)
2004-03-19 17:33:38 +01:00
2003-06-04 17:28:51 +02:00
ALTER TABLE user
2005-02-11 05:25:14 +01:00
ADD ssl_type enum ( ' ' , ' ANY ' , ' X509 ' , ' SPECIFIED ' ) COLLATE utf8_general_ci NOT NULL ,
2003-06-04 17:28:51 +02:00
ADD ssl_cipher BLOB NOT NULL ,
ADD x509_issuer BLOB NOT NULL ,
ADD x509_subject BLOB NOT NULL ;
ALTER TABLE user MODIFY ssl_type enum ( ' ' , ' ANY ' , ' X509 ' , ' SPECIFIED ' ) NOT NULL ;
2006-11-21 21:32:58 +01:00
#
2006-11-30 13:04:24 +01:00
# tables_priv
2006-11-21 21:32:58 +01:00
#
2005-02-11 05:25:14 +01:00
ALTER TABLE tables_priv
2006-11-29 12:04:29 +01:00
ADD KEY Grantor ( Grantor ) ;
2003-06-04 17:28:51 +02:00
2006-11-29 12:04:29 +01:00
ALTER TABLE tables_priv
MODIFY Host char ( 60 ) NOT NULL default ' ' ,
MODIFY Db char ( 64 ) NOT NULL default ' ' ,
MODIFY User char ( 16 ) NOT NULL default ' ' ,
MODIFY Table_name char ( 64 ) NOT NULL default ' ' ,
MODIFY Grantor char ( 77 ) NOT NULL default ' ' ,
ENGINE = MyISAM ,
CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin ;
2003-06-04 17:28:51 +02:00
2006-11-29 12:04:29 +01:00
ALTER TABLE tables_priv
MODIFY Column_priv set ( ' Select ' , ' Insert ' , ' Update ' , ' References ' )
COLLATE utf8_general_ci DEFAULT ' ' NOT NULL ,
MODIFY Table_priv set ( ' Select ' , ' Insert ' , ' Update ' , ' Delete ' , ' Create ' ,
' Drop ' , ' Grant ' , ' References ' , ' Index ' , ' Alter ' ,
2010-07-01 11:05:09 +02:00
' Create View ' , ' Show view ' , ' Trigger ' )
2006-11-29 12:04:29 +01:00
COLLATE utf8_general_ci DEFAULT ' ' NOT NULL ,
COMMENT = ' Table privileges ' ;
2006-11-30 13:04:24 +01:00
#
# columns_priv
#
2006-11-21 21:32:58 +01:00
#
# Name change of Type -> Column_priv from MySQL 3.22.12
#
2006-11-29 12:04:29 +01:00
ALTER TABLE columns_priv
CHANGE Type Column_priv set ( ' Select ' , ' Insert ' , ' Update ' , ' References ' )
COLLATE utf8_general_ci DEFAULT ' ' NOT NULL ;
2004-03-19 17:33:38 +01:00
2006-11-29 12:04:29 +01:00
ALTER TABLE columns_priv
MODIFY Host char ( 60 ) NOT NULL default ' ' ,
MODIFY Db char ( 64 ) NOT NULL default ' ' ,
MODIFY User char ( 16 ) NOT NULL default ' ' ,
MODIFY Table_name char ( 64 ) NOT NULL default ' ' ,
MODIFY Column_name char ( 64 ) NOT NULL default ' ' ,
ENGINE = MyISAM ,
CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin ,
COMMENT = ' Column privileges ' ;
2004-03-19 17:33:38 +01:00
2006-11-29 12:04:29 +01:00
ALTER TABLE columns_priv
MODIFY Column_priv set ( ' Select ' , ' Insert ' , ' Update ' , ' References ' )
COLLATE utf8_general_ci DEFAULT ' ' NOT NULL ;
2003-06-04 17:28:51 +02:00
2006-11-21 21:32:58 +01:00
#
# Add the new 'type' column to the func table.
#
2004-03-19 17:33:38 +01:00
2005-02-11 05:25:14 +01:00
ALTER TABLE func add type enum ( ' function ' , ' aggregate ' ) COLLATE utf8_general_ci NOT NULL ;
2003-06-04 17:28:51 +02:00
2006-11-21 21:32:58 +01:00
#
2007-02-26 11:49:24 +01:00
# Change the user,db and host tables to current format
2006-11-21 21:32:58 +01:00
#
2004-03-19 17:33:38 +01:00
2003-06-04 17:28:51 +02:00
# Detect whether we had Show_db_priv
SET @ hadShowDbPriv : = 0 ;
SELECT @ hadShowDbPriv : = 1 FROM user WHERE Show_db_priv LIKE ' % ' ;
ALTER TABLE user
2005-02-11 05:25:14 +01:00
ADD Show_db_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Alter_priv ,
ADD Super_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Show_db_priv ,
ADD Create_tmp_table_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Super_priv ,
ADD Lock_tables_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Create_tmp_table_priv ,
ADD Execute_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Lock_tables_priv ,
ADD Repl_slave_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Execute_priv ,
ADD Repl_client_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Repl_slave_priv ;
2003-06-04 17:28:51 +02:00
2006-11-21 21:32:58 +01:00
# Convert privileges so that users have similar privileges as before
2004-03-19 17:33:38 +01:00
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 ;
2006-11-21 21:32:58 +01:00
# Add fields that can be used to limit number of questions and connections
# for some users.
2003-06-04 17:28:51 +02:00
ALTER TABLE user
2004-10-02 21:20:08 +02:00
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 ;
2003-06-04 17:28:51 +02:00
2004-03-19 17:33:38 +01:00
2006-11-21 21:32:58 +01:00
#
# Add Create_tmp_table_priv and Lock_tables_priv to db and host
#
2004-03-19 17:33:38 +01:00
2003-06-04 17:28:51 +02:00
ALTER TABLE db
2005-02-11 05:25:14 +01:00
ADD Create_tmp_table_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
ADD Lock_tables_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ;
2003-06-04 17:28:51 +02:00
ALTER TABLE host
ADD Create_tmp_table_priv enum ( ' N ' , ' Y ' ) DEFAULT ' N ' NOT NULL ,
ADD Lock_tables_priv enum ( ' N ' , ' Y ' ) DEFAULT ' N ' NOT NULL ;
2004-03-03 16:12:13 +01:00
2004-03-19 17:33:38 +01:00
alter table user change max_questions max_questions int ( 11 ) unsigned DEFAULT 0 NOT NULL ;
2006-11-29 12:04:29 +01:00
2004-03-19 17:33:38 +01:00
alter table db comment = ' Database privileges ' ;
alter table host comment = ' Host privileges; Merged with database privileges ' ;
alter table user comment = ' Users and global privileges ' ;
alter table func comment = ' User defined functions ' ;
2004-09-11 17:46:06 +02:00
2006-11-21 21:32:58 +01:00
# Convert all tables to UTF-8 with binary collation
# and reset all char columns to correct width
2005-02-11 05:25:14 +01:00
ALTER TABLE user
MODIFY Host char ( 60 ) NOT NULL default ' ' ,
MODIFY User char ( 16 ) NOT NULL default ' ' ,
ENGINE = MyISAM , CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin ;
ALTER TABLE user
2005-10-13 16:16:19 +02:00
MODIFY Password char ( 41 ) character set latin1 collate latin1_bin NOT NULL default ' ' ,
2005-02-11 05:25:14 +01:00
MODIFY Select_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Insert_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Update_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Delete_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Create_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Drop_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Reload_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Shutdown_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Process_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY File_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Grant_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY References_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Index_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Alter_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Show_db_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Super_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Create_tmp_table_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Lock_tables_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Execute_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Repl_slave_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Repl_client_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
2013-11-13 22:58:10 +01:00
MODIFY ssl_type enum ( ' ' , ' ANY ' , ' X509 ' , ' SPECIFIED ' ) COLLATE utf8_general_ci DEFAULT ' ' NOT NULL ;
2006-11-21 16:31:44 +01:00
2005-02-11 05:25:14 +01:00
ALTER TABLE db
MODIFY Host char ( 60 ) NOT NULL default ' ' ,
MODIFY Db char ( 64 ) NOT NULL default ' ' ,
MODIFY User char ( 16 ) NOT NULL default ' ' ,
ENGINE = MyISAM , CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin ;
ALTER TABLE db
MODIFY Select_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Insert_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Update_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Delete_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Create_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Drop_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Grant_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY References_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Index_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Alter_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Create_tmp_table_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Lock_tables_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ;
2006-11-21 16:31:44 +01:00
2005-02-11 05:25:14 +01:00
ALTER TABLE host
MODIFY Host char ( 60 ) NOT NULL default ' ' ,
MODIFY Db char ( 64 ) NOT NULL default ' ' ,
ENGINE = MyISAM , CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin ;
ALTER TABLE host
MODIFY Select_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Insert_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Update_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Delete_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Create_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Drop_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Grant_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY References_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Index_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Alter_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Create_tmp_table_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ,
MODIFY Lock_tables_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ;
2006-11-21 16:31:44 +01:00
2005-02-11 05:25:14 +01:00
ALTER TABLE func
ENGINE = MyISAM , CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin ;
ALTER TABLE func
MODIFY type enum ( ' function ' , ' aggregate ' ) COLLATE utf8_general_ci NOT NULL ;
2009-03-11 21:30:56 +01:00
#
# Modify log tables.
#
SET @ old_log_state = @ @ global . general_log ;
SET GLOBAL general_log = ' OFF ' ;
2010-02-26 13:22:48 +01:00
ALTER TABLE general_log
2013-06-16 20:26:40 +02:00
MODIFY event_time TIMESTAMP ( 6 ) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
2010-02-26 13:22:48 +01:00
MODIFY user_host MEDIUMTEXT NOT NULL ,
MODIFY thread_id INTEGER NOT NULL ,
MODIFY server_id INTEGER UNSIGNED NOT NULL ,
MODIFY command_type VARCHAR ( 64 ) NOT NULL ,
2013-06-16 20:26:40 +02:00
MODIFY argument MEDIUMTEXT NOT NULL ,
MODIFY thread_id BIGINT ( 21 ) UNSIGNED NOT NULL ;
2009-03-11 21:30:56 +01:00
SET GLOBAL general_log = @ old_log_state ;
SET @ old_log_state = @ @ global . slow_query_log ;
SET GLOBAL slow_query_log = ' OFF ' ;
2010-02-26 13:22:48 +01:00
ALTER TABLE slow_log
2013-06-16 20:26:40 +02:00
ADD COLUMN thread_id BIGINT ( 21 ) UNSIGNED NOT NULL AFTER sql_text ;
ALTER TABLE slow_log
MODIFY start_time TIMESTAMP ( 6 ) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
2010-02-26 13:22:48 +01:00
MODIFY user_host MEDIUMTEXT NOT NULL ,
2011-05-19 19:19:44 +02:00
MODIFY query_time TIME ( 6 ) NOT NULL ,
MODIFY lock_time TIME ( 6 ) NOT NULL ,
2010-02-26 13:22:48 +01:00
MODIFY rows_sent INTEGER NOT NULL ,
MODIFY rows_examined INTEGER NOT NULL ,
MODIFY db VARCHAR ( 512 ) NOT NULL ,
MODIFY last_insert_id INTEGER NOT NULL ,
MODIFY insert_id INTEGER NOT NULL ,
MODIFY server_id INTEGER UNSIGNED NOT NULL ,
2013-06-16 20:26:40 +02:00
MODIFY sql_text MEDIUMTEXT NOT NULL ,
MODIFY thread_id BIGINT ( 21 ) UNSIGNED NOT NULL ;
2009-03-11 21:30:56 +01:00
SET GLOBAL slow_query_log = @ old_log_state ;
2009-10-12 20:15:10 +02:00
ALTER TABLE plugin
MODIFY name varchar ( 64 ) COLLATE utf8_general_ci NOT NULL DEFAULT ' ' ,
MODIFY dl varchar ( 128 ) COLLATE utf8_general_ci NOT NULL DEFAULT ' ' ,
CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci ;
2004-09-11 17:46:06 +02:00
#
# Detect whether we had Create_view_priv
2007-02-26 11:49:24 +01:00
#
2004-09-11 17:46:06 +02:00
SET @ hadCreateViewPriv : = 0 ;
SELECT @ hadCreateViewPriv : = 1 FROM user WHERE Create_view_priv LIKE ' % ' ;
2004-07-16 00:15:55 +02:00
#
2004-07-19 05:16:42 +02:00
# Create VIEWs privileges (v5.0)
2004-07-16 00:15:55 +02:00
#
2005-02-18 03:07:14 +01:00
ALTER TABLE db ADD Create_view_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Lock_tables_priv ;
2006-11-21 16:31:44 +01:00
ALTER TABLE db MODIFY Create_view_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Lock_tables_priv ;
2005-02-18 03:07:14 +01:00
ALTER TABLE host ADD Create_view_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Lock_tables_priv ;
2006-11-21 16:31:44 +01:00
ALTER TABLE host MODIFY Create_view_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Lock_tables_priv ;
2005-02-18 03:07:14 +01:00
ALTER TABLE user ADD Create_view_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Repl_client_priv ;
2006-11-21 16:31:44 +01:00
ALTER TABLE user MODIFY Create_view_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Repl_client_priv ;
2004-07-16 00:15:55 +02:00
#
2004-07-19 05:16:42 +02:00
# Show VIEWs privileges (v5.0)
2004-07-16 00:15:55 +02:00
#
2005-02-18 03:07:14 +01:00
ALTER TABLE db ADD Show_view_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Create_view_priv ;
2006-11-21 16:31:44 +01:00
ALTER TABLE db MODIFY Show_view_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Create_view_priv ;
2005-02-18 03:07:14 +01:00
ALTER TABLE host ADD Show_view_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Create_view_priv ;
2006-11-21 16:31:44 +01:00
ALTER TABLE host MODIFY Show_view_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Create_view_priv ;
2004-03-19 17:33:38 +01:00
2005-02-18 03:07:14 +01:00
ALTER TABLE user ADD Show_view_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Create_view_priv ;
2006-11-21 16:31:44 +01:00
ALTER TABLE user MODIFY Show_view_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Create_view_priv ;
2005-07-05 12:36:36 +02:00
2004-09-11 17:46:06 +02: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 ;
2004-12-23 11:46:24 +01:00
#
#
#
SET @ hadCreateRoutinePriv : = 0 ;
SELECT @ hadCreateRoutinePriv : = 1 FROM user WHERE Create_routine_priv LIKE ' % ' ;
#
# Create PROCEDUREs privileges (v5.0)
#
2005-02-18 03:07:14 +01:00
ALTER TABLE db ADD Create_routine_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Show_view_priv ;
2006-11-21 16:31:44 +01:00
ALTER TABLE db MODIFY Create_routine_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Show_view_priv ;
2005-05-02 19:25:47 +02:00
ALTER TABLE host ADD Create_routine_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Show_view_priv ;
2006-11-21 16:31:44 +01:00
ALTER TABLE host MODIFY Create_routine_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Show_view_priv ;
2005-02-18 03:07:14 +01:00
ALTER TABLE user ADD Create_routine_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Show_view_priv ;
2006-11-21 16:31:44 +01:00
ALTER TABLE user MODIFY Create_routine_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Show_view_priv ;
2004-12-23 11:46:24 +01:00
#
# Alter PROCEDUREs privileges (v5.0)
#
2005-02-18 03:07:14 +01:00
ALTER TABLE db ADD Alter_routine_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Create_routine_priv ;
2006-11-21 16:31:44 +01:00
ALTER TABLE db MODIFY Alter_routine_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Create_routine_priv ;
2005-05-02 19:25:47 +02:00
ALTER TABLE host ADD Alter_routine_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Create_routine_priv ;
2006-11-21 16:31:44 +01:00
ALTER TABLE host MODIFY Alter_routine_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Create_routine_priv ;
2005-02-18 03:07:14 +01:00
ALTER TABLE user ADD Alter_routine_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Create_routine_priv ;
2006-11-21 16:31:44 +01:00
ALTER TABLE user MODIFY Alter_routine_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Create_routine_priv ;
2004-12-23 11:46:24 +01:00
2005-02-18 03:07:14 +01:00
ALTER TABLE db ADD Execute_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Alter_routine_priv ;
2006-11-21 16:31:44 +01:00
ALTER TABLE db MODIFY Execute_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Alter_routine_priv ;
2005-05-02 19:25:47 +02:00
ALTER TABLE host ADD Execute_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Alter_routine_priv ;
2006-11-21 16:31:44 +01:00
ALTER TABLE host MODIFY Execute_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Alter_routine_priv ;
2004-12-23 11:46:24 +01: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 ;
2005-02-08 03:40:14 +01:00
UPDATE host SET Create_routine_priv = Create_priv , Alter_routine_priv = Alter_priv , Execute_priv = Select_priv where @ hadCreateRoutinePriv = 0 ;
2004-12-23 11:46:24 +01:00
2004-12-29 18:30:37 +01:00
#
2007-02-26 11:49:24 +01:00
# Add max_user_connections resource limit
2011-09-26 19:26:47 +02:00
# this is signed in MariaDB so that if one sets it's to -1 then the user
# can't connect anymore.
2004-12-29 18:30:37 +01:00
#
2011-09-26 19:26:47 +02: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 18:30:37 +01:00
2005-03-22 15:54:18 +01:00
#
# user.Create_user_priv
#
SET @ hadCreateUserPriv : = 0 ;
SELECT @ hadCreateUserPriv : = 1 FROM user WHERE Create_user_priv LIKE ' % ' ;
ALTER TABLE user ADD Create_user_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Alter_routine_priv ;
2006-11-21 16:31:44 +01:00
ALTER TABLE user MODIFY Create_user_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Alter_routine_priv ;
2005-03-22 15:54:18 +01: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
#
2004-12-23 11:46:24 +01:00
2006-11-29 12:04:29 +01:00
ALTER TABLE procs_priv
ENGINE = MyISAM ,
CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin ;
ALTER TABLE procs_priv
MODIFY Proc_priv set ( ' Execute ' , ' Alter Routine ' , ' Grant ' )
COLLATE utf8_general_ci DEFAULT ' ' NOT NULL ;
2009-10-27 09:09:19 +01:00
ALTER IGNORE TABLE procs_priv
MODIFY Routine_name char ( 64 )
COLLATE utf8_general_ci DEFAULT ' ' NOT NULL ;
2006-11-29 12:04:29 +01:00
ALTER TABLE procs_priv
ADD Routine_type enum ( ' FUNCTION ' , ' PROCEDURE ' )
COLLATE utf8_general_ci NOT NULL AFTER Routine_name ;
ALTER TABLE procs_priv
2013-06-16 20:26:40 +02: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
2004-03-23 12:04:40 +01:00
ALTER TABLE proc MODIFY name char ( 64 ) DEFAULT ' ' NOT NULL ,
2004-10-14 18:07:09 +02:00
MODIFY specific_name char ( 64 ) DEFAULT ' ' NOT NULL ,
2005-07-08 16:33:15 +02:00
MODIFY sql_data_access
enum ( ' CONTAINS_SQL ' ,
' NO_SQL ' ,
' READS_SQL_DATA ' ,
' MODIFIES_SQL_DATA '
) DEFAULT ' CONTAINS_SQL ' NOT NULL ,
2007-03-08 15:43:54 +01:00
MODIFY body longblob NOT NULL ,
2007-10-17 10:13:56 +02:00
MODIFY returns longblob NOT NULL ,
2005-03-09 02:40:43 +01:00
MODIFY sql_mode
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-09 02:40:43 +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 11:47:39 +01:00
' HIGH_NOT_PRECEDENCE ' ,
' NO_ENGINE_SUBSTITUTION ' ,
' PAD_CHAR_TO_FULL_LENGTH '
2005-08-24 01:37:21 +02:00
) DEFAULT ' ' NOT NULL ,
2005-07-08 16:33:15 +02:00
DEFAULT CHARACTER SET utf8 ;
# Correct the character set and collation
ALTER TABLE proc CONVERT TO CHARACTER SET utf8 ;
# Reset some fields after the conversion
ALTER TABLE proc MODIFY db
char ( 64 ) collate utf8_bin DEFAULT ' ' NOT NULL ,
MODIFY definer
char ( 77 ) collate utf8_bin DEFAULT ' ' NOT NULL ,
MODIFY comment
char ( 64 ) collate utf8_bin DEFAULT ' ' NOT NULL ;
2005-12-05 11:45:04 +01:00
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 19:34:54 +02:00
ALTER TABLE proc ADD character_set_client
char ( 32 ) collate utf8_bin DEFAULT NULL
AFTER comment ;
ALTER TABLE proc MODIFY character_set_client
char ( 32 ) collate utf8_bin DEFAULT NULL ;
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 19:34:54 +02:00
ALTER TABLE proc ADD collation_connection
char ( 32 ) collate utf8_bin DEFAULT NULL
AFTER character_set_client ;
ALTER TABLE proc MODIFY collation_connection
char ( 32 ) collate utf8_bin DEFAULT NULL ;
2009-12-03 17:15:47 +01:00
SELECT CASE WHEN COUNT ( * ) > 0 THEN
CONCAT ( " WARNING: NULL values of the 'collation_connection' column ('mysql.proc' table) have been updated with a default value ( " , @ @ collation_connection , " ). Please verify if necessary. " )
ELSE NULL
END
AS value FROM proc WHERE collation_connection IS NULL ;
UPDATE proc SET collation_connection = @ @ collation_connection
WHERE collation_connection IS NULL ;
Patch for the following bugs:
- BUG#11986: Stored routines and triggers can fail if the code
has a non-ascii symbol
- BUG#16291: mysqldump corrupts string-constants with non-ascii-chars
- BUG#19443: INFORMATION_SCHEMA does not support charsets properly
- BUG#21249: Character set of SP-var can be ignored
- BUG#25212: Character set of string constant is ignored (stored routines)
- BUG#25221: Character set of string constant is ignored (triggers)
There were a few general problems that caused these bugs:
1. Character set information of the original (definition) query for views,
triggers, stored routines and events was lost.
2. mysqldump output query in client character set, which can be
inappropriate to encode definition-query.
3. INFORMATION_SCHEMA used strings with mixed encodings to display object
definition;
1. No query-definition-character set.
In order to compile query into execution code, some extra data (such as
environment variables or the database character set) is used. The problem
here was that this context was not preserved. So, on the next load it can
differ from the original one, thus the result will be different.
The context contains the following data:
- client character set;
- connection collation (character set and collation);
- collation of the owner database;
The fix is to store this context and use it each time we parse (compile)
and execute the object (stored routine, trigger, ...).
2. Wrong mysqldump-output.
The original query can contain several encodings (by means of character set
introducers). The problem here was that we tried to convert original query
to the mysqldump-client character set.
Moreover, we stored queries in different character sets for different
objects (views, for one, used UTF8, triggers used original character set).
The solution is
- to store definition queries in the original character set;
- to change SHOW CREATE statement to output definition query in the
binary character set (i.e. without any conversion);
- introduce SHOW CREATE TRIGGER statement;
- to dump special statements to switch the context to the original one
before dumping and restore it afterwards.
Note, in order to preserve the database collation at the creation time,
additional ALTER DATABASE might be used (to temporary switch the database
collation back to the original value). In this case, ALTER DATABASE
privilege will be required. This is a backward-incompatible change.
3. INFORMATION_SCHEMA showed non-UTF8 strings
The fix is to generate UTF8-query during the parsing, store it in the object
and show it in the INFORMATION_SCHEMA.
Basically, the idea is to create a copy of the original query convert it to
UTF8. Character set introducers are removed and all text literals are
converted to UTF8.
This UTF8 query is intended to provide user-readable output. It must not be
used to recreate the object. Specialized SHOW CREATE statements should be
used for this.
The reason for this limitation is the following: the original query can
contain symbols from several character sets (by means of character set
introducers).
Example:
- original query:
CREATE VIEW v1 AS SELECT _cp1251 'Hello' AS c1;
- UTF8 query (for INFORMATION_SCHEMA):
CREATE VIEW v1 AS SELECT 'Hello' AS c1;
client/mysqldump.c:
Set original character set and collation before dumping definition query.
include/my_sys.h:
Move out-parameter to the end of list.
mysql-test/lib/mtr_report.pl:
Ignore server-warnings during the test case.
mysql-test/r/create.result:
Update result file.
mysql-test/r/ctype_cp932_binlog_stm.result:
Update result file.
mysql-test/r/events.result:
Update result file.
mysql-test/r/events_bugs.result:
Update result file.
mysql-test/r/events_grant.result:
Update result file.
mysql-test/r/func_in.result:
Update result file.
mysql-test/r/gis.result:
Update result file.
mysql-test/r/grant.result:
Update result file.
mysql-test/r/information_schema.result:
Update result file.
mysql-test/r/information_schema_db.result:
Update result file.
mysql-test/r/lowercase_view.result:
Update result file.
mysql-test/r/mysqldump.result:
Update result file.
mysql-test/r/ndb_sp.result:
Update result file.
mysql-test/r/ps.result:
Update result file.
mysql-test/r/rpl_replicate_do.result:
Update result file.
mysql-test/r/rpl_sp.result:
Update result file.
mysql-test/r/rpl_trigger.result:
Update result file.
mysql-test/r/rpl_view.result:
Update result file.
mysql-test/r/show_check.result:
Update result file.
mysql-test/r/skip_grants.result:
Update result file.
mysql-test/r/sp-destruct.result:
Update result file.
mysql-test/r/sp-error.result:
Update result file.
mysql-test/r/sp-security.result:
Update result file.
mysql-test/r/sp.result:
Update result file.
mysql-test/r/sql_mode.result:
Update result file.
mysql-test/r/system_mysql_db.result:
Update result file.
mysql-test/r/temp_table.result:
Update result file.
mysql-test/r/trigger-compat.result:
Update result file.
mysql-test/r/trigger-grant.result:
Update result file.
mysql-test/r/trigger.result:
Update result file.
mysql-test/r/view.result:
Update result file.
mysql-test/r/view_grant.result:
Update result file.
mysql-test/t/events.test:
Update test case (new columns added).
mysql-test/t/information_schema.test:
Update test case (new columns added).
mysql-test/t/show_check.test:
Test case for SHOW CREATE TRIGGER in prepared statements and
stored routines.
mysql-test/t/sp-destruct.test:
Update test case (new columns added).
mysql-test/t/sp.test:
Update test case (new columns added).
mysql-test/t/view.test:
Update test.
mysys/charset.c:
Move out-parameter to the end of list.
scripts/mysql_system_tables.sql:
Add new columns to mysql.proc and mysql.event.
scripts/mysql_system_tables_fix.sql:
Add new columns to mysql.proc and mysql.event.
sql/event_data_objects.cc:
Support new attributes for events.
sql/event_data_objects.h:
Support new attributes for events.
sql/event_db_repository.cc:
Support new attributes for events.
sql/event_db_repository.h:
Support new attributes for events.
sql/events.cc:
Add new columns to SHOW CREATE event resultset.
sql/mysql_priv.h:
1. Introduce Object_creation_ctx;
2. Introduce SHOW CREATE TRIGGER;
3. Introduce auxilary functions.
sql/sp.cc:
Add support for new store routines attributes.
sql/sp_head.cc:
Add support for new store routines attributes.
sql/sp_head.h:
Add support for new store routines attributes.
sql/sql_lex.cc:
Generate UTF8-body on parsing/lexing.
sql/sql_lex.h:
1. Generate UTF8-body on parsing/lexing.
2. Introduce SHOW CREATE TRIGGER.
sql/sql_parse.cc:
Introduce SHOW CREATE TRIGGER.
sql/sql_partition.cc:
Update parse_sql().
sql/sql_prepare.cc:
Update parse_sql().
sql/sql_show.cc:
Support new attributes for views
sql/sql_trigger.cc:
Support new attributes for views
sql/sql_trigger.h:
Support new attributes for views
sql/sql_view.cc:
Support new attributes for views
sql/sql_yacc.yy:
1. Add SHOW CREATE TRIGGER statement.
2. Generate UTF8-body for views, stored routines, triggers and events.
sql/table.cc:
Introduce Object_creation_ctx.
sql/table.h:
Introduce Object_creation_ctx.
sql/share/errmsg.txt:
Add new errors.
mysql-test/include/ddl_i18n.check_events.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_sp.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_triggers.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_views.inc:
Aux file for test suite.
mysql-test/include/have_cp1251.inc:
Aux file for test suite.
mysql-test/include/have_cp866.inc:
Aux file for test suite.
mysql-test/include/have_koi8r.inc:
Aux file for test suite.
mysql-test/include/have_utf8.inc:
Aux file for test suite.
mysql-test/r/ddl_i18n_koi8r.result:
Result file.
mysql-test/r/ddl_i18n_utf8.result:
Result file.
mysql-test/r/have_cp1251.require:
Aux file for test suite.
mysql-test/r/have_cp866.require:
Aux file for test suite.
mysql-test/r/have_koi8r.require:
Aux file for test suite.
mysql-test/r/have_utf8.require:
Aux file for test suite.
mysql-test/t/ddl_i18n_koi8r.test:
Complete koi8r test case for the CS patch.
mysql-test/t/ddl_i18n_utf8.test:
Complete utf8 test case for the CS patch.
2007-06-28 19:34:54 +02:00
ALTER TABLE proc ADD db_collation
char ( 32 ) collate utf8_bin DEFAULT NULL
AFTER collation_connection ;
ALTER TABLE proc MODIFY db_collation
char ( 32 ) collate utf8_bin DEFAULT NULL ;
2009-12-03 17:15:47 +01:00
SELECT CASE WHEN COUNT ( * ) > 0 THEN
CONCAT ( " WARNING: NULL values of the 'db_collation' column ('mysql.proc' table) have been updated with default values. Please verify if necessary. " )
ELSE NULL
END
AS value FROM proc WHERE db_collation IS NULL ;
UPDATE proc AS p SET db_collation =
( SELECT DEFAULT_COLLATION_NAME
FROM INFORMATION_SCHEMA . SCHEMATA
WHERE SCHEMA_NAME = p . db )
WHERE db_collation IS NULL ;
Patch for the following bugs:
- BUG#11986: Stored routines and triggers can fail if the code
has a non-ascii symbol
- BUG#16291: mysqldump corrupts string-constants with non-ascii-chars
- BUG#19443: INFORMATION_SCHEMA does not support charsets properly
- BUG#21249: Character set of SP-var can be ignored
- BUG#25212: Character set of string constant is ignored (stored routines)
- BUG#25221: Character set of string constant is ignored (triggers)
There were a few general problems that caused these bugs:
1. Character set information of the original (definition) query for views,
triggers, stored routines and events was lost.
2. mysqldump output query in client character set, which can be
inappropriate to encode definition-query.
3. INFORMATION_SCHEMA used strings with mixed encodings to display object
definition;
1. No query-definition-character set.
In order to compile query into execution code, some extra data (such as
environment variables or the database character set) is used. The problem
here was that this context was not preserved. So, on the next load it can
differ from the original one, thus the result will be different.
The context contains the following data:
- client character set;
- connection collation (character set and collation);
- collation of the owner database;
The fix is to store this context and use it each time we parse (compile)
and execute the object (stored routine, trigger, ...).
2. Wrong mysqldump-output.
The original query can contain several encodings (by means of character set
introducers). The problem here was that we tried to convert original query
to the mysqldump-client character set.
Moreover, we stored queries in different character sets for different
objects (views, for one, used UTF8, triggers used original character set).
The solution is
- to store definition queries in the original character set;
- to change SHOW CREATE statement to output definition query in the
binary character set (i.e. without any conversion);
- introduce SHOW CREATE TRIGGER statement;
- to dump special statements to switch the context to the original one
before dumping and restore it afterwards.
Note, in order to preserve the database collation at the creation time,
additional ALTER DATABASE might be used (to temporary switch the database
collation back to the original value). In this case, ALTER DATABASE
privilege will be required. This is a backward-incompatible change.
3. INFORMATION_SCHEMA showed non-UTF8 strings
The fix is to generate UTF8-query during the parsing, store it in the object
and show it in the INFORMATION_SCHEMA.
Basically, the idea is to create a copy of the original query convert it to
UTF8. Character set introducers are removed and all text literals are
converted to UTF8.
This UTF8 query is intended to provide user-readable output. It must not be
used to recreate the object. Specialized SHOW CREATE statements should be
used for this.
The reason for this limitation is the following: the original query can
contain symbols from several character sets (by means of character set
introducers).
Example:
- original query:
CREATE VIEW v1 AS SELECT _cp1251 'Hello' AS c1;
- UTF8 query (for INFORMATION_SCHEMA):
CREATE VIEW v1 AS SELECT 'Hello' AS c1;
client/mysqldump.c:
Set original character set and collation before dumping definition query.
include/my_sys.h:
Move out-parameter to the end of list.
mysql-test/lib/mtr_report.pl:
Ignore server-warnings during the test case.
mysql-test/r/create.result:
Update result file.
mysql-test/r/ctype_cp932_binlog_stm.result:
Update result file.
mysql-test/r/events.result:
Update result file.
mysql-test/r/events_bugs.result:
Update result file.
mysql-test/r/events_grant.result:
Update result file.
mysql-test/r/func_in.result:
Update result file.
mysql-test/r/gis.result:
Update result file.
mysql-test/r/grant.result:
Update result file.
mysql-test/r/information_schema.result:
Update result file.
mysql-test/r/information_schema_db.result:
Update result file.
mysql-test/r/lowercase_view.result:
Update result file.
mysql-test/r/mysqldump.result:
Update result file.
mysql-test/r/ndb_sp.result:
Update result file.
mysql-test/r/ps.result:
Update result file.
mysql-test/r/rpl_replicate_do.result:
Update result file.
mysql-test/r/rpl_sp.result:
Update result file.
mysql-test/r/rpl_trigger.result:
Update result file.
mysql-test/r/rpl_view.result:
Update result file.
mysql-test/r/show_check.result:
Update result file.
mysql-test/r/skip_grants.result:
Update result file.
mysql-test/r/sp-destruct.result:
Update result file.
mysql-test/r/sp-error.result:
Update result file.
mysql-test/r/sp-security.result:
Update result file.
mysql-test/r/sp.result:
Update result file.
mysql-test/r/sql_mode.result:
Update result file.
mysql-test/r/system_mysql_db.result:
Update result file.
mysql-test/r/temp_table.result:
Update result file.
mysql-test/r/trigger-compat.result:
Update result file.
mysql-test/r/trigger-grant.result:
Update result file.
mysql-test/r/trigger.result:
Update result file.
mysql-test/r/view.result:
Update result file.
mysql-test/r/view_grant.result:
Update result file.
mysql-test/t/events.test:
Update test case (new columns added).
mysql-test/t/information_schema.test:
Update test case (new columns added).
mysql-test/t/show_check.test:
Test case for SHOW CREATE TRIGGER in prepared statements and
stored routines.
mysql-test/t/sp-destruct.test:
Update test case (new columns added).
mysql-test/t/sp.test:
Update test case (new columns added).
mysql-test/t/view.test:
Update test.
mysys/charset.c:
Move out-parameter to the end of list.
scripts/mysql_system_tables.sql:
Add new columns to mysql.proc and mysql.event.
scripts/mysql_system_tables_fix.sql:
Add new columns to mysql.proc and mysql.event.
sql/event_data_objects.cc:
Support new attributes for events.
sql/event_data_objects.h:
Support new attributes for events.
sql/event_db_repository.cc:
Support new attributes for events.
sql/event_db_repository.h:
Support new attributes for events.
sql/events.cc:
Add new columns to SHOW CREATE event resultset.
sql/mysql_priv.h:
1. Introduce Object_creation_ctx;
2. Introduce SHOW CREATE TRIGGER;
3. Introduce auxilary functions.
sql/sp.cc:
Add support for new store routines attributes.
sql/sp_head.cc:
Add support for new store routines attributes.
sql/sp_head.h:
Add support for new store routines attributes.
sql/sql_lex.cc:
Generate UTF8-body on parsing/lexing.
sql/sql_lex.h:
1. Generate UTF8-body on parsing/lexing.
2. Introduce SHOW CREATE TRIGGER.
sql/sql_parse.cc:
Introduce SHOW CREATE TRIGGER.
sql/sql_partition.cc:
Update parse_sql().
sql/sql_prepare.cc:
Update parse_sql().
sql/sql_show.cc:
Support new attributes for views
sql/sql_trigger.cc:
Support new attributes for views
sql/sql_trigger.h:
Support new attributes for views
sql/sql_view.cc:
Support new attributes for views
sql/sql_yacc.yy:
1. Add SHOW CREATE TRIGGER statement.
2. Generate UTF8-body for views, stored routines, triggers and events.
sql/table.cc:
Introduce Object_creation_ctx.
sql/table.h:
Introduce Object_creation_ctx.
sql/share/errmsg.txt:
Add new errors.
mysql-test/include/ddl_i18n.check_events.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_sp.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_triggers.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_views.inc:
Aux file for test suite.
mysql-test/include/have_cp1251.inc:
Aux file for test suite.
mysql-test/include/have_cp866.inc:
Aux file for test suite.
mysql-test/include/have_koi8r.inc:
Aux file for test suite.
mysql-test/include/have_utf8.inc:
Aux file for test suite.
mysql-test/r/ddl_i18n_koi8r.result:
Result file.
mysql-test/r/ddl_i18n_utf8.result:
Result file.
mysql-test/r/have_cp1251.require:
Aux file for test suite.
mysql-test/r/have_cp866.require:
Aux file for test suite.
mysql-test/r/have_koi8r.require:
Aux file for test suite.
mysql-test/r/have_utf8.require:
Aux file for test suite.
mysql-test/t/ddl_i18n_koi8r.test:
Complete koi8r test case for the CS patch.
mysql-test/t/ddl_i18n_utf8.test:
Complete utf8 test case for the CS patch.
2007-06-28 19:34:54 +02:00
ALTER TABLE proc ADD body_utf8 longblob DEFAULT NULL
AFTER db_collation ;
ALTER TABLE proc MODIFY body_utf8 longblob DEFAULT NULL ;
2009-10-09 17:35:07 +02:00
# Change comment from char(64) to text
ALTER TABLE proc MODIFY comment
text collate utf8_bin NOT NULL ;
Patch for the following bugs:
- BUG#11986: Stored routines and triggers can fail if the code
has a non-ascii symbol
- BUG#16291: mysqldump corrupts string-constants with non-ascii-chars
- BUG#19443: INFORMATION_SCHEMA does not support charsets properly
- BUG#21249: Character set of SP-var can be ignored
- BUG#25212: Character set of string constant is ignored (stored routines)
- BUG#25221: Character set of string constant is ignored (triggers)
There were a few general problems that caused these bugs:
1. Character set information of the original (definition) query for views,
triggers, stored routines and events was lost.
2. mysqldump output query in client character set, which can be
inappropriate to encode definition-query.
3. INFORMATION_SCHEMA used strings with mixed encodings to display object
definition;
1. No query-definition-character set.
In order to compile query into execution code, some extra data (such as
environment variables or the database character set) is used. The problem
here was that this context was not preserved. So, on the next load it can
differ from the original one, thus the result will be different.
The context contains the following data:
- client character set;
- connection collation (character set and collation);
- collation of the owner database;
The fix is to store this context and use it each time we parse (compile)
and execute the object (stored routine, trigger, ...).
2. Wrong mysqldump-output.
The original query can contain several encodings (by means of character set
introducers). The problem here was that we tried to convert original query
to the mysqldump-client character set.
Moreover, we stored queries in different character sets for different
objects (views, for one, used UTF8, triggers used original character set).
The solution is
- to store definition queries in the original character set;
- to change SHOW CREATE statement to output definition query in the
binary character set (i.e. without any conversion);
- introduce SHOW CREATE TRIGGER statement;
- to dump special statements to switch the context to the original one
before dumping and restore it afterwards.
Note, in order to preserve the database collation at the creation time,
additional ALTER DATABASE might be used (to temporary switch the database
collation back to the original value). In this case, ALTER DATABASE
privilege will be required. This is a backward-incompatible change.
3. INFORMATION_SCHEMA showed non-UTF8 strings
The fix is to generate UTF8-query during the parsing, store it in the object
and show it in the INFORMATION_SCHEMA.
Basically, the idea is to create a copy of the original query convert it to
UTF8. Character set introducers are removed and all text literals are
converted to UTF8.
This UTF8 query is intended to provide user-readable output. It must not be
used to recreate the object. Specialized SHOW CREATE statements should be
used for this.
The reason for this limitation is the following: the original query can
contain symbols from several character sets (by means of character set
introducers).
Example:
- original query:
CREATE VIEW v1 AS SELECT _cp1251 'Hello' AS c1;
- UTF8 query (for INFORMATION_SCHEMA):
CREATE VIEW v1 AS SELECT 'Hello' AS c1;
client/mysqldump.c:
Set original character set and collation before dumping definition query.
include/my_sys.h:
Move out-parameter to the end of list.
mysql-test/lib/mtr_report.pl:
Ignore server-warnings during the test case.
mysql-test/r/create.result:
Update result file.
mysql-test/r/ctype_cp932_binlog_stm.result:
Update result file.
mysql-test/r/events.result:
Update result file.
mysql-test/r/events_bugs.result:
Update result file.
mysql-test/r/events_grant.result:
Update result file.
mysql-test/r/func_in.result:
Update result file.
mysql-test/r/gis.result:
Update result file.
mysql-test/r/grant.result:
Update result file.
mysql-test/r/information_schema.result:
Update result file.
mysql-test/r/information_schema_db.result:
Update result file.
mysql-test/r/lowercase_view.result:
Update result file.
mysql-test/r/mysqldump.result:
Update result file.
mysql-test/r/ndb_sp.result:
Update result file.
mysql-test/r/ps.result:
Update result file.
mysql-test/r/rpl_replicate_do.result:
Update result file.
mysql-test/r/rpl_sp.result:
Update result file.
mysql-test/r/rpl_trigger.result:
Update result file.
mysql-test/r/rpl_view.result:
Update result file.
mysql-test/r/show_check.result:
Update result file.
mysql-test/r/skip_grants.result:
Update result file.
mysql-test/r/sp-destruct.result:
Update result file.
mysql-test/r/sp-error.result:
Update result file.
mysql-test/r/sp-security.result:
Update result file.
mysql-test/r/sp.result:
Update result file.
mysql-test/r/sql_mode.result:
Update result file.
mysql-test/r/system_mysql_db.result:
Update result file.
mysql-test/r/temp_table.result:
Update result file.
mysql-test/r/trigger-compat.result:
Update result file.
mysql-test/r/trigger-grant.result:
Update result file.
mysql-test/r/trigger.result:
Update result file.
mysql-test/r/view.result:
Update result file.
mysql-test/r/view_grant.result:
Update result file.
mysql-test/t/events.test:
Update test case (new columns added).
mysql-test/t/information_schema.test:
Update test case (new columns added).
mysql-test/t/show_check.test:
Test case for SHOW CREATE TRIGGER in prepared statements and
stored routines.
mysql-test/t/sp-destruct.test:
Update test case (new columns added).
mysql-test/t/sp.test:
Update test case (new columns added).
mysql-test/t/view.test:
Update test.
mysys/charset.c:
Move out-parameter to the end of list.
scripts/mysql_system_tables.sql:
Add new columns to mysql.proc and mysql.event.
scripts/mysql_system_tables_fix.sql:
Add new columns to mysql.proc and mysql.event.
sql/event_data_objects.cc:
Support new attributes for events.
sql/event_data_objects.h:
Support new attributes for events.
sql/event_db_repository.cc:
Support new attributes for events.
sql/event_db_repository.h:
Support new attributes for events.
sql/events.cc:
Add new columns to SHOW CREATE event resultset.
sql/mysql_priv.h:
1. Introduce Object_creation_ctx;
2. Introduce SHOW CREATE TRIGGER;
3. Introduce auxilary functions.
sql/sp.cc:
Add support for new store routines attributes.
sql/sp_head.cc:
Add support for new store routines attributes.
sql/sp_head.h:
Add support for new store routines attributes.
sql/sql_lex.cc:
Generate UTF8-body on parsing/lexing.
sql/sql_lex.h:
1. Generate UTF8-body on parsing/lexing.
2. Introduce SHOW CREATE TRIGGER.
sql/sql_parse.cc:
Introduce SHOW CREATE TRIGGER.
sql/sql_partition.cc:
Update parse_sql().
sql/sql_prepare.cc:
Update parse_sql().
sql/sql_show.cc:
Support new attributes for views
sql/sql_trigger.cc:
Support new attributes for views
sql/sql_trigger.h:
Support new attributes for views
sql/sql_view.cc:
Support new attributes for views
sql/sql_yacc.yy:
1. Add SHOW CREATE TRIGGER statement.
2. Generate UTF8-body for views, stored routines, triggers and events.
sql/table.cc:
Introduce Object_creation_ctx.
sql/table.h:
Introduce Object_creation_ctx.
sql/share/errmsg.txt:
Add new errors.
mysql-test/include/ddl_i18n.check_events.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_sp.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_triggers.inc:
Aux file for test suite.
mysql-test/include/ddl_i18n.check_views.inc:
Aux file for test suite.
mysql-test/include/have_cp1251.inc:
Aux file for test suite.
mysql-test/include/have_cp866.inc:
Aux file for test suite.
mysql-test/include/have_koi8r.inc:
Aux file for test suite.
mysql-test/include/have_utf8.inc:
Aux file for test suite.
mysql-test/r/ddl_i18n_koi8r.result:
Result file.
mysql-test/r/ddl_i18n_utf8.result:
Result file.
mysql-test/r/have_cp1251.require:
Aux file for test suite.
mysql-test/r/have_cp866.require:
Aux file for test suite.
mysql-test/r/have_koi8r.require:
Aux file for test suite.
mysql-test/r/have_utf8.require:
Aux file for test suite.
mysql-test/t/ddl_i18n_koi8r.test:
Complete koi8r test case for the CS patch.
mysql-test/t/ddl_i18n_utf8.test:
Complete utf8 test case for the CS patch.
2007-06-28 19:34:54 +02:00
2005-12-05 11:45:04 +01:00
#
# EVENT privilege
#
2006-02-24 00:29:50 +01:00
SET @ hadEventPriv : = 0 ;
SELECT @ hadEventPriv : = 1 FROM user WHERE Event_priv LIKE ' % ' ;
2006-01-11 18:09:05 +01:00
ALTER TABLE user add Event_priv enum ( ' N ' , ' Y ' ) character set utf8 DEFAULT ' N ' NOT NULL AFTER Create_user_priv ;
2006-11-21 17:44:43 +01:00
ALTER TABLE user MODIFY Event_priv enum ( ' N ' , ' Y ' ) character set utf8 DEFAULT ' N ' NOT NULL AFTER Create_user_priv ;
2007-03-21 17:20:44 +01:00
UPDATE user SET Event_priv = Super_priv WHERE @ hadEventPriv = 0 ;
2006-01-11 18:09:05 +01:00
ALTER TABLE db add Event_priv enum ( ' N ' , ' Y ' ) character set utf8 DEFAULT ' N ' NOT NULL ;
2006-11-21 17:44:43 +01:00
ALTER TABLE db MODIFY Event_priv enum ( ' N ' , ' Y ' ) character set utf8 DEFAULT ' N ' NOT NULL ;
2007-03-21 17:20:44 +01:00
#
# EVENT table
#
fix for bug#16642 (Events: No INFORMATION_SCHEMA.EVENTS table)
post-review change - use pointer instead of copy on the stack.
WL#1034 (Internal CRON)
This patch adds INFORMATION_SCHEMA.EVENTS table with the following format:
EVENT_CATALOG - MYSQL_TYPE_STRING (Always NULL)
EVENT_SCHEMA - MYSQL_TYPE_STRING (the database)
EVENT_NAME - MYSQL_TYPE_STRING (the name)
DEFINER - MYSQL_TYPE_STRING (user@host)
EVENT_BODY - MYSQL_TYPE_STRING (the body from mysql.event)
EVENT_TYPE - MYSQL_TYPE_STRING ("ONE TIME" | "RECURRING")
EXECUTE_AT - MYSQL_TYPE_TIMESTAMP (set for "ONE TIME" otherwise NULL)
INTERVAL_VALUE - MYSQL_TYPE_LONG (set for RECURRING otherwise NULL)
INTERVAL_FIELD - MYSQL_TYPE_STRING (set for RECURRING otherwise NULL)
SQL_MODE - MYSQL_TYPE_STRING (for now NULL)
STARTS - MYSQL_TYPE_TIMESTAMP (starts from mysql.event)
ENDS - MYSQL_TYPE_TIMESTAMP (ends from mysql.event)
STATUS - MYSQL_TYPE_STRING (ENABLED | DISABLED)
ON_COMPLETION - MYSQL_TYPE_STRING (NOT PRESERVE | PRESERVE)
CREATED - MYSQL_TYPE_TIMESTAMP
LAST_ALTERED - MYSQL_TYPE_TIMESTAMP
LAST_EXECUTED - MYSQL_TYPE_TIMESTAMP
EVENT_COMMENT - MYSQL_TYPE_STRING
SQL_MODE is NULL for now, because the value is still not stored in mysql.event .
Support will be added as a fix for another bug.
This patch also adds SHOW [FULL] EVENTS [FROM db] [LIKE pattern]
1. SHOW EVENTS shows always only the events on the same user,
because the PK of mysql.event is (definer, db, name) several
users may have event with the same name -> no information disclosure.
2. SHOW FULL EVENTS - shows the events (in the current db as SHOW EVENTS)
of all users. The user has to have PROCESS privilege, if not then
SHOW FULL EVENTS behave like SHOW EVENTS.
3. If [FROM db] is specified then this db is considered.
4. Event names can be filtered with LIKE pattern.
SHOW EVENTS returns table with the following columns, which are subset of
the data which is returned by SELECT * FROM I_S.EVENTS
Db
Name
Definer
Type
Execute at
Interval value
Interval field
Starts
Ends
Status
mysql-test/lib/init_db.sql:
change the PK - (definer, db, name)
quicker searches when SHOW EVENTS;
allow also different users to have events with the same name ->
no information disclosure
mysql-test/r/events.result:
result of new tests
mysql-test/r/information_schema.result:
result of new tests
mysql-test/r/information_schema_db.result:
result of new tests
mysql-test/r/system_mysql_db.result:
result of new tests
mysql-test/t/events.test:
new tests for information_schema.events
scripts/mysql_create_system_tables.sh:
change the PK of mysql.event to (definer, db, name)
scripts/mysql_fix_privilege_tables.sql:
change the PK of mysql.event to (definer, db, name)
sql/event.cc:
pass around the definer of the event because of the new PK
which is (definer, db, name). It's needed for index searching.
sql/event.h:
- make enum evex_table_field again public so it can be used
in sql_show.cc
- make created and modified ulonglong, because they should be such
- make public evex_open_event_table so it can be used in sql_show.cc
sql/event_executor.cc:
- cosmetics
sql/event_priv.h:
- moved enum evex_table_field and evex_open_event_table()
to event.h (made them therefore public)
sql/event_timed.cc:
- in event_timed::init_definer() always fill this.definer with
the concatenated value of definer_user@definer_host. Makes
later the work easier.
- pass around the definer wherever is needed for searching
(new prototype of evex_db_find_evex_aux)
sql/mysqld.cc:
- add counter for SHOW EVENTS
sql/sql_lex.h:
- register SHOW EVENTS as command
sql/sql_parse.cc:
- handle SCH_EVENTS (I_S.EVENTS like SCH_TRIGGERS)
- make additional check in case of SHOW EVENTS (check for EVENT on
the current database. if it is null check_access() gives appropriate
message back.
sql/sql_show.cc:
- add INFORMATION_SCHEMA.EVENTS and SHOW EVENTS
- I_S.EVENTS.SQL_MODE is NULL for now -> not implemented. Trudy
asked to be added so bug #16642 can be completely closed. There
is another bug report which will fix the lack of storage of
SQL_MODE during event creation.
sql/sql_yacc.yy:
- always call event_timed::init_definer() when CREATE/ALTER/DROP
EVENT but not when just compiling the body of the event because
in this case this operation is not needed, it takes memory and
CPU time and at the end the result is not used. event_timed::definer
is used only on SQLCOM_CREATE/ALTER/DROP_EVENT execution not on
statement compilation.
- add SHOW [FULL] EVENTS [FROM db] [LIKE pattern]
in case of FULL and the user has PROCESS privilege then he will see
also others' events in the current database, otherwise the output
is the same as of SHOW EVENTS. Because the events are per DB only
the events from the current database are shown. pattern is applied
against event name. FROM db is self explanatory.
sql/table.h:
add SCH_EVENTS as part of INFORMATION_SCHEMA
2006-01-30 13:15:23 +01:00
ALTER TABLE event DROP PRIMARY KEY ;
2006-05-29 10:39:45 +02:00
ALTER TABLE event ADD PRIMARY KEY ( db , name ) ;
2008-04-04 18:46:05 +02:00
# Add sql_mode column just in case.
2010-04-08 14:10:05 +02:00
ALTER TABLE event ADD sql_mode set ( ' IGNORE_BAD_TABLE_OPTIONS ' ) AFTER on_completion ;
2008-04-04 18:46:05 +02: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 11:47:39 +01:00
' HIGH_NOT_PRECEDENCE ' ,
' NO_ENGINE_SUBSTITUTION ' ,
' PAD_CHAR_TO_FULL_LENGTH '
2006-01-31 23:29:03 +01:00
) DEFAULT ' ' NOT NULL AFTER on_completion ;
2006-03-24 17:45:52 +01:00
ALTER TABLE event MODIFY name char ( 64 ) CHARACTER SET utf8 NOT NULL default ' ' ;
2009-03-11 21:30:56 +01:00
ALTER TABLE event MODIFY COLUMN originator INT UNSIGNED NOT NULL ;
ALTER TABLE event ADD COLUMN originator INT UNSIGNED NOT NULL AFTER comment ;
2007-03-16 14:56:57 +01:00
ALTER TABLE event MODIFY COLUMN status ENUM ( ' ENABLED ' , ' DISABLED ' , ' SLAVESIDE_DISABLED ' ) NOT NULL default ' ENABLED ' ;
2006-02-24 00:29:50 +01:00
BUG#16420: Events: timestamps become UTC
BUG#26429: SHOW CREATE EVENT is incorrect for an event that
STARTS NOW()
BUG#26431: Impossible to re-create an event from backup if its
STARTS clause is in the past
WL#3698: Events: execution in local time zone
The problem was that local times specified by the user in AT, STARTS
and ENDS of CREATE EVENT/ALTER EVENT statement were converted to UTC,
and the original time zone was forgotten. This way, event scheduler
couldn't honor Daylight Saving Time shifts, and times shown to the
user were also in UTC. Additionally, CREATE EVENT didn't allow times
in the past, thus preventing straightforward event restoration from
old backups.
This patch reworks event scheduler time computations, performing them
in the time zone associated with the event. Also it allows times to
be in the past.
The patch adds time_zone column to mysql.event table.
NOTE: The patch is almost final, but the bug#9953 should be pushed
first.
client/mysqldump.c:
Before every CREATE EVENT, output its time zone.
mysql-test/include/wait_condition.inc:
Add optional $wait_timeout parameter.
mysql-test/lib/init_db.sql:
Add time_zone column.
mysql-test/r/events.result:
Update result.
mysql-test/r/events_bugs.result:
Update result.
mysql-test/r/events_grant.result:
Update result.
mysql-test/r/events_restart_phase1.result:
Update result.
mysql-test/r/events_scheduling.result:
Update result.
mysql-test/r/mysqldump.result:
Update result.
mysql-test/r/ps.result:
Update result.
mysql-test/r/system_mysql_db.result:
Update result.
mysql-test/t/events.test:
Remove STARTS from the result, as it depends on current time.
mysql-test/t/events_bugs.test:
Time in the past is no longer an error.
mysql-test/t/events_restart_phase1.test:
Fill new column 'time_zone' in mysql.event.
mysql-test/t/events_scheduling.test:
Cleanup: disable event scheduler.
scripts/mysql_create_system_tables.sh:
Add new column 'time_zone' to mysql.event.
scripts/mysql_fix_privilege_tables.sql:
Add new column 'time_zone' to mysql.event.
sql/event_data_objects.cc:
The essence of the change is the following:
- for internal times use my_time_t instead of TIME. Assignment and
comparison is done now on plain numbers.
- in init_execute_at(), init_starts(), init_ends() convert given time
to number of seconds since Epoch (aka Unix time, in UTC).
- handle time_zone field loading and storing.
- in get_next_time(), Unix time is converted back to event time zone,
interval is added, and the result is converted to UTC again.
- fix Event_timed::get_create_event() to report STARTS and ENDS.
- before executing the event body we set thread time zone to the
event time zone.
sql/event_data_objects.h:
Add time_zone member to Event_basic class.
Store internal times in my_time_t (number of seconds since Epoch),
rather than in broken down TIME structure.
sql/event_db_repository.cc:
Add time_zone column handling.
Give a warning and do not create an event if its execution time is in
the past, and ON COMPLETION NOT PRESERVE is set, because such an event
should be dropped by that time. Also, do not allow ALTER EVENT to
set execution time in the past when ON COMPLETION NOT PRESERVE is set.
sql/event_db_repository.h:
Add enum member for new time zone column.
sql/event_queue.cc:
Replace handling of broken down times with simple handling of
my_time_t.
sql/event_queue.h:
Store internal times in my_time_t (number of seconds since Epoch),
rather than in broken down TIME structure.
sql/event_scheduler.cc:
Add TODO comment.
sql/events.cc:
Send time_zone column for SHOW CREATE EVENT.
sql/share/errmsg.txt:
Update error message, and add two more errors.
sql/sql_show.cc:
Add TIME_ZONE column to the output of SHOW EVENTS.
mysql-test/r/events_time_zone.result:
BitKeeper file /home/tomash/src/mysql_ab/mysql-5.1-wl3698/mysql-test/r/events_time_zone.result
mysql-test/t/events_time_zone.test:
BitKeeper file /home/tomash/src/mysql_ab/mysql-5.1-wl3698/mysql-test/t/events_time_zone.test
2007-03-16 15:31:07 +01:00
ALTER TABLE event ADD COLUMN time_zone char ( 64 ) CHARACTER SET latin1
2007-03-29 22:43:00 +02:00
NOT NULL DEFAULT ' SYSTEM ' AFTER originator ;
2006-02-24 00:29:50 +01:00
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 19:34:54 +02:00
ALTER TABLE event ADD character_set_client
char ( 32 ) collate utf8_bin DEFAULT NULL
AFTER time_zone ;
ALTER TABLE event MODIFY character_set_client
char ( 32 ) collate utf8_bin DEFAULT NULL ;
ALTER TABLE event ADD collation_connection
char ( 32 ) collate utf8_bin DEFAULT NULL
AFTER character_set_client ;
ALTER TABLE event MODIFY collation_connection
char ( 32 ) collate utf8_bin DEFAULT NULL ;
ALTER TABLE event ADD db_collation
char ( 32 ) collate utf8_bin DEFAULT NULL
AFTER collation_connection ;
ALTER TABLE event MODIFY db_collation
char ( 32 ) collate utf8_bin DEFAULT NULL ;
ALTER TABLE event ADD body_utf8 longblob DEFAULT NULL
AFTER db_collation ;
ALTER TABLE event MODIFY body_utf8 longblob DEFAULT NULL ;
2006-11-21 21:32:58 +01:00
#
# TRIGGER privilege
#
2006-02-01 11:28:45 +01:00
SET @ hadTriggerPriv : = 0 ;
SELECT @ hadTriggerPriv : = 1 FROM user WHERE Trigger_priv LIKE ' % ' ;
2006-02-02 11:36:07 +01:00
ALTER TABLE user ADD Trigger_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Event_priv ;
2006-11-21 17:44:43 +01:00
ALTER TABLE user MODIFY Trigger_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Event_priv ;
2006-02-02 11:36:07 +01:00
ALTER TABLE host ADD Trigger_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ;
2006-11-21 17:44:43 +01:00
ALTER TABLE host MODIFY Trigger_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ;
ALTER TABLE db ADD Trigger_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ;
ALTER TABLE db MODIFY Trigger_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ;
2006-02-01 11:28:45 +01:00
UPDATE user SET Trigger_priv = Super_priv WHERE @ hadTriggerPriv = 0 ;
2006-02-25 20:54:34 +01:00
2009-10-09 22:01:10 +02:00
#
# user.Create_tablespace_priv
#
SET @ hadCreateTablespacePriv : = 0 ;
SELECT @ hadCreateTablespacePriv : = 1 FROM user WHERE Create_tablespace_priv LIKE ' % ' ;
ALTER TABLE user ADD Create_tablespace_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Trigger_priv ;
ALTER TABLE user MODIFY Create_tablespace_priv enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL AFTER Trigger_priv ;
UPDATE user SET Create_tablespace_priv = Super_priv WHERE @ hadCreateTablespacePriv = 0 ;
2011-03-18 15:16:17 +01:00
ALTER TABLE user ADD plugin char ( 64 ) DEFAULT ' ' , ADD authentication_string TEXT ;
2013-06-16 20:26:40 +02:00
ALTER TABLE user ADD password_expired ENUM ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ;
2013-11-13 22:58:10 +01:00
ALTER TABLE user ADD is_role enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ;
2013-07-04 14:36:43 +02:00
ALTER TABLE user MODIFY plugin char ( 64 ) CHARACTER SET latin1 DEFAULT ' ' NOT NULL , MODIFY authentication_string TEXT NOT NULL ;
2013-07-04 15:01:36 +02:00
-- Somewhere above, we ran ALTER TABLE user .... CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin.
-- we want password_expired column to have collation utf8_general_ci.
ALTER TABLE user MODIFY password_expired ENUM ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ;
2013-11-13 22:58:10 +01:00
ALTER TABLE user MODIFY is_role enum ( ' N ' , ' Y ' ) COLLATE utf8_general_ci DEFAULT ' N ' NOT NULL ;
2010-08-09 10:32:50 +02:00
2010-11-19 15:35:04 +01:00
-- Need to pre-fill mysql.proxies_priv with access for root even when upgrading from
-- older versions
CREATE TEMPORARY TABLE tmp_proxies_priv LIKE proxies_priv ;
INSERT INTO tmp_proxies_priv VALUES ( ' localhost ' , ' root ' , ' ' , ' ' , TRUE , ' ' , now ( ) ) ;
INSERT INTO proxies_priv SELECT * FROM tmp_proxies_priv WHERE @ had_proxies_priv_table = 0 ;
DROP TABLE tmp_proxies_priv ;
2013-11-03 16:31:52 +01:00
# MDEV-4332 longer user names
2013-11-13 22:58:10 +01:00
alter table user modify User char ( 80 ) binary not null default ' ' ;
alter table db modify User char ( 80 ) binary not null default ' ' ;
alter table tables_priv modify User char ( 80 ) binary not null default ' ' ;
alter table columns_priv modify User char ( 80 ) binary not null default ' ' ;
alter table procs_priv modify User char ( 80 ) binary not null default ' ' ;
alter table proc modify definer char ( 141 ) collate utf8_bin not null default ' ' ;
alter table event modify definer char ( 141 ) collate utf8_bin not null default ' ' ;
alter table proxies_priv modify User char ( 80 ) COLLATE utf8_bin not null default ' ' ;
alter table proxies_priv modify Proxied_user char ( 80 ) COLLATE utf8_bin not null default ' ' ;
alter table proxies_priv modify Grantor char ( 141 ) COLLATE utf8_bin not null default ' ' ;
alter table servers modify Username char ( 80 ) not null default ' ' ;
alter table procs_priv modify Grantor char ( 141 ) COLLATE utf8_bin not null default ' ' ;
alter table tables_priv modify Grantor char ( 141 ) COLLATE utf8_bin not null default ' ' ;
2010-08-09 10:32:50 +02:00
2006-02-24 17:34:15 +01:00
# Activate the new, possible modified privilege tables
# This should not be needed, but gives us some extra testing that the above
# changes was correct
flush privileges ;
2012-08-14 16:23:34 +02:00