@@ -102,6 +102,13 @@ void
102102pgBackupConfigInit (pgBackupConfig * config )
103103{
104104 config -> system_identifier = 0 ;
105+
106+ #if PG_VERSION_NUM >= 110000
107+ config -> xlog_seg_size = 0 ;
108+ #else
109+ config -> xlog_seg_size = XLOG_SEG_SIZE ;
110+ #endif
111+
105112 config -> pgdata = NULL ;
106113 config -> pgdatabase = NULL ;
107114 config -> pghost = NULL ;
@@ -140,6 +147,9 @@ writeBackupCatalogConfig(FILE *out, pgBackupConfig *config)
140147 fprintf (out , "#Backup instance info\n" );
141148 fprintf (out , "PGDATA = %s\n" , config -> pgdata );
142149 fprintf (out , "system-identifier = " UINT64_FORMAT "\n" , config -> system_identifier );
150+ #if PG_VERSION_NUM >= 110000
151+ fprintf (out , "xlog-seg-size = %u\n" , config -> xlog_seg_size );
152+ #endif
143153
144154 fprintf (out , "#Connection parameters:\n" );
145155 if (config -> pgdatabase )
@@ -253,6 +263,9 @@ readBackupCatalogConfigFile(void)
253263 { 'u' , 0 , "replica-timeout" , & (config -> replica_timeout ), SOURCE_CMDLINE , SOURCE_DEFAULT , OPTION_UNIT_MS },
254264 /* other options */
255265 { 'U' , 0 , "system-identifier" , & (config -> system_identifier ), SOURCE_FILE_STRICT },
266+ #if PG_VERSION_NUM >= 110000
267+ {'u' , 0 , "xlog-seg-size" , & config -> xlog_seg_size , SOURCE_FILE_STRICT },
268+ #endif
256269 /* archive options */
257270 { 'u' , 0 , "archive-timeout" , & (config -> archive_timeout ), SOURCE_CMDLINE , SOURCE_DEFAULT , OPTION_UNIT_MS },
258271 {0 }
@@ -263,11 +276,44 @@ readBackupCatalogConfigFile(void)
263276 join_path_components (path , backup_instance_path , BACKUP_CATALOG_CONF_FILE );
264277
265278 pgBackupConfigInit (config );
266- pgut_readopt (path , options , ERROR );
279+ pgut_readopt (path , options , ERROR , true);
280+
281+ #if PG_VERSION_NUM >= 110000
282+ if (!IsValidWalSegSize (config -> xlog_seg_size ))
283+ elog (ERROR , "Invalid WAL segment size %u" , config -> xlog_seg_size );
284+ #endif
267285
268286 return config ;
269287}
270288
289+ /*
290+ * Read xlog-seg-size from BACKUP_CATALOG_CONF_FILE.
291+ */
292+ uint32
293+ get_config_xlog_seg_size (void )
294+ {
295+ #if PG_VERSION_NUM >= 110000
296+ char path [MAXPGPATH ];
297+ uint32 seg_size ;
298+ pgut_option options [] =
299+ {
300+ {'u' , 0 , "xlog-seg-size" , & seg_size , SOURCE_FILE_STRICT },
301+ {0 }
302+ };
303+
304+ join_path_components (path , backup_instance_path , BACKUP_CATALOG_CONF_FILE );
305+ pgut_readopt (path , options , ERROR , false);
306+
307+ if (!IsValidWalSegSize (seg_size ))
308+ elog (ERROR , "Invalid WAL segment size %u" , seg_size );
309+
310+ return seg_size ;
311+
312+ #else
313+ return (uint32 ) XLOG_SEG_SIZE ;
314+ #endif
315+ }
316+
271317static void
272318opt_log_level_console (pgut_option * opt , const char * arg )
273319{
@@ -349,6 +395,11 @@ show_configure_json(pgBackupConfig *config)
349395 json_add_key (buf , "system-identifier" , json_level , true);
350396 appendPQExpBuffer (buf , UINT64_FORMAT , config -> system_identifier );
351397
398+ #if PG_VERSION_NUM >= 110000
399+ json_add_key (buf , "xlog-seg-size" , json_level , true);
400+ appendPQExpBuffer (buf , "%u" , config -> xlog_seg_size );
401+ #endif
402+
352403 /* Connection parameters */
353404 if (config -> pgdatabase )
354405 json_add_value (buf , "pgdatabase" , config -> pgdatabase , json_level , true);
0 commit comments