From 353ed2248a33e2c9b623ec367743590b67b032cc Mon Sep 17 00:00:00 2001 From: totaj Date: Mon, 9 Jan 2023 16:16:01 +0800 Subject: [PATCH] Fix alter role core. --- src/common/backend/utils/error/elog.cpp | 4 +++- src/test/regress/expected/hw_test_operate_user.out | 10 ++++++++++ src/test/regress/sql/hw_test_operate_user.sql | 4 ++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/common/backend/utils/error/elog.cpp b/src/common/backend/utils/error/elog.cpp index 989e071713..6fe7f4c5c9 100644 --- a/src/common/backend/utils/error/elog.cpp +++ b/src/common/backend/utils/error/elog.cpp @@ -4517,6 +4517,8 @@ static char* mask_Password_internal(const char* query_string) if (query_string[position[i] + length[i] - 1] == ';') { length[i]--; } + curStmtType = 0; + isPassword = false; } /* @@ -4546,7 +4548,7 @@ static char* mask_Password_internal(const char* query_string) char* maskBegin = mask_string + (position[i] - truncateLen); int copySize = strlen(mask_string) - (position[i] - truncateLen) - length[i] + 1; - if (copySize > 0) { + if ((position[i] - truncateLen) >= 0 && copySize > 0) { rc = memmove_s(maskBegin + maskLen, copySize, maskBegin + length[i], copySize); securec_check(rc, "", ""); rc = memset_s(maskBegin, maskLen, '*', maskLen); diff --git a/src/test/regress/expected/hw_test_operate_user.out b/src/test/regress/expected/hw_test_operate_user.out index af250f02bf..ca0c8f5ffd 100644 --- a/src/test/regress/expected/hw_test_operate_user.out +++ b/src/test/regress/expected/hw_test_operate_user.out @@ -18,3 +18,13 @@ ERROR: Permission denied. reset role; drop role test_myrole001; drop role test_myrole002; +alter user u1 identified by aswd3456 replace dfg1637484kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkklll; +ERROR: Password must be quoted +alter user u1 ACCOUNT LOCK PASSWORD EXPIRE NEVER PASSWORD EXPIRE NEVER ACCOUNT UNLOCK ACCOUNT UNLOCK ACCOUNT UNLOCK ACCOUNT UNLOCK; +ERROR: syntax error at or near "PASSWORD" +LINE 1: alter user u1 ACCOUNT LOCK PASSWORD EXPIRE NEVER ... + ^ +alter user u1 lock password expir never lock password expire never lock password expire never lock; +ERROR: syntax error at or near "lock" +LINE 1: alter user u1 lock password expir never lock password expire... + ^ diff --git a/src/test/regress/sql/hw_test_operate_user.sql b/src/test/regress/sql/hw_test_operate_user.sql index 10a167d789..b1a106925b 100644 --- a/src/test/regress/sql/hw_test_operate_user.sql +++ b/src/test/regress/sql/hw_test_operate_user.sql @@ -18,3 +18,7 @@ alter role test_myrole002 rename to temp_myrole; reset role; drop role test_myrole001; drop role test_myrole002; + +alter user u1 identified by aswd3456 replace dfg1637484kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkklll; +alter user u1 ACCOUNT LOCK PASSWORD EXPIRE NEVER PASSWORD EXPIRE NEVER ACCOUNT UNLOCK ACCOUNT UNLOCK ACCOUNT UNLOCK ACCOUNT UNLOCK; +alter user u1 lock password expir never lock password expire never lock password expire never lock; \ No newline at end of file -- Gitee