12
12
* This is a C implementation of the previous shell script for setting up a
13
13
* PostgreSQL cluster location, and should be highly compatible with it.
14
14
*
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 $
16
16
*
17
17
* TODO:
18
18
* - clean up find_postgres code and return values
@@ -356,7 +356,7 @@ readfile(char *path)
356
356
357
357
if ((infile = fopen (path , "r" )) == NULL )
358
358
{
359
- fprintf (stderr , "could not read %s ... " , path );
359
+ fprintf (stderr , "could not read %s\n " , path );
360
360
exit_nicely ();
361
361
}
362
362
@@ -415,7 +415,7 @@ writefile(char *path, char **lines)
415
415
;
416
416
if ((out_file = fopen (path , PG_BINARY_W )) == NULL )
417
417
{
418
- fprintf (stderr , "could not write %s ... " , path );
418
+ fprintf (stderr , "could not write %s\n " , path );
419
419
exit_nicely ();
420
420
}
421
421
for (line = lines ; * line != NULL ; line ++ )
@@ -1005,6 +1005,9 @@ test_connections(void)
1005
1005
int i ,
1006
1006
status ;
1007
1007
1008
+ printf ("selecting default max_connections ... " );
1009
+ fflush (stdout );
1010
+
1008
1011
for (i = 0 ; i < len ; i ++ )
1009
1012
{
1010
1013
snprintf (cmd , sizeof (cmd ), format ,
@@ -1016,7 +1019,8 @@ test_connections(void)
1016
1019
if (i >= len )
1017
1020
i = len - 1 ;
1018
1021
n_connections = conns [i ];
1019
- printf ("connections set to %d\n" , n_connections );
1022
+
1023
+ printf ("%d\n" , n_connections );
1020
1024
}
1021
1025
1022
1026
/*
@@ -1035,6 +1039,9 @@ test_buffers(void)
1035
1039
int i ,
1036
1040
status ;
1037
1041
1042
+ printf ("selecting default shared_buffers ... " );
1043
+ fflush (stdout );
1044
+
1038
1045
for (i = 0 ; i < len ; i ++ )
1039
1046
{
1040
1047
snprintf (cmd , sizeof (cmd ), format , pgpath , bufs [i ], n_connections ,
@@ -1046,7 +1053,8 @@ test_buffers(void)
1046
1053
if (i >= len )
1047
1054
i = len - 1 ;
1048
1055
n_buffers = bufs [i ];
1049
- printf ("buffers set to %d\n" , n_buffers );
1056
+
1057
+ printf ("%d\n" , n_buffers );
1050
1058
}
1051
1059
1052
1060
/*
@@ -1062,6 +1070,7 @@ setup_config(void)
1062
1070
char path [MAXPGPATH ];
1063
1071
1064
1072
fputs ("creating configuration files ... " , stdout );
1073
+ fflush (stdout );
1065
1074
1066
1075
/* postgresql.conf */
1067
1076
@@ -1140,6 +1149,7 @@ bootstrap_template1(char *short_version)
1140
1149
PG_CMD_DECL ;
1141
1150
1142
1151
printf ("creating template1 database in %s/base/1 ... " , pg_data );
1152
+ fflush (stdout );
1143
1153
1144
1154
if (debug )
1145
1155
talkargs = "-d 5" ;
@@ -1226,6 +1236,7 @@ setup_shadow(void)
1226
1236
PG_CMD_DECL ;
1227
1237
1228
1238
fputs ("initializing pg_shadow ... " , stdout );
1239
+ fflush (stdout );
1229
1240
1230
1241
snprintf (cmd , MAXPGPATH ,
1231
1242
"\"%s/postgres\" -F -O -c search_path=pg_catalog "
@@ -1266,16 +1277,16 @@ get_set_pwd(void)
1266
1277
free (pwd2 );
1267
1278
1268
1279
printf ("storing the password ... " );
1280
+ fflush (stdout );
1269
1281
1270
1282
snprintf (cmd , MAXPGPATH ,
1271
1283
"\"%s/postgres\" -F -O -c search_path=pg_catalog "
1272
1284
"-c exit_on_error=true template1 >%s" , pgpath , DEVNULL );
1273
1285
1274
-
1275
1286
PG_CMD_OPEN ;
1276
1287
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 )
1279
1290
{
1280
1291
/* write failure */
1281
1292
exit_nicely ();
@@ -1320,6 +1331,7 @@ unlimit_systables(void)
1320
1331
PG_CMD_DECL ;
1321
1332
1322
1333
fputs ("enabling unlimited row size for system tables ... " , stdout );
1334
+ fflush (stdout );
1323
1335
1324
1336
snprintf (cmd , MAXPGPATH ,
1325
1337
"\"%s/postgres\" -F -O -c search_path=pg_catalog "
@@ -1389,6 +1401,7 @@ setup_depend(void)
1389
1401
PG_CMD_DECL ;
1390
1402
1391
1403
fputs ("initializing pg_depend ... " , stdout );
1404
+ fflush (stdout );
1392
1405
1393
1406
snprintf (cmd , MAXPGPATH ,
1394
1407
"\"%s/postgres\" -F -O -c search_path=pg_catalog "
@@ -1417,6 +1430,7 @@ setup_sysviews(void)
1417
1430
char * * sysviews_setup ;
1418
1431
1419
1432
fputs ("creating system views ... " , stdout );
1433
+ fflush (stdout );
1420
1434
1421
1435
sysviews_setup = readfile (system_views_file );
1422
1436
@@ -1472,6 +1486,7 @@ setup_description(void)
1472
1486
char * * desc_lines ;
1473
1487
1474
1488
fputs ("loading pg_description ... " , stdout );
1489
+ fflush (stdout );
1475
1490
1476
1491
snprintf (cmd , MAXPGPATH ,
1477
1492
"\"%s/postgres\" -F -O -c search_path=pg_catalog "
@@ -1513,6 +1528,7 @@ setup_conversion(void)
1513
1528
char * * conv_lines ;
1514
1529
1515
1530
fputs ("creating conversions ... " , stdout );
1531
+ fflush (stdout );
1516
1532
1517
1533
snprintf (cmd , MAXPGPATH ,
1518
1534
"\"%s/postgres\" -F -O -c search_path=pg_catalog "
@@ -1563,7 +1579,8 @@ setup_privileges(void)
1563
1579
1564
1580
char * * priv_lines ;
1565
1581
1566
- fputs ("setting privileges on builtin objects ... " , stdout );
1582
+ fputs ("setting privileges on built-in objects ... " , stdout );
1583
+ fflush (stdout );
1567
1584
1568
1585
snprintf (cmd , MAXPGPATH ,
1569
1586
"\"%s/postgres\" -F -O -c search_path=pg_catalog "
@@ -1624,6 +1641,7 @@ setup_schema(void)
1624
1641
int fres ;
1625
1642
1626
1643
fputs ("creating information schema ... " , stdout );
1644
+ fflush (stdout );
1627
1645
1628
1646
lines = readfile (info_schema_file );
1629
1647
@@ -1710,6 +1728,7 @@ vacuum_db(void)
1710
1728
PG_CMD_DECL_NOLINE ;
1711
1729
1712
1730
fputs ("vacuuming database template1 ... " , stdout );
1731
+ fflush (stdout );
1713
1732
1714
1733
snprintf (cmd , MAXPGPATH ,
1715
1734
"\"%s/postgres\" -F -O -c search_path=pg_catalog "
@@ -1768,6 +1787,7 @@ make_template0(void)
1768
1787
PG_CMD_DECL ;
1769
1788
1770
1789
fputs ("copying template1 to template0 ... " , stdout );
1790
+ fflush (stdout );
1771
1791
1772
1792
snprintf (cmd , MAXPGPATH ,
1773
1793
"\"%s/postgres\" -F -O -c search_path=pg_catalog "
@@ -2263,7 +2283,7 @@ main(int argc, char *argv[])
2263
2283
strcmp (lc_ctype , lc_monetary ) == 0 &&
2264
2284
strcmp (lc_ctype , lc_messages ) == 0 )
2265
2285
{
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" ,
2267
2287
lc_ctype );
2268
2288
}
2269
2289
else
@@ -2274,7 +2294,7 @@ main(int argc, char *argv[])
2274
2294
" MESSAGES: %s\n"
2275
2295
" MONETARY: %s\n"
2276
2296
" NUMERIC: %s\n"
2277
- " TIME: %s\n" ,
2297
+ " TIME: %s\n\n " ,
2278
2298
lc_collate ,
2279
2299
lc_ctype ,
2280
2300
lc_messages ,
@@ -2326,7 +2346,8 @@ main(int argc, char *argv[])
2326
2346
*/
2327
2347
if (errno == ENOENT )
2328
2348
{
2329
- printf ("creating directory \"%s\" ... " , pg_data );
2349
+ printf ("creating directory %s ... " , pg_data );
2350
+ fflush (stdout );
2330
2351
2331
2352
if (!mkdatadir (NULL ))
2332
2353
exit_nicely ();
@@ -2339,6 +2360,7 @@ main(int argc, char *argv[])
2339
2360
for (i = 0 ; i < (sizeof (subdirs ) / sizeof (char * )); i ++ )
2340
2361
{
2341
2362
printf ("creating directory %s/%s ... " , pg_data , subdirs [i ]);
2363
+ fflush (stdout );
2342
2364
2343
2365
if (!mkdatadir (subdirs [i ]))
2344
2366
exit_nicely ();
0 commit comments