diff --git a/src/bin/gs_guc/cluster_guc.cpp b/src/bin/gs_guc/cluster_guc.cpp index cadfcbd35..f57e75074 100755 --- a/src/bin/gs_guc/cluster_guc.cpp +++ b/src/bin/gs_guc/cluster_guc.cpp @@ -4137,17 +4137,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; @@ -4172,6 +4161,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}; @@ -4195,7 +4195,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/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/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.