@@ -61,6 +61,16 @@ typedef struct TablespaceList
6161 */
6262#define MINIMUM_VERSION_FOR_PG_WAL 100000
6363
64+ /*
65+ * Different ways to include WAL
66+ */
67+ typedef enum
68+ {
69+ NO_WAL ,
70+ FETCH_WAL ,
71+ STREAM_WAL
72+ } IncludeWal ;
73+
6474/* Global options */
6575static char * basedir = NULL ;
6676static TablespaceList tablespace_dirs = {NULL , NULL };
@@ -71,8 +81,7 @@ static bool noclean = false;
7181static bool showprogress = false;
7282static int verbose = 0 ;
7383static int compresslevel = 0 ;
74- static bool includewal = true;
75- static bool streamwal = true;
84+ static IncludeWal includewal = STREAM_WAL ;
7685static bool fastcheckpoint = false;
7786static bool writerecoveryconf = false;
7887static bool do_sync = true;
@@ -1697,7 +1706,7 @@ BaseBackup(void)
16971706 * If WAL streaming was requested, also check that the server is new
16981707 * enough for that.
16991708 */
1700- if (streamwal && !CheckServerVersionForStreaming (conn ))
1709+ if (includewal == STREAM_WAL && !CheckServerVersionForStreaming (conn ))
17011710 {
17021711 /*
17031712 * Error message already written in CheckServerVersionForStreaming(),
@@ -1731,9 +1740,9 @@ BaseBackup(void)
17311740 psprintf ("BASE_BACKUP LABEL '%s' %s %s %s %s %s %s" ,
17321741 escaped_label ,
17331742 showprogress ? "PROGRESS" : "" ,
1734- includewal && ! streamwal ? "WAL" : "" ,
1743+ includewal == FETCH_WAL ? "WAL" : "" ,
17351744 fastcheckpoint ? "FAST" : "" ,
1736- includewal ? "NOWAIT " : "" ,
1745+ includewal == NO_WAL ? "" : "NOWAIT " ,
17371746 maxrate_clause ? maxrate_clause : "" ,
17381747 format == 't' ? "TABLESPACE_MAP" : "" );
17391748
@@ -1776,7 +1785,7 @@ BaseBackup(void)
17761785 PQclear (res );
17771786 MemSet (xlogend , 0 , sizeof (xlogend ));
17781787
1779- if (verbose && includewal )
1788+ if (verbose && includewal != NO_WAL )
17801789 fprintf (stderr , _ ("transaction log start point: %s on timeline %u\n" ),
17811790 xlogstart , starttli );
17821791
@@ -1833,7 +1842,7 @@ BaseBackup(void)
18331842 * If we're streaming WAL, start the streaming session before we start
18341843 * receiving the actual data chunks.
18351844 */
1836- if (streamwal )
1845+ if (includewal == STREAM_WAL )
18371846 {
18381847 if (verbose )
18391848 fprintf (stderr , _ ("%s: starting background WAL receiver\n" ),
@@ -1879,7 +1888,7 @@ BaseBackup(void)
18791888 disconnect_and_exit (1 );
18801889 }
18811890 strlcpy (xlogend , PQgetvalue (res , 0 , 0 ), sizeof (xlogend ));
1882- if (verbose && includewal )
1891+ if (verbose && includewal != NO_WAL )
18831892 fprintf (stderr , "transaction log end point: %s\n" , xlogend );
18841893 PQclear (res );
18851894
@@ -2117,20 +2126,17 @@ main(int argc, char **argv)
21172126 if (strcmp (optarg , "n" ) == 0 ||
21182127 strcmp (optarg , "none" ) == 0 )
21192128 {
2120- includewal = false;
2121- streamwal = false;
2129+ includewal = NO_WAL ;
21222130 }
21232131 else if (strcmp (optarg , "f" ) == 0 ||
21242132 strcmp (optarg , "fetch" ) == 0 )
21252133 {
2126- includewal = true;
2127- streamwal = false;
2134+ includewal = FETCH_WAL ;
21282135 }
21292136 else if (strcmp (optarg , "s" ) == 0 ||
21302137 strcmp (optarg , "stream" ) == 0 )
21312138 {
2132- includewal = true;
2133- streamwal = true;
2139+ includewal = STREAM_WAL ;
21342140 }
21352141 else
21362142 {
@@ -2261,7 +2267,7 @@ main(int argc, char **argv)
22612267 exit (1 );
22622268 }
22632269
2264- if (format == 't' && streamwal && strcmp (basedir , "-" ) == 0 )
2270+ if (format == 't' && includewal == STREAM_WAL && strcmp (basedir , "-" ) == 0 )
22652271 {
22662272 fprintf (stderr ,
22672273 _ ("%s: cannot stream transaction logs in tar mode to stdout\n" ),
@@ -2271,7 +2277,7 @@ main(int argc, char **argv)
22712277 exit (1 );
22722278 }
22732279
2274- if (replication_slot && ! streamwal )
2280+ if (replication_slot && includewal != STREAM_WAL )
22752281 {
22762282 fprintf (stderr ,
22772283 _ ("%s: replication slots can only be used with WAL streaming\n" ),
0 commit comments