File tree 5 files changed +62
-21
lines changed
5 files changed +62
-21
lines changed Original file line number Diff line number Diff line change 40
40
#include <sys/stat.h>
41
41
42
42
#include "access/transam.h"
43
+ #include "common/string.h"
43
44
#include "miscadmin.h"
44
45
#include "replication/slot.h"
45
46
#include "storage/fd.h"
@@ -779,24 +780,6 @@ CheckSlotRequirements(void)
779
780
errmsg ("replication slots can only be used if wal_level >= archive" )));
780
781
}
781
782
782
- /*
783
- * Returns whether the string `str' has the postfix `end'.
784
- */
785
- static bool
786
- string_endswith (const char * str , const char * end )
787
- {
788
- size_t slen = strlen (str );
789
- size_t elen = strlen (end );
790
-
791
- /* can't be a postfix if longer */
792
- if (elen > slen )
793
- return false;
794
-
795
- /* compare the end of the strings */
796
- str += slen - elen ;
797
- return strcmp (str , end ) == 0 ;
798
- }
799
-
800
783
/*
801
784
* Flush all replication slots to disk.
802
785
*
@@ -864,7 +847,7 @@ StartupReplicationSlots(void)
864
847
continue ;
865
848
866
849
/* we crashed while a slot was being setup or deleted, clean up */
867
- if (string_endswith (replication_de -> d_name , ".tmp" ))
850
+ if (pg_str_endswith (replication_de -> d_name , ".tmp" ))
868
851
{
869
852
if (!rmtree (path , true))
870
853
{
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ include $(top_builddir)/src/Makefile.global
23
23
override CPPFLAGS := -DFRONTEND $(CPPFLAGS )
24
24
LIBS += $(PTHREAD_LIBS )
25
25
26
- OBJS_COMMON = exec.o pgfnames.o psprintf.o relpath.o rmtree.o username.o wait_error.o
26
+ OBJS_COMMON = exec.o pgfnames.o psprintf.o relpath.o rmtree.o string.o username.o wait_error.o
27
27
28
28
OBJS_FRONTEND = $(OBJS_COMMON ) fe_memutils.o
29
29
Original file line number Diff line number Diff line change
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * string.c
4
+ * string handling helpers
5
+ *
6
+ *
7
+ * Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
8
+ * Portions Copyright (c) 1994, Regents of the University of California
9
+ *
10
+ *
11
+ * IDENTIFICATION
12
+ * src/common/string.c
13
+ *
14
+ *-------------------------------------------------------------------------
15
+ */
16
+
17
+
18
+ #ifndef FRONTEND
19
+ #include "postgres.h"
20
+ #else
21
+ #include "postgres_fe.h"
22
+ #endif
23
+
24
+ #include "common/string.h"
25
+
26
+
27
+ /*
28
+ * Returns whether the string `str' has the postfix `end'.
29
+ */
30
+ bool
31
+ pg_str_endswith (const char * str , const char * end )
32
+ {
33
+ size_t slen = strlen (str );
34
+ size_t elen = strlen (end );
35
+
36
+ /* can't be a postfix if longer */
37
+ if (elen > slen )
38
+ return false;
39
+
40
+ /* compare the end of the strings */
41
+ str += slen - elen ;
42
+ return strcmp (str , end ) == 0 ;
43
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * string.h
3
+ * string handling helpers
4
+ *
5
+ * Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
6
+ * Portions Copyright (c) 1994, Regents of the University of California
7
+ *
8
+ * src/include/common/string.h
9
+ */
10
+ #ifndef COMMON_STRING_H
11
+ #define COMMON_STRING_H
12
+
13
+ extern bool pg_str_endswith (const char * str , const char * end );
14
+
15
+ #endif /* COMMON_STRING_H */
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ sub mkvcbuild
76
76
push (@pgportfiles , ' rint.c' ) if ($vsVersion < ' 12.00' );
77
77
78
78
our @pgcommonallfiles = qw(
79
- exec.c pgfnames.c psprintf.c relpath.c rmtree.c username.c wait_error.c) ;
79
+ exec.c pgfnames.c psprintf.c relpath.c rmtree.c string.c username.c wait_error.c) ;
80
80
81
81
our @pgcommonfrontendfiles = (@pgcommonallfiles , qw( fe_memutils.c) );
82
82
You can’t perform that action at this time.
0 commit comments