diff --git a/src/gausskernel/storage/replication/slot.cpp b/src/gausskernel/storage/replication/slot.cpp index 0785932f7..cabcd08c1 100755 --- a/src/gausskernel/storage/replication/slot.cpp +++ b/src/gausskernel/storage/replication/slot.cpp @@ -125,29 +125,31 @@ bool ReplicationSlotValidateName(const char *name, int elevel) { const char *cp = NULL; - if (name == NULL) { + if (name == NULL || strlen(name) == 0) { ereport(elevel, (errcode(ERRCODE_INVALID_NAME), errmsg("replication slot name should not be NULL."))); return false; } - if (strlen(name) == 0) { - ereport(elevel, (errcode(ERRCODE_INVALID_NAME), errmsg("replication slot name \"%s\" is too short", name))); - return false; - } - if (strlen(name) >= NAMEDATALEN) { ereport(elevel, (errcode(ERRCODE_NAME_TOO_LONG), errmsg("replication slot name \"%s\" is too long", name))); return false; } + if ((strlen(name) == 1 && name[0] == '.') || + (strlen(name) == strlen("..") && strncmp(name, "..", strlen("..")) == 0)) { + ereport(elevel, (errcode(ERRCODE_INVALID_NAME), + errmsg("'.' and '..' are not allowed to be slot names independently."))); + } + for (cp = name; *cp; cp++) { if (!((*cp >= 'a' && *cp <= 'z') || (*cp >= '0' && *cp <= '9') || (*cp == '_') || (*cp == '?') || - (*cp == '<') || (*cp == '!') || (*cp == '-') || (*cp == '.'))) { + (*cp == '.') || (*cp == '-'))) { ereport(elevel, (errcode(ERRCODE_INVALID_NAME), errmsg("replication slot name \"%s\" contains invalid character", name), errhint("Replication slot names may only contain lower letters, " - "numbers and the underscore character."))); + "numbers and the 4 following special characters: '_', '?', '.', '-'.\n" + "'.' and '..' are also not allowed to be slot names independently."))); return false; } }