diff --git a/src/gausskernel/optimizer/commands/tablespace.cpp b/src/gausskernel/optimizer/commands/tablespace.cpp index 3ca2a56e6de104d5e215c094c594f078759821e5..316bf02c84baa28cd186151cc7c507fe6c823d5d 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 5c5e542fd5fbb7d4a7c8d78d4e58d67e2c79b152..593eff37bd331e82f898f94028d71a864cf9f7f0 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.