Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9a9890d

Browse files
committed
Add fflush() calls so that I'm-about-to-do-this messages actually
come out before the action is done.
1 parent88dd65a commit9a9890d

File tree

1 file changed

+34
-12
lines changed

1 file changed

+34
-12
lines changed

‎src/bin/initdb/initdb.c

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
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

357357
if ((infile=fopen(path,"r"))==NULL)
358358
{
359-
fprintf(stderr,"could not read %s ...",path);
359+
fprintf(stderr,"could not read %s\n",path);
360360
exit_nicely();
361361
}
362362

@@ -415,7 +415,7 @@ writefile(char *path, char **lines)
415415
;
416416
if ((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);
419419
exit_nicely();
420420
}
421421
for (line=lines;*line!=NULL;line++)
@@ -1005,6 +1005,9 @@ test_connections(void)
10051005
inti,
10061006
status;
10071007

1008+
printf("selecting default max_connections ... ");
1009+
fflush(stdout);
1010+
10081011
for (i=0;i<len;i++)
10091012
{
10101013
snprintf(cmd,sizeof(cmd),format,
@@ -1016,7 +1019,8 @@ test_connections(void)
10161019
if (i >=len)
10171020
i=len-1;
10181021
n_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)
10351039
inti,
10361040
status;
10371041

1042+
printf("selecting default shared_buffers ... ");
1043+
fflush(stdout);
1044+
10381045
for (i=0;i<len;i++)
10391046
{
10401047
snprintf(cmd,sizeof(cmd),format,pgpath,bufs[i],n_connections,
@@ -1046,7 +1053,8 @@ test_buffers(void)
10461053
if (i >=len)
10471054
i=len-1;
10481055
n_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)
10621070
charpath[MAXPGPATH];
10631071

10641072
fputs("creating configuration files ... ",stdout);
1073+
fflush(stdout);
10651074

10661075
/* postgresql.conf */
10671076

@@ -1140,6 +1149,7 @@ bootstrap_template1(char *short_version)
11401149
PG_CMD_DECL;
11411150

11421151
printf("creating template1 database in %s/base/1 ... ",pg_data);
1152+
fflush(stdout);
11431153

11441154
if (debug)
11451155
talkargs="-d 5";
@@ -1226,6 +1236,7 @@ setup_shadow(void)
12261236
PG_CMD_DECL;
12271237

12281238
fputs("initializing pg_shadow ... ",stdout);
1239+
fflush(stdout);
12291240

12301241
snprintf(cmd,MAXPGPATH,
12311242
"\"%s/postgres\" -F -O -c search_path=pg_catalog "
@@ -1266,16 +1277,16 @@ get_set_pwd(void)
12661277
free(pwd2);
12671278

12681279
printf("storing the password ... ");
1280+
fflush(stdout);
12691281

12701282
snprintf(cmd,MAXPGPATH,
12711283
"\"%s/postgres\" -F -O -c search_path=pg_catalog "
12721284
"-c exit_on_error=true template1 >%s",pgpath,DEVNULL);
12731285

1274-
12751286
PG_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 */
12811292
exit_nicely();
@@ -1320,6 +1331,7 @@ unlimit_systables(void)
13201331
PG_CMD_DECL;
13211332

13221333
fputs("enabling unlimited row size for system tables ... ",stdout);
1334+
fflush(stdout);
13231335

13241336
snprintf(cmd,MAXPGPATH,
13251337
"\"%s/postgres\" -F -O -c search_path=pg_catalog "
@@ -1389,6 +1401,7 @@ setup_depend(void)
13891401
PG_CMD_DECL;
13901402

13911403
fputs("initializing pg_depend ... ",stdout);
1404+
fflush(stdout);
13921405

13931406
snprintf(cmd,MAXPGPATH,
13941407
"\"%s/postgres\" -F -O -c search_path=pg_catalog "
@@ -1417,6 +1430,7 @@ setup_sysviews(void)
14171430
char**sysviews_setup;
14181431

14191432
fputs("creating system views ... ",stdout);
1433+
fflush(stdout);
14201434

14211435
sysviews_setup=readfile(system_views_file);
14221436

@@ -1472,6 +1486,7 @@ setup_description(void)
14721486
char**desc_lines;
14731487

14741488
fputs("loading pg_description ... ",stdout);
1489+
fflush(stdout);
14751490

14761491
snprintf(cmd,MAXPGPATH,
14771492
"\"%s/postgres\" -F -O -c search_path=pg_catalog "
@@ -1513,6 +1528,7 @@ setup_conversion(void)
15131528
char**conv_lines;
15141529

15151530
fputs("creating conversions ... ",stdout);
1531+
fflush(stdout);
15161532

15171533
snprintf(cmd,MAXPGPATH,
15181534
"\"%s/postgres\" -F -O -c search_path=pg_catalog "
@@ -1563,7 +1579,8 @@ setup_privileges(void)
15631579

15641580
char**priv_lines;
15651581

1566-
fputs("setting privileges on builtin objects ... ",stdout);
1582+
fputs("setting privileges on built-in objects ... ",stdout);
1583+
fflush(stdout);
15671584

15681585
snprintf(cmd,MAXPGPATH,
15691586
"\"%s/postgres\" -F -O -c search_path=pg_catalog "
@@ -1624,6 +1641,7 @@ setup_schema(void)
16241641
intfres;
16251642

16261643
fputs("creating information schema ... ",stdout);
1644+
fflush(stdout);
16271645

16281646
lines=readfile(info_schema_file);
16291647

@@ -1710,6 +1728,7 @@ vacuum_db(void)
17101728
PG_CMD_DECL_NOLINE;
17111729

17121730
fputs("vacuuming database template1 ... ",stdout);
1731+
fflush(stdout);
17131732

17141733
snprintf(cmd,MAXPGPATH,
17151734
"\"%s/postgres\" -F -O -c search_path=pg_catalog "
@@ -1768,6 +1787,7 @@ make_template0(void)
17681787
PG_CMD_DECL;
17691788

17701789
fputs("copying template1 to template0 ... ",stdout);
1790+
fflush(stdout);
17711791

17721792
snprintf(cmd,MAXPGPATH,
17731793
"\"%s/postgres\" -F -O -c search_path=pg_catalog "
@@ -2263,7 +2283,7 @@ main(int argc, char *argv[])
22632283
strcmp(lc_ctype,lc_monetary)==0&&
22642284
strcmp(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",
22672287
lc_ctype);
22682288
}
22692289
else
@@ -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",
22782298
lc_collate,
22792299
lc_ctype,
22802300
lc_messages,
@@ -2326,7 +2346,8 @@ main(int argc, char *argv[])
23262346
*/
23272347
if (errno==ENOENT)
23282348
{
2329-
printf("creating directory \"%s\" ... ",pg_data);
2349+
printf("creating directory %s ... ",pg_data);
2350+
fflush(stdout);
23302351

23312352
if (!mkdatadir(NULL))
23322353
exit_nicely();
@@ -2339,6 +2360,7 @@ main(int argc, char *argv[])
23392360
for (i=0;i< (sizeof(subdirs) /sizeof(char*));i++)
23402361
{
23412362
printf("creating directory %s/%s ... ",pg_data,subdirs[i]);
2363+
fflush(stdout);
23422364

23432365
if (!mkdatadir(subdirs[i]))
23442366
exit_nicely();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp