Commit 3226b9fa authored by unknown's avatar unknown

Bug #3403 Wrong encoding in SHOW GRANTS, EPLAIN SELECT output

This change fixes SHOW GRANTS problem, while EXPLAIN will be fixed
in a separate patch.

parent 6f0946d6
......@@ -204,3 +204,27 @@ show grants for mysqltest_1@localhost;
Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19'
drop user mysqltest_1@localhost;
SET NAMES koi8r;
CREATE DATABASE ;
USE ;
CREATE TABLE ( int);
GRANT SELECT ON .* TO @localhost;
SHOW GRANTS FOR @localhost;
Grants for @localhost
GRANT USAGE ON *.* TO ''@'localhost'
GRANT SELECT ON ``.* TO ''@'localhost'
REVOKE SELECT ON .* FROM @localhost;
GRANT SELECT ON . TO @localhost;
SHOW GRANTS FOR @localhost;
Grants for @localhost
GRANT USAGE ON *.* TO ''@'localhost'
GRANT SELECT ON ``.`` TO ''@'localhost'
REVOKE SELECT ON . FROM @localhost;
GRANT SELECT () ON . TO @localhost;
SHOW GRANTS FOR @localhost;
Grants for @localhost
GRANT USAGE ON *.* TO ''@'localhost'
GRANT SELECT () ON ``.`` TO ''@'localhost'
REVOKE SELECT () ON . FROM @localhost;
DROP DATABASE ;
SET NAMES latin1;
......@@ -148,3 +148,26 @@ grant usage on *.* to mysqltest_1@localhost identified by "password";
grant select, update, insert on test.* to mysqltest@localhost;
show grants for mysqltest_1@localhost;
drop user mysqltest_1@localhost;
#
# Bug #3403 Wrong encodin in SHOW GRANTS output
#
SET NAMES koi8r;
CREATE DATABASE ;
USE ;
CREATE TABLE ( int);
GRANT SELECT ON .* TO @localhost;
SHOW GRANTS FOR @localhost;
REVOKE SELECT ON .* FROM @localhost;
GRANT SELECT ON . TO @localhost;
SHOW GRANTS FOR @localhost;
REVOKE SELECT ON . FROM @localhost;
GRANT SELECT () ON . TO @localhost;
SHOW GRANTS FOR @localhost;
REVOKE SELECT () ON . FROM @localhost;
DROP DATABASE ;
SET NAMES latin1;
......@@ -3064,7 +3064,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
/* Add first global access grants */
{
String global(buff,sizeof(buff),&my_charset_latin1);
String global(buff,sizeof(buff),system_charset_info);
global.length(0);
global.append("GRANT ",6);
......@@ -3089,7 +3089,8 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
}
}
global.append (" ON *.* TO '",12);
global.append(lex_user->user.str,lex_user->user.length);
global.append(lex_user->user.str, lex_user->user.length,
system_charset_info);
global.append ("'@'",3);
global.append(lex_user->host.str,lex_user->host.length);
global.append ('\'');
......@@ -3177,7 +3178,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
want_access=acl_db->access;
if (want_access)
{
String db(buff,sizeof(buff),&my_charset_latin1);
String db(buff,sizeof(buff),system_charset_info);
db.length(0);
db.append("GRANT ",6);
......@@ -3203,7 +3204,8 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
db.append (" ON ",4);
append_identifier(thd, &db, acl_db->db, strlen(acl_db->db));
db.append (".* TO '",7);
db.append(lex_user->user.str,lex_user->user.length);
db.append(lex_user->user.str, lex_user->user.length,
system_charset_info);
db.append ("'@'",3);
db.append(lex_user->host.str, lex_user->host.length);
db.append ('\'');
......@@ -3237,7 +3239,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
ulong table_access= grant_table->privs;
if ((table_access | grant_table->cols) != 0)
{
String global(buff,sizeof(buff),&my_charset_latin1);
String global(buff, sizeof(buff), system_charset_info);
ulong test_access= (table_access | grant_table->cols) & ~GRANT_ACL;
global.length(0);
......@@ -3291,7 +3293,8 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
else
global.append(", ",2);
global.append(grant_column->column,
grant_column->key_length);
grant_column->key_length,
system_charset_info);
}
}
if (found_col)
......@@ -3307,7 +3310,8 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
append_identifier(thd, &global, grant_table->tname,
strlen(grant_table->tname));
global.append(" TO '",5);
global.append(lex_user->user.str,lex_user->user.length);
global.append(lex_user->user.str, lex_user->user.length,
system_charset_info);
global.append("'@'",3);
global.append(lex_user->host.str,lex_user->host.length);
global.append('\'');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment