Hi Robert,

sorry for the delay.

Il 27/01/12 15:47, Robert Haas ha scritto:
This email thread seems to have trailed off without reaching a conclusion. The patch is marked as Waiting on Author in the CommitFest application, but I'm not sure that's accurate. Can we try to nail this down?
Here is my final version which embeds comments from Josh. I have also added debug information to be printed in case '-d' is given.

I will update the CommitFest website.

Thanks,
Gabriele

--
 Gabriele Bartolini - 2ndQuadrant Italia
 PostgreSQL Training, Services and Support
 gabriele.bartol...@2ndquadrant.it | www.2ndQuadrant.it

*** a/contrib/pg_archivecleanup/pg_archivecleanup.c
--- b/contrib/pg_archivecleanup/pg_archivecleanup.c
***************
*** 36,41 **** const char *progname;
--- 36,42 ----
  
  /* Options and defaults */
  bool          debug = false;          /* are we debugging? */
+ bool          dryrun = false;         /* are we performing a dry-run 
operation? */
  
  char     *archiveLocation;    /* where to find the archive? */
  char     *restartWALFileName; /* the file from which we can restart restore */
***************
*** 119,124 **** CleanupPriorWALFiles(void)
--- 120,137 ----
                        {
                                snprintf(WALFilePath, MAXPGPATH, "%s/%s",
                                                 archiveLocation, xlde->d_name);
+ 
+                               if (dryrun)
+                               {
+                                       /* Prints the name of the file and
+                                        * skips the actual removal of the file 
*/
+                                       fprintf(stdout, "%s\n", WALFilePath);
+                                       if (debug)
+                                               fprintf(stderr, "%s: dry-run 
mode suggests removing file \"%s\"\n",
+                                                               progname, 
WALFilePath);
+                                       continue;
+                               }
+ 
                                if (debug)
                                        fprintf(stderr, "%s: removing file 
\"%s\"\n",
                                                        progname, WALFilePath);
***************
*** 205,210 **** usage(void)
--- 218,224 ----
        printf("  %s [OPTION]... ARCHIVELOCATION OLDESTKEPTWALFILE\n", 
progname);
        printf("\nOptions:\n");
        printf("  -d                 generates debug output (verbose mode)\n");
+       printf("  -n                 shows the names of the files that would 
have been removed (dry-run)\n");
        printf("  --help             show this help, then exit\n");
        printf("  --version          output version information, then exit\n");
        printf("\n"
***************
*** 241,253 **** main(int argc, char **argv)
                }
        }
  
!       while ((c = getopt(argc, argv, "d")) != -1)
        {
                switch (c)
                {
                        case 'd':                       /* Debug mode */
                                debug = true;
                                break;
                        default:
                                fprintf(stderr, "Try \"%s --help\" for more 
information.\n", progname);
                                exit(2);
--- 255,270 ----
                }
        }
  
!       while ((c = getopt(argc, argv, "dn")) != -1)
        {
                switch (c)
                {
                        case 'd':                       /* Debug mode */
                                debug = true;
                                break;
+                       case 'n':                       /* Dry-Run mode */
+                               dryrun = true;
+                               break;
                        default:
                                fprintf(stderr, "Try \"%s --help\" for more 
information.\n", progname);
                                exit(2);
*** a/doc/src/sgml/pgarchivecleanup.sgml
--- b/doc/src/sgml/pgarchivecleanup.sgml
***************
*** 98,103 **** pg_archivecleanup:  removing file 
"archive/00000001000000370000000E"
--- 98,112 ----
        </listitem>
       </varlistentry>
  
+      <varlistentry>
+       <term><option>-n</option></term>
+       <listitem>
+        <para>
+         Print the names of the files that would have been removed on 
<filename>stdout</> (performs a dry run).
+        </para>
+       </listitem>
+      </varlistentry>
+ 
      </variablelist>
     </para>
  
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to