Re: [HACKERS] warning in pg_upgrade

2011-11-10 Thread Bruce Momjian
Robert Haas wrote:
> On Thu, Nov 3, 2011 at 3:45 PM, Kevin Grittner
>  wrote:
> > "Kevin Grittner"  wrote:
> >> Untested patch attached for purposes of discussion.
> >
> > I got in a little testing on it -- not only does this patch
> > eliminate the compile-time warning, but if you try to run pg_upgrade
> > when another session has removed your current working directory, you
> > get a reasonable message instead of the program attempting to
> > proceed with undefined (potential garbage) for a working directory.
> 
> Committed.  Also fixed another compiler warning that popped up for me.

Thanks Kevin and Robert.

-- 
  Bruce Momjian  http://momjian.us
  EnterpriseDB http://enterprisedb.com

  + It's impossible for everything to be true. +

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] warning in pg_upgrade

2011-11-04 Thread Robert Haas
On Thu, Nov 3, 2011 at 3:45 PM, Kevin Grittner
 wrote:
> "Kevin Grittner"  wrote:
>> Untested patch attached for purposes of discussion.
>
> I got in a little testing on it -- not only does this patch
> eliminate the compile-time warning, but if you try to run pg_upgrade
> when another session has removed your current working directory, you
> get a reasonable message instead of the program attempting to
> proceed with undefined (potential garbage) for a working directory.

Committed.  Also fixed another compiler warning that popped up for me.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] warning in pg_upgrade

2011-11-03 Thread Kevin Grittner
"Kevin Grittner"  wrote:
 
> Untested patch attached for purposes of discussion.
 
I got in a little testing on it -- not only does this patch
eliminate the compile-time warning, but if you try to run pg_upgrade
when another session has removed your current working directory, you
get a reasonable message instead of the program attempting to
proceed with undefined (potential garbage) for a working directory.
 
-Kevin

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


[HACKERS] warning in pg_upgrade

2011-10-31 Thread Kevin Grittner
I just noticed a warning in pg_upgrade:
 
option.c: In function *parseCommandLine*:
option.c:96:8: warning: ignoring return value of *getcwd*,
declared
with attribute warn_unused_result
 
It looks like it might be worth testing the return value here for
NULL, which would indicate an error accessing the current working
directory.  Untested patch attached for purposes of discussion.
 
http://www.kernel.org/doc/man-pages/online/pages/man3/getcwd.3.html
 
-Kevin

*** a/contrib/pg_upgrade/option.c
--- b/contrib/pg_upgrade/option.c
***
*** 56,61  parseCommandLine(int argc, char *argv[])
--- 56,62 
int option; /* Command line option 
*/
int optindex = 0;   /* used by getopt_long */
int os_user_effective_id;
+   char*return_buf;
  
user_opts.transfer_mode = TRANSFER_MODE_COPY;
  
***
*** 93,99  parseCommandLine(int argc, char *argv[])
if (os_user_effective_id == 0)
pg_log(PG_FATAL, "%s: cannot be run as root\n", 
os_info.progname);
  
!   getcwd(os_info.cwd, MAXPGPATH);
  
while ((option = getopt_long(argc, argv, "d:D:b:B:cgG:kl:o:O:p:P:u:v",
 long_options, 
&optindex)) != -1)
--- 94,102 
if (os_user_effective_id == 0)
pg_log(PG_FATAL, "%s: cannot be run as root\n", 
os_info.progname);
  
!   return_buf = getcwd(os_info.cwd, MAXPGPATH);
!   if (return_buf == NULL)
!   pg_log(PG_FATAL, "Could not access current working directory: 
%s\n", getErrorText(errno));
  
while ((option = getopt_long(argc, argv, "d:D:b:B:cgG:kl:o:O:p:P:u:v",
 long_options, 
&optindex)) != -1)

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers