Re: initdb in C

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL Win32 port list <pgsql-hackers-win32(at)postgresql(dot)org>, "Patches (PostgreSQL)" <pgsql-patches(at)postgresql(dot)org>
Subject: Re: initdb in C
Date: 2003-11-08 16:51:13
Message-ID: 3FAD1F01.7030308@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-hackers-win32 pgsql-patches

Bruce Momjian wrote:

>Andrew Dunstan wrote:
>
>
>>
>>
>>My comments:
>>
>>I have no problem with shelling out to rmdir - although my goal was to
>>avoid shelling out to anything other than postgres itself. I think
>>recreating the datadir if we didn't create it initially should be OK in
>>that case, and it makes the code simpler. Not handling dot files in the
>>Unix case should also be fine, as we know the directory was empty to
>>start with and we don't create any.
>>
>>
>
>Good. I can do rmdir() in C in port/dirmod.c if we need it. Right now
>we are doing system(rm/rmdir) in dbcommands.c so we should consistent.
>Let's stay with system(rm/rmdir) and if it doesn't work as we expect, we
>can add your rmdir() code and put it in port/dirmod.c.
>
>

In view of Peter's email of a few minutes ago I think we need to do that.

>>The changes you made for the final message are not going to work for
>>Windows - if pgpath or pg_data contain spaces we need quotes (even on
>>Unix, although there most people know better than to put spaces in
>>names). Also see above about mixed slashes. Also, putting a \ before
>>pg_data will be nasty if it starts with a drive or network specifier -
>>or even without (you might turn a directory specifier into a network
>>drive specifier). It's just a message, though, and we shouldn't hold up
>>for that - we can patch it to get it right.
>>
>>
>
>I am confused. The only change I made was to have the quotes appear
>only on WIN32.
>
> #ifndef WIN32
> #define QUOTE_PATH ""
> #else
> #define QUOTE_PATH "\""
> #endif
>
> ...
>
> printf("\n"
> "Success. You can now start the database server using:\n\n"
> " %s/postmaster -D %s%s%s\n"
> "or\n"
> " %s/pg_ctl -D %s%s%s -l logfile start\n\n",
> pgpath, QUOTE_PATH, pg_data, QUOTE_PATH,
> pgpath, QUOTE_PATH, pg_data, QUOTE_PATH);
>
>(I also merged multiple \n into a single line.) My logic was that
>spaces in directory names are much more common on WIN32, so we should
>display the quotes only on WIN32. Perhaps you read "\"" as "\\"?
>
>

Yes, I did. Sorry about that. But we also need to quote the path (the
most obvious place to put it after all is "C:\Program
Files\PostgreSQL"). In fact, that's more important than the data
location. Unfortunately, the Windows command processor barfs on multiple
quotes strings ;-(

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Rod Taylor 2003-11-08 16:55:06 ALTER TABLE modifications
Previous Message Tom Lane 2003-11-08 16:51:03 Re: initdb in C

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Bruce Momjian 2003-11-08 17:09:51 Re: initdb in C
Previous Message Tom Lane 2003-11-08 16:51:03 Re: initdb in C

Browse pgsql-patches by date

  From Date Subject
Next Message Rod Taylor 2003-11-08 16:55:06 ALTER TABLE modifications
Previous Message Tom Lane 2003-11-08 16:51:03 Re: initdb in C