!354 Fix bug of invalid username/password when "SET ROLE role_name PASSWORD 'passwd'" is used in loop.
Merge pull request !354 from Yuejia/master
This commit is contained in:
@ -2217,7 +2217,8 @@ static int _SPI_execute_plan(SPIPlanPtr plan, ParamListInfo paramLI, Snapshot sn
|
||||
ClearCreateStmtUUIDS((CreateStmt *)stmt);
|
||||
}
|
||||
|
||||
if (IsA(stmt, CreateRoleStmt) || IsA(stmt, AlterRoleStmt)) {
|
||||
if (IsA(stmt, CreateRoleStmt) || IsA(stmt, AlterRoleStmt) ||
|
||||
(IsA(stmt, VariableSetStmt) && ((VariableSetStmt *)stmt)->kind == VAR_SET_ROLEPWD)) {
|
||||
stmt = (Node *)copyObject(stmt);
|
||||
}
|
||||
|
||||
@ -2263,7 +2264,8 @@ static int _SPI_execute_plan(SPIPlanPtr plan, ParamListInfo paramLI, Snapshot sn
|
||||
res = SPI_OK_UTILITY;
|
||||
}
|
||||
|
||||
if (IsA(stmt, CreateRoleStmt) || IsA(stmt, AlterRoleStmt)) {
|
||||
if (IsA(stmt, CreateRoleStmt) || IsA(stmt, AlterRoleStmt) ||
|
||||
(IsA(stmt, VariableSetStmt) && ((VariableSetStmt *)stmt)->kind == VAR_SET_ROLEPWD)) {
|
||||
pfree_ext(stmt);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,15 @@
|
||||
create role test_myrole001 with password "ttest@123";
|
||||
create role test_myrole002 with sysadmin password "ttest@123";
|
||||
-- test "SET ROLE role_name PASSWORD 'passwd'" in loop
|
||||
BEGIN
|
||||
FOR i in 1..5 LOOP
|
||||
SET ROLE test_myrole001 PASSWORD 'ttest@123';
|
||||
RESET ROLE;
|
||||
SET ROLE test_myrole002 PASSWORD 'ttest@123';
|
||||
RESET ROLE;
|
||||
END LOOP;
|
||||
END;
|
||||
/
|
||||
set role test_myrole001 password "ttest@123";
|
||||
alter role test_myrole002 SET maintenance_work_mem = 100000;
|
||||
ERROR: Permission denied.
|
||||
|
@ -1,6 +1,17 @@
|
||||
create role test_myrole001 with password "ttest@123";
|
||||
create role test_myrole002 with sysadmin password "ttest@123";
|
||||
|
||||
-- test "SET ROLE role_name PASSWORD 'passwd'" in loop
|
||||
BEGIN
|
||||
FOR i in 1..5 LOOP
|
||||
SET ROLE test_myrole001 PASSWORD 'ttest@123';
|
||||
RESET ROLE;
|
||||
SET ROLE test_myrole002 PASSWORD 'ttest@123';
|
||||
RESET ROLE;
|
||||
END LOOP;
|
||||
END;
|
||||
/
|
||||
|
||||
set role test_myrole001 password "ttest@123";
|
||||
alter role test_myrole002 SET maintenance_work_mem = 100000;
|
||||
alter role test_myrole002 rename to temp_myrole;
|
||||
|
Reference in New Issue
Block a user