Обсуждение: pg_ctl restart bug
"pg_ctl restart" fails if anything is quoted in postmaster.opts.
$ pg_ctl restart
Smart Shutdown request at Fri Apr 20 10:11:38 2001
postmaster successfully shut down
postmaster successfully started
/usr/bin/postmaster: invalid argument -- '-D'
Try '/usr/bin/postmaster --help' for more information.
$ cat postmaster.opts
/usr/bin/postmaster '-D' '/var/lib/pgsql/data'
It appears that the script doesn't cause the parameters in
postmaster.opts to get dequoted.
I think this is the source of the problem.
Joe
--
Joe Mitchell
Knowledge Engineer
Great Bridge, LLC
www.greatbridge.com
jmitchell@greatbridge.com writes: > "pg_ctl restart" fails if anything is quoted in postmaster.opts. > > $ pg_ctl restart > Smart Shutdown request at Fri Apr 20 10:11:38 2001 > postmaster successfully shut down > postmaster successfully started > /usr/bin/postmaster: invalid argument -- '-D' > Try '/usr/bin/postmaster --help' for more information. > > > $ cat postmaster.opts > /usr/bin/postmaster '-D' '/var/lib/pgsql/data' Unless someone can show me a way to extract the command line options out of the opts file while preserving whitespace in them, I'm going to eliminate the quotes being put out. -- Peter Eisentraut peter_e@gmx.net http://funkturm.homeip.net/~peter
Peter Eisentraut <peter_e@gmx.net> writes:
> Unless someone can show me a way to extract the command line options out
> of the opts file while preserving whitespace in them, I'm going to
> eliminate the quotes being put out.
Won't work if any of the options contain whitespace, which is quite
probable. For example, my postmaster.opts currently contains
/home/postgres/testversion/bin/postmaster '-i' '-o' '-F -S 5120'
Removing the quotes will certainly break this. We need to find a
smarter way for the script to parse the file contents.
regards, tom lane
pg_ctl restart works fine with this patch, but I'm not sure whether it
breaks useful cases for the other paths:
***************
*** 323,335 ****
shift
po_path=$1
shift
! POSTOPTS=$@
fi
else # -o given
POSTOPTS="-D $PGDATA $POSTOPTS"
fi
! eval '$po_path' '$POSTOPTS' $logopt '&'
# if had an old lockfile, check to see if we were able to start
if [ -n "$oldpid" ];then
--- 323,335 ----
shift
po_path=$1
shift
! POSTOPTS="$@"
fi
else # -o given
POSTOPTS="-D $PGDATA $POSTOPTS"
fi
! eval '$po_path' $POSTOPTS $logopt '&'
# if had an old lockfile, check to see if we were able to start
if [ -n "$oldpid" ];then
regards, tom lane
> > $ cat postmaster.opts > > /usr/bin/postmaster '-D' '/var/lib/pgsql/data' > > Unless someone can show me a way to extract the command line options out > of the opts file while preserving whitespace in them, I'm going to > eliminate the quotes being put out. You know, I looked at that pg_ctl script and couldn't figure out how it properly passed all the options to the postmaster. Guess it doesn't. :-) -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
I can assure you that $@ is never the way to go, always use "$@". Not sure about the second change. > pg_ctl restart works fine with this patch, but I'm not sure whether it > breaks useful cases for the other paths: > > *************** > *** 323,335 **** > shift > po_path=$1 > shift > ! POSTOPTS=$@ > fi > else # -o given > POSTOPTS="-D $PGDATA $POSTOPTS" > fi > > ! eval '$po_path' '$POSTOPTS' $logopt '&' > > # if had an old lockfile, check to see if we were able to start > if [ -n "$oldpid" ];then > --- 323,335 ---- > shift > po_path=$1 > shift > ! POSTOPTS="$@" > fi > else # -o given > POSTOPTS="-D $PGDATA $POSTOPTS" > fi > > ! eval '$po_path' $POSTOPTS $logopt '&' > > # if had an old lockfile, check to see if we were able to start > if [ -n "$oldpid" ];then > > > > regards, tom lane > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Tom Lane writes: > pg_ctl restart works fine with this patch, but I'm not sure whether it > breaks useful cases for the other paths: Looks good. -- Peter Eisentraut peter_e@gmx.net http://funkturm.homeip.net/~peter
Tom Lane writes: > ! eval '$po_path' '$POSTOPTS' $logopt '&' > --- 323,335 ---- > ! eval '$po_path' $POSTOPTS $logopt '&' Actually, I think it needs to be "$POSTOPTS" (double quoted), to preserve whitespace. peter ~$ opts="-N -o '-F -S'" peter ~$ eval ./argprint $opts -N -o -F -S peter ~$ eval ./argprint "$opts" -N -o -F -S peter ~$ cat argprint #!/bin/sh for arg do echo "$arg" done -- Peter Eisentraut peter_e@gmx.net http://funkturm.homeip.net/~peter