From 3f9840bbe2d510b7be606ecc0414881600513b50 Mon Sep 17 00:00:00 2001 From: zhengxue Date: Sun, 27 Dec 2020 21:11:46 +0800 Subject: [PATCH] fix the parameter quote-all-identifiers for gs_dumpall --- src/common/backend/utils/misc/guc.cpp | 31 +++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/common/backend/utils/misc/guc.cpp b/src/common/backend/utils/misc/guc.cpp index 2ecdeec56..f234c0e04 100644 --- a/src/common/backend/utils/misc/guc.cpp +++ b/src/common/backend/utils/misc/guc.cpp @@ -219,6 +219,11 @@ THR_LOCAL int comm_ackchk_time; static THR_LOCAL GucContext currentGucContext; +const char* PG_TEMP[] = {"pg_temp", + "\"pg_temp\""}; +const char* PG_CATALOG[] = {"pg_catalog", + "\"pg_catalog\""}; + const char* sync_guc_variable_namelist[] = {"work_mem", "query_mem", "ssl_renegotiation_limit", @@ -406,6 +411,7 @@ const char* sync_guc_variable_namelist[] = {"work_mem", "sql_use_spacelimit", "basebackup_timeout"}; +static int JudgeSystemSchema(const char* spcname, const char** schema_type); static void set_config_sourcefile(const char* name, char* sourcefile, int sourceline); static bool call_bool_check_hook(struct config_bool* conf, bool* newval, void** extra, GucSource source, int elevel); static bool call_int_check_hook(struct config_int* conf, int* newval, void** extra, GucSource source, int elevel); @@ -16353,6 +16359,27 @@ void AlterSystemSetConfigFile(AlterSystemStmt * altersysstmt) } } +/* + * This function macth the order of the schema in the search path with the system schema to + * make sure the system schema pg_temp and pg_catalog before the others schema in the search path + */ +static int JudgeSystemSchema(const char* spcname, const char** schema_type) +{ + /* match the system schema pg_temp and pg_catalog in the search path */ + int flag = 0; + for (int i = 0; i < 4; i++) { + int len = strlen(schema_type[i]); + char* schema_name = (char*)malloc(sizeof(char) * (len + 1)); + memset_s(schema_name, len + 1, '\0', len + 1); + strncpy_s(schema_name, len + 1, spcname, len + 1); + if (strcmp(schema_name, schema_type[i]) == 0) { + flag = 1; + return flag; + } + } + return flag; +} + /* * SET command */ @@ -16415,8 +16442,8 @@ void ExecSetVariableStmt(VariableSetStmt* stmt) if (spcname != NULL) { char* tempname = strstr(spcname, SCHEMA_TEMP_NAME); char* catalogname = strstr(spcname, SCHEMA_CATALOG_NAME); - if ((tempname != NULL && tempname - spcname != 0) || - (catalogname != NULL && catalogname - spcname != 0)) { + if ((tempname != NULL && JudgeSystemSchema(spcname, PG_TEMP) == 0) || + (catalogname != NULL && JudgeSystemSchema(spcname, PG_CATALOG) == 0)) { ereport(WARNING, (errmsg("It is invalid to set pg_temp or pg_catalog behind other schemas in search path " "explicitly. The priority order is pg_temp, pg_catalog and other schemas.")));