1212 * This is a C implementation of the previous shell script for setting up a
1313 * PostgreSQL cluster location, and should be highly compatible with it.
1414 *
15- * $Header: /cvsroot/pgsql/src/bin/initdb/initdb.c,v 1.3 2003/11/13 01:09:24 tgl Exp $
15+ * $Header: /cvsroot/pgsql/src/bin/initdb/initdb.c,v 1.4 2003/11/13 01:36:00 tgl Exp $
1616 *
1717 * TODO:
1818 * - clean up find_postgres code and return values
@@ -356,7 +356,7 @@ readfile(char *path)
356356
357357if ((infile = fopen (path ,"r" ))== NULL )
358358{
359- fprintf (stderr ,"could not read %s ... " ,path );
359+ fprintf (stderr ,"could not read %s\n " ,path );
360360exit_nicely ();
361361}
362362
@@ -415,7 +415,7 @@ writefile(char *path, char **lines)
415415;
416416if ((out_file = fopen (path ,PG_BINARY_W ))== NULL )
417417{
418- fprintf (stderr ,"could not write %s ... " ,path );
418+ fprintf (stderr ,"could not write %s\n " ,path );
419419exit_nicely ();
420420}
421421for (line = lines ;* line != NULL ;line ++ )
@@ -1005,6 +1005,9 @@ test_connections(void)
10051005int i ,
10061006status ;
10071007
1008+ printf ("selecting default max_connections ... " );
1009+ fflush (stdout );
1010+
10081011for (i = 0 ;i < len ;i ++ )
10091012{
10101013snprintf (cmd ,sizeof (cmd ),format ,
@@ -1016,7 +1019,8 @@ test_connections(void)
10161019if (i >=len )
10171020i = len - 1 ;
10181021n_connections = conns [i ];
1019- printf ("connections set to %d\n" ,n_connections );
1022+
1023+ printf ("%d\n" ,n_connections );
10201024}
10211025
10221026/*
@@ -1035,6 +1039,9 @@ test_buffers(void)
10351039int i ,
10361040status ;
10371041
1042+ printf ("selecting default shared_buffers ... " );
1043+ fflush (stdout );
1044+
10381045for (i = 0 ;i < len ;i ++ )
10391046{
10401047snprintf (cmd ,sizeof (cmd ),format ,pgpath ,bufs [i ],n_connections ,
@@ -1046,7 +1053,8 @@ test_buffers(void)
10461053if (i >=len )
10471054i = len - 1 ;
10481055n_buffers = bufs [i ];
1049- printf ("buffers set to %d\n" ,n_buffers );
1056+
1057+ printf ("%d\n" ,n_buffers );
10501058}
10511059
10521060/*
@@ -1062,6 +1070,7 @@ setup_config(void)
10621070char path [MAXPGPATH ];
10631071
10641072fputs ("creating configuration files ... " ,stdout );
1073+ fflush (stdout );
10651074
10661075/* postgresql.conf */
10671076
@@ -1140,6 +1149,7 @@ bootstrap_template1(char *short_version)
11401149PG_CMD_DECL ;
11411150
11421151printf ("creating template1 database in %s/base/1 ... " ,pg_data );
1152+ fflush (stdout );
11431153
11441154if (debug )
11451155talkargs = "-d 5" ;
@@ -1226,6 +1236,7 @@ setup_shadow(void)
12261236PG_CMD_DECL ;
12271237
12281238fputs ("initializing pg_shadow ... " ,stdout );
1239+ fflush (stdout );
12291240
12301241snprintf (cmd ,MAXPGPATH ,
12311242"\"%s/postgres\" -F -O -c search_path=pg_catalog "
@@ -1266,16 +1277,16 @@ get_set_pwd(void)
12661277free (pwd2 );
12671278
12681279printf ("storing the password ... " );
1280+ fflush (stdout );
12691281
12701282snprintf (cmd ,MAXPGPATH ,
12711283"\"%s/postgres\" -F -O -c search_path=pg_catalog "
12721284"-c exit_on_error=true template1 >%s" ,pgpath ,DEVNULL );
12731285
1274-
12751286PG_CMD_OPEN ;
12761287
1277- if (fprintf (
1278- pg , "ALTER USER \"%s\" WITH PASSWORD '%s';\n" ,username ,pwd1 )< 0 )
1288+ if (fprintf (pg ,
1289+ "ALTER USER \"%s\" WITH PASSWORD '%s';\n" ,username ,pwd1 )< 0 )
12791290{
12801291/* write failure */
12811292exit_nicely ();
@@ -1320,6 +1331,7 @@ unlimit_systables(void)
13201331PG_CMD_DECL ;
13211332
13221333fputs ("enabling unlimited row size for system tables ... " ,stdout );
1334+ fflush (stdout );
13231335
13241336snprintf (cmd ,MAXPGPATH ,
13251337"\"%s/postgres\" -F -O -c search_path=pg_catalog "
@@ -1389,6 +1401,7 @@ setup_depend(void)
13891401PG_CMD_DECL ;
13901402
13911403fputs ("initializing pg_depend ... " ,stdout );
1404+ fflush (stdout );
13921405
13931406snprintf (cmd ,MAXPGPATH ,
13941407"\"%s/postgres\" -F -O -c search_path=pg_catalog "
@@ -1417,6 +1430,7 @@ setup_sysviews(void)
14171430char * * sysviews_setup ;
14181431
14191432fputs ("creating system views ... " ,stdout );
1433+ fflush (stdout );
14201434
14211435sysviews_setup = readfile (system_views_file );
14221436
@@ -1472,6 +1486,7 @@ setup_description(void)
14721486char * * desc_lines ;
14731487
14741488fputs ("loading pg_description ... " ,stdout );
1489+ fflush (stdout );
14751490
14761491snprintf (cmd ,MAXPGPATH ,
14771492"\"%s/postgres\" -F -O -c search_path=pg_catalog "
@@ -1513,6 +1528,7 @@ setup_conversion(void)
15131528char * * conv_lines ;
15141529
15151530fputs ("creating conversions ... " ,stdout );
1531+ fflush (stdout );
15161532
15171533snprintf (cmd ,MAXPGPATH ,
15181534"\"%s/postgres\" -F -O -c search_path=pg_catalog "
@@ -1563,7 +1579,8 @@ setup_privileges(void)
15631579
15641580char * * priv_lines ;
15651581
1566- fputs ("setting privileges on builtin objects ... " ,stdout );
1582+ fputs ("setting privileges on built-in objects ... " ,stdout );
1583+ fflush (stdout );
15671584
15681585snprintf (cmd ,MAXPGPATH ,
15691586"\"%s/postgres\" -F -O -c search_path=pg_catalog "
@@ -1624,6 +1641,7 @@ setup_schema(void)
16241641int fres ;
16251642
16261643fputs ("creating information schema ... " ,stdout );
1644+ fflush (stdout );
16271645
16281646lines = readfile (info_schema_file );
16291647
@@ -1710,6 +1728,7 @@ vacuum_db(void)
17101728PG_CMD_DECL_NOLINE ;
17111729
17121730fputs ("vacuuming database template1 ... " ,stdout );
1731+ fflush (stdout );
17131732
17141733snprintf (cmd ,MAXPGPATH ,
17151734"\"%s/postgres\" -F -O -c search_path=pg_catalog "
@@ -1768,6 +1787,7 @@ make_template0(void)
17681787PG_CMD_DECL ;
17691788
17701789fputs ("copying template1 to template0 ... " ,stdout );
1790+ fflush (stdout );
17711791
17721792snprintf (cmd ,MAXPGPATH ,
17731793"\"%s/postgres\" -F -O -c search_path=pg_catalog "
@@ -2263,7 +2283,7 @@ main(int argc, char *argv[])
22632283strcmp (lc_ctype ,lc_monetary )== 0 &&
22642284strcmp (lc_ctype ,lc_messages )== 0 )
22652285{
2266- printf ("The database cluster will be initialized with locale %s\n" ,
2286+ printf ("The database cluster will be initialized with locale %s.\n \n" ,
22672287lc_ctype );
22682288}
22692289else
@@ -2274,7 +2294,7 @@ main(int argc, char *argv[])
22742294" MESSAGES: %s\n"
22752295" MONETARY: %s\n"
22762296" NUMERIC: %s\n"
2277- " TIME: %s\n" ,
2297+ " TIME: %s\n\n " ,
22782298lc_collate ,
22792299lc_ctype ,
22802300lc_messages ,
@@ -2326,7 +2346,8 @@ main(int argc, char *argv[])
23262346 */
23272347if (errno == ENOENT )
23282348{
2329- printf ("creating directory \"%s\" ... " ,pg_data );
2349+ printf ("creating directory %s ... " ,pg_data );
2350+ fflush (stdout );
23302351
23312352if (!mkdatadir (NULL ))
23322353exit_nicely ();
@@ -2339,6 +2360,7 @@ main(int argc, char *argv[])
23392360for (i = 0 ;i < (sizeof (subdirs ) /sizeof (char * ));i ++ )
23402361{
23412362printf ("creating directory %s/%s ... " ,pg_data ,subdirs [i ]);
2363+ fflush (stdout );
23422364
23432365if (!mkdatadir (subdirs [i ]))
23442366exit_nicely ();