On Thu, Jul  7, 2011 at 06:09:54PM -0400, Tom Lane wrote:
> I wrote:
> > Peter Eisentraut <pete...@gmx.net> writes:
> >> I was adding gcc printf attributes to more functions in obscure places,
> >> and now I'm seeing this in pg_upgrade:
> 
> >> relfilenode.c:72:2: warning: zero-length gnu_printf format string 
> >> [-Wformat-zero-length]
> 
> > Shouldn't it be prep_status("\n")?  If not, why not?
> 
> On closer inspection, it appears to me that prep_status should never be
> called with a string containing a newline, period, and the test it
> contains for that case is just brain damage.  The only reason to call it
> at all is to produce a line like
> 
>       message ......................
> 
> where something more is expected to be added to the line later.  Calls
> that are meant to produce a complete line could go directly to pg_log.
> 
> This in turn implies that transfer_all_new_dbs's use of the function is
> broken and needs to be rethought.

I changed a prep_status() call to pg_log() as you suggested, and
backpatched to 9.2.  Patch attached.

-- 
  Bruce Momjian  <br...@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +
diff --git a/contrib/pg_upgrade/relfilenode.c b/contrib/pg_upgrade/relfilenode.c
new file mode 100644
index 7688914..33a867f
*** a/contrib/pg_upgrade/relfilenode.c
--- b/contrib/pg_upgrade/relfilenode.c
*************** transfer_all_new_dbs(DbInfoArr *old_db_a
*** 36,42 ****
  				new_dbnum;
  	const char *msg = NULL;
  
! 	prep_status("%s user relation files\n",
  	  user_opts.transfer_mode == TRANSFER_MODE_LINK ? "Linking" : "Copying");
  
  	/* Scan the old cluster databases and transfer their files */
--- 36,42 ----
  				new_dbnum;
  	const char *msg = NULL;
  
! 	pg_log(PG_REPORT, "%s user relation files\n",
  	  user_opts.transfer_mode == TRANSFER_MODE_LINK ? "Linking" : "Copying");
  
  	/* Scan the old cluster databases and transfer their files */
diff --git a/contrib/pg_upgrade/util.c b/contrib/pg_upgrade/util.c
new file mode 100644
index 76cd20b..1c71204
*** a/contrib/pg_upgrade/util.c
--- b/contrib/pg_upgrade/util.c
*************** pg_log(eLogType type, char *fmt,...)
*** 81,87 ****
  	if (type != PG_VERBOSE || log_opts.verbose)
  	{
  		fwrite(message, strlen(message), 1, log_opts.internal);
! 		/* if we are using OVERWRITE_MESSAGE, add newline */
  		if (strchr(message, '\r') != NULL)
  			fwrite("\n", 1, 1, log_opts.internal);
  		fflush(log_opts.internal);
--- 81,87 ----
  	if (type != PG_VERBOSE || log_opts.verbose)
  	{
  		fwrite(message, strlen(message), 1, log_opts.internal);
! 		/* if we are using OVERWRITE_MESSAGE, add newline to log file */
  		if (strchr(message, '\r') != NULL)
  			fwrite("\n", 1, 1, log_opts.internal);
  		fflush(log_opts.internal);
-- 
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