Bug: pg_ctl restart fails

From: wsheldah(at)lexmark(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: Bug: pg_ctl restart fails
Date: 2001-04-20 18:40:11
Message-ID: 200104201840.OAA23565@interlock2.lexmark.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

When I try to restart postgresql, I get the following error:

postgres(at)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(at)lexmark(dot)com

Browse pgsql-bugs by date

  From Date Subject
Next Message pgsql-bugs 2001-04-20 18:53:50 wrong dump order in pg_dump for new data types
Previous Message jmitchell 2001-04-20 17:52:37 pg_ctl restart bug