summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xBitKeeper/triggers/post-commit7
-rw-r--r--cmd-line-utils/readline/bind.c2
-rw-r--r--mysql-test/r/ctype_sjis.result4
-rw-r--r--mysql-test/r/lowercase_table2.result18
-rw-r--r--mysql-test/r/lowercase_table_grant.result23
-rw-r--r--mysql-test/r/skip_name_resolve.result7
-rw-r--r--mysql-test/r/system_mysql_db.result100
-rw-r--r--mysql-test/t/ctype_sjis.test7
-rw-r--r--mysql-test/t/lowercase_table2.test17
-rw-r--r--mysql-test/t/lowercase_table_grant-master.opt1
-rw-r--r--mysql-test/t/lowercase_table_grant.test25
-rw-r--r--mysql-test/t/skip_name_resolve-master.opt1
-rw-r--r--mysql-test/t/skip_name_resolve.test5
-rw-r--r--mysys/charset.c17
-rw-r--r--scripts/mysql_create_system_tables.sh102
-rw-r--r--scripts/mysql_fix_privilege_tables.sql178
-rw-r--r--sql/mysql_priv.h2
-rw-r--r--sql/sql_acl.cc39
-rw-r--r--sql/sql_base.cc12
-rw-r--r--sql/sql_lex.cc32
-rw-r--r--tests/mysql_client_test.c49
21 files changed, 482 insertions, 166 deletions
diff --git a/BitKeeper/triggers/post-commit b/BitKeeper/triggers/post-commit
index 184c6243ef8..93151f3e2b6 100755
--- a/BitKeeper/triggers/post-commit
+++ b/BitKeeper/triggers/post-commit
@@ -19,6 +19,13 @@ BK_STATUS=$BK_STATUS$BK_COMMIT
if [ "$BK_STATUS" = OK ]
then
+HAS_ACTUAL_CHANGES=`bk cset -r+ -d | grep -v "^#"`
+if [ "$HAS_ACTUAL_CHANGES" = "" ]
+then
+ echo ChangeSet had no real changes, not sending emails
+ exit
+fi
+
CHANGESET=`bk -R prs -r+ -h -d':P:::I:' ChangeSet`
BUG=`bk -R prs -r+ -h -d':C:' ChangeSet | sed -ne 's/^.*[Bb][Uu][Gg] *# *\([0-9][0-9]*\).*$/\1/p'`
WL=`bk -R prs -r+ -h -d':C:' ChangeSet | sed -ne 's/^.*[Ww][Ll] *# *\([0-9][0-9]*\).*$/ WL#\1/p'`
diff --git a/cmd-line-utils/readline/bind.c b/cmd-line-utils/readline/bind.c
index 7e8ca04e0d6..fd01049f09f 100644
--- a/cmd-line-utils/readline/bind.c
+++ b/cmd-line-utils/readline/bind.c
@@ -311,7 +311,7 @@ rl_generic_bind (type, keyseq, data, map)
mapped to something, `abc' to be mapped to something else,
and the function bound to `a' to be executed when the user
types `abx', leaving `bx' in the input queue. */
- if (k.function /* && k.type == ISFUNC */)
+ if (k.function && ((k.type == ISFUNC && k.function != rl_do_lowercase_version) || k.type == ISMACR))
{
map[ANYOTHERKEY] = k;
k.function = 0;
diff --git a/mysql-test/r/ctype_sjis.result b/mysql-test/r/ctype_sjis.result
index 1f414f89e20..98e5992f374 100644
--- a/mysql-test/r/ctype_sjis.result
+++ b/mysql-test/r/ctype_sjis.result
@@ -91,3 +91,7 @@ sjis_bin 6109
sjis_bin 61
sjis_bin 6120
drop table t1;
+SET NAMES sjis;
+SELECT HEX('@\\') FROM DUAL;
+HEX('@_\')
+8DB2939181408C5C
diff --git a/mysql-test/r/lowercase_table2.result b/mysql-test/r/lowercase_table2.result
index a79b6b04063..8361b66817a 100644
--- a/mysql-test/r/lowercase_table2.result
+++ b/mysql-test/r/lowercase_table2.result
@@ -141,3 +141,21 @@ select * from T1;
a b
1 abc
drop table T1;
+create database mysqltest_LC2;
+use mysqltest_LC2;
+create table myUC (i int);
+insert into myUC values (1),(2),(3);
+select * from myUC;
+i
+1
+2
+3
+use test;
+drop database mysqltest_LC2;
+create database mysqltest_LC2;
+use mysqltest_LC2;
+create table myUC (i int);
+select * from myUC;
+i
+use test;
+drop database mysqltest_LC2;
diff --git a/mysql-test/r/lowercase_table_grant.result b/mysql-test/r/lowercase_table_grant.result
new file mode 100644
index 00000000000..3889bd418db
--- /dev/null
+++ b/mysql-test/r/lowercase_table_grant.result
@@ -0,0 +1,23 @@
+use mysql;
+create database MYSQLtest;
+grant all on MySQLtest.* to mysqltest_1@localhost;
+show grants for mysqltest_1@localhost;
+Grants for mysqltest_1@localhost
+GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
+GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_1'@'localhost'
+select * from db where user = 'mysqltest_1';
+Host Db User Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Grant_priv References_priv Index_priv Alter_priv Create_tmp_table_priv Lock_tables_priv
+localhost mysqltest mysqltest_1 Y Y Y Y Y Y N Y Y Y Y Y
+update db set db = 'MYSQLtest' where db = 'mysqltest' and user = 'mysqltest_1' and host = 'localhost';
+flush privileges;
+show grants for mysqltest_1@localhost;
+Grants for mysqltest_1@localhost
+GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
+GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_1'@'localhost'
+select * from db where user = 'mysqltest_1';
+Host Db User Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Grant_priv References_priv Index_priv Alter_priv Create_tmp_table_priv Lock_tables_priv
+localhost MYSQLtest mysqltest_1 Y Y Y Y Y Y N Y Y Y Y Y
+delete from db where db = 'MYSQLtest' and user = 'mysqltest_1' and host = 'localhost';
+flush privileges;
+drop user mysqltest_1@localhost;
+drop database MYSQLtest;
diff --git a/mysql-test/r/skip_name_resolve.result b/mysql-test/r/skip_name_resolve.result
new file mode 100644
index 00000000000..d8d873699a5
--- /dev/null
+++ b/mysql-test/r/skip_name_resolve.result
@@ -0,0 +1,7 @@
+GRANT ALL ON test.* TO mysqltest_1@'127.0.0.1/255.255.255.255';
+SHOW GRANTS FOR mysqltest_1@'127.0.0.1/255.255.255.255';
+Grants for mysqltest_1@127.0.0.1/255.255.255.255
+GRANT USAGE ON *.* TO 'mysqltest_1'@'127.0.0.1/255.255.255.255'
+GRANT ALL PRIVILEGES ON `test`.* TO 'mysqltest_1'@'127.0.0.1/255.255.255.255'
+REVOKE ALL ON test.* FROM mysqltest_1@'127.0.0.1/255.255.255.255';
+DROP USER mysqltest_1@'127.0.0.1/255.255.255.255';
diff --git a/mysql-test/r/system_mysql_db.result b/mysql-test/r/system_mysql_db.result
index ebb24159373..141878a7bf6 100644
--- a/mysql-test/r/system_mysql_db.result
+++ b/mysql-test/r/system_mysql_db.result
@@ -21,18 +21,18 @@ db CREATE TABLE `db` (
`Host` char(60) collate utf8_bin NOT NULL default '',
`Db` char(64) collate utf8_bin NOT NULL default '',
`User` char(16) collate utf8_bin NOT NULL default '',
- `Select_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Insert_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Update_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Delete_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Create_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Drop_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Grant_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `References_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Index_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Alter_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Create_tmp_table_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Lock_tables_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
+ `Select_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Insert_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Update_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Delete_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Create_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Drop_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Grant_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `References_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Index_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Alter_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Create_tmp_table_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Lock_tables_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
PRIMARY KEY (`Host`,`Db`,`User`),
KEY `User` (`User`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Database privileges'
@@ -41,18 +41,18 @@ Table Create Table
host CREATE TABLE `host` (
`Host` char(60) collate utf8_bin NOT NULL default '',
`Db` char(64) collate utf8_bin NOT NULL default '',
- `Select_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Insert_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Update_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Delete_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Create_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Drop_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Grant_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `References_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Index_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Alter_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Create_tmp_table_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Lock_tables_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
+ `Select_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Insert_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Update_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Delete_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Create_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Drop_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Grant_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `References_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Index_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Alter_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Create_tmp_table_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Lock_tables_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
PRIMARY KEY (`Host`,`Db`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Host privileges; Merged with database privileges'
show create table user;
@@ -61,28 +61,28 @@ user CREATE TABLE `user` (
`Host` varchar(60) collate utf8_bin NOT NULL default '',
`User` varchar(16) collate utf8_bin NOT NULL default '',
`Password` varchar(41) collate utf8_bin NOT NULL default '',
- `Select_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Insert_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Update_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Delete_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Create_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Drop_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Reload_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Shutdown_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Process_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `File_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Grant_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `References_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Index_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Alter_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Show_db_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Super_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Create_tmp_table_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Lock_tables_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Execute_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Repl_slave_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `Repl_client_priv` enum('N','Y') collate utf8_bin NOT NULL default 'N',
- `ssl_type` enum('','ANY','X509','SPECIFIED') collate utf8_bin NOT NULL default '',
+ `Select_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Insert_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Update_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Delete_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Create_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Drop_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Reload_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Shutdown_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Process_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `File_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Grant_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `References_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Index_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Alter_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Show_db_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Super_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Create_tmp_table_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Lock_tables_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Execute_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Repl_slave_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `Repl_client_priv` enum('N','Y') character set utf8 NOT NULL default 'N',
+ `ssl_type` enum('','ANY','X509','SPECIFIED') character set utf8 NOT NULL default '',
`ssl_cipher` blob NOT NULL,
`x509_issuer` blob NOT NULL,
`x509_subject` blob NOT NULL,
@@ -97,7 +97,7 @@ func CREATE TABLE `func` (
`name` char(64) collate utf8_bin NOT NULL default '',
`ret` tinyint(1) NOT NULL default '0',
`dl` char(128) collate utf8_bin NOT NULL default '',
- `type` enum('function','aggregate') collate utf8_bin NOT NULL default 'function',
+ `type` enum('function','aggregate') character set utf8 NOT NULL default 'function',
PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='User defined functions'
show create table tables_priv;
@@ -109,8 +109,8 @@ tables_priv CREATE TABLE `tables_priv` (
`Table_name` char(64) collate utf8_bin NOT NULL default '',
`Grantor` char(77) collate utf8_bin NOT NULL default '',
`Timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
- `Table_priv` set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') collate utf8_bin NOT NULL default '',
- `Column_priv` set('Select','Insert','Update','References') collate utf8_bin NOT NULL default '',
+ `Table_priv` set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') character set utf8 NOT NULL default '',
+ `Column_priv` set('Select','Insert','Update','References') character set utf8 NOT NULL default '',
PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`),
KEY `Grantor` (`Grantor`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Table privileges'
@@ -123,7 +123,7 @@ columns_priv CREATE TABLE `columns_priv` (
`Table_name` char(64) collate utf8_bin NOT NULL default '',
`Column_name` char(64) collate utf8_bin NOT NULL default '',
`Timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
- `Column_priv` set('Select','Insert','Update','References') collate utf8_bin NOT NULL default '',
+ `Column_priv` set('Select','Insert','Update','References') character set utf8 NOT NULL default '',
PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`,`Column_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Column privileges'
show tables;
diff --git a/mysql-test/t/ctype_sjis.test b/mysql-test/t/ctype_sjis.test
index 58ca3c6a997..50d286f28b9 100644
--- a/mysql-test/t/ctype_sjis.test
+++ b/mysql-test/t/ctype_sjis.test
@@ -68,3 +68,10 @@ SET collation_connection='sjis_japanese_ci';
-- source include/ctype_filesort.inc
SET collation_connection='sjis_bin';
-- source include/ctype_filesort.inc
+
+# Check parsing of string literals in SJIS with multibyte characters that
+# have an embedded \ in them. (Bug #8303)
+
+--character_set sjis
+SET NAMES sjis;
+SELECT HEX('@\\') FROM DUAL;
diff --git a/mysql-test/t/lowercase_table2.test b/mysql-test/t/lowercase_table2.test
index a766e39abab..eff5f2a99ec 100644
--- a/mysql-test/t/lowercase_table2.test
+++ b/mysql-test/t/lowercase_table2.test
@@ -111,3 +111,20 @@ select * from T1;
alter table T1 add index (a);
select * from T1;
drop table T1;
+
+#
+# Bug #8355: Tables not dropped from table cache on drop db
+#
+create database mysqltest_LC2;
+use mysqltest_LC2;
+create table myUC (i int);
+insert into myUC values (1),(2),(3);
+select * from myUC;
+use test;
+drop database mysqltest_LC2;
+create database mysqltest_LC2;
+use mysqltest_LC2;
+create table myUC (i int);
+select * from myUC;
+use test;
+drop database mysqltest_LC2;
diff --git a/mysql-test/t/lowercase_table_grant-master.opt b/mysql-test/t/lowercase_table_grant-master.opt
new file mode 100644
index 00000000000..c718e2feb1b
--- /dev/null
+++ b/mysql-test/t/lowercase_table_grant-master.opt
@@ -0,0 +1 @@
+--lower_case_table_names
diff --git a/mysql-test/t/lowercase_table_grant.test b/mysql-test/t/lowercase_table_grant.test
new file mode 100644
index 00000000000..5ac35c81c21
--- /dev/null
+++ b/mysql-test/t/lowercase_table_grant.test
@@ -0,0 +1,25 @@
+# Test of grants when lower_case_table_names is on
+use mysql;
+
+# mixed-case database name for testing
+create database MYSQLtest;
+
+# check that database name gets forced to lowercase
+grant all on MySQLtest.* to mysqltest_1@localhost;
+show grants for mysqltest_1@localhost;
+
+# now force it to mixed case, but see that it is lowercased in the acl cache
+select * from db where user = 'mysqltest_1';
+update db set db = 'MYSQLtest' where db = 'mysqltest' and user = 'mysqltest_1' and host = 'localhost';
+flush privileges;
+show grants for mysqltest_1@localhost;
+select * from db where user = 'mysqltest_1';
+
+# clear out the user we created
+#
+# can't use REVOKE because of the mixed-case database name
+delete from db where db = 'MYSQLtest' and user = 'mysqltest_1' and host = 'localhost';
+flush privileges;
+drop user mysqltest_1@localhost;
+
+drop database MYSQLtest;
diff --git a/mysql-test/t/skip_name_resolve-master.opt b/mysql-test/t/skip_name_resolve-master.opt
new file mode 100644
index 00000000000..ab6ca1731f5
--- /dev/null
+++ b/mysql-test/t/skip_name_resolve-master.opt
@@ -0,0 +1 @@
+--skip-name-resolve
diff --git a/mysql-test/t/skip_name_resolve.test b/mysql-test/t/skip_name_resolve.test
new file mode 100644
index 00000000000..68dcf329427
--- /dev/null
+++ b/mysql-test/t/skip_name_resolve.test
@@ -0,0 +1,5 @@
+# Bug #8471: IP address with mask fail when skip-name-resolve is on
+GRANT ALL ON test.* TO mysqltest_1@'127.0.0.1/255.255.255.255';
+SHOW GRANTS FOR mysqltest_1@'127.0.0.1/255.255.255.255';
+REVOKE ALL ON test.* FROM mysqltest_1@'127.0.0.1/255.255.255.255';
+DROP USER mysqltest_1@'127.0.0.1/255.255.255.255';
diff --git a/mysys/charset.c b/mysys/charset.c
index cb2379f8723..5587a6d685f 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -581,6 +581,23 @@ ulong escape_string_for_mysql(CHARSET_INFO *charset_info, char *to,
from--;
continue;
}
+ /*
+ If the next character appears to begin a multi-byte character, we
+ escape that first byte of that apparent multi-byte character. (The
+ character just looks like a multi-byte character -- if it were actually
+ a multi-byte character, it would have been passed through in the test
+ above.)
+
+ Without this check, we can create a problem by converting an invalid
+ multi-byte character into a valid one. For example, 0xbf27 is not
+ a valid GBK character, but 0xbf5c is. (0x27 = ', 0x5c = \)
+ */
+ if (use_mb_flag && (l= my_mbcharlen(charset_info, *from)) > 1)
+ {
+ *to++= '\\';
+ *to++= *from;
+ continue;
+ }
#endif
switch (*from) {
case 0: /* Must be escaped for 'mysql' */
diff --git a/scripts/mysql_create_system_tables.sh b/scripts/mysql_create_system_tables.sh
index 83fdc0639ce..993efcb0fda 100644
--- a/scripts/mysql_create_system_tables.sh
+++ b/scripts/mysql_create_system_tables.sh
@@ -54,18 +54,18 @@ then
c_d="$c_d Host char(60) binary DEFAULT '' NOT NULL,"
c_d="$c_d Db char(64) binary DEFAULT '' NOT NULL,"
c_d="$c_d User char(16) binary DEFAULT '' NOT NULL,"
- c_d="$c_d Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_d="$c_d Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_d="$c_d Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_d="$c_d Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_d="$c_d Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_d="$c_d Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_d="$c_d Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_d="$c_d References_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_d="$c_d Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_d="$c_d Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_d="$c_d Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_d="$c_d Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
+ c_d="$c_d Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_d="$c_d Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_d="$c_d Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_d="$c_d Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_d="$c_d Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_d="$c_d Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_d="$c_d Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_d="$c_d References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_d="$c_d Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_d="$c_d Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_d="$c_d Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_d="$c_d Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
c_d="$c_d PRIMARY KEY Host (Host,Db,User),"
c_d="$c_d KEY User (User)"
c_d="$c_d ) engine=MyISAM"
@@ -85,18 +85,18 @@ then
c_h="$c_h CREATE TABLE host ("
c_h="$c_h Host char(60) binary DEFAULT '' NOT NULL,"
c_h="$c_h Db char(64) binary DEFAULT '' NOT NULL,"
- c_h="$c_h Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_h="$c_h Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_h="$c_h Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_h="$c_h Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_h="$c_h Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_h="$c_h Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_h="$c_h Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_h="$c_h References_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_h="$c_h Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_h="$c_h Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_h="$c_h Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_h="$c_h Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
+ c_h="$c_h Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_h="$c_h Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_h="$c_h Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_h="$c_h Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_h="$c_h Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_h="$c_h Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_h="$c_h Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_h="$c_h References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_h="$c_h Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_h="$c_h Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_h="$c_h Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_h="$c_h Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
c_h="$c_h PRIMARY KEY Host (Host,Db)"
c_h="$c_h ) engine=MyISAM"
c_h="$c_h CHARACTER SET utf8 COLLATE utf8_bin"
@@ -113,28 +113,28 @@ then
c_u="$c_u Host char(60) binary DEFAULT '' NOT NULL,"
c_u="$c_u User char(16) binary DEFAULT '' NOT NULL,"
c_u="$c_u Password char(41) binary DEFAULT '' NOT NULL,"
- c_u="$c_u Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Reload_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Shutdown_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Process_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u File_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u References_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Show_db_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Super_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Execute_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Repl_slave_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Repl_client_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u ssl_type enum('','ANY','X509', 'SPECIFIED') DEFAULT '' NOT NULL,"
+ c_u="$c_u Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_u="$c_u Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_u="$c_u Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_u="$c_u Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_u="$c_u Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_u="$c_u Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_u="$c_u Reload_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_u="$c_u Shutdown_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_u="$c_u Process_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_u="$c_u File_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_u="$c_u Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_u="$c_u References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_u="$c_u Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_u="$c_u Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_u="$c_u Show_db_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_u="$c_u Super_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_u="$c_u Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_u="$c_u Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_u="$c_u Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_u="$c_u Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_u="$c_u Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
+ c_u="$c_u ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci DEFAULT '' NOT NULL,"
c_u="$c_u ssl_cipher BLOB NOT NULL,"
c_u="$c_u x509_issuer BLOB NOT NULL,"
c_u="$c_u x509_subject BLOB NOT NULL,"
@@ -178,7 +178,7 @@ then
c_f="$c_f name char(64) binary DEFAULT '' NOT NULL,"
c_f="$c_f ret tinyint(1) DEFAULT '0' NOT NULL,"
c_f="$c_f dl char(128) DEFAULT '' NOT NULL,"
- c_f="$c_f type enum ('function','aggregate') NOT NULL,"
+ c_f="$c_f type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL,"
c_f="$c_f PRIMARY KEY (name)"
c_f="$c_f ) engine=MyISAM"
c_f="$c_f CHARACTER SET utf8 COLLATE utf8_bin"
@@ -198,8 +198,8 @@ then
c_t="$c_t Table_name char(64) binary DEFAULT '' NOT NULL,"
c_t="$c_t Grantor char(77) DEFAULT '' NOT NULL,"
c_t="$c_t Timestamp timestamp(14),"
- c_t="$c_t Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') DEFAULT '' NOT NULL,"
- c_t="$c_t Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL,"
+ c_t="$c_t Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') COLLATE utf8_general_ci DEFAULT '' NOT NULL,"
+ c_t="$c_t Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL,"
c_t="$c_t PRIMARY KEY (Host,Db,User,Table_name),"
c_t="$c_t KEY Grantor (Grantor)"
c_t="$c_t ) engine=MyISAM"
@@ -220,7 +220,7 @@ then
c_c="$c_c Table_name char(64) binary DEFAULT '' NOT NULL,"
c_c="$c_c Column_name char(64) binary DEFAULT '' NOT NULL,"
c_c="$c_c Timestamp timestamp(14),"
- c_c="$c_c Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL,"
+ c_c="$c_c Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL,"
c_c="$c_c PRIMARY KEY (Host,Db,User,Table_name,Column_name)"
c_c="$c_c ) engine=MyISAM"
c_c="$c_c CHARACTER SET utf8 COLLATE utf8_bin"
@@ -328,7 +328,7 @@ then
c_tz="$c_tz CREATE TABLE time_zone ("
c_tz="$c_tz Time_zone_id int unsigned NOT NULL auto_increment,"
- c_tz="$c_tz Use_leap_seconds enum('Y','N') DEFAULT 'N' NOT NULL,"
+ c_tz="$c_tz Use_leap_seconds enum('Y','N') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,"
c_tz="$c_tz PRIMARY KEY TzId (Time_zone_id)"
c_tz="$c_tz ) engine=MyISAM CHARACTER SET utf8"
c_tz="$c_tz comment='Time zones';"
diff --git a/scripts/mysql_fix_privilege_tables.sql b/scripts/mysql_fix_privilege_tables.sql
index 536b263f7bd..8f398689bd9 100644
--- a/scripts/mysql_fix_privilege_tables.sql
+++ b/scripts/mysql_fix_privilege_tables.sql
@@ -9,54 +9,23 @@
-- this sql script.
-- On windows you should do 'mysql --force mysql < mysql_fix_privilege_tables.sql'
--- Convert all tables to UTF-8 with binary collation
--- and reset all char columns to correct width
-ALTER TABLE user
- MODIFY Host char(60) NOT NULL default '',
- MODIFY User char(16) NOT NULL default '',
- MODIFY Password char(41) NOT NULL default '',
- ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
-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 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 func
- ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
-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;
-ALTER TABLE tables_priv
- MODIFY Host char(60) NOT NULL default '',
- MODIFY Db char(64) NOT NULL default '',
- MODIFY User char(16) NOT NULL default '',
- MODIFY Table_name char(64) NOT NULL default '',
- MODIFY Grantor char(77) NOT NULL default '',
- ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
-ALTER TABLE user add File_priv enum('N','Y') NOT NULL;
CREATE TABLE IF NOT EXISTS func (
name char(64) binary DEFAULT '' NOT NULL,
ret tinyint(1) DEFAULT '0' NOT NULL,
dl char(128) DEFAULT '' NOT NULL,
- type enum ('function','aggregate') NOT NULL,
+ type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY (name)
) CHARACTER SET utf8 COLLATE utf8_bin;
+ALTER TABLE user add File_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL;
+
-- Detect whether or not we had the Grant_priv column
SET @hadGrantPriv:=0;
SELECT @hadGrantPriv:=1 FROM user WHERE Grant_priv LIKE '%';
-ALTER TABLE user add Grant_priv enum('N','Y') NOT NULL,add References_priv enum('N','Y') NOT NULL,add Index_priv enum('N','Y') NOT NULL,add Alter_priv enum('N','Y') NOT NULL;
-ALTER TABLE host add Grant_priv enum('N','Y') NOT NULL,add References_priv enum('N','Y') NOT NULL,add Index_priv enum('N','Y') NOT NULL,add Alter_priv enum('N','Y') NOT NULL;
-ALTER TABLE db add Grant_priv enum('N','Y') NOT NULL,add References_priv enum('N','Y') NOT NULL,add Index_priv enum('N','Y') NOT NULL,add Alter_priv enum('N','Y') NOT NULL;
+ALTER TABLE user add Grant_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add References_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Index_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Alter_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL;
+ALTER TABLE host add Grant_priv enum('N','Y') NOT NULL,add References_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Index_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Alter_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL;
+ALTER TABLE db add Grant_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add References_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Index_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Alter_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL;
--- Fix privileges for old tables
UPDATE user SET Grant_priv=File_priv,References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0;
@@ -68,7 +37,7 @@ UPDATE host SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Cr
-- Adding columns needed by GRANT .. REQUIRE (openssl)"
ALTER TABLE user
-ADD ssl_type enum('','ANY','X509', 'SPECIFIED') NOT NULL,
+ADD ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci NOT NULL,
ADD ssl_cipher BLOB NOT NULL,
ADD x509_issuer BLOB NOT NULL,
ADD x509_subject BLOB NOT NULL;
@@ -85,10 +54,14 @@ CREATE TABLE IF NOT EXISTS tables_priv (
Table_name char(64) binary DEFAULT '' NOT NULL,
Grantor char(77) DEFAULT '' NOT NULL,
Timestamp timestamp(14),
- Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') DEFAULT '' NOT NULL,
- Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL,
+ Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') COLLATE utf8_general_ci DEFAULT '' NOT NULL,
+ Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL,
PRIMARY KEY (Host,Db,User,Table_name)
) CHARACTER SET utf8 COLLATE utf8_bin;
+-- Fix collation of set fields
+ALTER TABLE tables_priv
+ modify Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') COLLATE utf8_general_ci DEFAULT '' NOT NULL,
+ modify Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL;
CREATE TABLE IF NOT EXISTS columns_priv (
Host char(60) DEFAULT '' NOT NULL,
@@ -97,22 +70,25 @@ CREATE TABLE IF NOT EXISTS columns_priv (
Table_name char(60) DEFAULT '' NOT NULL,
Column_name char(59) DEFAULT '' NOT NULL,
Timestamp timestamp(14),
- Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL,
+ Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL,
PRIMARY KEY (Host,Db,User,Table_name,Column_name)
) CHARACTER SET utf8 COLLATE utf8_bin;
+-- Fix collation of set fields
+ALTER TABLE columns_priv
+ MODIFY Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL;
--
-- Name change of Type -> Column_priv from MySQL 3.22.12
--
-ALTER TABLE columns_priv change Type Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL;
+ALTER TABLE columns_priv change Type Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL;
--
-- Add the new 'type' column to the func table.
--
-ALTER TABLE func add type enum ('function','aggregate') NOT NULL;
+ALTER TABLE func add type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL;
--
-- Change the user,db and host tables to MySQL 4.0 format
@@ -123,13 +99,13 @@ SET @hadShowDbPriv:=0;
SELECT @hadShowDbPriv:=1 FROM user WHERE Show_db_priv LIKE '%';
ALTER TABLE user
-ADD Show_db_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Alter_priv,
-ADD Super_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Show_db_priv,
-ADD Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Super_priv,
-ADD Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Create_tmp_table_priv,
-ADD Execute_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Lock_tables_priv,
-ADD Repl_slave_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Execute_priv,
-ADD Repl_client_priv enum('N','Y') DEFAULT 'N' NOT NULL AFTER Repl_slave_priv;
+ADD Show_db_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_priv,
+ADD Super_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_db_priv,
+ADD Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Super_priv,
+ADD Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_tmp_table_priv,
+ADD Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv,
+ADD Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Execute_priv,
+ADD Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Repl_slave_priv;
-- Convert privileges so that users have similar privileges as before
@@ -150,11 +126,11 @@ ADD max_connections int(11) unsigned NOT NULL AFTER max_updates;
--
ALTER TABLE db
-ADD Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,
-ADD Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL;
+ADD Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ADD Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
ALTER TABLE host
-ADD Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,
-ADD Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL;
+ADD Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ADD Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
alter table db change Db Db char(64) binary DEFAULT '' NOT NULL;
alter table host change Db Db char(64) binary DEFAULT '' NOT NULL;
@@ -170,6 +146,95 @@ alter table func comment='User defined functions';
alter table tables_priv comment='Table privileges';
alter table columns_priv comment='Column privileges';
+-- Convert all tables to UTF-8 with binary collation
+-- and reset all char columns to correct width
+ALTER TABLE user
+ MODIFY Host char(60) NOT NULL default '',
+ MODIFY User char(16) NOT NULL default '',
+ MODIFY Password char(41) NOT NULL default '',
+ ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
+ALTER TABLE user
+ MODIFY Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Reload_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Shutdown_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Process_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY File_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Show_db_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Super_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci DEFAULT '' NOT NULL;
+ALTER TABLE db
+ MODIFY Host char(60) NOT NULL default '',
+ MODIFY Db char(64) NOT NULL default '',
+ MODIFY User char(16) NOT NULL default '',
+ ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
+ALTER TABLE db
+ MODIFY Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
+ALTER TABLE host
+ MODIFY Host char(60) NOT NULL default '',
+ MODIFY Db char(64) NOT NULL default '',
+ ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
+ALTER TABLE host
+ MODIFY Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
+ MODIFY Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
+ALTER TABLE func
+ ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
+ALTER TABLE func
+ MODIFY type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL;
+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;
+ALTER TABLE columns_priv
+ MODIFY Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL;
+ALTER TABLE tables_priv
+ MODIFY Host char(60) NOT NULL default '',
+ MODIFY Db char(64) NOT NULL default '',
+ MODIFY User char(16) NOT NULL default '',
+ MODIFY Table_name char(64) NOT NULL default '',
+ MODIFY Grantor char(77) NOT NULL default '',
+ ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
+ALTER TABLE tables_priv
+ MODIFY Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') COLLATE utf8_general_ci DEFAULT '' NOT NULL,
+ MODIFY Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL;
+
#
# Create some possible missing tables
#
@@ -217,9 +282,12 @@ PRIMARY KEY Name (Name)
CREATE TABLE IF NOT EXISTS time_zone (
Time_zone_id int unsigned NOT NULL auto_increment,
-Use_leap_seconds enum('Y','N') DEFAULT 'N' NOT NULL,
+Use_leap_seconds enum('Y','N') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
PRIMARY KEY TzId (Time_zone_id)
) CHARACTER SET utf8 comment='Time zones';
+-- Make enum field case-insensitive
+ALTER TABLE time_zone
+ MODIFY Use_leap_seconds enum('Y','N') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
CREATE TABLE IF NOT EXISTS time_zone_transition (
Time_zone_id int unsigned NOT NULL,
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 6218bc49f53..f851e36dcad 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -750,7 +750,7 @@ bool close_temporary_table(THD *thd, const char *db, const char *table_name);
void close_temporary(TABLE *table, bool delete_table=1);
bool rename_temporary_table(THD* thd, TABLE *table, const char *new_db,
const char *table_name);
-void remove_db_from_cache(const my_string db);
+void remove_db_from_cache(const char *db);
void flush_tables();
bool remove_table_from_cache(THD *thd, const char *db, const char *table,
bool return_if_owned_by_thd=0);
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 7c17a4ef275..f6b304406d5 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -139,6 +139,7 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
MYSQL_LOCK *lock;
my_bool return_val=1;
bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE;
+ char tmp_name[NAME_LEN+1];
DBUG_ENTER("acl_init");
@@ -197,6 +198,24 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
ACL_HOST host;
update_hostname(&host.host,get_field(&mem, table->field[0]));
host.db= get_field(&mem, table->field[1]);
+ if (lower_case_table_names)
+ {
+ /*
+ We make a temporary copy of the database, force it to lower case,
+ and then copy it back over the original name. We can't just update
+ the host.db pointer, because tmp_name is allocated on the stack.
+ */
+ (void)strmov(tmp_name, host.db);
+ my_casedn_str(files_charset_info, tmp_name);
+ if (strcmp(host.db, tmp_name) != 0)
+ {
+ sql_print_warning("'host' entry '%s|%s' had database in mixed "
+ "case that has been forced to lowercase because "
+ "lower_case_table_names is set.",
+ host.host.hostname, host.db);
+ (void)strmov(host.db, tmp_name);
+ }
+ }
host.access= get_access(table,2);
host.access= fix_rights_for_db(host.access);
host.sort= get_sort(2,host.host.hostname,host.db);
@@ -380,6 +399,24 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
}
db.access=get_access(table,3);
db.access=fix_rights_for_db(db.access);
+ if (lower_case_table_names)
+ {
+ /*
+ We make a temporary copy of the database, force it to lower case,
+ and then copy it back over the original name. We can't just update
+ the db.db pointer, because tmp_name is allocated on the stack.
+ */
+ (void)strmov(tmp_name, db.db);
+ my_casedn_str(files_charset_info, tmp_name);
+ if (strcmp(db.db, tmp_name) != 0)
+ {
+ sql_print_warning("'db' entry '%s %s@%s' had database in mixed "
+ "case that has been forced to lowercase because "
+ "lower_case_table_names is set.",
+ db.db, db.user, db.host.hostname, db.host.hostname);
+ (void)strmov(db.db, tmp_name);
+ }
+ }
db.sort=get_sort(3,db.host.hostname,db.db,db.user);
#ifndef TO_BE_REMOVED
if (table->fields <= 9)
@@ -1339,7 +1376,7 @@ bool hostname_requires_resolving(const char *hostname)
return FALSE;
for (; (cur=*hostname); hostname++)
{
- if ((cur != '%') && (cur != '_') && (cur != '.') &&
+ if ((cur != '%') && (cur != '_') && (cur != '.') && (cur != '/') &&
((cur < '0') || (cur > '9')))
return TRUE;
}
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 7434897ab90..8d694c48849 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -2868,8 +2868,18 @@ static void mysql_rm_tmp_tables(void)
** and afterwards delete those marked unused.
*/
-void remove_db_from_cache(const my_string db)
+void remove_db_from_cache(const char *db)
{
+ char name_buff[NAME_LEN+1];
+ if (db && lower_case_table_names)
+ {
+ /*
+ convert database to lower case for comparision.
+ */
+ strmake(name_buff, db, sizeof(name_buff)-1);
+ my_casedn_str(files_charset_info, name_buff);
+ db= name_buff;
+ }
for (uint idx=0 ; idx < open_cache.records ; idx++)
{
TABLE *table=(TABLE*) hash_element(&open_cache,idx);
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index ed974a48ad3..d6dcd9ce9ae 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -295,7 +295,18 @@ static char *get_text(LEX *lex)
found_escape=1;
if (lex->ptr == lex->end_of_query)
return 0;
- yySkip();
+#ifdef USE_MB
+ int l;
+ if (use_mb(cs) &&
+ (l = my_ismbchar(cs,
+ (const char *)lex->ptr,
+ (const char *)lex->end_of_query))) {
+ lex->ptr += l;
+ continue;
+ }
+ else
+#endif
+ yySkip();
}
else if (c == sep)
{
@@ -323,6 +334,10 @@ static char *get_text(LEX *lex)
else
{
uchar *to;
+
+ /* Re-use found_escape for tracking state of escapes */
+ found_escape= 0;
+
for (to=start ; str != end ; str++)
{
#ifdef USE_MB
@@ -336,7 +351,7 @@ static char *get_text(LEX *lex)
continue;
}
#endif
- if (*str == '\\' && str+1 != end)
+ if (!found_escape && *str == '\\' && str+1 != end)
{
switch(*++str) {
case 'n':
@@ -362,15 +377,20 @@ static char *get_text(LEX *lex)
*to++= '\\'; // remember prefix for wildcard
/* Fall through */
default:
- *to++ = *str;
+ found_escape= 1;
+ str--;
break;
}
}
- else if (*str == sep)
- *to++= *str++; // Two ' or "
+ else if (!found_escape && *str == sep)
+ {
+ found_escape= 1;
+ }
else
+ {
*to++ = *str;
-
+ found_escape= 0;
+ }
}
*to=0;
lex->yytoklen=(uint) (to-start);
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 14b3ddbf8b2..3974bacc2eb 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -11606,6 +11606,54 @@ static void test_bug7990()
/*
+ Test mysql_real_escape_string() with gbk charset
+
+ The important part is that 0x27 (') is the second-byte in a invalid
+ two-byte GBK character here. But 0xbf5c is a valid GBK character, so
+ it needs to be escaped as 0x5cbf27
+*/
+#define TEST_BUG8378_IN "\xef\xbb\xbf\x27\xbf\x10"
+#define TEST_BUG8378_OUT "\xef\xbb\x5c\xbf\x5c\x27\x5c\xbf\x10"
+
+static void test_bug8378()
+{
+ MYSQL *lmysql;
+ char out[9]; /* strlen(TEST_BUG8378)*2+1 */
+ int len;
+
+ myheader("test_bug8378");
+
+ if (!opt_silent)
+ fprintf(stdout, "\n Establishing a test connection ...");
+ if (!(lmysql= mysql_init(NULL)))
+ {
+ myerror("mysql_init() failed");
+ exit(1);
+ }
+ if (mysql_options(lmysql, MYSQL_SET_CHARSET_NAME, "gbk"))
+ {
+ myerror("mysql_options() failed");
+ exit(1);
+ }
+ if (!(mysql_real_connect(lmysql, opt_host, opt_user,
+ opt_password, current_db, opt_port,
+ opt_unix_socket, 0)))
+ {
+ myerror("connection failed");
+ exit(1);
+ }
+ if (!opt_silent)
+ fprintf(stdout, " OK");
+
+ len= mysql_real_escape_string(lmysql, out, TEST_BUG8378_IN, 4);
+
+ /* No escaping should have actually happened. */
+ DIE_UNLESS(memcmp(out, TEST_BUG8378_OUT, len) == 0);
+
+ mysql_close(lmysql);
+}
+
+/*
Read and parse arguments and MySQL options from my.cnf
*/
@@ -11814,6 +11862,7 @@ static struct my_tests_st my_tests[]= {
{ "test_bug6761", test_bug6761 },
{ "test_bug8330", test_bug8330 },
{ "test_bug7990", test_bug7990 },
+ { "test_bug8378", test_bug8378 },
{ 0, 0 }
};