Thread: Re: [BUGS] 8.0: Absolute path required for INITDB?

Re: [BUGS] 8.0: Absolute path required for INITDB?

From
Bruce Momjian
Date:
Patch to throw an error if -L is not an abolute path attached and
applied.

---------------------------------------------------------------------------

Josh Berkus wrote:
> 8.0 beta CVS of 8/8/2004:
>
> If a relative path is used for the -L option in initdb, the following fatal
> error happens:
>
> ./initdb -D ../data -L ../share/postgresql/
> <snip>
> creating system views ... ok
> loading pg_description ... ERROR:  could not open file
> "../share/postgresql/postgres.description" for reading: No such file or
> directory
> child process exited with exit code 1
>
> Is this intentional?  The first dozen or so commands work fine with a relative
> path, and this executes fine with an absolute path for both -D and -L.
>
> SuSE 9.1, GCC 3.3.3
>
> --
> Josh Berkus
> Aglio Database Solutions
> San Francisco
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: src/bin/initdb/initdb.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/initdb/initdb.c,v
retrieving revision 1.49
diff -c -c -r1.49 initdb.c
*** src/bin/initdb/initdb.c    11 Aug 2004 23:28:54 -0000    1.49
--- src/bin/initdb/initdb.c    16 Aug 2004 03:41:45 -0000
***************
*** 2234,2240 ****
          share_path = xmalloc(MAXPGPATH);
          get_share_path(backend_exec, share_path);
      }
!
      canonicalize_path(share_path);

      if ((short_version = get_short_version()) == NULL)
--- 2234,2245 ----
          share_path = xmalloc(MAXPGPATH);
          get_share_path(backend_exec, share_path);
      }
!     else if (!is_absolute_path(share_path))
!     {
!         fprintf(stderr, _("%s: input file location must be an absolute path\n"), progname);
!         exit(1);
!     }
!
      canonicalize_path(share_path);

      if ((short_version = get_short_version()) == NULL)

Re: [BUGS] 8.0: Absolute path required for INITDB?

From
Andrew Dunstan
Date:

Bruce Momjian wrote:

>Patch to throw an error if -L is not an abolute path attached and
>applied.
>
>


Why are we placing this restriction? What Josh tried to do seems
perfectly reasonable to me. Rather I would ask why we changed the
description-loading routine in version 1.7 of initdb.c to use a copy
from file instead of what happens everywhere else where initdb loads the
file and feeds it to the postgres stdin? And if we want to keep doing
that rather than being consistent with the rest of initdb, can't we just
make sure we make the path absolute?

cheers

andrew




Re: [BUGS] 8.0: Absolute path required for INITDB?

From
Tom Lane
Date:
Andrew Dunstan <andrew@dunslane.net> writes:
> Rather I would ask why we changed the
> description-loading routine in version 1.7 of initdb.c to use a copy
> from file instead of what happens everywhere else where initdb loads the
> file and feeds it to the postgres stdin?

That was to avoid a Windows-only newline problem.  Don't complain too
hard.

You are in any case missing the point: -L is a useless switch and there
is no reason to make it easy to use.  (I don't think I have ever once
had occasion to use it in all the years I've worked on Postgres, and I
have certainly run initdb in orders-of-magnitude more contexts than any
ordinary user would.)  If I have to waste any more time on this
discussion, I will propose solving the problem by removing the switch
entirely.

            regards, tom lane

Re: [BUGS] 8.0: Absolute path required for INITDB?

From
Bruce Momjian
Date:
Andrew Dunstan wrote:
>
>
> Bruce Momjian wrote:
>
> >Patch to throw an error if -L is not an abolute path attached and
> >applied.
> >
> >
>
>
> Why are we placing this restriction? What Josh tried to do seems
> perfectly reasonable to me. Rather I would ask why we changed the
> description-loading routine in version 1.7 of initdb.c to use a copy
> from file instead of what happens everywhere else where initdb loads the
> file and feeds it to the postgres stdin? And if we want to keep doing
> that rather than being consistent with the rest of initdb, can't we just
> make sure we make the path absolute?

I am fine with that if someone wants to code it.  I just did the minimal
to prevent strange failures.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: [BUGS] 8.0: Absolute path required for INITDB?

From
Andrew Dunstan
Date:

Tom Lane wrote:

>Andrew Dunstan <andrew@dunslane.net> writes:
>
>
>>Rather I would ask why we changed the
>>description-loading routine in version 1.7 of initdb.c to use a copy
>>from file instead of what happens everywhere else where initdb loads the
>>file and feeds it to the postgres stdin?
>>
>>
>
>That was to avoid a Windows-only newline problem.  Don't complain too
>hard.
>
>

Well, I've tried to fix every newline problem I've come across - I
wasn't aware of this one.

>You are in any case missing the point: -L is a useless switch and there
>is no reason to make it easy to use.  (I don't think I have ever once
>had occasion to use it in all the years I've worked on Postgres, and I
>have certainly run initdb in orders-of-magnitude more contexts than any
>ordinary user would.)  If I have to waste any more time on this
>discussion, I will propose solving the problem by removing the switch
>entirely.
>
>
>
>
Sorry - I don't read -bugs so I haven't followed the discussion.

Removing it makes more sense to me, frankly.

cheers

andrew