@@ -98,6 +98,8 @@ static void opt_log_level_console(pgut_option *opt, const char *arg);
9898static void opt_log_level_file (pgut_option * opt , const char * arg );
9999static void opt_compress_alg (pgut_option * opt , const char * arg );
100100
101+ static void compress_init (void );
102+
101103static pgut_option options [] =
102104{
103105 /* directory options */
@@ -394,27 +396,7 @@ main(int argc, char *argv[])
394396 if (num_threads < 1 )
395397 num_threads = 1 ;
396398
397- if (compress_shortcut )
398- compress_alg = ZLIB_COMPRESS ;
399-
400- if (backup_subcmd != SET_CONFIG )
401- {
402- if (compress_level != DEFAULT_COMPRESS_LEVEL
403- && compress_alg == NONE_COMPRESS )
404- elog (ERROR , "Cannot specify compress-level option without compress-alg option" );
405- }
406-
407- if (compress_level < 0 || compress_level > 9 )
408- elog (ERROR , "--compress-level value must be in the range from 0 to 9" );
409-
410- if (compress_level == 0 )
411- compress_alg = NOT_DEFINED_COMPRESS ;
412-
413- #ifndef HAVE_LIBZ
414- if ((backup_subcmd == BACKUP || backup_subcmd == ARCHIVE_PUSH ) &&
415- compress_alg == ZLIB_COMPRESS )
416- elog (ERROR , "This build does not support zlib compression" );
417- #endif
399+ compress_init ();
418400
419401 /* do actual operation */
420402 switch (backup_subcmd )
@@ -544,3 +526,38 @@ opt_compress_alg(pgut_option *opt, const char *arg)
544526{
545527 compress_alg = parse_compress_alg (arg );
546528}
529+
530+ /*
531+ * Initialize compress and sanity checks for compress.
532+ */
533+ static
534+ void compress_init (void )
535+ {
536+ /* Default algorithm is zlib */
537+ if (compress_shortcut )
538+ compress_alg = ZLIB_COMPRESS ;
539+
540+ if (backup_subcmd != SET_CONFIG )
541+ {
542+ if (compress_level != DEFAULT_COMPRESS_LEVEL
543+ && compress_alg == NONE_COMPRESS )
544+ elog (ERROR , "Cannot specify compress-level option without compress-alg option" );
545+ }
546+
547+ if (compress_level < 0 || compress_level > 9 )
548+ elog (ERROR , "--compress-level value must be in the range from 0 to 9" );
549+
550+ if (compress_level == 0 )
551+ compress_alg = NOT_DEFINED_COMPRESS ;
552+
553+ if (backup_subcmd == BACKUP || backup_subcmd == ARCHIVE_PUSH )
554+ {
555+ #ifndef HAVE_LIBZ
556+ if (compress_alg == ZLIB_COMPRESS )
557+ elog (ERROR , "This build does not support zlib compression" );
558+ else
559+ #endif
560+ if (compress_alg == PGLZ_COMPRESS && num_threads > 1 )
561+ elog (ERROR , "Multithread backup does not support pglz compression" );
562+ }
563+ }
0 commit comments