diff --git a/src/gausskernel/runtime/executor/spi.cpp b/src/gausskernel/runtime/executor/spi.cpp index 5a07e6c09..f1cd85378 100755 --- a/src/gausskernel/runtime/executor/spi.cpp +++ b/src/gausskernel/runtime/executor/spi.cpp @@ -2338,7 +2338,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); } @@ -2374,7 +2375,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); } } diff --git a/src/test/regress/expected/hw_test_operate_user.out b/src/test/regress/expected/hw_test_operate_user.out index 65d744b12..af250f02b 100644 --- a/src/test/regress/expected/hw_test_operate_user.out +++ b/src/test/regress/expected/hw_test_operate_user.out @@ -1,5 +1,15 @@ create role test_myrole001 with password "gauss@123"; create role test_myrole002 with sysadmin password "gauss@123"; +-- test "SET ROLE role_name PASSWORD 'passwd'" in loop +BEGIN + FOR i in 1..5 LOOP + SET ROLE test_myrole001 PASSWORD 'gauss@123'; + RESET ROLE; + SET ROLE test_myrole002 PASSWORD 'gauss@123'; + RESET ROLE; + END LOOP; +END; +/ set role test_myrole001 password "gauss@123"; alter role test_myrole002 SET maintenance_work_mem = 100000; ERROR: Permission denied. diff --git a/src/test/regress/sql/hw_test_operate_user.sql b/src/test/regress/sql/hw_test_operate_user.sql index 99f3a69e1..10a167d78 100644 --- a/src/test/regress/sql/hw_test_operate_user.sql +++ b/src/test/regress/sql/hw_test_operate_user.sql @@ -1,6 +1,17 @@ create role test_myrole001 with password "gauss@123"; create role test_myrole002 with sysadmin password "gauss@123"; +-- test "SET ROLE role_name PASSWORD 'passwd'" in loop +BEGIN + FOR i in 1..5 LOOP + SET ROLE test_myrole001 PASSWORD 'gauss@123'; + RESET ROLE; + SET ROLE test_myrole002 PASSWORD 'gauss@123'; + RESET ROLE; + END LOOP; +END; +/ + set role test_myrole001 password "gauss@123"; alter role test_myrole002 SET maintenance_work_mem = 100000; alter role test_myrole002 rename to temp_myrole;