Thread

  1. Bug: pg_ctl restart fails

    wsheldah@lexmark.com — 2001-04-20T18:40:11Z

    
    Hi,
    
    When I try to restart postgresql, I get the following error:
    
    postgres@host $ pg_ctl restart
    [ok messages snipped here]
    /usr/local/pgsql/bin/postmaster: invalid argument -- '-D'
    
    The problem seems to be the single quotes surrounding the command line args.  I
    confirmed this by starting postgresql, then editing postgresql.opts to remove
    the single quotes around '-D', then issuing the restart command as above.  This
    time I got the following error:
    
    /usr/local/pgsql/bin/postmaster does not find the database system.
         Expected to find it in the PGDATA directory "'/usr/local/pgsql/data'"
         but unable to open file "'/usr/local/pgsql/data'/global/pg_control": No
    such file or directory
    
    I've tried to retype the error messages as accurately as possible.  Note the
    single and double quotes on the last line.  After, this, I used `pg_ctl start`
    to start the system, edited postgresql.opts to remove single quotes from around
    both -D and the database directory, and then attempted a restart.  This time it
    worked like a charm.
    
    I think I've traced the problem to postgresql.c, function CreateOptsFile.  When
    it writes to postgresql.opts, it first writes the full program name, then writes
    each command line argument surrounded by single quotes.  It seems that it needs
    to either omit the single quotes altogether, or be more selective about what it
    quotes, like ignoring command line switches like -D while still quoting path
    names.  If path names are left quoted, those quotes should be stripped before
    the path name is used to build a longer path, as per my second error.  I suppose
    this could be done in the pc_ctl script.  I would submit a patch, but the best
    way I know to handle string problems like this is via perl.  :-)
    
    HTH.
    
    Wes Sheldahl
    wsheldah@lexmark.com