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

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 15:15:26
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackerspgsql-hackers-win32pgsql-patches

Bruce Momjian wrote:

>Here is a slightly modified version of Andrew's great work in making a C
>version of initdb.  Other than minor cleanups, the only big change was
>to remove rmdir handling because we using rm -r and rmdir /s in
>commands/dbcommands.c, so we might as use the same thing for initdb.c
>rather than having code that traverses the directory tree doing 'rm'.
>The other change was to remove the unlink code and instead use
>port/dirmod.c's version.
>It passes all the regression tests.  I have also included a diff against
>Andrew's version so you can see my changes.  It seems Andrew had a very
>current version of initdb.  The only update he missed was the change to
>test the number of connections before shared buffers --- I made that
>change myself.
>I would like to apply this in the next few days to HEAD before
>drifts.  We are no longer using the WIN32_DEV branch because all our
>work is now in 7.5 head.

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.

Regarding the #endif comments you removed - Peter had asked me to put 
them in. See

You put a comment on canonicalise_path() asking if it is needed. The 
short answer is very much "yes". The Windows command processor will 
accept suitably quoted paths with forward slashes, but barfs badly with 
mixed forward and back slashes. (See recent discussion on 
hackers-win32).Removing the trailing slash on a path means we never get 
ugly double slashes. Feel free to put that info in as a comment if you 
think it is needed.

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.

(Getting the path and slash thing working portably was by far the 
biggest headache in this project - the rest was just grunt work for the 
most part, although I learned a few interesting things.)

Otherwise I'm fine with this.



In response to

  • initdb in C at 2003-11-08 05:15:42 from Bruce Momjian


pgsql-hackers by date

Next:From: Rod TaylorDate: 2003-11-08 15:20:46
Subject: Re: What do you want me to do?
Previous:From: Abhijit Menon-SenDate: 2003-11-08 15:04:22
Subject: Re: What do you want me to do?

pgsql-patches by date

Next:From: Bruce MomjianDate: 2003-11-08 15:39:38
Subject: Re: [PATCHES] initdb in C
Previous:From: Peter EisentrautDate: 2003-11-08 11:04:43
Subject: Re: alter schema help is not available in psql

pgsql-hackers-win32 by date

Next:From: Bruce MomjianDate: 2003-11-08 15:39:38
Subject: Re: [PATCHES] initdb in C
Previous:From: Hisaji OnoDate: 2003-11-08 10:38:10
Subject: Error to build snapshot

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