From a8c75f8830a9cde642a6022c69975eb4eb7ca7e7 Mon Sep 17 00:00:00 2001 From: l00584793 <1165977584@qq.com> Date: Wed, 30 Dec 2020 16:56:44 +0800 Subject: [PATCH] bug --- src/bin/gs_guc/cluster_guc.conf | 2 + src/bin/gs_guc/cluster_guc.cpp | 26 +++--- src/common/backend/utils/misc/guc.cpp | 6 +- .../backend/utils/misc/postgresql.conf.sample | 2 +- .../regress/expected/alarm_component_test.out | 6 ++ src/test/regress/input/enum_empty_test.source | 3 + src/test/regress/input/gs_guc.source | 5 +- .../input/unify_superuser_definition.source | 35 ++++++++ .../regress/output/enum_empty_test.source | 18 +++++ src/test/regress/output/gs_guc.source | 29 ++++++- .../output/hw_sec_account_lock_unlock.source | 14 ++-- .../output/unify_superuser_definition.source | 81 +++++++++++++++++++ src/test/regress/parallel_schedule10 | 5 +- src/test/regress/sql/alarm_component_test.sql | 1 + 14 files changed, 208 insertions(+), 25 deletions(-) create mode 100644 src/test/regress/expected/alarm_component_test.out create mode 100644 src/test/regress/input/enum_empty_test.source create mode 100644 src/test/regress/input/unify_superuser_definition.source create mode 100644 src/test/regress/output/enum_empty_test.source create mode 100644 src/test/regress/output/unify_superuser_definition.source create mode 100644 src/test/regress/sql/alarm_component_test.sql diff --git a/src/bin/gs_guc/cluster_guc.conf b/src/bin/gs_guc/cluster_guc.conf index 6d03319c0..57ac13454 100644 --- a/src/bin/gs_guc/cluster_guc.conf +++ b/src/bin/gs_guc/cluster_guc.conf @@ -505,6 +505,8 @@ stream_multiple|real|0,1.79769e+308|NULL|NULL| string_hash_compatible|bool|0,0|NULL|NULL| enable_slow_query_log|bool|0,0|NULL|NULL| support_batch_bind|bool|0,0|NULL|NULL| +enable_beta_opfusion|bool|0,0|NULL|NULL| +enable_beta_nestloop_fusion|bool|0,0|NULL|NULL| support_extended_features|bool|0,0|NULL|NULL| lastval_supported|bool|0,0|NULL|NULL| enable_beta_features|bool|0,0|NULL|NULL| diff --git a/src/bin/gs_guc/cluster_guc.cpp b/src/bin/gs_guc/cluster_guc.cpp index 8d9943e4b..c2cb1d867 100755 --- a/src/bin/gs_guc/cluster_guc.cpp +++ b/src/bin/gs_guc/cluster_guc.cpp @@ -4290,15 +4290,6 @@ int parse_double_value(const char* paraname, const char* value, const char* guc_ return SUCCESS; } -/************************************************************************************* - Function: check_enum_type_value - Desc : check the parameter value of enum type. - Input : paraname parameter name - guc_list_value the string from config file - value parameter value - Return : SUCCESS - FAILURE - *************************************************************************************/ int is_value_in_range(const char* guc_list_value, const char* value) { char* ptr = NULL; @@ -4322,6 +4313,17 @@ int is_value_in_range(const char* guc_list_value, const char* value) return FAILURE; } +/* + ************************************************************************************ + Function: check_enum_type_value + Desc : check the parameter value of enum type. + Input : paraname parameter name + guc_list_value the string from config file + value parameter value + Return : SUCCESS + FAILURE + ************************************************************************************ +*/ int check_enum_type_value(const char* paraname, char* guc_list_value, const char* value) { char guc_val[MAX_VALUE_LEN] = {0}; @@ -4345,7 +4347,11 @@ int check_enum_type_value(const char* paraname, char* guc_list_value, const char } make_string_tolower(value, tmp_paraname, sizeof(tmp_paraname) / sizeof(char)); - vptr = strtok_r(tmp_paraname, delims, &vouter_ptr); + if (tmp_paraname != NULL && strlen(tmp_paraname) > 0) { + vptr = strtok_r(tmp_paraname, delims, &vouter_ptr); + } else { + vptr = ""; + } while (NULL != vptr) { p = vptr; while (isspace((unsigned char)*p)) diff --git a/src/common/backend/utils/misc/guc.cpp b/src/common/backend/utils/misc/guc.cpp index d794be90a..bea043ab8 100644 --- a/src/common/backend/utils/misc/guc.cpp +++ b/src/common/backend/utils/misc/guc.cpp @@ -7845,7 +7845,7 @@ static void InitConfigureNamesString() NULL, GUC_SUPERUSER_ONLY}, &g_instance.attr.attr_common.Alarm_component, - "/opt/huawei/snas/bin/snas_cm_cmd", + "/opt/snas/bin/snas_cm_cmd", NULL, NULL, NULL}, @@ -14180,7 +14180,7 @@ char* GetConfigOptionByName(const char* name, const char** varname) ereport( ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("unrecognized configuration parameter \"%s\"", name))); - if ((record->flags & GUC_SUPERUSER_ONLY) && (GetUserId() != BOOTSTRAP_SUPERUSERID)) + if ((record->flags & GUC_SUPERUSER_ONLY) && !superuser()) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), errmsg("must be initial account to examine \"%s\"", name))); @@ -14207,7 +14207,7 @@ void GetConfigOptionByNum(int varnum, const char** values, bool* noshow) if (noshow != NULL) { if ((conf->flags & GUC_NO_SHOW_ALL) || - ((conf->flags & GUC_SUPERUSER_ONLY) && (GetUserId() != BOOTSTRAP_SUPERUSERID))) + ((conf->flags & GUC_SUPERUSER_ONLY) && !superuser())) *noshow = true; else *noshow = false; diff --git a/src/common/backend/utils/misc/postgresql.conf.sample b/src/common/backend/utils/misc/postgresql.conf.sample index a75587204..35aabe661 100755 --- a/src/common/backend/utils/misc/postgresql.conf.sample +++ b/src/common/backend/utils/misc/postgresql.conf.sample @@ -502,7 +502,7 @@ log_line_prefix = '%m %u %d %h %p %S ' # special values: enable_alarm = on connection_alarm_rate = 0.9 alarm_report_interval = 10 -alarm_component = '/opt/huawei/snas/bin/snas_cm_cmd' +alarm_component = '/opt/snas/bin/snas_cm_cmd' #------------------------------------------------------------------------------ # RUNTIME STATISTICS diff --git a/src/test/regress/expected/alarm_component_test.out b/src/test/regress/expected/alarm_component_test.out new file mode 100644 index 000000000..255f8e22d --- /dev/null +++ b/src/test/regress/expected/alarm_component_test.out @@ -0,0 +1,6 @@ +show alarm_component; + alarm_component +--------------------------- + /opt/snas/bin/snas_cm_cmd +(1 row) + diff --git a/src/test/regress/input/enum_empty_test.source b/src/test/regress/input/enum_empty_test.source new file mode 100644 index 000000000..a5f529b6a --- /dev/null +++ b/src/test/regress/input/enum_empty_test.source @@ -0,0 +1,3 @@ +\! @abs_bindir@/gs_guc set -D @abs_srcdir@/tmp_check/datanode1/ -c "wal_level=hot_standby" +\! @abs_bindir@/gs_guc set -D @abs_srcdir@/tmp_check/datanode1/ -c "wal_level=on" +\! @abs_bindir@/gs_guc set -D @abs_srcdir@/tmp_check/datanode1/ -c "wal_level=''" diff --git a/src/test/regress/input/gs_guc.source b/src/test/regress/input/gs_guc.source index 890d249e3..0a1a7b34c 100644 --- a/src/test/regress/input/gs_guc.source +++ b/src/test/regress/input/gs_guc.source @@ -6,5 +6,8 @@ -----Set(GUC) \! @abs_bindir@/gs_guc set -D @abs_srcdir@/tmp_check/datanode1/ -c "cstore_buffers=10GB" \! @abs_bindir@/gs_guc set -D @abs_srcdir@/tmp_check/datanode1/ -c "intervalstyle=a" +\! @abs_bindir@/gs_guc set -D @abs_srcdir@/tmp_check/datanode1/ -c "enable_beta_opfusion=on" +\! @abs_bindir@/gs_guc set -D @abs_srcdir@/tmp_check/datanode1/ -c "enable_beta_nestloop_fusion=on" -----Reload(GUC) -\! @abs_bindir@/gs_guc reload -D @abs_srcdir@/tmp_check/datanode1/ -c "cstore_buffers=10GB" \ No newline at end of file +\! @abs_bindir@/gs_guc reload -D @abs_srcdir@/tmp_check/datanode1/ -c "cstore_buffers=10GB" + diff --git a/src/test/regress/input/unify_superuser_definition.source b/src/test/regress/input/unify_superuser_definition.source new file mode 100644 index 000000000..d2d8e2e75 --- /dev/null +++ b/src/test/regress/input/unify_superuser_definition.source @@ -0,0 +1,35 @@ +create user grant_all with password 'openGauss@123'; +grant all privileges to grant_all; +create user standard_user with password 'openGauss@123'; + +-- sighup +\! @gsqldir@/gsql -d postgres -p @portstring@ -U grant_all -W openGauss@123 -c "show password_reuse_max;"; +\! @gsqldir@/gsql -d postgres -p @portstring@ -U grant_all -W openGauss@123 -c "alter system set password_reuse_max=1;"; +\! @gsqldir@/gsql -d postgres -p @portstring@ -U grant_all -W openGauss@123 -c "show password_reuse_max;"; +\! @gsqldir@/gsql -d postgres -p @portstring@ -U grant_all -W openGauss@123 -c "alter system set password_reuse_max=0;" + +\! @gsqldir@/gsql -d postgres -p @portstring@ -U standard_user -W openGauss@123 -c "show password_reuse_max;"; +\! @gsqldir@/gsql -d postgres -p @portstring@ -U standard_user -W openGauss@123 -c "alter system set password_reuse_max=1;"; +\! @gsqldir@/gsql -d postgres -p @portstring@ -U standard_user -W openGauss@123 -c "show password_reuse_max;"; +\! @gsqldir@/gsql -d postgres -p @portstring@ -U standard_user -W openGauss@123 -c "alter system set password_reuse_max=0;" + +show password_reuse_max; +alter system set password_reuse_max=1; +show password_reuse_max; +alter system set password_reuse_max=0; + +-- suset +\! @gsqldir@/gsql -d postgres -p @portstring@ -U grant_all -W openGauss@123 -c "show pljava_vmoptions;"; +\! @gsqldir@/gsql -d postgres -p @portstring@ -U grant_all -W openGauss@123 -c "set pljava_vmoptions='aaa';"; +\! @gsqldir@/gsql -d postgres -p @portstring@ -U grant_all -W openGauss@123 -c "show pljava_vmoptions;"; +\! @gsqldir@/gsql -d postgres -p @portstring@ -U grant_all -W openGauss@123 -c "set pljava_vmoptions='';" + +\! @gsqldir@/gsql -d postgres -p @portstring@ -U standard_user -W openGauss@123 -c "show pljava_vmoptions;"; +\! @gsqldir@/gsql -d postgres -p @portstring@ -U standard_user -W openGauss@123 -c "set pljava_vmoptions='aaa';"; +\! @gsqldir@/gsql -d postgres -p @portstring@ -U standard_user -W openGauss@123 -c "show pljava_vmoptions;"; +\! @gsqldir@/gsql -d postgres -p @portstring@ -U standard_user -W openGauss@123 -c "set pljava_vmoptions='';" + +show pljava_vmoptions; +set pljava_vmoptions='aaa'; +show pljava_vmoptions; +set pljava_vmoptions=''; diff --git a/src/test/regress/output/enum_empty_test.source b/src/test/regress/output/enum_empty_test.source new file mode 100644 index 000000000..50428ceef --- /dev/null +++ b/src/test/regress/output/enum_empty_test.source @@ -0,0 +1,18 @@ +\! @abs_bindir@/gs_guc set -D @abs_srcdir@/tmp_check/datanode1/ -c "wal_level=hot_standby" +NOTICE: If you need to copy the data stream for WAL log archiving and standby machine. You must be set to the parameter with archive or hot_standby. If this parameter is setted to archive. The hot_standby must be setted to off, otherwise it will cause the database can not be started, at the same time the max_wal_senders must be set at least 1. +expected instance path: [@abs_srcdir@/tmp_check/datanode1/postgresql.conf] +gs_guc set: wal_level=hot_standby: [@abs_srcdir@/tmp_check/datanode1/postgresql.conf] + +Total instances: 1. Failed instances: 0. +Success to perform gs_guc! + +\! @abs_bindir@/gs_guc set -D @abs_srcdir@/tmp_check/datanode1/ -c "wal_level=on" +NOTICE: If you need to copy the data stream for WAL log archiving and standby machine. You must be set to the parameter with archive or hot_standby. If this parameter is setted to archive. The hot_standby must be setted to off, otherwise it will cause the database can not be started, at the same time the max_wal_senders must be set at least 1. +ERROR: The value "on" is outside the valid range(minimal,archive,hot_standby,logical) for parameter "wal_level". +ERROR: The value "on" for parameter "wal_level" is incorrect. +Try "gs_guc --help" for more information. +\! @abs_bindir@/gs_guc set -D @abs_srcdir@/tmp_check/datanode1/ -c "wal_level=''" +NOTICE: If you need to copy the data stream for WAL log archiving and standby machine. You must be set to the parameter with archive or hot_standby. If this parameter is setted to archive. The hot_standby must be setted to off, otherwise it will cause the database can not be started, at the same time the max_wal_senders must be set at least 1. +ERROR: The value "" is outside the valid range(minimal,archive,hot_standby,logical) for parameter "wal_level". +ERROR: The value "''" for parameter "wal_level" is incorrect. +Try "gs_guc --help" for more information. diff --git a/src/test/regress/output/gs_guc.source b/src/test/regress/output/gs_guc.source index d7f15f682..9baa9a28a 100644 --- a/src/test/regress/output/gs_guc.source +++ b/src/test/regress/output/gs_guc.source @@ -90,6 +90,29 @@ gs_guc set: cstore_buffers=10GB: [@abs_srcdir@/tmp_check/datanode1/postgresql.co Total instances: 1. Failed instances: 0. Success to perform gs_guc! +\! @abs_bindir@/gs_guc set -D @abs_srcdir@/tmp_check/datanode1/ -c "enable_beta_opfusion=on" +expected instance path: [@abs_srcdir@/tmp_check/datanode1/postgresql.conf] +gs_guc set: enable_beta_opfusion=on: [@abs_srcdir@/tmp_check/datanode1/postgresql.conf] + +Total instances: 1. Failed instances: 0. +Success to perform gs_guc! + +\! @abs_bindir@/gs_guc set -D @abs_srcdir@/tmp_check/datanode1/ -c "enable_beta_nestloop_fusion=on" +expected instance path: [@abs_srcdir@/tmp_check/datanode1/postgresql.conf] +gs_guc set: enable_beta_nestloop_fusion=on: [@abs_srcdir@/tmp_check/datanode1/postgresql.conf] + +Total instances: 1. Failed instances: 0. +Success to perform gs_guc! + +-----Reload(GUC) +\! @abs_bindir@/gs_guc reload -D @abs_srcdir@/tmp_check/datanode1/ -c "cstore_buffers=10GB" +expected instance path: [@abs_srcdir@/tmp_check/datanode1/postgresql.conf] +gs_guc reload: cstore_buffers=10GB: [@abs_srcdir@/tmp_check/datanode1/postgresql.conf] +server signaled + +Total instances: 1. Failed instances: 0. +Success to perform gs_guc! + \! @abs_bindir@/gs_guc set -D @abs_srcdir@/tmp_check/datanode1/ -c "intervalstyle=a" --?The gs_guc run with the following arguments: [@abs_bindir@/gs_guc -D @abs_srcdir@/tmp_check/datanode1/ -c intervalstyle=a set ]. --?.* @@ -100,14 +123,12 @@ gs_guc set: intervalstyle=a: [@abs_srcdir@/tmp_check/datanode1/postgresql.conf] Total instances: 1. Failed instances: 0. Success to perform gs_guc! ------Reload(GUC) -\! @abs_bindir@/gs_guc reload -D @abs_srcdir@/tmp_check/datanode1/ -c "cstore_buffers=10GB" +\! @abs_bindir@/gs_guc set -D @abs_srcdir@/tmp_check/datanode1/ -c "intervalstyle=a" --?The gs_guc run with the following arguments: [@abs_bindir@/gs_guc -D @abs_srcdir@/tmp_check/datanode1/ -c cstore_buffers=10GB reload ]. --?.* --?.* expected instance path: [@abs_srcdir@/tmp_check/datanode1/postgresql.conf] -gs_guc reload: cstore_buffers=10GB: [@abs_srcdir@/tmp_check/datanode1/postgresql.conf] -server signaled +gs_guc set: intervalstyle=a: [@abs_srcdir@/tmp_check/datanode1/postgresql.conf] Total instances: 1. Failed instances: 0. Success to perform gs_guc! diff --git a/src/test/regress/output/hw_sec_account_lock_unlock.source b/src/test/regress/output/hw_sec_account_lock_unlock.source index c55918fdb..71c5a4b3b 100644 --- a/src/test/regress/output/hw_sec_account_lock_unlock.source +++ b/src/test/regress/output/hw_sec_account_lock_unlock.source @@ -320,13 +320,17 @@ ERROR: must be initial account to examine "alarm_component" CONTEXT: referenced column: current_setting set role user_guc_sysadmin password 'Ttest@123'; select name, setting, sourcefile from pg_settings where name = 'alarm_component'; - name | setting | sourcefile -------+---------+------------ -(0 rows) +--?.* +--?.* + alarm_component | /opt/snas/bin/snas_cm_cmd | @abs_srcdir@/./tmp_check/datanode1/postgresql.conf +(1 row) select current_setting('alarm_component'); -ERROR: must be initial account to examine "alarm_component" -CONTEXT: referenced column: current_setting +--?current_setting.* +--?.* + /opt/snas/bin/snas_cm_cmd +(1 row) + reset role; drop user user_guc_normal; drop user user_guc_sysadmin; diff --git a/src/test/regress/output/unify_superuser_definition.source b/src/test/regress/output/unify_superuser_definition.source new file mode 100644 index 000000000..d22f954c5 --- /dev/null +++ b/src/test/regress/output/unify_superuser_definition.source @@ -0,0 +1,81 @@ +create user grant_all with password 'openGauss@123'; +grant all privileges to grant_all; +create user standard_user with password 'openGauss@123'; +-- sighup +\! @gsqldir@/gsql -d postgres -p 25632 -U grant_all -W openGauss@123 -c "show password_reuse_max;"; + password_reuse_max +-------------------- + 0 +(1 row) + +\! @gsqldir@/gsql -d postgres -p 25632 -U grant_all -W openGauss@123 -c "alter system set password_reuse_max=1;"; +ALTER SYSTEM SET +\! @gsqldir@/gsql -d postgres -p 25632 -U grant_all -W openGauss@123 -c "show password_reuse_max;"; + password_reuse_max +-------------------- + 1 +(1 row) + +\! @gsqldir@/gsql -d postgres -p 25632 -U grant_all -W openGauss@123 -c "alter system set password_reuse_max=0;" +ALTER SYSTEM SET +\! @gsqldir@/gsql -d postgres -p 25632 -U standard_user -W openGauss@123 -c "show password_reuse_max;"; +ERROR: must be initial account to examine "password_reuse_max" +\! @gsqldir@/gsql -d postgres -p 25632 -U standard_user -W openGauss@123 -c "alter system set password_reuse_max=1;"; +ERROR: must be superuser to execute ALTER SYSTEM SET command +\! @gsqldir@/gsql -d postgres -p 25632 -U standard_user -W openGauss@123 -c "show password_reuse_max;"; +ERROR: must be initial account to examine "password_reuse_max" +\! @gsqldir@/gsql -d postgres -p 25632 -U standard_user -W openGauss@123 -c "alter system set password_reuse_max=0;" +ERROR: must be superuser to execute ALTER SYSTEM SET command +show password_reuse_max; + password_reuse_max +-------------------- + 0 +(1 row) + +alter system set password_reuse_max=1; +show password_reuse_max; + password_reuse_max +-------------------- + 0 +(1 row) + +alter system set password_reuse_max=0; +-- suset +\! @gsqldir@/gsql -d postgres -p 25632 -U grant_all -W openGauss@123 -c "show pljava_vmoptions;"; + pljava_vmoptions +------------------ + +(1 row) + +\! @gsqldir@/gsql -d postgres -p 25632 -U grant_all -W openGauss@123 -c "set pljava_vmoptions='aaa';"; +SET +\! @gsqldir@/gsql -d postgres -p 25632 -U grant_all -W openGauss@123 -c "show pljava_vmoptions;"; + pljava_vmoptions +------------------ + +(1 row) + +\! @gsqldir@/gsql -d postgres -p 25632 -U grant_all -W openGauss@123 -c "set pljava_vmoptions='';" +SET +\! @gsqldir@/gsql -d postgres -p 25632 -U standard_user -W openGauss@123 -c "show pljava_vmoptions;"; +ERROR: must be initial account to examine "pljava_vmoptions" +\! @gsqldir@/gsql -d postgres -p 25632 -U standard_user -W openGauss@123 -c "set pljava_vmoptions='aaa';"; +ERROR: permission denied to set parameter "pljava_vmoptions" +\! @gsqldir@/gsql -d postgres -p 25632 -U standard_user -W openGauss@123 -c "show pljava_vmoptions;"; +ERROR: must be initial account to examine "pljava_vmoptions" +\! @gsqldir@/gsql -d postgres -p 25632 -U standard_user -W openGauss@123 -c "set pljava_vmoptions='';" +ERROR: permission denied to set parameter "pljava_vmoptions" +show pljava_vmoptions; + pljava_vmoptions +------------------ + +(1 row) + +set pljava_vmoptions='aaa'; +show pljava_vmoptions; + pljava_vmoptions +------------------ + aaa +(1 row) + +set pljava_vmoptions=''; diff --git a/src/test/regress/parallel_schedule10 b/src/test/regress/parallel_schedule10 index b0073f081..08d778ae2 100644 --- a/src/test/regress/parallel_schedule10 +++ b/src/test/regress/parallel_schedule10 @@ -81,4 +81,7 @@ test: not_support_nodegroup test: double_support_unit test: gs_guc_value_range - test: alter_set_same_parameter \ No newline at end of file + test: alter_set_same_parameter + test: enum_empty_test + test: alarm_component_test + test: unify_definition_superuser diff --git a/src/test/regress/sql/alarm_component_test.sql b/src/test/regress/sql/alarm_component_test.sql new file mode 100644 index 000000000..1710f1905 --- /dev/null +++ b/src/test/regress/sql/alarm_component_test.sql @@ -0,0 +1 @@ +show alarm_component;