diff --git a/src/gausskernel/optimizer/commands/tablespace.cpp b/src/gausskernel/optimizer/commands/tablespace.cpp index 3ca2a56e6..316bf02c8 100644 --- a/src/gausskernel/optimizer/commands/tablespace.cpp +++ b/src/gausskernel/optimizer/commands/tablespace.cpp @@ -2503,11 +2503,12 @@ bool IsPathContainsSymlink(char* path) *ptr = '\0'; rc = memset_s(&statbuf, sizeof(statbuf), 0, sizeof(statbuf)); - if (rc != EOK) { - continue; - } + securec_check(rc, "\0", "\0"); if (lstat(path, &statbuf) == 0 && S_ISLNK(statbuf.st_mode)) { + if (!isLast) { + *ptr = '/'; + } return true; } diff --git a/src/test/regress/output/tablespace_1.source b/src/test/regress/output/tablespace_1.source index 5c5e542fd..593eff37b 100644 --- a/src/test/regress/output/tablespace_1.source +++ b/src/test/regress/output/tablespace_1.source @@ -277,5 +277,5 @@ ERROR: location "@testtablespace@/symlink/sym2" is symbolic link \! ln -s @testtablespace@/symlink/will_delete @testtablespace@/symlink/will_delete_link \! rm -rf @testtablespace@/symlink/will_delete CREATE TABLESPACE deleted_symlink LOCATION '@testtablespace@/symlink/will_delete_link/local'; -ERROR: recheck location "@testtablespace@/symlink/will_delete_link" exeed max times. +ERROR: recheck location "@testtablespace@/symlink/will_delete_link/local" exeed max times. DETAIL: the location contains symbolic link, the linked path likely has been deleted.