Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitccb161b

Browse files
committed
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 thatneeds to be backpatched, requires the function. Earlier branches willhave to duplicate the code.
1 parentd6657d2 commitccb161b

File tree

5 files changed

+62
-21
lines changed

5 files changed

+62
-21
lines changed

‎src/backend/replication/slot.c

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include<sys/stat.h>
4141

4242
#include"access/transam.h"
43+
#include"common/string.h"
4344
#include"miscadmin.h"
4445
#include"replication/slot.h"
4546
#include"storage/fd.h"
@@ -779,24 +780,6 @@ CheckSlotRequirements(void)
779780
errmsg("replication slots can only be used if wal_level >= archive")));
780781
}
781782

782-
/*
783-
* Returns whether the string `str' has the postfix `end'.
784-
*/
785-
staticbool
786-
string_endswith(constchar*str,constchar*end)
787-
{
788-
size_tslen=strlen(str);
789-
size_telen=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-
returnstrcmp(str,end)==0;
798-
}
799-
800783
/*
801784
* Flush all replication slots to disk.
802785
*
@@ -864,7 +847,7 @@ StartupReplicationSlots(void)
864847
continue;
865848

866849
/* 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"))
868851
{
869852
if (!rmtree(path, true))
870853
{

‎src/common/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ include $(top_builddir)/src/Makefile.global
2323
overrideCPPFLAGS := -DFRONTEND$(CPPFLAGS)
2424
LIBS +=$(PTHREAD_LIBS)
2525

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.ostring.ousername.o wait_error.o
2727

2828
OBJS_FRONTEND =$(OBJS_COMMON) fe_memutils.o
2929

‎src/common/string.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
#ifndefFRONTEND
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(constchar*str,constchar*end)
32+
{
33+
size_tslen=strlen(str);
34+
size_telen=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+
returnstrcmp(str,end)==0;
43+
}

‎src/include/common/string.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
#ifndefCOMMON_STRING_H
11+
#defineCOMMON_STRING_H
12+
13+
externboolpg_str_endswith(constchar*str,constchar*end);
14+
15+
#endif/* COMMON_STRING_H */

‎src/tools/msvc/Mkvcbuild.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ sub mkvcbuild
7676
push(@pgportfiles,'rint.c')if ($vsVersion <'12.00');
7777

7878
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.cstring.cusername.c wait_error.c);
8080

8181
our@pgcommonfrontendfiles = (@pgcommonallfiles,qw(fe_memutils.c));
8282

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp