Skip to content

Commit b3c3b54

Browse files
committed
Do an explicit fflush after writing a progress message with puts.
This ensures stdout is kept in sync with messages on stderr. Per report from Olaf Ferger.
1 parent 8042c79 commit b3c3b54

File tree

6 files changed

+55
-32
lines changed

6 files changed

+55
-32
lines changed

src/bin/scripts/clusterdb.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Portions Copyright (c) 2002-2003, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/bin/scripts/clusterdb.c,v 1.4 2003/11/29 19:52:07 pgsql Exp $
7+
* $PostgreSQL: pgsql/src/bin/scripts/clusterdb.c,v 1.5 2004/01/01 19:27:15 tgl Exp $
88
*
99
*-------------------------------------------------------------------------
1010
*/
@@ -14,14 +14,14 @@
1414
#include "dumputils.h"
1515

1616

17-
static
18-
void
17+
static void
1918
cluster_one_database(const char *dbname, const char *table,
20-
const char *host, const char *port, const char *username, bool password,
19+
const char *host, const char *port,
20+
const char *username, bool password,
2121
const char *progname, bool echo, bool quiet);
22-
static
23-
void
24-
cluster_all_databases(const char *host, const char *port, const char *username, bool password,
22+
static void
23+
cluster_all_databases(const char *host, const char *port,
24+
const char *username, bool password,
2525
const char *progname, bool echo, bool quiet);
2626

2727
static void help(const char *progname);
@@ -151,10 +151,10 @@ main(int argc, char *argv[])
151151
}
152152

153153

154-
static
155-
void
154+
static void
156155
cluster_one_database(const char *dbname, const char *table,
157-
const char *host, const char *port, const char *username, bool password,
156+
const char *host, const char *port,
157+
const char *username, bool password,
158158
const char *progname, bool echo, bool quiet)
159159
{
160160
PQExpBufferData sql;
@@ -192,13 +192,16 @@ cluster_one_database(const char *dbname, const char *table,
192192
termPQExpBuffer(&sql);
193193

194194
if (!quiet)
195+
{
195196
puts("CLUSTER");
197+
fflush(stdout);
198+
}
196199
}
197200

198201

199-
static
200-
void
201-
cluster_all_databases(const char *host, const char *port, const char *username, bool password,
202+
static void
203+
cluster_all_databases(const char *host, const char *port,
204+
const char *username, bool password,
202205
const char *progname, bool echo, bool quiet)
203206
{
204207
PGconn *conn;

src/bin/scripts/createdb.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
8-
* $PostgreSQL: pgsql/src/bin/scripts/createdb.c,v 1.6 2003/11/29 19:52:07 pgsql Exp $
8+
* $PostgreSQL: pgsql/src/bin/scripts/createdb.c,v 1.7 2004/01/01 19:27:15 tgl Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -177,7 +177,10 @@ main(int argc, char *argv[])
177177
PQfinish(conn);
178178

179179
if (!quiet)
180+
{
180181
puts("CREATE DATABASE");
182+
fflush(stdout);
183+
}
181184

182185
if (comment)
183186
{
@@ -200,7 +203,10 @@ main(int argc, char *argv[])
200203

201204
PQfinish(conn);
202205
if (!quiet)
206+
{
203207
puts("COMMENT");
208+
fflush(stdout);
209+
}
204210
}
205211

206212
exit(0);

src/bin/scripts/createuser.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
8-
* $PostgreSQL: pgsql/src/bin/scripts/createuser.c,v 1.7 2003/11/29 19:52:07 pgsql Exp $
8+
* $PostgreSQL: pgsql/src/bin/scripts/createuser.c,v 1.8 2004/01/01 19:27:15 tgl Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -224,7 +224,10 @@ main(int argc, char *argv[])
224224

225225
PQfinish(conn);
226226
if (!quiet)
227+
{
227228
puts("CREATE USER");
229+
fflush(stdout);
230+
}
228231
exit(0);
229232
}
230233

src/bin/scripts/dropdb.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
8-
* $PostgreSQL: pgsql/src/bin/scripts/dropdb.c,v 1.7 2003/11/29 19:52:07 pgsql Exp $
8+
* $PostgreSQL: pgsql/src/bin/scripts/dropdb.c,v 1.8 2004/01/01 19:27:15 tgl Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -131,7 +131,10 @@ main(int argc, char *argv[])
131131

132132
PQfinish(conn);
133133
if (!quiet)
134+
{
134135
puts("DROP DATABASE");
136+
fflush(stdout);
137+
}
135138
exit(0);
136139
}
137140

src/bin/scripts/dropuser.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
8-
* $PostgreSQL: pgsql/src/bin/scripts/dropuser.c,v 1.6 2003/11/29 19:52:07 pgsql Exp $
8+
* $PostgreSQL: pgsql/src/bin/scripts/dropuser.c,v 1.7 2004/01/01 19:27:15 tgl Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -131,7 +131,10 @@ main(int argc, char *argv[])
131131

132132
PQfinish(conn);
133133
if (!quiet)
134+
{
134135
puts("DROP USER");
136+
fflush(stdout);
137+
}
135138
exit(0);
136139
}
137140

src/bin/scripts/vacuumdb.c

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
8-
* $PostgreSQL: pgsql/src/bin/scripts/vacuumdb.c,v 1.4 2003/11/29 19:52:07 pgsql Exp $
8+
* $PostgreSQL: pgsql/src/bin/scripts/vacuumdb.c,v 1.5 2004/01/01 19:27:15 tgl Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -14,15 +14,16 @@
1414
#include "common.h"
1515

1616

17-
static
18-
void
19-
vacuum_one_database(const char *dbname, bool full, bool verbose, bool analyze, const char *table,
20-
const char *host, const char *port, const char *username, bool password,
17+
static void
18+
vacuum_one_database(const char *dbname, bool full, bool verbose, bool analyze,
19+
const char *table,
20+
const char *host, const char *port,
21+
const char *username, bool password,
2122
const char *progname, bool echo, bool quiet);
22-
static
23-
void
23+
static void
2424
vacuum_all_databases(bool full, bool verbose, bool analyze,
25-
const char *host, const char *port, const char *username, bool password,
25+
const char *host, const char *port,
26+
const char *username, bool password,
2627
const char *progname, bool echo, bool quiet);
2728

2829
static void help(const char *progname);
@@ -168,10 +169,11 @@ main(int argc, char *argv[])
168169
}
169170

170171

171-
static
172-
void
173-
vacuum_one_database(const char *dbname, bool full, bool verbose, bool analyze, const char *table,
174-
const char *host, const char *port, const char *username, bool password,
172+
static void
173+
vacuum_one_database(const char *dbname, bool full, bool verbose, bool analyze,
174+
const char *table,
175+
const char *host, const char *port,
176+
const char *username, bool password,
175177
const char *progname, bool echo, bool quiet)
176178
{
177179
PQExpBufferData sql;
@@ -215,14 +217,17 @@ vacuum_one_database(const char *dbname, bool full, bool verbose, bool analyze, c
215217
termPQExpBuffer(&sql);
216218

217219
if (!quiet)
220+
{
218221
puts("VACUUM");
222+
fflush(stdout);
223+
}
219224
}
220225

221226

222-
static
223-
void
227+
static void
224228
vacuum_all_databases(bool full, bool verbose, bool analyze,
225-
const char *host, const char *port, const char *username, bool password,
229+
const char *host, const char *port,
230+
const char *username, bool password,
226231
const char *progname, bool echo, bool quiet)
227232
{
228233
PGconn *conn;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy