@@ -825,25 +825,25 @@ usage(void)
825825 printf (_ (" %s [OPTION]... [STARTSEG [ENDSEG]]\n" ), progname );
826826 printf (_ ("\nOptions:\n" ));
827827 printf (_ (" -b, --bkp-details output detailed information about backup blocks\n" ));
828+ printf (_ (" -B, --block=N with --relation, only show records that modify block N\n" ));
828829 printf (_ (" -e, --end=RECPTR stop reading at WAL location RECPTR\n" ));
829830 printf (_ (" -f, --follow keep retrying after reaching end of WAL\n" ));
830- printf (_ (" -k, --block=N with --relation, only show records matching this block\n" ));
831- printf (_ (" -F, --fork=N only show records matching a specific fork number\n"
832- " (defaults to showing all)\n" ));
833- printf (_ (" -l, --relation=N/N/N only show records that affect a specific relation\n" ));
831+ printf (_ (" -F, --fork=FORK only show records that modify blocks in fork FORK;\n"
832+ " valid names are main, fsm, vm, init\n" ));
834833 printf (_ (" -n, --limit=N number of records to display\n" ));
835834 printf (_ (" -p, --path=PATH directory in which to find log segment files or a\n"
836835 " directory with a ./pg_wal that contains such files\n"
837836 " (default: current directory, ./pg_wal, $PGDATA/pg_wal)\n" ));
838837 printf (_ (" -q, --quiet do not print any output, except for errors\n" ));
839838 printf (_ (" -r, --rmgr=RMGR only show records generated by resource manager RMGR;\n"
840839 " use --rmgr=list to list valid resource manager names\n" ));
840+ printf (_ (" -R, --relation=T/D/R only show records that modify blocks in relation T/D/R\n" ));
841841 printf (_ (" -s, --start=RECPTR start reading at WAL location RECPTR\n" ));
842842 printf (_ (" -t, --timeline=TLI timeline from which to read log records\n"
843843 " (default: 1 or the value used in STARTSEG)\n" ));
844844 printf (_ (" -V, --version output version information, then exit\n" ));
845- printf (_ (" -x, --xid=XID only show records with transaction ID XID\n" ));
846845 printf (_ (" -w, --fullpage only show records with a full page write\n" ));
846+ printf (_ (" -x, --xid=XID only show records with transaction ID XID\n" ));
847847 printf (_ (" -z, --stats[=record] show statistics instead of records\n"
848848 " (optionally, show per-record statistics)\n" ));
849849 printf (_ (" -?, --help show this help, then exit\n" ));
@@ -867,7 +867,7 @@ main(int argc, char **argv)
867867
868868 static struct option long_options [] = {
869869 {"bkp-details" , no_argument , NULL , 'b' },
870- {"block" , required_argument , NULL , 'k ' },
870+ {"block" , required_argument , NULL , 'B ' },
871871 {"end" , required_argument , NULL , 'e' },
872872 {"follow" , no_argument , NULL , 'f' },
873873 {"fork" , required_argument , NULL , 'F' },
@@ -876,7 +876,7 @@ main(int argc, char **argv)
876876 {"limit" , required_argument , NULL , 'n' },
877877 {"path" , required_argument , NULL , 'p' },
878878 {"quiet" , no_argument , NULL , 'q' },
879- {"relation" , required_argument , NULL , 'l ' },
879+ {"relation" , required_argument , NULL , 'R ' },
880880 {"rmgr" , required_argument , NULL , 'r' },
881881 {"start" , required_argument , NULL , 's' },
882882 {"timeline" , required_argument , NULL , 't' },
@@ -946,14 +946,24 @@ main(int argc, char **argv)
946946 goto bad_argument ;
947947 }
948948
949- while ((option = getopt_long (argc , argv , "be: fF:k:l: n:p:qr:s:t:wx:z" ,
949+ while ((option = getopt_long (argc , argv , "bB:e: fF:n:p:qr:R :s:t:wx:z" ,
950950 long_options , & optindex )) != -1 )
951951 {
952952 switch (option )
953953 {
954954 case 'b' :
955955 config .bkp_details = true;
956956 break ;
957+ case 'B' :
958+ if (sscanf (optarg , "%u" , & config .filter_by_relation_block ) != 1 ||
959+ !BlockNumberIsValid (config .filter_by_relation_block ))
960+ {
961+ pg_log_error ("could not parse valid block number \"%s\"" , optarg );
962+ goto bad_argument ;
963+ }
964+ config .filter_by_relation_block_enabled = true;
965+ config .filter_by_extended = true;
966+ break ;
957967 case 'e' :
958968 if (sscanf (optarg , "%X/%X" , & xlogid , & xrecoff ) != 2 )
959969 {
@@ -967,44 +977,12 @@ main(int argc, char **argv)
967977 config .follow = true;
968978 break ;
969979 case 'F' :
980+ config .filter_by_relation_forknum = forkname_to_number (optarg );
981+ if (config .filter_by_relation_forknum == InvalidForkNumber )
970982 {
971- unsigned int forknum ;
972-
973- if (sscanf (optarg , "%u" , & forknum ) != 1 ||
974- forknum > MAX_FORKNUM )
975- {
976- pg_log_error ("could not parse valid fork number (0..%d) \"%s\"" ,
977- MAX_FORKNUM , optarg );
978- goto bad_argument ;
979- }
980- config .filter_by_relation_forknum = (ForkNumber ) forknum ;
981- config .filter_by_extended = true;
982- }
983- break ;
984- case 'k' :
985- if (sscanf (optarg , "%u" , & config .filter_by_relation_block ) != 1 ||
986- !BlockNumberIsValid (config .filter_by_relation_block ))
987- {
988- pg_log_error ("could not parse valid block number \"%s\"" , optarg );
989- goto bad_argument ;
990- }
991- config .filter_by_relation_block_enabled = true;
992- config .filter_by_extended = true;
993- break ;
994- case 'l' :
995- if (sscanf (optarg , "%u/%u/%u" ,
996- & config .filter_by_relation .spcNode ,
997- & config .filter_by_relation .dbNode ,
998- & config .filter_by_relation .relNode ) != 3 ||
999- !OidIsValid (config .filter_by_relation .spcNode ) ||
1000- !OidIsValid (config .filter_by_relation .relNode ))
1001- {
1002- pg_log_error ("could not parse valid relation from \"%s\""
1003- " (expecting \"tablespace OID/database OID/"
1004- "relation filenode\")" , optarg );
983+ pg_log_error ("could not parse fork \"%s\"" , optarg );
1005984 goto bad_argument ;
1006985 }
1007- config .filter_by_relation_enabled = true;
1008986 config .filter_by_extended = true;
1009987 break ;
1010988 case 'n' :
@@ -1047,6 +1025,22 @@ main(int argc, char **argv)
10471025 }
10481026 }
10491027 break ;
1028+ case 'R' :
1029+ if (sscanf (optarg , "%u/%u/%u" ,
1030+ & config .filter_by_relation .spcNode ,
1031+ & config .filter_by_relation .dbNode ,
1032+ & config .filter_by_relation .relNode ) != 3 ||
1033+ !OidIsValid (config .filter_by_relation .spcNode ) ||
1034+ !OidIsValid (config .filter_by_relation .relNode ))
1035+ {
1036+ pg_log_error ("could not parse valid relation from \"%s\""
1037+ " (expecting \"tablespace OID/database OID/"
1038+ "relation filenode\")" , optarg );
1039+ goto bad_argument ;
1040+ }
1041+ config .filter_by_relation_enabled = true;
1042+ config .filter_by_extended = true;
1043+ break ;
10501044 case 's' :
10511045 if (sscanf (optarg , "%X/%X" , & xlogid , & xrecoff ) != 2 )
10521046 {
0 commit comments