gs_basebackup: tablespace_mapping option doesn't work

This commit is contained in:
wuyuechuan
2020-09-11 14:46:53 +08:00
parent 0a38575e7e
commit a5f63f6391
2 changed files with 7 additions and 5 deletions

View File

@ -247,7 +247,7 @@ static void tablespace_list_create()
securec_check_c(rcm, "", "");
}
static void save_tablespace_dir(char* dir)
static void save_tablespace_dir(const char* dir)
{
if (tblspaceDirectory != NULL) {
tblspaceDirectory[tblspaceIndex] = xstrdup(dir);
@ -1268,10 +1268,10 @@ static void BaseBackup(void)
tablespacepath);
securec_check_ss_c(rc, "\0", "\0");
verify_dir_is_empty_or_create(nodetablespacepath);
const char* mappingSpacePath = get_tablespace_mapping(nodetablespacepath);
verify_dir_is_empty_or_create((char*)mappingSpacePath);
/* Save the tablespace directory here so we can remove it when errors happen. */
save_tablespace_dir(nodetablespacepath);
save_tablespace_dir(mappingSpacePath);
}
}

View File

@ -737,7 +737,9 @@ Datum pg_tablespace_location(PG_FUNCTION_ARGS)
target_path[rllen] = '\0';
/* relative location will contain t_thrd.proc_cxt.DataDir */
if (0 == strncmp(target_path, t_thrd.proc_cxt.DataDir, strlen(t_thrd.proc_cxt.DataDir))) {
size_t dataDirLength = strlen(t_thrd.proc_cxt.DataDir);
if (0 == strncmp(target_path, t_thrd.proc_cxt.DataDir, dataDirLength) && rllen > dataDirLength &&
target_path[dataDirLength] == '/') {
/*
* The position is not '/' when skip t_thrd.proc_cxt.DataDir. the relative location can't start from '/'
* We only need get the relative location, so remove the common prefix