aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2015-01-03 20:51:52 +0100
committerAndres Freund <andres@anarazel.de>2015-01-03 20:54:12 +0100
commitccb161b66addc9d0ede31359c05f7e9df61ab8d4 (patch)
tree71a9798e0fd2ad3117d972167fde404379f0f48b /src/backend
parentd6657d2a107bee20d63ec2f776d873242f9355e9 (diff)
downloadpostgresql-ccb161b66addc9d0ede31359c05f7e9df61ab8d4.tar.gz
postgresql-ccb161b66addc9d0ede31359c05f7e9df61ab8d4.zip
Add pg_string_endswith as the start of a string helper library in src/common.
Backpatch to 9.3 where src/common was introduce, because a bugfix that needs to be backpatched, requires the function. Earlier branches will have to duplicate the code.
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/replication/slot.c21
1 files changed, 2 insertions, 19 deletions
diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c
index 937b669e8cd..87086166b77 100644
--- a/src/backend/replication/slot.c
+++ b/src/backend/replication/slot.c
@@ -40,6 +40,7 @@
#include <sys/stat.h>
#include "access/transam.h"
+#include "common/string.h"
#include "miscadmin.h"
#include "replication/slot.h"
#include "storage/fd.h"
@@ -780,24 +781,6 @@ CheckSlotRequirements(void)
}
/*
- * Returns whether the string `str' has the postfix `end'.
- */
-static bool
-string_endswith(const char *str, const char *end)
-{
- size_t slen = strlen(str);
- size_t elen = strlen(end);
-
- /* can't be a postfix if longer */
- if (elen > slen)
- return false;
-
- /* compare the end of the strings */
- str += slen - elen;
- return strcmp(str, end) == 0;
-}
-
-/*
* Flush all replication slots to disk.
*
* This needn't actually be part of a checkpoint, but it's a convenient
@@ -864,7 +847,7 @@ StartupReplicationSlots(void)
continue;
/* we crashed while a slot was being setup or deleted, clean up */
- if (string_endswith(replication_de->d_name, ".tmp"))
+ if (pg_str_endswith(replication_de->d_name, ".tmp"))
{
if (!rmtree(path, true))
{