fix the parameter quote-all-identifiers for gs_dumpall

This commit is contained in:
zhengxue
2020-12-27 21:11:46 +08:00
parent 15b10cb5d5
commit 3f9840bbe2

View File

@ -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.")));