Path expansion in initdb

Started by Peter Eisentrautabout 21 years ago2 messages
#1Peter Eisentraut
peter_e@gmx.net

It used to be that calling

initdb -D /some/where

suggested starting

postmaster -D /some/where

and

./mydir/bin/initdb -D ./mydir/var/data

suggested starting

./mydir/bin/postmaster -D ./mydir/var/data

In the current sources, the path to the postmaster is fully expanded in
either case (resulting in something like
/home/peter/./mydir/bin/postmaster in the second case). (Curiously,
the data directory path is not changed.) I don't find this to be an
improvement. Is there a reason for this change?

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#2Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Peter Eisentraut (#1)
1 attachment(s)
Re: [HACKERS] Path expansion in initdb

Peter Eisentraut wrote:

It used to be that calling

initdb -D /some/where

suggested starting

postmaster -D /some/where

and

./mydir/bin/initdb -D ./mydir/var/data

suggested starting

./mydir/bin/postmaster -D ./mydir/var/data

In the current sources, the path to the postmaster is fully expanded in
either case (resulting in something like
/home/peter/./mydir/bin/postmaster in the second case). (Curiously,
the data directory path is not changed.) I don't find this to be an
improvement. Is there a reason for this change?

I have applied the following patch to address your concerns. We needed
this anyway because we were not using native paths in the display.

-- 
  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

Attachments:

/bjm/difftext/plainDownload
Index: src/bin/initdb/initdb.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/initdb/initdb.c,v
retrieving revision 1.68
diff -c -c -r1.68 initdb.c
*** src/bin/initdb/initdb.c	27 Nov 2004 18:51:05 -0000	1.68
--- src/bin/initdb/initdb.c	28 Nov 2004 23:37:14 -0000
***************
*** 216,223 ****
--- 216,225 ----
  
  #ifndef WIN32
  #define QUOTE_PATH	""
+ #define DIR_SEP "/"
  #else
  #define QUOTE_PATH	"\""
+ #define DIR_SEP "\\"
  #endif
  
  /*
***************
*** 2079,2084 ****
--- 2081,2088 ----
  	char	   *short_version;
  	char	   *pgdenv;			/* PGDATA value gotten from and sent to
  								 * environment */
+ 	char		bin_dir[MAXPGPATH];
+ 	char		*pg_data_native;
  	static const char *subdirs[] = {
  		"global",
  		"pg_xlog",
***************
*** 2256,2261 ****
--- 2260,2266 ----
  		}
  	}
  
+ 	pg_data_native = pg_data;
  	canonicalize_path(pg_data);
  
  	/*
***************
*** 2567,2578 ****
  	if (authwarning != NULL)
  		fprintf(stderr, authwarning);
  
  	printf(_("\nSuccess. You can now start the database server using:\n\n"
! 			 "    %s%s%s/postmaster -D %s%s%s\n"
  			 "or\n"
! 			 "    %s%s%s/pg_ctl -D %s%s%s -l logfile start\n\n"),
! 	   QUOTE_PATH, bin_path, QUOTE_PATH, QUOTE_PATH, pg_data, QUOTE_PATH,
! 	  QUOTE_PATH, bin_path, QUOTE_PATH, QUOTE_PATH, pg_data, QUOTE_PATH);
  
  	return 0;
  }
--- 2572,2589 ----
  	if (authwarning != NULL)
  		fprintf(stderr, authwarning);
  
+ 	/* Get directory specification used to start this executable */
+ 	strcpy(bin_dir, argv[0]);
+ 	get_parent_directory(bin_dir);
+ 	
  	printf(_("\nSuccess. You can now start the database server using:\n\n"
! 			 "    %s%s%s%spostmaster -D %s%s%s\n"
  			 "or\n"
! 			 "    %s%s%s%spg_ctl -D %s%s%s -l logfile start\n\n"),
! 	  QUOTE_PATH, bin_dir, QUOTE_PATH, (strlen(bin_dir) > 0) ? DIR_SEP : "",
! 	  QUOTE_PATH, pg_data_native, QUOTE_PATH,
! 	  QUOTE_PATH, bin_dir, QUOTE_PATH, (strlen(bin_dir) > 0) ? DIR_SEP : "",
! 	  QUOTE_PATH, pg_data_native, QUOTE_PATH);
  
  	return 0;
  }