Skip site navigation (1) Skip section navigation (2)

Re: Cannot initdb in cvs tip

From: "Andrew Dunstan" <andrew(at)dunslane(dot)net>
To: <pgsql-hackers(at)postgresql(dot)org>, <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Cannot initdb in cvs tip
Date: 2004-06-20 07:12:19
Message-ID: 1722.24.211.141.25.1087715539.squirrel@www.dunslane.net (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-hackers-win32pgsql-patches
John Hansen said:
> On Sun, 2004-06-20 at 08:04, Dave Page wrote:
>> > > although it says it's clearing the contents of the directory, in
>> > > actual fact it leaves the directory structure in place, thus a
>> > > subsequent initdb will not run without a manual clearup.
>> >
>> > Hm.  The rmtree() function in initdb.c is responsible for
>> > this, and I see it has WIN32-specific behavior, which is
>> > evidently wrong.
>> > Can you recommend a fix?
>>
>> The current solution does an "rmdir /q /s $PGDATA" if the datadir was
>> created, and "del /q /s $PGDATA" if the directory already existed. The
>> second case  will not work, as del will not remove directories.
>> AFAICS, there is no easy way to do this using system() as rmdir won't
>> accept wildcards, so we can't do "del $PGDATA/* && rmdir $PGDATA/*".
>>
>> It seems to me that the simple answer is to put Andrew's recursive
>> unlink code back in (as he suggested), which Bruce removed as rm etc.
>> were being used in commands/dbcommands.c (which should work fine under
>> Windows). Patch below....
>>
>
> you could of course rmdir /s /q $PGDATA && mkdir $PGDATA if the purpose
> is to leave the directory intact if it already existed prior to
> install.
>

No we can't. This was discussed months ago, IIRC. The user might very well
not have the privileges necessary to delete the directory, and might not
have the privileges to recreate it if they do.

The direct recursive delete is not a lot of code, and I must confess I
*hate* having C programs calling system() for such tasks. One of my goals
in rewriting initdb in C was to avoid any calls at all to any external
program other than postgres itself.

cheers

andrew



In response to

Responses

pgsql-hackers by date

Next:From: Dave PageDate: 2004-06-20 08:32:33
Subject: Re: Cannot initdb in cvs tip
Previous:From: Gavin SherryDate: 2004-06-20 02:31:48
Subject: ALTER TABLE ... SET TABLESPACE

pgsql-patches by date

Next:From: Dave PageDate: 2004-06-20 08:32:33
Subject: Re: Cannot initdb in cvs tip
Previous:From: Gavin SherryDate: 2004-06-20 02:31:48
Subject: ALTER TABLE ... SET TABLESPACE

pgsql-hackers-win32 by date

Next:From: Andreas PflugDate: 2004-06-20 09:28:26
Subject: Re: Compiling libpq with VisualC
Previous:From: John HansenDate: 2004-06-20 01:27:36
Subject: Re: Cannot initdb in cvs tip

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group