@@ -609,23 +609,29 @@ main(int argc, char *argv[])
609609 restore_params -> skip_block_validation = skip_block_validation ;
610610 restore_params -> skip_external_dirs = skip_external_dirs ;
611611 restore_params -> partial_db_list = NULL ;
612+ restore_params -> partial_restore_type = NONE ;
612613
613614 /* handle partial restore parameters */
614615 if (datname_exclude_list && datname_include_list )
615616 elog (ERROR , "You cannot specify '--db-include' and '--db-exclude' together" );
616617
617618 if (datname_exclude_list )
618619 {
619- restore_params -> is_include_list = false ;
620+ restore_params -> partial_restore_type = EXCLUDE ;
620621 restore_params -> partial_db_list = datname_exclude_list ;
621622 }
622623 else if (datname_include_list )
623624 {
624- restore_params -> is_include_list = true ;
625+ restore_params -> partial_restore_type = INCLUDE ;
625626 restore_params -> partial_db_list = datname_include_list ;
626627 }
627628 }
628629
630+ /* sanity */
631+ if (backup_subcmd == VALIDATE_CMD && restore_params -> no_validate )
632+ elog (ERROR , "You cannot specify \"--no-validate\" option with the \"%s\" command" ,
633+ command_name );
634+
629635 if (num_threads < 1 )
630636 num_threads = 1 ;
631637
@@ -663,8 +669,15 @@ main(int argc, char *argv[])
663669 restore_params );
664670 case VALIDATE_CMD :
665671 if (current .backup_id == 0 && target_time == 0 && target_xid == 0 && !target_lsn )
672+ {
673+ /* sanity */
674+ if (datname_exclude_list || datname_include_list )
675+ elog (ERROR , "You must specify parameter (-i, --backup-id) for partial validation" );
676+
666677 return do_validate_all ();
678+ }
667679 else
680+ /* PITR validation and, optionally, partial validation */
668681 return do_restore_or_validate (current .backup_id ,
669682 recovery_target_options ,
670683 restore_params );
@@ -797,7 +810,10 @@ opt_datname_include_list(ConfigOption *opt, const char *arg)
797810
798811 dbname = pgut_malloc (strlen (arg ) + 1 );
799812
800- /* TODO add sanity for database name */
813+ if (strcmp (dbname , "tempate0" ) == 0 ||
814+ strcmp (dbname , "tempate1" ) == 0 )
815+ elog (ERROR , "Databases 'template0' and 'template1' cannot be used for partial restore or validation" );
816+
801817 strcpy (dbname , arg );
802818
803819 parray_append (datname_include_list , dbname );
0 commit comments