解决user@host中当用户名过长时的报错信息与mysql报错信息不一致的问题
This commit is contained in:
@ -1692,6 +1692,9 @@ UserId:
|
||||
ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("syntax error at or near \"%s\"", $1), parser_errposition(@1)));
|
||||
if (strchr($1,'@'))
|
||||
ereport(ERROR,(errcode(ERRCODE_INVALID_NAME),errmsg("@ can't be allowed in username")));
|
||||
if (strlen($1) >= NAMEDATALEN) {
|
||||
ereport(ERROR,(errcode(ERRCODE_INVALID_NAME),errmsg("String %s is too long for user name (should be no longer than 64)", $1)));
|
||||
}
|
||||
$$ = $1;
|
||||
}
|
||||
| RoleId SET_USER_IDENT
|
||||
@ -31352,6 +31355,9 @@ static char* GetValidUserHostId(char* userName, char* hostId)
|
||||
appendStringInfoString(&buf, userName);
|
||||
appendStringInfoString(&buf, "@");
|
||||
appendStringInfoString(&buf, userHostId);
|
||||
if (strlen(buf.data) >= NAMEDATALEN) {
|
||||
ereport(ERROR,(errcode(ERRCODE_INVALID_NAME),errmsg("String %s is too long for user name (should be no longer than 64)", buf.data)));
|
||||
}
|
||||
return buf.data;
|
||||
}
|
||||
|
||||
|
||||
@ -17,6 +17,9 @@ create user 'test_user_host'@'127.0.%' password 'test123@';
|
||||
create user 'test_user_host%' password 'test123@';
|
||||
create user 'test_user_host'@'127.0.0.1' password 'test123@';
|
||||
set b_compatibility_user_host_auth = on;
|
||||
CREATE USER 'sssssssssssssskkdcjhshfedrfbberfheurfhefhhdfjdfhkdfjshdfk vjhsdkfuhc'@'%' PASSWORD 'test123@';
|
||||
CREATE USER 'sssssssssssssskkdcjhshfedrfbberfheurfhefhhdfjdfhkdfjshdfk vjhsdkfuhc' PASSWORD 'test123@';
|
||||
CREATE USER sssssssssssssskkdcjhshfedrfbberfheurfhefhhdfjdfhkdfjshdfkvjhsdkfu@127.0.0.1 PASSWORD 'test123@';
|
||||
CREATE USER 'da@localhost'@'%' PASSWORD 'test123@';
|
||||
create user if not exists 'test_user_host'@'%' password 'test123@';
|
||||
alter user 'test_user_host'@'%' with account lock;
|
||||
|
||||
@ -48,6 +48,13 @@ LINE 1: create user 'test_user_host%' password 'test123@';
|
||||
create user 'test_user_host'@'127.0.0.1' password 'test123@';
|
||||
ERROR: user@host is only supported in b database when the b_compatibility_user_host_auth is on
|
||||
set b_compatibility_user_host_auth = on;
|
||||
CREATE USER 'sssssssssssssskkdcjhshfedrfbberfheurfhefhhdfjdfhkdfjshdfk vjhsdkfuhc'@'%' PASSWORD 'test123@';
|
||||
ERROR: String sssssssssssssskkdcjhshfedrfbberfheurfhefhhdfjdfhkdfjshdfk vjhsdkfuhc@% is too long for user name (should be no longer than 64)
|
||||
CREATE USER 'sssssssssssssskkdcjhshfedrfbberfheurfhefhhdfjdfhkdfjshdfk vjhsdkfuhc' PASSWORD 'test123@';
|
||||
ERROR: String sssssssssssssskkdcjhshfedrfbberfheurfhefhhdfjdfhkdfjshdfk vjhsdkfuhc is too long for user name (should be no longer than 64)
|
||||
CREATE USER sssssssssssssskkdcjhshfedrfbberfheurfhefhhdfjdfhkdfjshdfkvjhsdkfu@127.0.0.1 PASSWORD 'test123@';
|
||||
NOTICE: identifier "sssssssssssssskkdcjhshfedrfbberfheurfhefhhdfjdfhkdfjshdfkvjhsdkfu" will be truncated to "sssssssssssssskkdcjhshfedrfbberfheurfhefhhdfjdfhkdfjshdfkvjhsdk"
|
||||
ERROR: String sssssssssssssskkdcjhshfedrfbberfheurfhefhhdfjdfhkdfjshdfkvjhsdk@127.0.0.1 is too long for user name (should be no longer than 64)
|
||||
CREATE USER 'da@localhost'@'%' PASSWORD 'test123@';
|
||||
ERROR: @ can't be allowed in username
|
||||
create user if not exists 'test_user_host'@'%' password 'test123@';
|
||||
|
||||
Reference in New Issue
Block a user