summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/pg_basebackup/pg_basebackup.c18
-rw-r--r--src/bin/pg_basebackup/pg_receivexlog.c23
-rw-r--r--src/bin/pg_basebackup/receivelog.c115
-rw-r--r--src/bin/pg_basebackup/receivelog.h2
-rw-r--r--src/bin/pg_basebackup/streamutil.c14
-rw-r--r--src/bin/pg_basebackup/streamutil.h12
-rw-r--r--src/bin/pg_basebackup/t/010_pg_basebackup.pl24
-rw-r--r--src/bin/pg_ctl/pg_ctl.c13
-rw-r--r--src/bin/pg_ctl/t/001_start_stop.pl4
-rw-r--r--src/bin/pg_ctl/t/002_status.pl2
-rw-r--r--src/bin/pg_dump/pg_dump.c126
-rw-r--r--src/bin/pg_dump/pg_dump.h2
-rw-r--r--src/bin/pg_dump/pg_dumpall.c2
-rw-r--r--src/bin/pg_resetxlog/pg_resetxlog.c6
-rw-r--r--src/bin/pg_rewind/RewindTest.pm148
-rw-r--r--src/bin/pg_rewind/filemap.c19
-rw-r--r--src/bin/pg_rewind/filemap.h28
-rw-r--r--src/bin/pg_rewind/parsexlog.c10
-rw-r--r--src/bin/pg_rewind/pg_rewind.c8
-rw-r--r--src/bin/pg_rewind/t/001_basic.pl20
-rw-r--r--src/bin/pg_rewind/t/002_databases.pl8
-rw-r--r--src/bin/pg_rewind/t/003_extrafiles.pl56
-rw-r--r--src/bin/pg_upgrade/check.c29
-rw-r--r--src/bin/pg_upgrade/dump.c8
-rw-r--r--src/bin/pg_upgrade/info.c160
-rw-r--r--src/bin/pg_upgrade/option.c12
-rw-r--r--src/bin/pg_upgrade/pg_upgrade.c6
-rw-r--r--src/bin/pg_upgrade/pg_upgrade.h6
-rw-r--r--src/bin/pg_upgrade/relfilenode.c8
-rw-r--r--src/bin/pg_upgrade/server.c11
-rw-r--r--src/bin/pg_upgrade/version.c4
-rw-r--r--src/bin/pg_xlogdump/pg_xlogdump.c30
-rw-r--r--src/bin/pgbench/pgbench.c119
-rw-r--r--src/bin/pgbench/pgbench.h34
-rw-r--r--src/bin/psql/command.c31
-rw-r--r--src/bin/psql/common.c9
-rw-r--r--src/bin/psql/common.h2
-rw-r--r--src/bin/psql/copy.c2
-rw-r--r--src/bin/psql/describe.c36
-rw-r--r--src/bin/psql/help.c40
-rw-r--r--src/bin/psql/print.c60
-rw-r--r--src/bin/psql/print.h8
-rw-r--r--src/bin/psql/startup.c2
-rw-r--r--src/bin/psql/tab-complete.c54
-rw-r--r--src/bin/scripts/common.c2
-rw-r--r--src/bin/scripts/reindexdb.c20
-rw-r--r--src/bin/scripts/t/102_vacuumdb_stages.pl2
-rw-r--r--src/bin/scripts/vacuumdb.c4
48 files changed, 745 insertions, 614 deletions
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c
index 2d0ea7bad8..5dd2887d12 100644
--- a/src/bin/pg_basebackup/pg_basebackup.c
+++ b/src/bin/pg_basebackup/pg_basebackup.c
@@ -236,7 +236,7 @@ usage(void)
printf(_(" -D, --pgdata=DIRECTORY receive base backup into directory\n"));
printf(_(" -F, --format=p|t output format (plain (default), tar)\n"));
printf(_(" -r, --max-rate=RATE maximum transfer rate to transfer data directory\n"
- " (in kB/s, or use suffix \"k\" or \"M\")\n"));
+ " (in kB/s, or use suffix \"k\" or \"M\")\n"));
printf(_(" -R, --write-recovery-conf\n"
" write recovery.conf after backup\n"));
printf(_(" -T, --tablespace-mapping=OLDDIR=NEWDIR\n"
@@ -1255,7 +1255,7 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
* failures on related directories.
*/
if (!((pg_str_endswith(filename, "/pg_xlog") ||
- pg_str_endswith(filename, "/archive_status")) &&
+ pg_str_endswith(filename, "/archive_status")) &&
errno == EEXIST))
{
fprintf(stderr,
@@ -1278,12 +1278,12 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
*
* It's most likely a link in pg_tblspc directory, to the
* location of a tablespace. Apply any tablespace mapping
- * given on the command line (--tablespace-mapping).
- * (We blindly apply the mapping without checking that
- * the link really is inside pg_tblspc. We don't expect
- * there to be other symlinks in a data directory, but
- * if there are, you can call it an undocumented feature
- * that you can map them too.)
+ * given on the command line (--tablespace-mapping). (We
+ * blindly apply the mapping without checking that the
+ * link really is inside pg_tblspc. We don't expect there
+ * to be other symlinks in a data directory, but if there
+ * are, you can call it an undocumented feature that you
+ * can map them too.)
*/
filename[strlen(filename) - 1] = '\0'; /* Remove trailing slash */
@@ -1659,7 +1659,7 @@ BaseBackup(void)
fastcheckpoint ? "FAST" : "",
includewal ? "NOWAIT" : "",
maxrate_clause ? maxrate_clause : "",
- format == 't' ? "TABLESPACE_MAP": "");
+ format == 't' ? "TABLESPACE_MAP" : "");
if (PQsendQuery(conn, basebkp) == 0)
{
diff --git a/src/bin/pg_basebackup/pg_receivexlog.c b/src/bin/pg_basebackup/pg_receivexlog.c
index 71fb94578e..5d964e4ee6 100644
--- a/src/bin/pg_basebackup/pg_receivexlog.c
+++ b/src/bin/pg_basebackup/pg_receivexlog.c
@@ -43,7 +43,7 @@ static bool synchronous = false;
static void usage(void);
-static DIR* get_destination_dir(char *dest_folder);
+static DIR *get_destination_dir(char *dest_folder);
static void close_destination_dir(DIR *dest_dir, char *dest_folder);
static XLogRecPtr FindStreamingStart(uint32 *tli);
static void StreamLog(void);
@@ -128,10 +128,10 @@ stop_streaming(XLogRecPtr xlogpos, uint32 timeline, bool segment_finished)
/*
* Get destination directory.
*/
-static DIR*
+static DIR *
get_destination_dir(char *dest_folder)
{
- DIR *dir;
+ DIR *dir;
Assert(dest_folder != NULL);
dir = opendir(dest_folder);
@@ -274,8 +274,10 @@ FindStreamingStart(uint32 *tli)
static void
StreamLog(void)
{
- XLogRecPtr startpos, serverpos;
- TimeLineID starttli, servertli;
+ XLogRecPtr startpos,
+ serverpos;
+ TimeLineID starttli,
+ servertli;
/*
* Connect in replication mode to the server
@@ -513,7 +515,8 @@ main(int argc, char **argv)
*/
if (!do_drop_slot)
{
- DIR *dir = get_destination_dir(basedir);
+ DIR *dir = get_destination_dir(basedir);
+
close_destination_dir(dir, basedir);
}
@@ -538,8 +541,8 @@ main(int argc, char **argv)
disconnect_and_exit(1);
/*
- * Check that there is a database associated with connection, none
- * should be defined in this context.
+ * Check that there is a database associated with connection, none should
+ * be defined in this context.
*/
if (db_name)
{
@@ -577,8 +580,8 @@ main(int argc, char **argv)
}
/*
- * Don't close the connection here so that subsequent StreamLog()
- * can reuse it.
+ * Don't close the connection here so that subsequent StreamLog() can
+ * reuse it.
*/
while (true)
diff --git a/src/bin/pg_basebackup/receivelog.c b/src/bin/pg_basebackup/receivelog.c
index 8caedff2b0..3c60626541 100644
--- a/src/bin/pg_basebackup/receivelog.c
+++ b/src/bin/pg_basebackup/receivelog.c
@@ -36,26 +36,26 @@ static bool still_sending = true; /* feedback still needs to be sent? */
static PGresult *HandleCopyStream(PGconn *conn, XLogRecPtr startpos,
uint32 timeline, char *basedir,
stream_stop_callback stream_stop, int standby_message_timeout,
- char *partial_suffix, XLogRecPtr *stoppos,
- bool synchronous, bool mark_done);
-static int CopyStreamPoll(PGconn *conn, long timeout_ms);
-static int CopyStreamReceive(PGconn *conn, long timeout, char **buffer);
+ char *partial_suffix, XLogRecPtr *stoppos,
+ bool synchronous, bool mark_done);
+static int CopyStreamPoll(PGconn *conn, long timeout_ms);
+static int CopyStreamReceive(PGconn *conn, long timeout, char **buffer);
static bool ProcessKeepaliveMsg(PGconn *conn, char *copybuf, int len,
- XLogRecPtr blockpos, int64 *last_status);
+ XLogRecPtr blockpos, int64 *last_status);
static bool ProcessXLogDataMsg(PGconn *conn, char *copybuf, int len,
- XLogRecPtr *blockpos, uint32 timeline,
- char *basedir, stream_stop_callback stream_stop,
- char *partial_suffix, bool mark_done);
+ XLogRecPtr *blockpos, uint32 timeline,
+ char *basedir, stream_stop_callback stream_stop,
+ char *partial_suffix, bool mark_done);
static PGresult *HandleEndOfCopyStream(PGconn *conn, char *copybuf,
- XLogRecPtr blockpos, char *basedir, char *partial_suffix,
- XLogRecPtr *stoppos, bool mark_done);
+ XLogRecPtr blockpos, char *basedir, char *partial_suffix,
+ XLogRecPtr *stoppos, bool mark_done);
static bool CheckCopyStreamStop(PGconn *conn, XLogRecPtr blockpos,
- uint32 timeline, char *basedir,
- stream_stop_callback stream_stop,
- char *partial_suffix, XLogRecPtr *stoppos,
- bool mark_done);
+ uint32 timeline, char *basedir,
+ stream_stop_callback stream_stop,
+ char *partial_suffix, XLogRecPtr *stoppos,
+ bool mark_done);
static long CalculateCopyStreamSleeptime(int64 now, int standby_message_timeout,
- int64 last_status);
+ int64 last_status);
static bool ReadEndOfStreamingResult(PGresult *res, XLogRecPtr *startpos,
uint32 *timeline);
@@ -63,7 +63,7 @@ static bool ReadEndOfStreamingResult(PGresult *res, XLogRecPtr *startpos,
static bool
mark_file_as_archived(const char *basedir, const char *fname)
{
- int fd;
+ int fd;
static char tmppath[MAXPGPATH];
snprintf(tmppath, sizeof(tmppath), "%s/archive_status/%s.done",
@@ -831,15 +831,15 @@ HandleCopyStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline,
* Check if we should continue streaming, or abort at this point.
*/
if (!CheckCopyStreamStop(conn, blockpos, timeline, basedir,
- stream_stop, partial_suffix, stoppos,
- mark_done))
+ stream_stop, partial_suffix, stoppos,
+ mark_done))
goto error;
now = feGetCurrentTimestamp();
/*
- * If synchronous option is true, issue sync command as soon as
- * there are WAL data which has not been flushed yet.
+ * If synchronous option is true, issue sync command as soon as there
+ * are WAL data which has not been flushed yet.
*/
if (synchronous && lastFlushPosition < blockpos && walfile != -1)
{
@@ -886,9 +886,10 @@ HandleCopyStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline,
goto error;
if (r == -2)
{
- PGresult *res = HandleEndOfCopyStream(conn, copybuf, blockpos,
- basedir, partial_suffix,
- stoppos, mark_done);
+ PGresult *res = HandleEndOfCopyStream(conn, copybuf, blockpos,
+ basedir, partial_suffix,
+ stoppos, mark_done);
+
if (res == NULL)
goto error;
else
@@ -910,7 +911,8 @@ HandleCopyStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline,
goto error;
/*
- * Check if we should continue streaming, or abort at this point.
+ * Check if we should continue streaming, or abort at this
+ * point.
*/
if (!CheckCopyStreamStop(conn, blockpos, timeline, basedir,
stream_stop, partial_suffix, stoppos,
@@ -925,8 +927,8 @@ HandleCopyStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline,
}
/*
- * Process the received data, and any subsequent data we
- * can read without blocking.
+ * Process the received data, and any subsequent data we can read
+ * without blocking.
*/
r = CopyStreamReceive(conn, 0, &copybuf);
}
@@ -972,7 +974,7 @@ CopyStreamPoll(PGconn *conn, long timeout_ms)
ret = select(PQsocket(conn) + 1, &input_mask, NULL, NULL, timeoutptr);
if (ret == 0 || (ret < 0 && errno == EINTR))
- return 0; /* Got a timeout or signal */
+ return 0; /* Got a timeout or signal */
else if (ret < 0)
{
fprintf(stderr, _("%s: select() failed: %s\n"),
@@ -1009,12 +1011,12 @@ CopyStreamReceive(PGconn *conn, long timeout, char **buffer)
if (rawlen == 0)
{
/*
- * No data available. Wait for some to appear, but not longer than
- * the specified timeout, so that we can ping the server.
+ * No data available. Wait for some to appear, but not longer than the
+ * specified timeout, so that we can ping the server.
*/
if (timeout != 0)
{
- int ret;
+ int ret;
ret = CopyStreamPoll(conn, timeout);
if (ret <= 0)
@@ -1061,13 +1063,12 @@ ProcessKeepaliveMsg(PGconn *conn, char *copybuf, int len,
int64 now;
/*
- * Parse the keepalive message, enclosed in the CopyData message.
- * We just check if the server requested a reply, and ignore the
- * rest.
+ * Parse the keepalive message, enclosed in the CopyData message. We just
+ * check if the server requested a reply, and ignore the rest.
*/
- pos = 1; /* skip msgtype 'k' */
- pos += 8; /* skip walEnd */
- pos += 8; /* skip sendTime */
+ pos = 1; /* skip msgtype 'k' */
+ pos += 8; /* skip walEnd */
+ pos += 8; /* skip sendTime */
if (len < pos + 1)
{
@@ -1084,11 +1085,11 @@ ProcessKeepaliveMsg(PGconn *conn, char *copybuf, int len,
walfile != -1)
{
/*
- * If a valid flush location needs to be reported,
- * flush the current WAL file so that the latest flush
- * location is sent back to the server. This is necessary to
- * see whether the last WAL data has been successfully
- * replicated or not, at the normal shutdown of the server.
+ * If a valid flush location needs to be reported, flush the
+ * current WAL file so that the latest flush location is sent back
+ * to the server. This is necessary to see whether the last WAL
+ * data has been successfully replicated or not, at the normal
+ * shutdown of the server.
*/
if (fsync(walfile) != 0)
{
@@ -1123,21 +1124,21 @@ ProcessXLogDataMsg(PGconn *conn, char *copybuf, int len,
int hdr_len;
/*
- * Once we've decided we don't want to receive any more, just
- * ignore any subsequent XLogData messages.
+ * Once we've decided we don't want to receive any more, just ignore any
+ * subsequent XLogData messages.
*/
if (!(still_sending))
return true;
/*
- * Read the header of the XLogData message, enclosed in the
- * CopyData message. We only need the WAL location field
- * (dataStart), the rest of the header is ignored.
+ * Read the header of the XLogData message, enclosed in the CopyData
+ * message. We only need the WAL location field (dataStart), the rest of
+ * the header is ignored.
*/
- hdr_len = 1; /* msgtype 'w' */
- hdr_len += 8; /* dataStart */
- hdr_len += 8; /* walEnd */
- hdr_len += 8; /* sendTime */
+ hdr_len = 1; /* msgtype 'w' */
+ hdr_len += 8; /* dataStart */
+ hdr_len += 8; /* walEnd */
+ hdr_len += 8; /* sendTime */
if (len < hdr_len)
{
fprintf(stderr, _("%s: streaming header too small: %d\n"),
@@ -1150,8 +1151,8 @@ ProcessXLogDataMsg(PGconn *conn, char *copybuf, int len,
xlogoff = *blockpos % XLOG_SEG_SIZE;
/*
- * Verify that the initial location in the stream matches where we
- * think we are.
+ * Verify that the initial location in the stream matches where we think
+ * we are.
*/
if (walfile == -1)
{
@@ -1208,7 +1209,7 @@ ProcessXLogDataMsg(PGconn *conn, char *copybuf, int len,
bytes_to_write) != bytes_to_write)
{
fprintf(stderr,
- _("%s: could not write %u bytes to WAL file \"%s\": %s\n"),
+ _("%s: could not write %u bytes to WAL file \"%s\": %s\n"),
progname, bytes_to_write, current_walfile_name,
strerror(errno));
return false;
@@ -1252,15 +1253,15 @@ ProcessXLogDataMsg(PGconn *conn, char *copybuf, int len,
*/
static PGresult *
HandleEndOfCopyStream(PGconn *conn, char *copybuf,
- XLogRecPtr blockpos, char *basedir, char *partial_suffix,
+ XLogRecPtr blockpos, char *basedir, char *partial_suffix,
XLogRecPtr *stoppos, bool mark_done)
{
PGresult *res = PQgetResult(conn);
/*
- * The server closed its end of the copy stream. If we haven't
- * closed ours already, we need to do so now, unless the server
- * threw an error, in which case we don't.
+ * The server closed its end of the copy stream. If we haven't closed
+ * ours already, we need to do so now, unless the server threw an error,
+ * in which case we don't.
*/
if (still_sending)
{
diff --git a/src/bin/pg_basebackup/receivelog.h b/src/bin/pg_basebackup/receivelog.h
index a957aea4d9..b38e993c1a 100644
--- a/src/bin/pg_basebackup/receivelog.h
+++ b/src/bin/pg_basebackup/receivelog.h
@@ -34,4 +34,4 @@ extern bool ReceiveXlogStream(PGconn *conn,
bool synchronous,
bool mark_done);
-#endif /* RECEIVELOG_H */
+#endif /* RECEIVELOG_H */
diff --git a/src/bin/pg_basebackup/streamutil.c b/src/bin/pg_basebackup/streamutil.c
index de37511ef1..ac84e6d360 100644
--- a/src/bin/pg_basebackup/streamutil.c
+++ b/src/bin/pg_basebackup/streamutil.c
@@ -241,7 +241,8 @@ RunIdentifySystem(PGconn *conn, char **sysid, TimeLineID *starttli,
XLogRecPtr *startpos, char **db_name)
{
PGresult *res;
- uint32 hi, lo;
+ uint32 hi,
+ lo;
/* Check connection existence */
Assert(conn != NULL);
@@ -279,7 +280,7 @@ RunIdentifySystem(PGconn *conn, char **sysid, TimeLineID *starttli,
if (sscanf(PQgetvalue(res, 0, 2), "%X/%X", &hi, &lo) != 2)
{
fprintf(stderr,
- _("%s: could not parse transaction log location \"%s\"\n"),
+ _("%s: could not parse transaction log location \"%s\"\n"),
progname, PQgetvalue(res, 0, 2));
PQclear(res);
@@ -289,7 +290,7 @@ RunIdentifySystem(PGconn *conn, char **sysid, TimeLineID *starttli,
}
/* Get database name, only available in 9.4 and newer versions */
- if (db_name != NULL)
+ if (db_name != NULL)
{
if (PQnfields(res) < 4)
fprintf(stderr,
@@ -297,7 +298,7 @@ RunIdentifySystem(PGconn *conn, char **sysid, TimeLineID *starttli,
progname, PQntuples(res), PQnfields(res), 1, 4);
if (PQgetisnull(res, 0, 3))
- *db_name = NULL;
+ *db_name = NULL;
else
*db_name = pg_strdup(PQgetvalue(res, 0, 3));
}
@@ -358,12 +359,13 @@ CreateReplicationSlot(PGconn *conn, const char *slot_name, const char *plugin,
/* Get LSN start position if necessary */
if (startpos != NULL)
{
- uint32 hi, lo;
+ uint32 hi,
+ lo;
if (sscanf(PQgetvalue(res, 0, 1), "%X/%X", &hi, &lo) != 2)
{
fprintf(stderr,
- _("%s: could not parse transaction log location \"%s\"\n"),
+ _("%s: could not parse transaction log location \"%s\"\n"),
progname, PQgetvalue(res, 0, 1));
destroyPQExpBuffer(query);
diff --git a/src/bin/pg_basebackup/streamutil.h b/src/bin/pg_basebackup/streamutil.h
index 6845662b42..01ab5660a1 100644
--- a/src/bin/pg_basebackup/streamutil.h
+++ b/src/bin/pg_basebackup/streamutil.h
@@ -32,13 +32,13 @@ extern PGconn *GetConnection(void);
/* Replication commands */
extern bool CreateReplicationSlot(PGconn *conn, const char *slot_name,
- const char *plugin, XLogRecPtr *startpos,
- bool is_physical);
+ const char *plugin, XLogRecPtr *startpos,
+ bool is_physical);
extern bool DropReplicationSlot(PGconn *conn, const char *slot_name);
extern bool RunIdentifySystem(PGconn *conn, char **sysid,
- TimeLineID *starttli,
- XLogRecPtr *startpos,
- char **db_name);
+ TimeLineID *starttli,
+ XLogRecPtr *startpos,
+ char **db_name);
extern int64 feGetCurrentTimestamp(void);
extern void feTimestampDifference(int64 start_time, int64 stop_time,
long *secs, int *microsecs);
@@ -48,4 +48,4 @@ extern bool feTimestampDifferenceExceeds(int64 start_time, int64 stop_time,
extern void fe_sendint64(int64 i, char *buf);
extern int64 fe_recvint64(char *buf);
-#endif /* STREAMUTIL_H */
+#endif /* STREAMUTIL_H */
diff --git a/src/bin/pg_basebackup/t/010_pg_basebackup.pl b/src/bin/pg_basebackup/t/010_pg_basebackup.pl
index 0e4bd12aff..3476ea686a 100644
--- a/src/bin/pg_basebackup/t/010_pg_basebackup.pl
+++ b/src/bin/pg_basebackup/t/010_pg_basebackup.pl
@@ -49,11 +49,11 @@ command_ok([ 'pg_basebackup', '-D', "$tempdir/tarbackup", '-Ft' ],
'tar format');
ok(-f "$tempdir/tarbackup/base.tar", 'backup tar was created');
-my $superlongname = "superlongname_" . ("x"x100);
+my $superlongname = "superlongname_" . ("x" x 100);
system_or_bail 'touch', "$tempdir/pgdata/$superlongname";
command_fails([ 'pg_basebackup', '-D', "$tempdir/tarbackup_l1", '-Ft' ],
- 'pg_basebackup tar with long name fails');
+ 'pg_basebackup tar with long name fails');
unlink "$tempdir/pgdata/$superlongname";
# Create a temporary directory in the system location and symlink it
@@ -64,7 +64,8 @@ my $shorter_tempdir = tempdir_short . "/tempdir";
symlink "$tempdir", $shorter_tempdir;
mkdir "$tempdir/tblspc1";
-psql 'postgres', "CREATE TABLESPACE tblspc1 LOCATION '$shorter_tempdir/tblspc1';";
+psql 'postgres',
+ "CREATE TABLESPACE tblspc1 LOCATION '$shorter_tempdir/tblspc1';";
psql 'postgres', "CREATE TABLE test1 (a int) TABLESPACE tblspc1;";
command_ok([ 'pg_basebackup', '-D', "$tempdir/tarbackup2", '-Ft' ],
'tar format with tablespaces');
@@ -77,14 +78,12 @@ command_fails(
'plain format with tablespaces fails without tablespace mapping');
command_ok(
- [ 'pg_basebackup', '-D',
- "$tempdir/backup1", '-Fp',
+ [ 'pg_basebackup', '-D', "$tempdir/backup1", '-Fp',
"-T$shorter_tempdir/tblspc1=$tempdir/tbackup/tblspc1" ],
'plain format with tablespaces succeeds with tablespace mapping');
ok(-d "$tempdir/tbackup/tblspc1", 'tablespace was relocated');
opendir(my $dh, "$tempdir/pgdata/pg_tblspc") or die;
-ok( ( grep
- {
+ok( ( grep {
-l "$tempdir/backup1/pg_tblspc/$_"
and readlink "$tempdir/backup1/pg_tblspc/$_" eq
"$tempdir/tbackup/tblspc1"
@@ -95,10 +94,10 @@ closedir $dh;
mkdir "$tempdir/tbl=spc2";
psql 'postgres', "DROP TABLE test1;";
psql 'postgres', "DROP TABLESPACE tblspc1;";
-psql 'postgres', "CREATE TABLESPACE tblspc2 LOCATION '$shorter_tempdir/tbl=spc2';";
+psql 'postgres',
+ "CREATE TABLESPACE tblspc2 LOCATION '$shorter_tempdir/tbl=spc2';";
command_ok(
- [ 'pg_basebackup', '-D',
- "$tempdir/backup3", '-Fp',
+ [ 'pg_basebackup', '-D', "$tempdir/backup3", '-Fp',
"-T$shorter_tempdir/tbl\\=spc2=$tempdir/tbackup/tbl\\=spc2" ],
'mapping tablespace with = sign in path');
ok(-d "$tempdir/tbackup/tbl=spc2", 'tablespace with = sign was relocated');
@@ -126,7 +125,8 @@ command_fails(
'-T with invalid format fails');
mkdir "$tempdir/$superlongname";
-psql 'postgres', "CREATE TABLESPACE tblspc3 LOCATION '$tempdir/$superlongname';";
+psql 'postgres',
+ "CREATE TABLESPACE tblspc3 LOCATION '$tempdir/$superlongname';";
command_ok([ 'pg_basebackup', '-D', "$tempdir/tarbackup_l3", '-Ft' ],
- 'pg_basebackup tar with long symlink target');
+ 'pg_basebackup tar with long symlink target');
psql 'postgres', "DROP TABLESPACE tblspc3;";
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 6a67cb7fca..74764fabda 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -176,7 +176,7 @@ write_eventlog(int level, const char *line)
if (evtHandle == INVALID_HANDLE_VALUE)
{
evtHandle = RegisterEventSource(NULL,
- event_source ? event_source : DEFAULT_EVENT_SOURCE);
+ event_source ? event_source : DEFAULT_EVENT_SOURCE);
if (evtHandle == NULL)
{
evtHandle = INVALID_HANDLE_VALUE;
@@ -263,7 +263,8 @@ get_pgpid(bool is_status_request)
/*
* The Linux Standard Base Core Specification 3.1 says this should
* return '4, program or service status is unknown'
- * https://refspecs.linuxbase.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
+ * https://refspecs.linuxbase.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-g
+ * eneric/iniscrptact.html
*/
exit(is_status_request ? 4 : 1);
}
@@ -1600,10 +1601,10 @@ pgwin32_ServiceMain(DWORD argc, LPTSTR *argv)
{
/*
* status.dwCheckPoint can be incremented by
- * test_postmaster_connection(true), so it might not
- * start from 0.
+ * test_postmaster_connection(true), so it might not start
+ * from 0.
*/
- int maxShutdownCheckPoint = status.dwCheckPoint + 12;;
+ int maxShutdownCheckPoint = status.dwCheckPoint + 12;;
kill(postmasterPID, SIGINT);
@@ -2215,7 +2216,7 @@ main(int argc, char **argv)
post_opts = pg_strdup(optarg);
else
{
- char *old_post_opts = post_opts;
+ char *old_post_opts = post_opts;
post_opts = psprintf("%s %s", old_post_opts, optarg);
free(old_post_opts);
diff --git a/src/bin/pg_ctl/t/001_start_stop.pl b/src/bin/pg_ctl/t/001_start_stop.pl
index 17309e8fcb..6c9ec5c717 100644
--- a/src/bin/pg_ctl/t/001_start_stop.pl
+++ b/src/bin/pg_ctl/t/001_start_stop.pl
@@ -3,7 +3,7 @@ use warnings;
use TestLib;
use Test::More tests => 17;
-my $tempdir = TestLib::tempdir;
+my $tempdir = TestLib::tempdir;
my $tempdir_short = TestLib::tempdir_short;
program_help_ok('pg_ctl');
@@ -11,7 +11,7 @@ program_version_ok('pg_ctl');
program_options_handling_ok('pg_ctl');
command_exit_is([ 'pg_ctl', 'start', '-D', "$tempdir/nonexistent" ],
- 1, 'pg_ctl start with nonexistent directory');
+ 1, 'pg_ctl start with nonexistent directory');
command_ok([ 'pg_ctl', 'initdb', '-D', "$tempdir/data" ], 'pg_ctl initdb');
command_ok(
diff --git a/src/bin/pg_ctl/t/002_status.pl b/src/bin/pg_ctl/t/002_status.pl
index b8cbbdaed5..055885495a 100644
--- a/src/bin/pg_ctl/t/002_status.pl
+++ b/src/bin/pg_ctl/t/002_status.pl
@@ -3,7 +3,7 @@ use warnings;
use TestLib;
use Test::More tests => 3;
-my $tempdir = TestLib::tempdir;
+my $tempdir = TestLib::tempdir;
my $tempdir_short = TestLib::tempdir_short;
command_exit_is([ 'pg_ctl', 'status', '-D', "$tempdir/nonexistent" ],
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index d39abf9242..687cbaaf7c 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -126,8 +126,8 @@ static const CatalogId nilCatalogId = {0, 0};
static void help(const char *progname);
static void setup_connection(Archive *AH, DumpOptions *dopt,
- const char *dumpencoding, const char *dumpsnapshot,
- char *use_role);
+ const char *dumpencoding, const char *dumpsnapshot,
+ char *use_role);
static ArchiveFormat parseArchiveFormat(const char *format, ArchiveMode *mode);
static void expand_schema_name_patterns(Archive *fout,
SimpleStringList *patterns,
@@ -671,7 +671,7 @@ main(int argc, char **argv)
/* check the version when a snapshot is explicitly specified by user */
if (dumpsnapshot && fout->remoteVersion < 90200)
exit_horribly(NULL,
- "Exported snapshots are not supported by this server version.\n");
+ "Exported snapshots are not supported by this server version.\n");
/* Find the last built-in OID, if needed */
if (fout->remoteVersion < 70300)
@@ -1052,8 +1052,8 @@ setup_connection(Archive *AH, DumpOptions *dopt, const char *dumpencoding,
"SET TRANSACTION ISOLATION LEVEL SERIALIZABLE");
/*
- * define an export snapshot, either chosen by user or needed for
- * parallel dump.
+ * define an export snapshot, either chosen by user or needed for parallel
+ * dump.
*/
if (dumpsnapshot)
AH->sync_snapshot_id = strdup(dumpsnapshot);
@@ -1061,6 +1061,7 @@ setup_connection(Archive *AH, DumpOptions *dopt, const char *dumpencoding,
if (AH->sync_snapshot_id)
{
PQExpBuffer query = createPQExpBuffer();
+
appendPQExpBuffer(query, "SET TRANSACTION SNAPSHOT ");
appendStringLiteralConn(query, AH->sync_snapshot_id, conn);
ExecuteSqlStatement(AH, query->data);
@@ -2841,8 +2842,8 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
/*
* Get row security enabled information for the table. We represent
- * RLS enabled on a table by creating PolicyInfo object with an
- * empty policy.
+ * RLS enabled on a table by creating PolicyInfo object with an empty
+ * policy.
*/
if (tbinfo->rowsec)
{
@@ -2882,8 +2883,8 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
"SELECT oid, tableoid, pol.polname, pol.polcmd, "
"CASE WHEN pol.polroles = '{0}' THEN 'PUBLIC' ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
- "pg_catalog.pg_get_expr(pol.polqual, pol.polrelid) AS polqual, "
- "pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid) AS polwithcheck "
+ "pg_catalog.pg_get_expr(pol.polqual, pol.polrelid) AS polqual, "
+ "pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid) AS polwithcheck "
"FROM pg_catalog.pg_policy pol "
"WHERE polrelid = '%u'",
tbinfo->dobj.catId.oid);
@@ -2895,8 +2896,8 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
{
/*
* No explicit policies to handle (only the default-deny policy,
- * which is handled as part of the table definition). Clean up and
- * return.
+ * which is handled as part of the table definition). Clean up
+ * and return.
*/
PQclear(res);
continue;
@@ -2959,9 +2960,9 @@ dumpPolicy(Archive *fout, DumpOptions *dopt, PolicyInfo *polinfo)
return;
/*
- * If polname is NULL, then this record is just indicating that ROW
- * LEVEL SECURITY is enabled for the table. Dump as ALTER TABLE <table>
- * ENABLE ROW LEVEL SECURITY.
+ * If polname is NULL, then this record is just indicating that ROW LEVEL
+ * SECURITY is enabled for the table. Dump as ALTER TABLE <table> ENABLE
+ * ROW LEVEL SECURITY.
*/
if (polinfo->polname == NULL)
{
@@ -3046,7 +3047,7 @@ binary_upgrade_set_type_oids_by_type_oid(Archive *fout,
appendPQExpBufferStr(upgrade_buffer, "\n-- For binary upgrade, must preserve pg_type oid\n");
appendPQExpBuffer(upgrade_buffer,
- "SELECT pg_catalog.binary_upgrade_set_next_pg_type_oid('%u'::pg_catalog.oid);\n\n",
+ "SELECT pg_catalog.binary_upgrade_set_next_pg_type_oid('%u'::pg_catalog.oid);\n\n",
pg_type_oid);
/* we only support old >= 8.3 for binary upgrades */
@@ -6597,7 +6598,7 @@ getTransforms(Archive *fout, int *numTransforms)
int ntups;
int i;
PQExpBuffer query;
- TransformInfo *transforminfo;
+ TransformInfo *transforminfo;
int i_tableoid;
int i_oid;
int i_trftype;
@@ -8462,7 +8463,7 @@ dumpExtension(Archive *fout, DumpOptions *dopt, ExtensionInfo *extinfo)
appendPQExpBuffer(q, "DROP EXTENSION IF EXISTS %s;\n", qextname);
appendPQExpBufferStr(q,
- "SELECT pg_catalog.binary_upgrade_create_empty_extension(");
+ "SELECT pg_catalog.binary_upgrade_create_empty_extension(");
appendStringLiteralAH(q, extinfo->dobj.name, fout);
appendPQExpBufferStr(q, ", ");
appendStringLiteralAH(q, extinfo->namespace, fout);
@@ -9367,7 +9368,7 @@ dumpDomain(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
for (i = 0; i < tyinfo->nDomChecks; i++)
{
ConstraintInfo *domcheck = &(tyinfo->domChecks[i]);
- PQExpBuffer labelq = createPQExpBuffer();
+ PQExpBuffer labelq = createPQExpBuffer();
appendPQExpBuffer(labelq, "CONSTRAINT %s ",
fmtId(domcheck->dobj.name));
@@ -10451,8 +10452,8 @@ dumpFunc(Archive *fout, DumpOptions *dopt, FuncInfo *finfo)
if (protrftypes != NULL && strcmp(protrftypes, "") != 0)
{
- Oid *typeids = palloc(FUNC_MAX_ARGS * sizeof(Oid));
- int i;
+ Oid *typeids = palloc(FUNC_MAX_ARGS * sizeof(Oid));
+ int i;
appendPQExpBufferStr(q, " TRANSFORM ");
parseOidArray(protrftypes, typeids, FUNC_MAX_ARGS);
@@ -10461,7 +10462,7 @@ dumpFunc(Archive *fout, DumpOptions *dopt, FuncInfo *finfo)
if (i != 0)
appendPQExpBufferStr(q, ", ");
appendPQExpBuffer(q, "FOR TYPE %s",
- getFormattedTypeName(fout, typeids[i], zeroAsNone));
+ getFormattedTypeName(fout, typeids[i], zeroAsNone));
}
}
@@ -10729,11 +10730,11 @@ dumpTransform(Archive *fout, DumpOptions *dopt, TransformInfo *transform)
lanname = get_language_name(fout, transform->trflang);
appendPQExpBuffer(delqry, "DROP TRANSFORM FOR %s LANGUAGE %s;\n",
- getFormattedTypeName(fout, transform->trftype, zeroAsNone),
+ getFormattedTypeName(fout, transform->trftype, zeroAsNone),
lanname);
appendPQExpBuffer(defqry, "CREATE TRANSFORM FOR %s LANGUAGE %s (",
- getFormattedTypeName(fout, transform->trftype, zeroAsNone),
+ getFormattedTypeName(fout, transform->trftype, zeroAsNone),
lanname);
if (!transform->trffromsql && !transform->trftosql)
@@ -10747,11 +10748,10 @@ dumpTransform(Archive *fout, DumpOptions *dopt, TransformInfo *transform)
/*
* Always qualify the function name, in case it is not in
- * pg_catalog schema (format_function_signature won't qualify
- * it).
+ * pg_catalog schema (format_function_signature won't qualify it).
*/
appendPQExpBuffer(defqry, "FROM SQL WITH FUNCTION %s.%s",
- fmtId(fromsqlFuncInfo->dobj.namespace->dobj.name), fsig);
+ fmtId(fromsqlFuncInfo->dobj.namespace->dobj.name), fsig);
free(fsig);
}
else
@@ -10769,11 +10769,10 @@ dumpTransform(Archive *fout, DumpOptions *dopt, TransformInfo *transform)
/*
* Always qualify the function name, in case it is not in
- * pg_catalog schema (format_function_signature won't qualify
- * it).
+ * pg_catalog schema (format_function_signature won't qualify it).
*/
appendPQExpBuffer(defqry, "TO SQL WITH FUNCTION %s.%s",
- fmtId(tosqlFuncInfo->dobj.namespace->dobj.name), fsig);
+ fmtId(tosqlFuncInfo->dobj.namespace->dobj.name), fsig);
free(fsig);
}
else
@@ -10783,7 +10782,7 @@ dumpTransform(Archive *fout, DumpOptions *dopt, TransformInfo *transform)
appendPQExpBuffer(defqry, ");\n");
appendPQExpBuffer(labelq, "TRANSFORM FOR %s LANGUAGE %s",
- getFormattedTypeName(fout, transform->trftype, zeroAsNone),
+ getFormattedTypeName(fout, transform->trftype, zeroAsNone),
lanname);
if (dopt->binary_upgrade)
@@ -14012,9 +14011,9 @@ dumpTableSchema(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo)
* here, also updating their attlen/attalign values so that the
* dropped column can be skipped properly. (We do not bother with
* restoring the original attbyval setting.) Also, inheritance
- * relationships are set up by doing ALTER TABLE INHERIT rather than using
- * an INHERITS clause --- the latter would possibly mess up the column
- * order. That also means we have to take care about setting
+ * relationships are set up by doing ALTER TABLE INHERIT rather than
+ * using an INHERITS clause --- the latter would possibly mess up the
+ * column order. That also means we have to take care about setting
* attislocal correctly, plus fix up any inherited CHECK constraints.
* Analogously, we set up typed tables using ALTER TABLE / OF here.
*/
@@ -15473,28 +15472,28 @@ dumpRule(Archive *fout, DumpOptions *dopt, RuleInfo *rinfo)
*
* 1. Identify objects which are members of extensions
*
- * Generally speaking, this is to mark them as *not* being dumped, as most
- * extension objects are created by the single CREATE EXTENSION command.
- * The one exception is binary upgrades with pg_upgrade will still dump the
- * non-table objects.
+ * Generally speaking, this is to mark them as *not* being dumped, as most
+ * extension objects are created by the single CREATE EXTENSION command.
+ * The one exception is binary upgrades with pg_upgrade will still dump the
+ * non-table objects.
*
* 2. Identify and create dump records for extension configuration tables.
*
- * Extensions can mark tables as "configuration", which means that the user
- * is able and expected to modify those tables after the extension has been
- * loaded. For these tables, we dump out only the data- the structure is
- * expected to be handled at CREATE EXTENSION time, including any indexes or
- * foreign keys, which brings us to-
+ * Extensions can mark tables as "configuration", which means that the user
+ * is able and expected to modify those tables after the extension has been
+ * loaded. For these tables, we dump out only the data- the structure is
+ * expected to be handled at CREATE EXTENSION time, including any indexes or
+ * foreign keys, which brings us to-
*
* 3. Record FK dependencies between configuration tables.
*
- * Due to the FKs being created at CREATE EXTENSION time and therefore before
- * the data is loaded, we have to work out what the best order for reloading
- * the data is, to avoid FK violations when the tables are restored. This is
- * not perfect- we can't handle circular dependencies and if any exist they
- * will cause an invalid dump to be produced (though at least all of the data
- * is included for a user to manually restore). This is currently documented
- * but perhaps we can provide a better solution in the future.
+ * Due to the FKs being created at CREATE EXTENSION time and therefore before
+ * the data is loaded, we have to work out what the best order for reloading
+ * the data is, to avoid FK violations when the tables are restored. This is
+ * not perfect- we can't handle circular dependencies and if any exist they
+ * will cause an invalid dump to be produced (though at least all of the data
+ * is included for a user to manually restore). This is currently documented
+ * but perhaps we can provide a better solution in the future.
*/
void
getExtensionMembership(Archive *fout, DumpOptions *dopt, ExtensionInfo extinfo[],
@@ -15691,21 +15690,20 @@ getExtensionMembership(Archive *fout, DumpOptions *dopt, ExtensionInfo extinfo[]
}
/*
- * Now that all the TableInfoData objects have been created for all
- * the extensions, check their FK dependencies and register them to
- * try and dump the data out in an order which they can be restored
- * in.
+ * Now that all the TableInfoData objects have been created for all the
+ * extensions, check their FK dependencies and register them to try and
+ * dump the data out in an order which they can be restored in.
*
* Note that this is not a problem for user tables as their FKs are
* recreated after the data has been loaded.
*/
printfPQExpBuffer(query,
- "SELECT conrelid, confrelid "
- "FROM pg_constraint "
- "JOIN pg_depend ON (objid = confrelid) "
- "WHERE contype = 'f' "
- "AND refclassid = 'pg_extension'::regclass "
- "AND classid = 'pg_class'::regclass;");
+ "SELECT conrelid, confrelid "
+ "FROM pg_constraint "
+ "JOIN pg_depend ON (objid = confrelid) "
+ "WHERE contype = 'f' "
+ "AND refclassid = 'pg_extension'::regclass "
+ "AND classid = 'pg_class'::regclass;");
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
ntups = PQntuples(res);
@@ -15716,8 +15714,10 @@ getExtensionMembership(Archive *fout, DumpOptions *dopt, ExtensionInfo extinfo[]
/* Now get the dependencies and register them */
for (i = 0; i < ntups; i++)
{
- Oid conrelid, confrelid;
- TableInfo *reftable, *contable;
+ Oid conrelid,
+ confrelid;
+ TableInfo *reftable,
+ *contable;
conrelid = atooid(PQgetvalue(res, i, i_conrelid));
confrelid = atooid(PQgetvalue(res, i, i_confrelid));
@@ -15731,8 +15731,8 @@ getExtensionMembership(Archive *fout, DumpOptions *dopt, ExtensionInfo extinfo[]
continue;
/*
- * Make referencing TABLE_DATA object depend on the
- * referenced table's TABLE_DATA object.
+ * Make referencing TABLE_DATA object depend on the referenced table's
+ * TABLE_DATA object.
*/
addObjectDependency(&contable->dataObj->dobj,
reftable->dataObj->dobj.dumpId);
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
index 4c796ad6a7..009dba5c9d 100644
--- a/src/bin/pg_dump/pg_dump.h
+++ b/src/bin/pg_dump/pg_dump.h
@@ -471,7 +471,7 @@ typedef struct _policyInfo
{
DumpableObject dobj;
TableInfo *poltable;
- char *polname; /* null indicates RLS is enabled on rel */
+ char *polname; /* null indicates RLS is enabled on rel */
char *polcmd;
char *polroles;
char *polqual;
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 2c72e19f2d..c6b9326cb1 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -1422,7 +1422,7 @@ dumpCreateDB(PGconn *conn)
{
appendPQExpBufferStr(buf, "-- For binary upgrade, set datfrozenxid and datminmxid.\n");
appendPQExpBuffer(buf, "UPDATE pg_catalog.pg_database "
- "SET datfrozenxid = '%u', datminmxid = '%u' "
+ "SET datfrozenxid = '%u', datminmxid = '%u' "
"WHERE datname = ",
dbfrozenxid, dbminmxid);
appendStringLiteralConn(buf, dbname, conn);
diff --git a/src/bin/pg_resetxlog/pg_resetxlog.c b/src/bin/pg_resetxlog/pg_resetxlog.c
index 393d580154..6ffe795348 100644
--- a/src/bin/pg_resetxlog/pg_resetxlog.c
+++ b/src/bin/pg_resetxlog/pg_resetxlog.c
@@ -914,9 +914,9 @@ FindEndOfXLOG(void)
XLogSegNo segno;
/*
- * Note: We don't use XLogFromFileName here, because we want
- * to use the segment size from the control file, not the size
- * the pg_resetxlog binary was compiled with
+ * Note: We don't use XLogFromFileName here, because we want to
+ * use the segment size from the control file, not the size the
+ * pg_resetxlog binary was compiled with
*/
sscanf(xlde->d_name, "%08X%08X%08X", &tli, &log, &seg);
segno = ((uint64) log) * segs_per_xlogid + seg;
diff --git a/src/bin/pg_rewind/RewindTest.pm b/src/bin/pg_rewind/RewindTest.pm
index 6ea2f871aa..5219ec967a 100644
--- a/src/bin/pg_rewind/RewindTest.pm
+++ b/src/bin/pg_rewind/RewindTest.pm
@@ -67,8 +67,8 @@ our @EXPORT = qw(
# for debugging purposes,
my $testroot = tempdir;
-our $test_master_datadir="$testroot/data_master";
-our $test_standby_datadir="$testroot/data_standby";
+our $test_master_datadir = "$testroot/data_master";
+our $test_standby_datadir = "$testroot/data_standby";
mkdir $testroot;
@@ -76,14 +76,14 @@ mkdir $testroot;
mkdir "regress_log";
# Define non-conflicting ports for both nodes.
-my $port_master=$ENV{PGPORT};
-my $port_standby=$port_master + 1;
+my $port_master = $ENV{PGPORT};
+my $port_standby = $port_master + 1;
my $log_path;
my $tempdir_short;
-my $connstr_master="port=$port_master";
-my $connstr_standby="port=$port_standby";
+my $connstr_master = "port=$port_master";
+my $connstr_standby = "port=$port_standby";
$ENV{PGDATABASE} = "postgres";
@@ -109,19 +109,25 @@ sub check_query
my ($stdout, $stderr);
# we want just the output, no formatting
- my $result = run ['psql', '-q', '-A', '-t', '--no-psqlrc',
- '-d', $connstr_master,
- '-c' , $query],
- '>', \$stdout, '2>', \$stderr;
+ my $result = run [
+ 'psql', '-q', '-A', '-t', '--no-psqlrc', '-d',
+ $connstr_master, '-c', $query ],
+ '>', \$stdout, '2>', \$stderr;
+
# We don't use ok() for the exit code and stderr, because we want this
# check to be just a single test.
- if (!$result) {
- fail ("$test_name: psql exit code");
- } elsif ($stderr ne '') {
+ if (!$result)
+ {
+ fail("$test_name: psql exit code");
+ }
+ elsif ($stderr ne '')
+ {
diag $stderr;
- fail ("$test_name: psql no stderr");
- } else {
- is ($stdout, $expected_stdout, "$test_name: query result matches");
+ fail("$test_name: psql no stderr");
+ }
+ else
+ {
+ is($stdout, $expected_stdout, "$test_name: query result matches");
}
}
@@ -131,12 +137,12 @@ sub poll_query_until
my ($query, $connstr) = @_;
my $max_attempts = 30;
- my $attempts = 0;
+ my $attempts = 0;
my ($stdout, $stderr);
while ($attempts < $max_attempts)
{
- my $cmd = ['psql', '-At', '-c', "$query", '-d', "$connstr" ];
+ my $cmd = [ 'psql', '-At', '-c', "$query", '-d', "$connstr" ];
my $result = run $cmd, '>', \$stdout, '2>', \$stderr;
chomp($stdout);
@@ -158,7 +164,7 @@ sub poll_query_until
sub append_to_file
{
- my($filename, $str) = @_;
+ my ($filename, $str) = @_;
open my $fh, ">>", $filename or die "could not open file $filename";
print $fh $str;
@@ -167,10 +173,10 @@ sub append_to_file
sub init_rewind_test
{
- my $testname = shift;
+ my $testname = shift;
my $test_mode = shift;
- $log_path="regress_log/pg_rewind_log_${testname}_${test_mode}";
+ $log_path = "regress_log/pg_rewind_log_${testname}_${test_mode}";
remove_tree $log_path;
}
@@ -184,7 +190,8 @@ sub setup_cluster
standard_initdb($test_master_datadir);
# Custom parameters for master's postgresql.conf
- append_to_file("$test_master_datadir/postgresql.conf", qq(
+ append_to_file(
+ "$test_master_datadir/postgresql.conf", qq(
wal_level = hot_standby
max_wal_senders = 2
wal_keep_segments = 20
@@ -197,38 +204,47 @@ max_connections = 10
));
# Accept replication connections on master
- append_to_file("$test_master_datadir/pg_hba.conf", qq(
+ append_to_file(
+ "$test_master_datadir/pg_hba.conf", qq(
local replication all trust
));
- system_or_bail("pg_ctl -w -D $test_master_datadir -o \"-k $tempdir_short --listen-addresses='' -p $port_master\" start >>$log_path 2>&1");
+ system_or_bail(
+"pg_ctl -w -D $test_master_datadir -o \"-k $tempdir_short --listen-addresses='' -p $port_master\" start >>$log_path 2>&1"
+ );
#### Now run the test-specific parts to initialize the master before setting
# up standby
- $ENV{PGHOST} = $tempdir_short;
+ $ENV{PGHOST} = $tempdir_short;
}
sub create_standby
{
+
# Set up standby with necessary parameter
remove_tree $test_standby_datadir;
# Base backup is taken with xlog files included
- system_or_bail("pg_basebackup -D $test_standby_datadir -p $port_master -x >>$log_path 2>&1");
- append_to_file("$test_standby_datadir/recovery.conf", qq(
+ system_or_bail(
+"pg_basebackup -D $test_standby_datadir -p $port_master -x >>$log_path 2>&1");
+ append_to_file(
+ "$test_standby_datadir/recovery.conf", qq(
primary_conninfo='$connstr_master application_name=rewind_standby'
standby_mode=on
recovery_target_timeline='latest'
));
# Start standby
- system_or_bail("pg_ctl -w -D $test_standby_datadir -o \"-k $tempdir_short --listen-addresses='' -p $port_standby\" start >>$log_path 2>&1");
+ system_or_bail(
+"pg_ctl -w -D $test_standby_datadir -o \"-k $tempdir_short --listen-addresses='' -p $port_standby\" start >>$log_path 2>&1"
+ );
# Wait until the standby has caught up with the primary, by polling
# pg_stat_replication.
- my $caughtup_query = "SELECT pg_current_xlog_location() = replay_location FROM pg_stat_replication WHERE application_name = 'rewind_standby';";
+ my $caughtup_query =
+"SELECT pg_current_xlog_location() = replay_location FROM pg_stat_replication WHERE application_name = 'rewind_standby';";
poll_query_until($caughtup_query, $connstr_master)
- or die "Timed out while waiting for standby to catch up";
+ or die "Timed out while waiting for standby to catch up";
}
sub promote_standby
@@ -239,9 +255,10 @@ sub promote_standby
# Now promote slave and insert some new data on master, this will put
# the master out-of-sync with the standby. Wait until the standby is
# out of recovery mode, and is ready to accept read-write connections.
- system_or_bail("pg_ctl -w -D $test_standby_datadir promote >>$log_path 2>&1");
+ system_or_bail(
+ "pg_ctl -w -D $test_standby_datadir promote >>$log_path 2>&1");
poll_query_until("SELECT NOT pg_is_in_recovery()", $connstr_standby)
- or die "Timed out while waiting for promotion of standby";
+ or die "Timed out while waiting for promotion of standby";
# Force a checkpoint after the promotion. pg_rewind looks at the control
# file todetermine what timeline the server is on, and that isn't updated
@@ -257,7 +274,8 @@ sub run_pg_rewind
my $test_mode = shift;
# Stop the master and be ready to perform the rewind
- system_or_bail("pg_ctl -w -D $test_master_datadir stop -m fast >>$log_path 2>&1");
+ system_or_bail(
+ "pg_ctl -w -D $test_master_datadir stop -m fast >>$log_path 2>&1");
# At this point, the rewind processing is ready to run.
# We now have a very simple scenario with a few diverged WAL record.
@@ -266,47 +284,67 @@ sub run_pg_rewind
# Keep a temporary postgresql.conf for master node or it would be
# overwritten during the rewind.
- copy("$test_master_datadir/postgresql.conf", "$testroot/master-postgresql.conf.tmp");
+ copy(
+ "$test_master_datadir/postgresql.conf",
+ "$testroot/master-postgresql.conf.tmp");
+
# Now run pg_rewind
if ($test_mode eq "local")
{
+
# Do rewind using a local pgdata as source
# Stop the master and be ready to perform the rewind
- system_or_bail("pg_ctl -w -D $test_standby_datadir stop -m fast >>$log_path 2>&1");
- my $result =
- run(['pg_rewind',
- "--debug",
- "--source-pgdata=$test_standby_datadir",
- "--target-pgdata=$test_master_datadir"],
- '>>', $log_path, '2>&1');
- ok ($result, 'pg_rewind local');
+ system_or_bail(
+ "pg_ctl -w -D $test_standby_datadir stop -m fast >>$log_path 2>&1"
+ );
+ my $result = run(
+ [ 'pg_rewind',
+ "--debug",
+ "--source-pgdata=$test_standby_datadir",
+ "--target-pgdata=$test_master_datadir" ],
+ '>>',
+ $log_path,
+ '2>&1');
+ ok($result, 'pg_rewind local');
}
elsif ($test_mode eq "remote")
{
+
# Do rewind using a remote connection as source
- my $result =
- run(['pg_rewind',
- "--source-server", "port=$port_standby dbname=postgres",
- "--target-pgdata=$test_master_datadir"],
- '>>', $log_path, '2>&1');
- ok ($result, 'pg_rewind remote');
- } else {
+ my $result = run(
+ [ 'pg_rewind',
+ "--source-server",
+ "port=$port_standby dbname=postgres",
+ "--target-pgdata=$test_master_datadir" ],
+ '>>',
+ $log_path,
+ '2>&1');
+ ok($result, 'pg_rewind remote');
+ }
+ else
+ {
+
# Cannot come here normally
die("Incorrect test mode specified");
}
# Now move back postgresql.conf with old settings
- move("$testroot/master-postgresql.conf.tmp", "$test_master_datadir/postgresql.conf");
+ move(
+ "$testroot/master-postgresql.conf.tmp",
+ "$test_master_datadir/postgresql.conf");
# Plug-in rewound node to the now-promoted standby node
- append_to_file("$test_master_datadir/recovery.conf", qq(
+ append_to_file(
+ "$test_master_datadir/recovery.conf", qq(
primary_conninfo='port=$port_standby'
standby_mode=on
recovery_target_timeline='latest'
));
# Restart the master to check that rewind went correctly
- system_or_bail("pg_ctl -w -D $test_master_datadir -o \"-k $tempdir_short --listen-addresses='' -p $port_master\" start >>$log_path 2>&1");
+ system_or_bail(
+"pg_ctl -w -D $test_master_datadir -o \"-k $tempdir_short --listen-addresses='' -p $port_master\" start >>$log_path 2>&1"
+ );
#### Now run the test-specific parts to check the result
}
@@ -316,11 +354,13 @@ sub clean_rewind_test
{
if ($test_master_datadir)
{
- system "pg_ctl -D $test_master_datadir -s -m immediate stop 2> /dev/null";
+ system
+ "pg_ctl -D $test_master_datadir -s -m immediate stop 2> /dev/null";
}
if ($test_standby_datadir)
{
- system "pg_ctl -D $test_standby_datadir -s -m immediate stop 2> /dev/null";
+ system
+ "pg_ctl -D $test_standby_datadir -s -m immediate stop 2> /dev/null";
}
}
diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c
index 1a56866fd4..cb2bf4d1a0 100644
--- a/src/bin/pg_rewind/filemap.c
+++ b/src/bin/pg_rewind/filemap.c
@@ -185,13 +185,13 @@ process_source_file(const char *path, file_type_t type, size_t newsize,
*
* If it's smaller in the target, it means that it has been
* truncated in the target, or enlarged in the source, or
- * both. If it was truncated in the target, we need to copy the
- * missing tail from the source system. If it was enlarged in
- * the source system, there will be WAL records in the source
- * system for the new blocks, so we wouldn't need to copy them
- * here. But we don't know which scenario we're dealing with,
- * and there's no harm in copying the missing blocks now, so
- * do it now.
+ * both. If it was truncated in the target, we need to copy
+ * the missing tail from the source system. If it was enlarged
+ * in the source system, there will be WAL records in the
+ * source system for the new blocks, so we wouldn't need to
+ * copy them here. But we don't know which scenario we're
+ * dealing with, and there's no harm in copying the missing
+ * blocks now, so do it now.
*
* If it's the same size, do nothing here. Any blocks modified
* in the target will be copied based on parsing the target
@@ -370,6 +370,7 @@ process_block_change(ForkNumber forknum, RelFileNode rnode, BlockNumber blkno)
break;
case FILE_ACTION_COPY_TAIL:
+
/*
* skip the modified block if it is part of the "tail" that
* we're copying anyway.
@@ -391,8 +392,8 @@ process_block_change(ForkNumber forknum, RelFileNode rnode, BlockNumber blkno)
/*
* If we don't have any record of this file in the file map, it means
* that it's a relation that doesn't exist in the source system, and
- * it was subsequently removed in the target system, too. We can safely
- * ignore it.
+ * it was subsequently removed in the target system, too. We can
+ * safely ignore it.
*/
}
}
diff --git a/src/bin/pg_rewind/filemap.h b/src/bin/pg_rewind/filemap.h
index 73113ecdeb..9943ec5f26 100644
--- a/src/bin/pg_rewind/filemap.h
+++ b/src/bin/pg_rewind/filemap.h
@@ -23,13 +23,13 @@
*/
typedef enum
{
- FILE_ACTION_CREATE, /* create local directory or symbolic link */
- FILE_ACTION_COPY, /* copy whole file, overwriting if exists */
- FILE_ACTION_COPY_TAIL, /* copy tail from 'oldsize' to 'newsize' */
- FILE_ACTION_NONE, /* no action (we might still copy modified blocks
- * based on the parsed WAL) */
- FILE_ACTION_TRUNCATE, /* truncate local file to 'newsize' bytes */
- FILE_ACTION_REMOVE /* remove local file / directory / symlink */
+ FILE_ACTION_CREATE, /* create local directory or symbolic link */
+ FILE_ACTION_COPY, /* copy whole file, overwriting if exists */
+ FILE_ACTION_COPY_TAIL, /* copy tail from 'oldsize' to 'newsize' */
+ FILE_ACTION_NONE, /* no action (we might still copy modified
+ * blocks based on the parsed WAL) */
+ FILE_ACTION_TRUNCATE, /* truncate local file to 'newsize' bytes */
+ FILE_ACTION_REMOVE /* remove local file / directory / symlink */
} file_action_t;
typedef enum
@@ -51,10 +51,10 @@ typedef struct file_entry_t
size_t newsize;
bool isrelfile; /* is it a relation data file? */
- datapagemap_t pagemap;
+ datapagemap_t pagemap;
/* for a symlink */
- char *link_target;
+ char *link_target;
struct file_entry_t *next;
} file_entry_t;
@@ -72,16 +72,16 @@ typedef struct filemap_t
/*
* After processing all the remote files, the entries in the linked list
* are moved to this array. After processing local files, too, all the
- * local entries are added to the array by filemap_finalize, and sorted
- * in the final order. After filemap_finalize, all the entries are in
- * the array, and the linked list is empty.
+ * local entries are added to the array by filemap_finalize, and sorted in
+ * the final order. After filemap_finalize, all the entries are in the
+ * array, and the linked list is empty.
*/
file_entry_t **array;
int narray; /* current length of array */
/*
- * Summary information. total_size is the total size of the source cluster,
- * and fetch_size is the number of bytes that needs to be copied.
+ * Summary information. total_size is the total size of the source
+ * cluster, and fetch_size is the number of bytes that needs to be copied.
*/
uint64 total_size;
uint64 fetch_size;
diff --git a/src/bin/pg_rewind/parsexlog.c b/src/bin/pg_rewind/parsexlog.c
index 9c112701e5..fca771d8cb 100644
--- a/src/bin/pg_rewind/parsexlog.c
+++ b/src/bin/pg_rewind/parsexlog.c
@@ -236,7 +236,7 @@ SimpleXLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr,
{
XLogPageReadPrivate *private = (XLogPageReadPrivate *) xlogreader->private_data;
uint32 targetPageOff;
- XLogSegNo targetSegNo PG_USED_FOR_ASSERTS_ONLY;
+ XLogSegNo targetSegNo PG_USED_FOR_ASSERTS_ONLY;
XLByteToSeg(targetPagePtr, targetSegNo);
targetPageOff = targetPagePtr % XLogSegSize;
@@ -315,10 +315,10 @@ extractPageInfo(XLogReaderState *record)
/*
* New databases can be safely ignored. It won't be present in the
* source system, so it will be deleted. There's one corner-case,
- * though: if a new, different, database is also created in the
- * source system, we'll see that the files already exist and not copy
- * them. That's OK, though; WAL replay of creating the new database,
- * from the source systems's WAL, will re-copy the new database,
+ * though: if a new, different, database is also created in the source
+ * system, we'll see that the files already exist and not copy them.
+ * That's OK, though; WAL replay of creating the new database, from
+ * the source systems's WAL, will re-copy the new database,
* overwriting the database created in the target system.
*/
}
diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c
index d3ae7674d7..8088be4fab 100644
--- a/src/bin/pg_rewind/pg_rewind.c
+++ b/src/bin/pg_rewind/pg_rewind.c
@@ -490,15 +490,15 @@ createBackupLabel(XLogRecPtr startpoint, TimeLineID starttli, XLogRecPtr checkpo
"BACKUP METHOD: pg_rewind\n"
"BACKUP FROM: standby\n"
"START TIME: %s\n",
- /* omit LABEL: line */
- (uint32) (startpoint >> 32), (uint32) startpoint, xlogfilename,
+ /* omit LABEL: line */
+ (uint32) (startpoint >> 32), (uint32) startpoint, xlogfilename,
(uint32) (checkpointloc >> 32), (uint32) checkpointloc,
strfbuf);
if (len >= sizeof(buf))
- pg_fatal("backup label buffer too small\n"); /* shouldn't happen */
+ pg_fatal("backup label buffer too small\n"); /* shouldn't happen */
/* TODO: move old file out of the way, if any. */
- open_target_file("backup_label", true); /* BACKUP_LABEL_FILE */
+ open_target_file("backup_label", true); /* BACKUP_LABEL_FILE */
write_target_range(buf, 0, len);
}
diff --git a/src/bin/pg_rewind/t/001_basic.pl b/src/bin/pg_rewind/t/001_basic.pl
index a1d679f6b8..f60368bd30 100644
--- a/src/bin/pg_rewind/t/001_basic.pl
+++ b/src/bin/pg_rewind/t/001_basic.pl
@@ -32,8 +32,11 @@ sub run_test
# Insert additional data on master that will be replicated to standby
master_psql("INSERT INTO tbl1 values ('in master, before promotion')");
- master_psql("INSERT INTO trunc_tbl values ('in master, before promotion')");
- master_psql("INSERT INTO tail_tbl SELECT g, 'in master, before promotion: ' || g FROM generate_series(1, 10000) g");
+ master_psql(
+ "INSERT INTO trunc_tbl values ('in master, before promotion')");
+ master_psql(
+"INSERT INTO tail_tbl SELECT g, 'in master, before promotion: ' || g FROM generate_series(1, 10000) g"
+ );
master_psql('CHECKPOINT');
@@ -50,7 +53,9 @@ sub run_test
# Insert enough rows to trunc_tbl to extend the file. pg_rewind should
# truncate it back to the old size.
- master_psql("INSERT INTO trunc_tbl SELECT 'in master, after promotion: ' || g FROM generate_series(1, 10000) g");
+ master_psql(
+"INSERT INTO trunc_tbl SELECT 'in master, after promotion: ' || g FROM generate_series(1, 10000) g"
+ );
# Truncate tail_tbl. pg_rewind should copy back the truncated part
# (We cannot use an actual TRUNCATE command here, as that creates a
@@ -60,20 +65,23 @@ sub run_test
RewindTest::run_pg_rewind($test_mode);
- check_query('SELECT * FROM tbl1',
+ check_query(
+ 'SELECT * FROM tbl1',
qq(in master
in master, before promotion
in standby, after promotion
),
'table content');
- check_query('SELECT * FROM trunc_tbl',
+ check_query(
+ 'SELECT * FROM trunc_tbl',
qq(in master
in master, before promotion
),
'truncation');
- check_query('SELECT count(*) FROM tail_tbl',
+ check_query(
+ 'SELECT count(*) FROM tail_tbl',
qq(10001
),
'tail-copy');
diff --git a/src/bin/pg_rewind/t/002_databases.pl b/src/bin/pg_rewind/t/002_databases.pl
index be1e1948a7..7564fa98a5 100644
--- a/src/bin/pg_rewind/t/002_databases.pl
+++ b/src/bin/pg_rewind/t/002_databases.pl
@@ -25,20 +25,22 @@ sub run_test
# Create databases in the old master and the new promoted standby.
master_psql('CREATE DATABASE master_afterpromotion');
standby_psql('CREATE DATABASE standby_afterpromotion');
+
# The clusters are now diverged.
RewindTest::run_pg_rewind($test_mode);
# Check that the correct databases are present after pg_rewind.
- check_query('SELECT datname FROM pg_database',
- qq(template1
+ check_query(
+ 'SELECT datname FROM pg_database',
+ qq(template1
template0
postgres
inmaster
beforepromotion
standby_afterpromotion
),
- 'database names');
+ 'database names');
RewindTest::clean_rewind_test();
}
diff --git a/src/bin/pg_rewind/t/003_extrafiles.pl b/src/bin/pg_rewind/t/003_extrafiles.pl
index ed50659195..9a952685be 100644
--- a/src/bin/pg_rewind/t/003_extrafiles.pl
+++ b/src/bin/pg_rewind/t/003_extrafiles.pl
@@ -24,44 +24,58 @@ sub run_test
append_to_file "$test_master_datadir/tst_both_dir/both_file1", "in both1";
append_to_file "$test_master_datadir/tst_both_dir/both_file2", "in both2";
mkdir "$test_master_datadir/tst_both_dir/both_subdir/";
- append_to_file "$test_master_datadir/tst_both_dir/both_subdir/both_file3", "in both3";
+ append_to_file "$test_master_datadir/tst_both_dir/both_subdir/both_file3",
+ "in both3";
RewindTest::create_standby();
# Create different subdirs and files in master and standby
mkdir "$test_standby_datadir/tst_standby_dir";
- append_to_file "$test_standby_datadir/tst_standby_dir/standby_file1", "in standby1";
- append_to_file "$test_standby_datadir/tst_standby_dir/standby_file2", "in standby2";
+ append_to_file "$test_standby_datadir/tst_standby_dir/standby_file1",
+ "in standby1";
+ append_to_file "$test_standby_datadir/tst_standby_dir/standby_file2",
+ "in standby2";
mkdir "$test_standby_datadir/tst_standby_dir/standby_subdir/";
- append_to_file "$test_standby_datadir/tst_standby_dir/standby_subdir/standby_file3", "in standby3";
+ append_to_file
+ "$test_standby_datadir/tst_standby_dir/standby_subdir/standby_file3",
+ "in standby3";
mkdir "$test_master_datadir/tst_master_dir";
- append_to_file "$test_master_datadir/tst_master_dir/master_file1", "in master1";
- append_to_file "$test_master_datadir/tst_master_dir/master_file2", "in master2";
+ append_to_file "$test_master_datadir/tst_master_dir/master_file1",
+ "in master1";
+ append_to_file "$test_master_datadir/tst_master_dir/master_file2",
+ "in master2";
mkdir "$test_master_datadir/tst_master_dir/master_subdir/";
- append_to_file "$test_master_datadir/tst_master_dir/master_subdir/master_file3", "in master3";
+ append_to_file
+ "$test_master_datadir/tst_master_dir/master_subdir/master_file3",
+ "in master3";
RewindTest::promote_standby();
RewindTest::run_pg_rewind($test_mode);
# List files in the data directory after rewind.
my @paths;
- find(sub {push @paths, $File::Find::name if $File::Find::name =~ m/.*tst_.*/},
- $test_master_datadir);
+ find(
+ sub {
+ push @paths, $File::Find::name
+ if $File::Find::name =~ m/.*tst_.*/;
+ },
+ $test_master_datadir);
@paths = sort @paths;
- is_deeply(\@paths,
- ["$test_master_datadir/tst_both_dir",
- "$test_master_datadir/tst_both_dir/both_file1",
- "$test_master_datadir/tst_both_dir/both_file2",
- "$test_master_datadir/tst_both_dir/both_subdir",
- "$test_master_datadir/tst_both_dir/both_subdir/both_file3",
- "$test_master_datadir/tst_standby_dir",
- "$test_master_datadir/tst_standby_dir/standby_file1",
- "$test_master_datadir/tst_standby_dir/standby_file2",
- "$test_master_datadir/tst_standby_dir/standby_subdir",
- "$test_master_datadir/tst_standby_dir/standby_subdir/standby_file3"],
- "file lists match");
+ is_deeply(
+ \@paths,
+ [ "$test_master_datadir/tst_both_dir",
+ "$test_master_datadir/tst_both_dir/both_file1",
+ "$test_master_datadir/tst_both_dir/both_file2",
+ "$test_master_datadir/tst_both_dir/both_subdir",
+ "$test_master_datadir/tst_both_dir/both_subdir/both_file3",
+ "$test_master_datadir/tst_standby_dir",
+ "$test_master_datadir/tst_standby_dir/standby_file1",
+ "$test_master_datadir/tst_standby_dir/standby_file2",
+ "$test_master_datadir/tst_standby_dir/standby_subdir",
+"$test_master_datadir/tst_standby_dir/standby_subdir/standby_file3" ],
+ "file lists match");
RewindTest::clean_rewind_test();
}
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 99c66be7fb..5a91871c35 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -317,16 +317,16 @@ equivalent_locale(int category, const char *loca, const char *locb)
int lenb;
/*
- * If the names are equal, the locales are equivalent. Checking this
- * first avoids calling setlocale() in the common case that the names
- * are equal. That's a good thing, if setlocale() is buggy, for example.
+ * If the names are equal, the locales are equivalent. Checking this first
+ * avoids calling setlocale() in the common case that the names are equal.
+ * That's a good thing, if setlocale() is buggy, for example.
*/
if (pg_strcasecmp(loca, locb) == 0)
return true;
/*
- * Not identical. Canonicalize both names, remove the encoding parts,
- * and try again.
+ * Not identical. Canonicalize both names, remove the encoding parts, and
+ * try again.
*/
canona = get_canonical_locale_name(category, loca);
chara = strrchr(canona, '.');
@@ -512,7 +512,7 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name)
{
/* reproduce warning from CREATE TABLESPACE that is in the log */
pg_log(PG_WARNING,
- "\nWARNING: user-defined tablespace locations should not be inside the data directory, e.g. %s\n", old_tablespace_dir);
+ "\nWARNING: user-defined tablespace locations should not be inside the data directory, e.g. %s\n", old_tablespace_dir);
/* Unlink file in case it is left over from a previous run. */
unlink(*deletion_script_file_name);
@@ -611,8 +611,8 @@ check_is_install_user(ClusterInfo *cluster)
/*
* We only allow the install user in the new cluster (see comment below)
- * and we preserve pg_authid.oid, so this must be the install user in
- * the old cluster too.
+ * and we preserve pg_authid.oid, so this must be the install user in the
+ * old cluster too.
*/
if (PQntuples(res) != 1 ||
atooid(PQgetvalue(res, 0, 1)) != BOOTSTRAP_SUPERUSERID)
@@ -681,10 +681,13 @@ check_proper_datallowconn(ClusterInfo *cluster)
}
else
{
- /* avoid datallowconn == false databases from being skipped on restore */
+ /*
+ * avoid datallowconn == false databases from being skipped on
+ * restore
+ */
if (strcmp(datallowconn, "f") == 0)
pg_fatal("All non-template0 databases must allow connections, "
- "i.e. their pg_database.datallowconn must be true\n");
+ "i.e. their pg_database.datallowconn must be true\n");
}
}
@@ -873,7 +876,7 @@ check_for_reg_data_type_usage(ClusterInfo *cluster)
" 'pg_catalog.regconfig'::pg_catalog.regtype, "
" 'pg_catalog.regdictionary'::pg_catalog.regtype) AND "
" c.relnamespace = n.oid AND "
- " n.nspname NOT IN ('pg_catalog', 'information_schema')");
+ " n.nspname NOT IN ('pg_catalog', 'information_schema')");
ntups = PQntuples(res);
i_nspname = PQfnumber(res, "nspname");
@@ -964,7 +967,7 @@ check_for_jsonb_9_4_usage(ClusterInfo *cluster)
" c.relnamespace = n.oid AND "
/* exclude possible orphaned temp tables */
" n.nspname !~ '^pg_temp_' AND "
- " n.nspname NOT IN ('pg_catalog', 'information_schema')");
+ " n.nspname NOT IN ('pg_catalog', 'information_schema')");
ntups = PQntuples(res);
i_nspname = PQfnumber(res, "nspname");
@@ -999,7 +1002,7 @@ check_for_jsonb_9_4_usage(ClusterInfo *cluster)
{
pg_log(PG_REPORT, "fatal\n");
pg_fatal("Your installation contains one of the JSONB data types in user tables.\n"
- "The internal format of JSONB changed during 9.4 beta so this cluster cannot currently\n"
+ "The internal format of JSONB changed during 9.4 beta so this cluster cannot currently\n"
"be upgraded. You can remove the problem tables and restart the upgrade. A list\n"
"of the problem columns is in the file:\n"
" %s\n\n", output_path);
diff --git a/src/bin/pg_upgrade/dump.c b/src/bin/pg_upgrade/dump.c
index 2c20e847ac..6d6f84d725 100644
--- a/src/bin/pg_upgrade/dump.c
+++ b/src/bin/pg_upgrade/dump.c
@@ -111,7 +111,7 @@ optionally_create_toast_tables(void)
"FROM pg_catalog.pg_class c, "
" pg_catalog.pg_namespace n "
"WHERE c.relnamespace = n.oid AND "
- " n.nspname NOT IN ('pg_catalog', 'information_schema') AND "
+ " n.nspname NOT IN ('pg_catalog', 'information_schema') AND "
"c.relkind IN ('r', 'm') AND "
"c.reltoastrelid = 0");
@@ -122,12 +122,12 @@ optionally_create_toast_tables(void)
{
/* enable auto-oid-numbered TOAST creation if needed */
PQclear(executeQueryOrDie(conn, "SELECT pg_catalog.binary_upgrade_set_next_toast_pg_class_oid('%d'::pg_catalog.oid);",
- OPTIONALLY_CREATE_TOAST_OID));
+ OPTIONALLY_CREATE_TOAST_OID));
/* dummy command that also triggers check for required TOAST table */
PQclear(executeQueryOrDie(conn, "ALTER TABLE %s.%s RESET (binary_upgrade_dummy_option);",
- quote_identifier(PQgetvalue(res, rowno, i_nspname)),
- quote_identifier(PQgetvalue(res, rowno, i_relname))));
+ quote_identifier(PQgetvalue(res, rowno, i_nspname)),
+ quote_identifier(PQgetvalue(res, rowno, i_relname))));
}
PQclear(res);
diff --git a/src/bin/pg_upgrade/info.c b/src/bin/pg_upgrade/info.c
index c0a5601209..e158c9ff8b 100644
--- a/src/bin/pg_upgrade/info.c
+++ b/src/bin/pg_upgrade/info.c
@@ -38,16 +38,16 @@ gen_db_file_maps(DbInfo *old_db, DbInfo *new_db,
int *nmaps, const char *old_pgdata, const char *new_pgdata)
{
FileNameMap *maps;
- int old_relnum, new_relnum;
+ int old_relnum,
+ new_relnum;
int num_maps = 0;
maps = (FileNameMap *) pg_malloc(sizeof(FileNameMap) *
old_db->rel_arr.nrels);
/*
- * The old database shouldn't have more relations than the new one.
- * We force the new cluster to have a TOAST table if the old table
- * had one.
+ * The old database shouldn't have more relations than the new one. We
+ * force the new cluster to have a TOAST table if the old table had one.
*/
if (old_db->rel_arr.nrels > new_db->rel_arr.nrels)
pg_fatal("old and new databases \"%s\" have a mismatched number of relations\n",
@@ -62,15 +62,15 @@ gen_db_file_maps(DbInfo *old_db, DbInfo *new_db,
/*
* It is possible that the new cluster has a TOAST table for a table
- * that didn't need one in the old cluster, e.g. 9.0 to 9.1 changed the
- * NUMERIC length computation. Therefore, if we have a TOAST table
- * in the new cluster that doesn't match, skip over it and continue
- * processing. It is possible this TOAST table used an OID that was
- * reserved in the old cluster, but we have no way of testing that,
- * and we would have already gotten an error at the new cluster schema
- * creation stage. Fortunately, since we only restore the OID counter
- * after schema restore, and restore in OID order via pg_dump, a
- * conflict would only happen if the new TOAST table had a very low
+ * that didn't need one in the old cluster, e.g. 9.0 to 9.1 changed
+ * the NUMERIC length computation. Therefore, if we have a TOAST
+ * table in the new cluster that doesn't match, skip over it and
+ * continue processing. It is possible this TOAST table used an OID
+ * that was reserved in the old cluster, but we have no way of testing
+ * that, and we would have already gotten an error at the new cluster
+ * schema creation stage. Fortunately, since we only restore the OID
+ * counter after schema restore, and restore in OID order via pg_dump,
+ * a conflict would only happen if the new TOAST table had a very low
* OID. However, TOAST tables created long after initial table
* creation can have any OID, particularly after OID wraparound.
*/
@@ -330,75 +330,77 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
*/
snprintf(query, sizeof(query),
- /* get regular heap */
- "WITH regular_heap (reloid) AS ( "
- " SELECT c.oid "
- " FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n "
- " ON c.relnamespace = n.oid "
- " LEFT OUTER JOIN pg_catalog.pg_index i "
- " ON c.oid = i.indexrelid "
- " WHERE relkind IN ('r', 'm', 'i', 'S') AND "
- /*
- * pg_dump only dumps valid indexes; testing indisready is necessary in
- * 9.2, and harmless in earlier/later versions.
- */
- " i.indisvalid IS DISTINCT FROM false AND "
- " i.indisready IS DISTINCT FROM false AND "
- /* exclude possible orphaned temp tables */
- " ((n.nspname !~ '^pg_temp_' AND "
- " n.nspname !~ '^pg_toast_temp_' AND "
- /* skip pg_toast because toast index have relkind == 'i', not 't' */
- " n.nspname NOT IN ('pg_catalog', 'information_schema', "
- " 'binary_upgrade', 'pg_toast') AND "
- " c.oid >= %u) OR "
- " (n.nspname = 'pg_catalog' AND "
- " relname IN ('pg_largeobject', 'pg_largeobject_loid_pn_index'%s) ))), "
- /*
- * We have to gather the TOAST tables in later steps because we
- * can't schema-qualify TOAST tables.
- */
- /* get TOAST heap */
- " toast_heap (reloid) AS ( "
- " SELECT reltoastrelid "
- " FROM regular_heap JOIN pg_catalog.pg_class c "
- " ON regular_heap.reloid = c.oid "
- " AND c.reltoastrelid != %u), "
- /* get indexes on regular and TOAST heap */
- " all_index (reloid) AS ( "
- " SELECT indexrelid "
- " FROM pg_index "
- " WHERE indisvalid "
- " AND indrelid IN (SELECT reltoastrelid "
- " FROM (SELECT reloid FROM regular_heap "
- " UNION ALL "
- " SELECT reloid FROM toast_heap) all_heap "
- " JOIN pg_catalog.pg_class c "
- " ON all_heap.reloid = c.oid "
- " AND c.reltoastrelid != %u)) "
- /* get all rels */
- "SELECT c.oid, n.nspname, c.relname, "
- " c.relfilenode, c.reltablespace, %s "
- "FROM (SELECT reloid FROM regular_heap "
- " UNION ALL "
- " SELECT reloid FROM toast_heap "
- " UNION ALL "
- " SELECT reloid FROM all_index) all_rels "
- " JOIN pg_catalog.pg_class c "
- " ON all_rels.reloid = c.oid "
- " JOIN pg_catalog.pg_namespace n "
- " ON c.relnamespace = n.oid "
- " LEFT OUTER JOIN pg_catalog.pg_tablespace t "
- " ON c.reltablespace = t.oid "
+ /* get regular heap */
+ "WITH regular_heap (reloid) AS ( "
+ " SELECT c.oid "
+ " FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n "
+ " ON c.relnamespace = n.oid "
+ " LEFT OUTER JOIN pg_catalog.pg_index i "
+ " ON c.oid = i.indexrelid "
+ " WHERE relkind IN ('r', 'm', 'i', 'S') AND "
+
+ /*
+ * pg_dump only dumps valid indexes; testing indisready is necessary in
+ * 9.2, and harmless in earlier/later versions.
+ */
+ " i.indisvalid IS DISTINCT FROM false AND "
+ " i.indisready IS DISTINCT FROM false AND "
+ /* exclude possible orphaned temp tables */
+ " ((n.nspname !~ '^pg_temp_' AND "
+ " n.nspname !~ '^pg_toast_temp_' AND "
+ /* skip pg_toast because toast index have relkind == 'i', not 't' */
+ " n.nspname NOT IN ('pg_catalog', 'information_schema', "
+ " 'binary_upgrade', 'pg_toast') AND "
+ " c.oid >= %u) OR "
+ " (n.nspname = 'pg_catalog' AND "
+ " relname IN ('pg_largeobject', 'pg_largeobject_loid_pn_index'%s) ))), "
+
+ /*
+ * We have to gather the TOAST tables in later steps because we can't
+ * schema-qualify TOAST tables.
+ */
+ /* get TOAST heap */
+ " toast_heap (reloid) AS ( "
+ " SELECT reltoastrelid "
+ " FROM regular_heap JOIN pg_catalog.pg_class c "
+ " ON regular_heap.reloid = c.oid "
+ " AND c.reltoastrelid != %u), "
+ /* get indexes on regular and TOAST heap */
+ " all_index (reloid) AS ( "
+ " SELECT indexrelid "
+ " FROM pg_index "
+ " WHERE indisvalid "
+ " AND indrelid IN (SELECT reltoastrelid "
+ " FROM (SELECT reloid FROM regular_heap "
+ " UNION ALL "
+ " SELECT reloid FROM toast_heap) all_heap "
+ " JOIN pg_catalog.pg_class c "
+ " ON all_heap.reloid = c.oid "
+ " AND c.reltoastrelid != %u)) "
+ /* get all rels */
+ "SELECT c.oid, n.nspname, c.relname, "
+ " c.relfilenode, c.reltablespace, %s "
+ "FROM (SELECT reloid FROM regular_heap "
+ " UNION ALL "
+ " SELECT reloid FROM toast_heap "
+ " UNION ALL "
+ " SELECT reloid FROM all_index) all_rels "
+ " JOIN pg_catalog.pg_class c "
+ " ON all_rels.reloid = c.oid "
+ " JOIN pg_catalog.pg_namespace n "
+ " ON c.relnamespace = n.oid "
+ " LEFT OUTER JOIN pg_catalog.pg_tablespace t "
+ " ON c.reltablespace = t.oid "
/* we preserve pg_class.oid so we sort by it to match old/new */
- "ORDER BY 1;",
- FirstNormalObjectId,
+ "ORDER BY 1;",
+ FirstNormalObjectId,
/* does pg_largeobject_metadata need to be migrated? */
- (GET_MAJOR_VERSION(old_cluster.major_version) <= 804) ?
- "" : ", 'pg_largeobject_metadata', 'pg_largeobject_metadata_oid_index'",
- InvalidOid, InvalidOid,
+ (GET_MAJOR_VERSION(old_cluster.major_version) <= 804) ?
+ "" : ", 'pg_largeobject_metadata', 'pg_largeobject_metadata_oid_index'",
+ InvalidOid, InvalidOid,
/* 9.2 removed the spclocation column */
- (GET_MAJOR_VERSION(cluster->major_version) <= 901) ?
- "t.spclocation" : "pg_catalog.pg_tablespace_location(t.oid) AS spclocation");
+ (GET_MAJOR_VERSION(cluster->major_version) <= 901) ?
+ "t.spclocation" : "pg_catalog.pg_tablespace_location(t.oid) AS spclocation");
res = executeQueryOrDie(conn, "%s", query);
diff --git a/src/bin/pg_upgrade/option.c b/src/bin/pg_upgrade/option.c
index b851056135..90f1401549 100644
--- a/src/bin/pg_upgrade/option.c
+++ b/src/bin/pg_upgrade/option.c
@@ -142,7 +142,7 @@ parseCommandLine(int argc, char *argv[])
old_cluster.pgopts = pg_strdup(optarg);
else
{
- char *old_pgopts = old_cluster.pgopts;
+ char *old_pgopts = old_cluster.pgopts;
old_cluster.pgopts = psprintf("%s %s", old_pgopts, optarg);
free(old_pgopts);
@@ -155,7 +155,7 @@ parseCommandLine(int argc, char *argv[])
new_cluster.pgopts = pg_strdup(optarg);
else
{
- char *new_pgopts = new_cluster.pgopts;
+ char *new_pgopts = new_cluster.pgopts;
new_cluster.pgopts = psprintf("%s %s", new_pgopts, optarg);
free(new_pgopts);
@@ -249,13 +249,15 @@ parseCommandLine(int argc, char *argv[])
"PGDATANEW", "-D", "new cluster data resides");
#ifdef WIN32
+
/*
* On Windows, initdb --sync-only will fail with a "Permission denied"
- * error on file pg_upgrade_utility.log if pg_upgrade is run inside
- * the new cluster directory, so we do a check here.
+ * error on file pg_upgrade_utility.log if pg_upgrade is run inside the
+ * new cluster directory, so we do a check here.
*/
{
- char cwd[MAXPGPATH], new_cluster_pgdata[MAXPGPATH];
+ char cwd[MAXPGPATH],
+ new_cluster_pgdata[MAXPGPATH];
strlcpy(new_cluster_pgdata, new_cluster.pgdata, MAXPGPATH);
canonicalize_path(new_cluster_pgdata);
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 4e6a9f91be..8cdfaf35ef 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -333,8 +333,8 @@ create_new_objects(void)
check_ok();
/*
- * We don't have minmxids for databases or relations in pre-9.3
- * clusters, so set those after we have restores the schemas.
+ * We don't have minmxids for databases or relations in pre-9.3 clusters,
+ * so set those after we have restores the schemas.
*/
if (GET_MAJOR_VERSION(old_cluster.major_version) < 903)
set_frozenxids(true);
@@ -473,7 +473,7 @@ copy_clog_xlog_xid(void)
/* now reset the wal archives in the new cluster */
prep_status("Resetting WAL archives");
exec_prog(UTILITY_LOG_FILE, NULL, true,
- /* use timeline 1 to match controldata and no WAL history file */
+ /* use timeline 1 to match controldata and no WAL history file */
"\"%s/pg_resetxlog\" -l 00000001%s \"%s\"", new_cluster.bindir,
old_cluster.controldata.nextxlogfile + 8,
new_cluster.pgdata);
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index aecf0df30c..13aa891d59 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -329,7 +329,7 @@ extern OSInfo os_info;
/* check.c */
void output_check_banner(bool live_check);
-void check_and_dump_old_cluster(bool live_check);
+void check_and_dump_old_cluster(bool live_check);
void check_new_cluster(void);
void report_clusters_compatible(void);
void issue_warnings(void);
@@ -358,7 +358,7 @@ void optionally_create_toast_tables(void);
#define EXEC_PSQL_ARGS "--echo-queries --set ON_ERROR_STOP=on --no-psqlrc --dbname=template1"
-bool exec_prog(const char *log_file, const char *opt_log_file,
+bool exec_prog(const char *log_file, const char *opt_log_file,
bool throw_error, const char *fmt,...) pg_attribute_printf(4, 5);
void verify_directories(void);
bool pid_lock_file_exists(const char *datadir);
@@ -471,7 +471,7 @@ void pg_putenv(const char *var, const char *val);
void new_9_0_populate_pg_largeobject_metadata(ClusterInfo *cluster,
bool check_mode);
-void old_9_3_check_for_line_data_type_usage(ClusterInfo *cluster);
+void old_9_3_check_for_line_data_type_usage(ClusterInfo *cluster);
/* parallel.c */
void parallel_exec_prog(const char *log_file, const char *opt_log_file,
diff --git a/src/bin/pg_upgrade/relfilenode.c b/src/bin/pg_upgrade/relfilenode.c
index 7b3215af56..c22df42949 100644
--- a/src/bin/pg_upgrade/relfilenode.c
+++ b/src/bin/pg_upgrade/relfilenode.c
@@ -35,10 +35,10 @@ transfer_all_new_tablespaces(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr,
user_opts.transfer_mode == TRANSFER_MODE_LINK ? "Linking" : "Copying");
/*
- * Transferring files by tablespace is tricky because a single database can
- * use multiple tablespaces. For non-parallel mode, we just pass a NULL
- * tablespace path, which matches all tablespaces. In parallel mode, we
- * pass the default tablespace and all user-created tablespaces and let
+ * Transferring files by tablespace is tricky because a single database
+ * can use multiple tablespaces. For non-parallel mode, we just pass a
+ * NULL tablespace path, which matches all tablespaces. In parallel mode,
+ * we pass the default tablespace and all user-created tablespaces and let
* those operations happen in parallel.
*/
if (user_opts.jobs <= 1)
diff --git a/src/bin/pg_upgrade/server.c b/src/bin/pg_upgrade/server.c
index 8d8e7d7073..8c6b6da515 100644
--- a/src/bin/pg_upgrade/server.c
+++ b/src/bin/pg_upgrade/server.c
@@ -204,11 +204,12 @@ start_postmaster(ClusterInfo *cluster, bool throw_error)
/*
* Since PG 9.1, we have used -b to disable autovacuum. For earlier
* releases, setting autovacuum=off disables cleanup vacuum and analyze,
- * but freeze vacuums can still happen, so we set autovacuum_freeze_max_age
- * to its maximum. (autovacuum_multixact_freeze_max_age was introduced
- * after 9.1, so there is no need to set that.) We assume all datfrozenxid
- * and relfrozenxid values are less than a gap of 2000000000 from the current
- * xid counter, so autovacuum will not touch them.
+ * but freeze vacuums can still happen, so we set
+ * autovacuum_freeze_max_age to its maximum.
+ * (autovacuum_multixact_freeze_max_age was introduced after 9.1, so there
+ * is no need to set that.) We assume all datfrozenxid and relfrozenxid
+ * values are less than a gap of 2000000000 from the current xid counter,
+ * so autovacuum will not touch them.
*
* Turn off durability requirements to improve object creation speed, and
* we only modify the new cluster, so only use it there. If there is a
diff --git a/src/bin/pg_upgrade/version.c b/src/bin/pg_upgrade/version.c
index e3e7387c92..9954daea17 100644
--- a/src/bin/pg_upgrade/version.c
+++ b/src/bin/pg_upgrade/version.c
@@ -167,9 +167,9 @@ old_9_3_check_for_line_data_type_usage(ClusterInfo *cluster)
{
pg_log(PG_REPORT, "fatal\n");
pg_fatal("Your installation contains the \"line\" data type in user tables. This\n"
- "data type changed its internal and input/output format between your old\n"
+ "data type changed its internal and input/output format between your old\n"
"and new clusters so this cluster cannot currently be upgraded. You can\n"
- "remove the problem tables and restart the upgrade. A list of the problem\n"
+ "remove the problem tables and restart the upgrade. A list of the problem\n"
"columns is in the file:\n"
" %s\n\n", output_path);
}
diff --git a/src/bin/pg_xlogdump/pg_xlogdump.c b/src/bin/pg_xlogdump/pg_xlogdump.c
index e9cbbd264d..c0a6816784 100644
--- a/src/bin/pg_xlogdump/pg_xlogdump.c
+++ b/src/bin/pg_xlogdump/pg_xlogdump.c
@@ -494,7 +494,10 @@ XLogDumpStatsRow(const char *name,
uint64 fpi_len, uint64 total_fpi_len,
uint64 tot_len, uint64 total_len)
{
- double n_pct, rec_len_pct, fpi_len_pct, tot_len_pct;
+ double n_pct,
+ rec_len_pct,
+ fpi_len_pct,
+ tot_len_pct;
n_pct = 0;
if (total_count != 0)
@@ -528,12 +531,14 @@ XLogDumpStatsRow(const char *name,
static void
XLogDumpDisplayStats(XLogDumpConfig *config, XLogDumpStats *stats)
{
- int ri, rj;
+ int ri,
+ rj;
uint64 total_count = 0;
uint64 total_rec_len = 0;
uint64 total_fpi_len = 0;
uint64 total_len = 0;
- double rec_len_pct, fpi_len_pct;
+ double rec_len_pct,
+ fpi_len_pct;
/* ---
* Make a first pass to calculate column totals:
@@ -551,11 +556,11 @@ XLogDumpDisplayStats(XLogDumpConfig *config, XLogDumpStats *stats)
total_rec_len += stats->rmgr_stats[ri].rec_len;
total_fpi_len += stats->rmgr_stats[ri].fpi_len;
}
- total_len = total_rec_len+total_fpi_len;
+ total_len = total_rec_len + total_fpi_len;
/*
- * 27 is strlen("Transaction/COMMIT_PREPARED"),
- * 20 is strlen(2^64), 8 is strlen("(100.00%)")
+ * 27 is strlen("Transaction/COMMIT_PREPARED"), 20 is strlen(2^64), 8 is
+ * strlen("(100.00%)")
*/
printf("%-27s %20s %8s %20s %8s %20s %8s %20s %8s\n"
@@ -565,7 +570,10 @@ XLogDumpDisplayStats(XLogDumpConfig *config, XLogDumpStats *stats)
for (ri = 0; ri < RM_NEXT_ID; ri++)
{
- uint64 count, rec_len, fpi_len, tot_len;
+ uint64 count,
+ rec_len,
+ fpi_len,
+ tot_len;
const RmgrDescData *desc = &RmgrDescTable[ri];
if (!config->stats_per_record)
@@ -610,10 +618,10 @@ XLogDumpDisplayStats(XLogDumpConfig *config, XLogDumpStats *stats)
"", "--------", "", "--------", "", "--------", "", "--------");
/*
- * The percentages in earlier rows were calculated against the
- * column total, but the ones that follow are against the row total.
- * Note that these are displayed with a % symbol to differentiate
- * them from the earlier ones, and are thus up to 9 characters long.
+ * The percentages in earlier rows were calculated against the column
+ * total, but the ones that follow are against the row total. Note that
+ * these are displayed with a % symbol to differentiate them from the
+ * earlier ones, and are thus up to 9 characters long.
*/
rec_len_pct = 0;
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index 8b8b5911d6..6f35db4763 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -100,7 +100,7 @@ static int pthread_join(pthread_t th, void **thread_return);
#define LOG_STEP_SECONDS 5 /* seconds between log messages */
#define DEFAULT_NXACTS 10 /* default nxacts */
-#define MIN_GAUSSIAN_THRESHOLD 2.0 /* minimum threshold for gauss */
+#define MIN_GAUSSIAN_THRESHOLD 2.0 /* minimum threshold for gauss */
int nxacts = 0; /* number of transactions per client */
int duration = 0; /* duration in seconds */
@@ -244,7 +244,8 @@ typedef struct
int64 throttle_trigger; /* previous/next throttling (us) */
int64 throttle_lag; /* total transaction lag behind throttling */
int64 throttle_lag_max; /* max transaction lag */
- int64 throttle_latency_skipped; /* lagging transactions skipped */
+ int64 throttle_latency_skipped; /* lagging transactions
+ * skipped */
int64 latency_late; /* late transactions */
} TState;
@@ -296,8 +297,8 @@ typedef struct
long start_time; /* when does the interval start */
int cnt; /* number of transactions */
- int skipped; /* number of transactions skipped under
- * --rate and --latency-limit */
+ int skipped; /* number of transactions skipped under --rate
+ * and --latency-limit */
double min_latency; /* min/max latencies */
double max_latency;
@@ -389,7 +390,7 @@ usage(void)
" -f, --file=FILENAME read transaction script from FILENAME\n"
" -j, --jobs=NUM number of threads (default: 1)\n"
" -l, --log write transaction times to log file\n"
- " -L, --latency-limit=NUM count transactions lasting more than NUM ms\n"
+ " -L, --latency-limit=NUM count transactions lasting more than NUM ms\n"
" as late.\n"
" -M, --protocol=simple|extended|prepared\n"
" protocol for submitting queries (default: simple)\n"
@@ -509,19 +510,22 @@ getrand(TState *thread, int64 min, int64 max)
static int64
getExponentialRand(TState *thread, int64 min, int64 max, double threshold)
{
- double cut, uniform, rand;
+ double cut,
+ uniform,
+ rand;
+
Assert(threshold > 0.0);
cut = exp(-threshold);
/* erand in [0, 1), uniform in (0, 1] */
uniform = 1.0 - pg_erand48(thread->random_state);
+
/*
- * inner expresion in (cut, 1] (if threshold > 0),
- * rand in [0, 1)
+ * inner expresion in (cut, 1] (if threshold > 0), rand in [0, 1)
*/
Assert((1.0 - cut) != 0.0);
- rand = - log(cut + (1.0 - cut) * uniform) / threshold;
+ rand = -log(cut + (1.0 - cut) * uniform) / threshold;
/* return int64 random number within between min and max */
- return min + (int64)((max - min + 1) * rand);
+ return min + (int64) ((max - min + 1) * rand);
}
/* random number generator: gaussian distribution from min to max inclusive */
@@ -532,34 +536,37 @@ getGaussianRand(TState *thread, int64 min, int64 max, double threshold)
double rand;
/*
- * Get user specified random number from this loop, with
- * -threshold < stdev <= threshold
+ * Get user specified random number from this loop, with -threshold <
+ * stdev <= threshold
*
* This loop is executed until the number is in the expected range.
*
* As the minimum threshold is 2.0, the probability of looping is low:
- * sqrt(-2 ln(r)) <= 2 => r >= e^{-2} ~ 0.135, then when taking the average
- * sinus multiplier as 2/pi, we have a 8.6% looping probability in the
- * worst case. For a 5.0 threshold value, the looping probability
- * is about e^{-5} * 2 / pi ~ 0.43%.
+ * sqrt(-2 ln(r)) <= 2 => r >= e^{-2} ~ 0.135, then when taking the
+ * average sinus multiplier as 2/pi, we have a 8.6% looping probability in
+ * the worst case. For a 5.0 threshold value, the looping probability is
+ * about e^{-5} * 2 / pi ~ 0.43%.
*/
do
{
/*
* pg_erand48 generates [0,1), but for the basic version of the
* Box-Muller transform the two uniformly distributed random numbers
- * are expected in (0, 1] (see http://en.wikipedia.org/wiki/Box_muller)
+ * are expected in (0, 1] (see
+ * http://en.wikipedia.org/wiki/Box_muller)
*/
- double rand1 = 1.0 - pg_erand48(thread->random_state);
- double rand2 = 1.0 - pg_erand48(thread->random_state);
+ double rand1 = 1.0 - pg_erand48(thread->random_state);
+ double rand2 = 1.0 - pg_erand48(thread->random_state);
/* Box-Muller basic form transform */
- double var_sqrt = sqrt(-2.0 * log(rand1));
+ double var_sqrt = sqrt(-2.0 * log(rand1));
+
stdev = var_sqrt * sin(2.0 * M_PI * rand2);
/*
- * we may try with cos, but there may be a bias induced if the previous
- * value fails the test. To be on the safe side, let us try over.
+ * we may try with cos, but there may be a bias induced if the
+ * previous value fails the test. To be on the safe side, let us try
+ * over.
*/
}
while (stdev < -threshold || stdev >= threshold);
@@ -568,7 +575,7 @@ getGaussianRand(TState *thread, int64 min, int64 max, double threshold)
rand = (stdev + threshold) / (threshold * 2.0);
/* return int64 random number within between min and max */
- return min + (int64)((max - min + 1) * rand);
+ return min + (int64) ((max - min + 1) * rand);
}
/*
@@ -582,7 +589,7 @@ getPoissonRand(TState *thread, int64 center)
* Use inverse transform sampling to generate a value > 0, such that the
* expected (i.e. average) value is the given argument.
*/
- double uniform;
+ double uniform;
/* erand in [0, 1), uniform in (0, 1] */
uniform = 1.0 - pg_erand48(thread->random_state);
@@ -918,7 +925,7 @@ evaluateExpr(CState *st, PgBenchExpr *expr, int64 *retval)
if ((var = getVariable(st, expr->u.variable.varname)) == NULL)
{
fprintf(stderr, "undefined variable %s\n",
- expr->u.variable.varname);
+ expr->u.variable.varname);
return false;
}
*retval = strtoint64(var);
@@ -927,8 +934,8 @@ evaluateExpr(CState *st, PgBenchExpr *expr, int64 *retval)
case ENODE_OPERATOR:
{
- int64 lval;
- int64 rval;
+ int64 lval;
+ int64 rval;
if (!evaluateExpr(st, expr->u.operator.lexpr, &lval))
return false;
@@ -1115,7 +1122,7 @@ agg_vals_init(AggVals *aggs, instr_time start)
aggs->skipped = 0; /* xacts skipped under --rate --latency-limit */
aggs->sum_latency = 0; /* SUM(latency) */
- aggs->sum2_latency = 0; /* SUM(latency*latency) */
+ aggs->sum2_latency = 0; /* SUM(latency*latency) */
/* min and max transaction duration */
aggs->min_latency = 0;
@@ -1535,9 +1542,10 @@ top:
/*
* Generate random number functions need to be able to subtract
* max from min and add one to the result without overflowing.
- * Since we know max > min, we can detect overflow just by checking
- * for a negative result. But we must check both that the subtraction
- * doesn't overflow, and that adding one to the result doesn't overflow either.
+ * Since we know max > min, we can detect overflow just by
+ * checking for a negative result. But we must check both that the
+ * subtraction doesn't overflow, and that adding one to the result
+ * doesn't overflow either.
*/
if (max - min < 0 || (max - min) + 1 < 0)
{
@@ -1546,7 +1554,7 @@ top:
return true;
}
- if (argc == 4 || /* uniform without or with "uniform" keyword */
+ if (argc == 4 || /* uniform without or with "uniform" keyword */
(argc == 5 && pg_strcasecmp(argv[4], "uniform") == 0))
{
#ifdef DEBUG
@@ -1598,7 +1606,7 @@ top:
snprintf(res, sizeof(res), INT64_FORMAT, getExponentialRand(thread, min, max, threshold));
}
}
- else /* this means an error somewhere in the parsing phase... */
+ else /* this means an error somewhere in the parsing phase... */
{
fprintf(stderr, "%s: unexpected arguments\n", argv[0]);
st->ecnt++;
@@ -1742,7 +1750,10 @@ doLog(TState *thread, CState *st, FILE *logfile, instr_time *now, AggVals *agg,
agg->cnt += 1;
if (skipped)
{
- /* there is no latency to record if the transaction was skipped */
+ /*
+ * there is no latency to record if the transaction was
+ * skipped
+ */
agg->skipped += 1;
}
else
@@ -1779,9 +1790,9 @@ doLog(TState *thread, CState *st, FILE *logfile, instr_time *now, AggVals *agg,
while (agg->start_time + agg_interval < INSTR_TIME_GET_DOUBLE(*now))
{
/*
- * This is a non-Windows branch (thanks to the
- * ifdef in usage), so we don't need to handle
- * this in a special way (see below).
+ * This is a non-Windows branch (thanks to the ifdef in
+ * usage), so we don't need to handle this in a special way
+ * (see below).
*/
fprintf(logfile, "%ld %d %.0f %.0f %.0f %.0f",
agg->start_time,
@@ -2217,7 +2228,7 @@ syntax_error(const char *source, const int lineno,
fprintf(stderr, "%s\n", line);
if (column != -1)
{
- int i;
+ int i;
for (i = 0; i < column - 1; i++)
fprintf(stderr, " ");
@@ -2260,7 +2271,8 @@ process_commands(char *buf, const char *source, const int lineno)
if (*p == '\\')
{
- int max_args = -1;
+ int max_args = -1;
+
my_commands->type = META_COMMAND;
j = 0;
@@ -2282,9 +2294,9 @@ process_commands(char *buf, const char *source, const int lineno)
if (pg_strcasecmp(my_commands->argv[0], "setrandom") == 0)
{
- /* parsing:
- * \setrandom variable min max [uniform]
- * \setrandom variable min max (gaussian|exponential) threshold
+ /*
+ * parsing: \setrandom variable min max [uniform] \setrandom
+ * variable min max (gaussian|exponential) threshold
*/
if (my_commands->argc < 4)
@@ -2295,20 +2307,21 @@ process_commands(char *buf, const char *source, const int lineno)
/* argc >= 4 */
- if (my_commands->argc == 4 || /* uniform without/with "uniform" keyword */
+ if (my_commands->argc == 4 || /* uniform without/with
+ * "uniform" keyword */
(my_commands->argc == 5 &&
pg_strcasecmp(my_commands->argv[4], "uniform") == 0))
{
/* nothing to do */
}
- else if (/* argc >= 5 */
+ else if ( /* argc >= 5 */
(pg_strcasecmp(my_commands->argv[4], "gaussian") == 0) ||
- (pg_strcasecmp(my_commands->argv[4], "exponential") == 0))
+ (pg_strcasecmp(my_commands->argv[4], "exponential") == 0))
{
if (my_commands->argc < 6)
{
syntax_error(source, lineno, my_commands->line, my_commands->argv[0],
- "missing threshold argument", my_commands->argv[4], -1);
+ "missing threshold argument", my_commands->argv[4], -1);
}
else if (my_commands->argc > 6)
{
@@ -2317,7 +2330,7 @@ process_commands(char *buf, const char *source, const int lineno)
my_commands->cols[6]);
}
}
- else /* cannot parse, unexpected arguments */
+ else /* cannot parse, unexpected arguments */
{
syntax_error(source, lineno, my_commands->line, my_commands->argv[0],
"unexpected argument", my_commands->argv[4],
@@ -2486,7 +2499,8 @@ process_file(char *filename)
Command **my_commands;
FILE *fd;
- int lineno, index;
+ int lineno,
+ index;
char *buf;
int alloc_num;
@@ -2514,6 +2528,7 @@ process_file(char *filename)
while ((buf = read_line_from_file(fd)) != NULL)
{
Command *command;
+
lineno += 1;
command = process_commands(buf, filename, lineno);
@@ -2547,7 +2562,8 @@ process_builtin(char *tb, const char *source)
#define COMMANDS_ALLOC_NUM 128
Command **my_commands;
- int lineno, index;
+ int lineno,
+ index;
char buf[BUFSIZ];
int alloc_num;
@@ -2653,7 +2669,7 @@ printResults(int ttype, int64 normal_xacts, int nclients,
if (latency_limit)
printf("number of transactions above the %.1f ms latency limit: " INT64_FORMAT " (%.3f %%)\n",
latency_limit / 1000.0, latency_late,
- 100.0 * latency_late / (throttle_latency_skipped + normal_xacts));
+ 100.0 * latency_late / (throttle_latency_skipped + normal_xacts));
if (throttle_delay || progress || latency_limit)
{
@@ -3045,7 +3061,8 @@ main(int argc, char **argv)
break;
case 'L':
{
- double limit_ms = atof(optarg);
+ double limit_ms = atof(optarg);
+
if (limit_ms <= 0.0)
{
fprintf(stderr, "invalid latency limit: %s\n", optarg);
diff --git a/src/bin/pgbench/pgbench.h b/src/bin/pgbench/pgbench.h
index a3db6b97cc..42e2aae294 100644
--- a/src/bin/pgbench/pgbench.h
+++ b/src/bin/pgbench/pgbench.h
@@ -22,39 +22,39 @@ typedef struct PgBenchExpr PgBenchExpr;
struct PgBenchExpr
{
- PgBenchExprType etype;
+ PgBenchExprType etype;
union
{
struct
{
- int64 ival;
- } integer_constant;
+ int64 ival;
+ } integer_constant;
struct
{
- char *varname;
- } variable;
+ char *varname;
+ } variable;
struct
{
- char operator;
- PgBenchExpr *lexpr;
+ char operator;
+ PgBenchExpr *lexpr;
PgBenchExpr *rexpr;
- } operator;
- } u;
+ } operator;
+ } u;
};
extern PgBenchExpr *expr_parse_result;
-extern int expr_yyparse(void);
-extern int expr_yylex(void);
+extern int expr_yyparse(void);
+extern int expr_yylex(void);
extern void expr_yyerror(const char *str);
extern void expr_scanner_init(const char *str, const char *source,
- const int lineno, const char *line,
- const char *cmd, const int ecol);
-extern void syntax_error(const char* source, const int lineno, const char* line,
- const char* cmd, const char* msg, const char* more,
- const int col);
+ const int lineno, const char *line,
+ const char *cmd, const int ecol);
+extern void syntax_error(const char *source, const int lineno, const char *line,
+ const char *cmd, const char *msg, const char *more,
+ const int col);
extern void expr_scanner_finish(void);
extern int64 strtoint64(const char *str);
-#endif /* PGBENCH_H */
+#endif /* PGBENCH_H */
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 70b7d3be15..38253fa098 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -1082,7 +1082,8 @@ exec_command(const char *cmd,
for (i = 0; my_list[i] != NULL; i++)
{
- char *val = pset_value_string(my_list[i], &pset.popt);
+ char *val = pset_value_string(my_list[i], &pset.popt);
+
printf("%-24s %s\n", my_list[i], val);
free(val);
}
@@ -1515,7 +1516,7 @@ exec_command(const char *cmd,
else if (strcmp(cmd, "?") == 0)
{
char *opt0 = psql_scan_slash_option(scan_state,
- OT_NORMAL, NULL, false);
+ OT_NORMAL, NULL, false);
if (!opt0 || strcmp(opt0, "commands") == 0)
slashUsage(pset.popt.topt.pager);
@@ -1636,8 +1637,8 @@ do_connect(char *dbname, char *user, char *host, char *port)
/*
* Any change in the parameters read above makes us discard the password.
- * We also discard it if we're to use a conninfo rather than the positional
- * syntax.
+ * We also discard it if we're to use a conninfo rather than the
+ * positional syntax.
*/
keep_password =
((strcmp(user, PQuser(o_conn)) == 0) &&
@@ -1863,7 +1864,7 @@ printSSLInfo(void)
protocol ? protocol : _("unknown"),
cipher ? cipher : _("unknown"),
bits ? bits : _("unknown"),
- (compression && strcmp(compression, "off") != 0) ? _("on") : _("off"));
+ (compression && strcmp(compression, "off") != 0) ? _("on") : _("off"));
}
@@ -2402,7 +2403,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
if (!value)
;
else if (!set_unicode_line_style(popt, value, vallen,
- &popt->topt.unicode_border_linestyle))
+ &popt->topt.unicode_border_linestyle))
{
psql_error("\\pset: allowed unicode border linestyle are single, double\n");
return false;
@@ -2415,7 +2416,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
if (!value)
;
else if (!set_unicode_line_style(popt, value, vallen,
- &popt->topt.unicode_column_linestyle))
+ &popt->topt.unicode_column_linestyle))
{
psql_error("\\pset: allowed unicode column linestyle are single, double\n");
return false;
@@ -2428,7 +2429,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
if (!value)
;
else if (!set_unicode_line_style(popt, value, vallen,
- &popt->topt.unicode_header_linestyle))
+ &popt->topt.unicode_header_linestyle))
{
psql_error("\\pset: allowed unicode header linestyle are single, double\n");
return false;
@@ -2742,19 +2743,19 @@ printPsetInfo(const char *param, struct printQueryOpt *popt)
else if (strcmp(param, "unicode_border_linestyle") == 0)
{
printf(_("Unicode border linestyle is \"%s\".\n"),
- _unicode_linestyle2string(popt->topt.unicode_border_linestyle));
+ _unicode_linestyle2string(popt->topt.unicode_border_linestyle));
}
else if (strcmp(param, "unicode_column_linestyle") == 0)
{
printf(_("Unicode column linestyle is \"%s\".\n"),
- _unicode_linestyle2string(popt->topt.unicode_column_linestyle));
+ _unicode_linestyle2string(popt->topt.unicode_column_linestyle));
}
else if (strcmp(param, "unicode_header_linestyle") == 0)
{
printf(_("Unicode border linestyle is \"%s\".\n"),
- _unicode_linestyle2string(popt->topt.unicode_header_linestyle));
+ _unicode_linestyle2string(popt->topt.unicode_header_linestyle));
}
else
@@ -2945,7 +2946,7 @@ do_watch(PQExpBuffer query_buf, long sleep)
for (;;)
{
- int res;
+ int res;
time_t timer;
long i;
@@ -2962,8 +2963,8 @@ do_watch(PQExpBuffer query_buf, long sleep)
res = PSQLexecWatch(query_buf->data, &myopt);
/*
- * PSQLexecWatch handles the case where we can no longer
- * repeat the query, and returns 0 or -1.
+ * PSQLexecWatch handles the case where we can no longer repeat the
+ * query, and returns 0 or -1.
*/
if (res == 0)
break;
@@ -3001,7 +3002,7 @@ do_watch(PQExpBuffer query_buf, long sleep)
* returns true unless we have ECHO_HIDDEN_NOEXEC.
*/
static bool
-lookup_function_echo_hidden(char * query)
+lookup_function_echo_hidden(char *query)
{
if (pset.echo_hidden != PSQL_ECHO_HIDDEN_OFF)
{
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c
index ff01368531..0e266a3e18 100644
--- a/src/bin/psql/common.c
+++ b/src/bin/psql/common.c
@@ -491,7 +491,7 @@ int
PSQLexecWatch(const char *query, const printQueryOpt *opt)
{
PGresult *res;
- double elapsed_msec = 0;
+ double elapsed_msec = 0;
instr_time before;
instr_time after;
@@ -524,10 +524,9 @@ PSQLexecWatch(const char *query, const printQueryOpt *opt)
}
/*
- * If SIGINT is sent while the query is processing, the interrupt
- * will be consumed. The user's intention, though, is to cancel
- * the entire watch process, so detect a sent cancellation request and
- * exit in this case.
+ * If SIGINT is sent while the query is processing, the interrupt will be
+ * consumed. The user's intention, though, is to cancel the entire watch
+ * process, so detect a sent cancellation request and exit in this case.
*/
if (cancel_pressed)
{
diff --git a/src/bin/psql/common.h b/src/bin/psql/common.h
index 3c3ffa3f14..caf31d19b8 100644
--- a/src/bin/psql/common.h
+++ b/src/bin/psql/common.h
@@ -36,7 +36,7 @@ extern void SetCancelConn(void);
extern void ResetCancelConn(void);
extern PGresult *PSQLexec(const char *query);
-extern int PSQLexecWatch(const char *query, const printQueryOpt *opt);
+extern int PSQLexecWatch(const char *query, const printQueryOpt *opt);
extern bool SendQuery(const char *query);
diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c
index 965a1dcb26..f1eb518de7 100644
--- a/src/bin/psql/copy.c
+++ b/src/bin/psql/copy.c
@@ -556,6 +556,7 @@ handleCopyIn(PGconn *conn, FILE *copystream, bool isbinary, PGresult **res)
if (showprompt)
{
const char *prompt = get_prompt(PROMPT_COPY);
+
fputs(prompt, stdout);
fflush(stdout);
}
@@ -593,6 +594,7 @@ handleCopyIn(PGconn *conn, FILE *copystream, bool isbinary, PGresult **res)
if (showprompt)
{
const char *prompt = get_prompt(PROMPT_COPY);
+
fputs(prompt, stdout);
fflush(stdout);
}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 04d769e3d6..db568096dc 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -531,7 +531,7 @@ describeTypes(const char *pattern, bool verbose, bool showSystem)
if (verbose)
{
appendPQExpBuffer(&buf,
- " pg_catalog.pg_get_userbyid(t.typowner) AS \"%s\",\n",
+ " pg_catalog.pg_get_userbyid(t.typowner) AS \"%s\",\n",
gettext_noop("Owner"));
}
if (verbose && pset.sversion >= 90200)
@@ -803,7 +803,7 @@ permissionsList(const char *pattern)
" ELSE E''\n"
" END"
" || CASE WHEN polroles <> '{0}' THEN\n"
- " E'\\n to: ' || pg_catalog.array_to_string(\n"
+ " E'\\n to: ' || pg_catalog.array_to_string(\n"
" ARRAY(\n"
" SELECT rolname\n"
" FROM pg_catalog.pg_roles\n"
@@ -2031,19 +2031,19 @@ describeOneTableDetails(const char *schemaname,
if (pset.sversion >= 90500)
{
printfPQExpBuffer(&buf,
- "SELECT pol.polname,\n"
- "CASE WHEN pol.polroles = '{0}' THEN NULL ELSE array_to_string(array(select rolname from pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
- "pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
- "pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
- "CASE pol.polcmd \n"
- "WHEN 'r' THEN 'SELECT'\n"
- "WHEN 'a' THEN 'INSERT'\n"
- "WHEN 'w' THEN 'UPDATE'\n"
- "WHEN 'd' THEN 'DELETE'\n"
- "WHEN '*' THEN 'ALL'\n"
- "END AS cmd\n"
+ "SELECT pol.polname,\n"
+ "CASE WHEN pol.polroles = '{0}' THEN NULL ELSE array_to_string(array(select rolname from pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
+ "pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
+ "pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
+ "CASE pol.polcmd \n"
+ "WHEN 'r' THEN 'SELECT'\n"
+ "WHEN 'a' THEN 'INSERT'\n"
+ "WHEN 'w' THEN 'UPDATE'\n"
+ "WHEN 'd' THEN 'DELETE'\n"
+ "WHEN '*' THEN 'ALL'\n"
+ "END AS cmd\n"
"FROM pg_catalog.pg_policy pol\n"
- "WHERE pol.polrelid = '%s' ORDER BY 1;",
+ "WHERE pol.polrelid = '%s' ORDER BY 1;",
oid);
result = PSQLexec(buf.data);
@@ -2053,9 +2053,9 @@ describeOneTableDetails(const char *schemaname,
tuples = PQntuples(result);
/*
- * Handle cases where RLS is enabled and there are policies,
- * or there aren't policies, or RLS isn't enabled but there
- * are policies
+ * Handle cases where RLS is enabled and there are policies, or
+ * there aren't policies, or RLS isn't enabled but there are
+ * policies
*/
if (tableinfo.rowsecurity && tuples > 0)
printTableAddFooter(&cont, _("Policies:"));
@@ -2070,7 +2070,7 @@ describeOneTableDetails(const char *schemaname,
for (i = 0; i < tuples; i++)
{
printfPQExpBuffer(&buf, " POLICY \"%s\"",
- PQgetvalue(result, i, 0));
+ PQgetvalue(result, i, 0));
if (!PQgetisnull(result, i, 4))
appendPQExpBuffer(&buf, " FOR %s",
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index ea05c3e37b..b523054825 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -81,11 +81,11 @@ usage(unsigned short int pager)
fprintf(output, _(" -f, --file=FILENAME execute commands from file, then exit\n"));
fprintf(output, _(" -l, --list list available databases, then exit\n"));
fprintf(output, _(" -v, --set=, --variable=NAME=VALUE\n"
- " set psql variable NAME to VALUE e.g.: -v ON_ERROR_STOP=1\n"));
+ " set psql variable NAME to VALUE e.g.: -v ON_ERROR_STOP=1\n"));
fprintf(output, _(" -V, --version output version information, then exit\n"));
fprintf(output, _(" -X, --no-psqlrc do not read startup file (~/.psqlrc)\n"));
fprintf(output, _(" -1 (\"one\"), --single-transaction\n"
- " execute as a single transaction (if non-interactive)\n"));
+ " execute as a single transaction (if non-interactive)\n"));
fprintf(output, _(" -?, --help[=options] show this help, then exit\n"));
fprintf(output, _(" --help=variables show a list of all specially treated variables, then exit\n"));
fprintf(output, _(" --help=commands show a list of backslash commands, then exit\n"));
@@ -105,29 +105,29 @@ usage(unsigned short int pager)
fprintf(output, _("\nOutput format options:\n"));
fprintf(output, _(" -A, --no-align unaligned table output mode\n"));
fprintf(output, _(" -F, --field-separator=STRING\n"
- " field separator for unaligned output (default: \"%s\")\n"),
- DEFAULT_FIELD_SEP);
+ " field separator for unaligned output (default: \"%s\")\n"),
+ DEFAULT_FIELD_SEP);
fprintf(output, _(" -H, --html HTML table output mode\n"));
fprintf(output, _(" -P, --pset=VAR[=ARG] set printing option VAR to ARG (see \\pset command)\n"));
fprintf(output, _(" -R, --record-separator=STRING\n"
- " record separator for unaligned output (default: newline)\n"));
+ " record separator for unaligned output (default: newline)\n"));
fprintf(output, _(" -t, --tuples-only print rows only\n"));
fprintf(output, _(" -T, --table-attr=TEXT set HTML table tag attributes (e.g., width, border)\n"));
fprintf(output, _(" -x, --expanded turn on expanded table output\n"));
fprintf(output, _(" -z, --field-separator-zero\n"
- " set field separator for unaligned output to zero byte\n"));
+ " set field separator for unaligned output to zero byte\n"));
fprintf(output, _(" -0, --record-separator-zero\n"
- " set record separator for unaligned output to zero byte\n"));
+ " set record separator for unaligned output to zero byte\n"));
fprintf(output, _("\nConnection options:\n"));
/* Display default host */
env = getenv("PGHOST");
fprintf(output, _(" -h, --host=HOSTNAME database server host or socket directory (default: \"%s\")\n"),
- env ? env : _("local socket"));
+ env ? env : _("local socket"));
/* Display default port */
env = getenv("PGPORT");
fprintf(output, _(" -p, --port=PORT database server port (default: \"%s\")\n"),
- env ? env : DEF_PGPORT_STR);
+ env ? env : DEF_PGPORT_STR);
/* Display default user */
env = getenv("PGUSER");
if (!env)
@@ -137,8 +137,8 @@ usage(unsigned short int pager)
fprintf(output, _(" -W, --password force password prompt (should happen automatically)\n"));
fprintf(output, _("\nFor more information, type \"\\?\" (for internal commands) or \"\\help\" (for SQL\n"
- "commands) from within psql, or consult the psql section in the PostgreSQL\n"
- "documentation.\n\n"));
+ "commands) from within psql, or consult the psql section in the PostgreSQL\n"
+ "documentation.\n\n"));
fprintf(output, _("Report bugs to <pgsql-bugs@postgresql.org>.\n"));
ClosePager(output);
@@ -315,15 +315,15 @@ helpVariables(unsigned short int pager)
fprintf(output, _(" AUTOCOMMIT if set, successful SQL commands are automatically committed\n"));
fprintf(output, _(" COMP_KEYWORD_CASE determine the case used to complete SQL keywords\n"
- " [lower, upper, preserve-lower, preserve-upper]\n"));
+ " [lower, upper, preserve-lower, preserve-upper]\n"));
fprintf(output, _(" DBNAME the currently connected database name\n"));
fprintf(output, _(" ECHO control what input is written to standard output\n"
- " [all, errors, none, queries]\n"));
+ " [all, errors, none, queries]\n"));
fprintf(output, _(" ECHO_HIDDEN display internal queries executed by backslash commands when it is set\n"
- " or with [noexec] just show without execution\n"));
+ " or with [noexec] just show without execution\n"));
fprintf(output, _(" ENCODING current client character set encoding\n"));
fprintf(output, _(" FETCH_COUNT the number of result rows to fetch and display at a time\n"
- " (default: 0=unlimited)\n"));
+ " (default: 0=unlimited)\n"));
fprintf(output, _(" HISTCONTROL control history list [ignorespace, ignoredups, ignoreboth]\n"));
fprintf(output, _(" HISTFILE file name used to store the history list\n"));
fprintf(output, _(" HISTSIZE the number of commands to store in the command history\n"));
@@ -356,18 +356,18 @@ helpVariables(unsigned short int pager)
fprintf(output, _(" linestyle set the border line drawing style [ascii, old-ascii, unicode]\n"));
fprintf(output, _(" null set the string to be printed in place of a null value\n"));
fprintf(output, _(" numericlocale enable or disable display of a locale-specific character to separate\n"
- " groups of digits [on, off]\n"));
+ " groups of digits [on, off]\n"));
fprintf(output, _(" pager control when an external pager is used [yes, no, always]\n"));
fprintf(output, _(" recordsep specify the record (line) separator to use in unaligned output format\n"));
fprintf(output, _(" recordsep_zero set the record separator to use in unaligned output format to a zero byte.\n"));
fprintf(output, _(" tableattr (or T) specify attributes for table tag in html format or proportional\n"
- " column width of left aligned data type in latex format\n"));
+ " column width of left aligned data type in latex format\n"));
fprintf(output, _(" title set the table title for any subsequently printed tables\n"));
fprintf(output, _(" tuples_only if set, only actual table data is shown\n"));
fprintf(output, _(" unicode_border_linestyle\n"));
fprintf(output, _(" unicode_column_linestyle\n"));
fprintf(output, _(" unicode_header_linestyle\n"
- " set the style of unicode line drawing [single, double]\n"));
+ " set the style of unicode line drawing [single, double]\n"));
fprintf(output, _("\nEnvironment variables:\n"));
fprintf(output, _("Usage:\n"));
@@ -388,9 +388,9 @@ helpVariables(unsigned short int pager)
fprintf(output, _(" PGPASSWORD connection password (not recommended)\n"));
fprintf(output, _(" PGPASSFILE password file name\n"));
fprintf(output, _(" PSQL_EDITOR, EDITOR, VISUAL\n"
- " editor used by the \\e and \\ef commands\n"));
+ " editor used by the \\e and \\ef commands\n"));
fprintf(output, _(" PSQL_EDITOR_LINENUMBER_ARG\n"
- " how to specify a line number when invoking the editor\n"));
+ " how to specify a line number when invoking the editor\n"));
fprintf(output, _(" PSQL_HISTORY alternative location for the command history file\n"));
fprintf(output, _(" PSQLRC alternative location for the user's .psqlrc file\n"));
fprintf(output, _(" SHELL shell used by the \\! command\n"));
diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c
index 94c69845c7..cab9e6eb44 100644
--- a/src/bin/psql/print.c
+++ b/src/bin/psql/print.c
@@ -92,20 +92,23 @@ const printTextFormat pg_asciiformat_old =
/* Default unicode linestyle format */
const printTextFormat pg_utf8format;
-typedef struct unicodeStyleRowFormat {
+typedef struct unicodeStyleRowFormat
+{
const char *horizontal;
const char *vertical_and_right[2];
const char *vertical_and_left[2];
} unicodeStyleRowFormat;
-typedef struct unicodeStyleColumnFormat {
+typedef struct unicodeStyleColumnFormat
+{
const char *vertical;
const char *vertical_and_horizontal[2];
const char *up_and_horizontal[2];
const char *down_and_horizontal[2];
} unicodeStyleColumnFormat;
-typedef struct unicodeStyleBorderFormat {
+typedef struct unicodeStyleBorderFormat
+{
const char *up_and_right;
const char *vertical;
const char *down_and_right;
@@ -114,7 +117,8 @@ typedef struct unicodeStyleBorderFormat {
const char *left_and_right;
} unicodeStyleBorderFormat;
-typedef struct unicodeStyleFormat {
+typedef struct unicodeStyleFormat
+{
unicodeStyleRowFormat row_style[2];
unicodeStyleColumnFormat column_style[2];
unicodeStyleBorderFormat border_style[2];
@@ -124,7 +128,7 @@ typedef struct unicodeStyleFormat {
const char *nl_right;
const char *wrap_left;
const char *wrap_right;
- bool wrap_right_border;
+ bool wrap_right_border;
} unicodeStyleFormat;
const unicodeStyleFormat unicode_style = {
@@ -175,11 +179,11 @@ const unicodeStyleFormat unicode_style = {
{"\342\225\232", "\342\225\221", "\342\225\224", "\342\225\220", "\342\225\227", "\342\225\235"},
},
" ",
- "\342\206\265", /* ↵ */
+ "\342\206\265", /* ↵ */
" ",
- "\342\206\265", /* ↵ */
- "\342\200\246", /* … */
- "\342\200\246", /* … */
+ "\342\206\265", /* ↵ */
+ "\342\200\246", /* … */
+ "\342\200\246", /* … */
true
};
@@ -984,7 +988,7 @@ print_aligned_text(const printTableContent *cont, FILE *fout)
int bytes_to_output;
int chars_to_output = width_wrap[j];
bool finalspaces = (opt_border == 2 ||
- (col_count > 0 && j < col_count - 1));
+ (col_count > 0 && j < col_count - 1));
/* Print left-hand wrap or newline mark */
if (opt_border != 0)
@@ -1356,12 +1360,13 @@ print_aligned_vertical(const printTableContent *cont, FILE *fout)
else if (opt_border == 1)
{
/*
- * For border = 1, one for the pipe (|) in the middle
- * between the two spaces.
+ * For border = 1, one for the pipe (|) in the middle between the
+ * two spaces.
*/
swidth = 3;
}
else
+
/*
* For border = 2, two more for the pipes (|) at the beginning and
* at the end of the lines.
@@ -1370,10 +1375,10 @@ print_aligned_vertical(const printTableContent *cont, FILE *fout)
if ((opt_border < 2) &&
((hmultiline &&
- (format == &pg_asciiformat_old)) ||
- (dmultiline &&
- (format != &pg_asciiformat_old))))
- iwidth++; /* for newline indicators */
+ (format == &pg_asciiformat_old)) ||
+ (dmultiline &&
+ (format != &pg_asciiformat_old))))
+ iwidth++; /* for newline indicators */
min_width = hwidth + iwidth + swidth + 3;
@@ -1386,6 +1391,7 @@ print_aligned_vertical(const printTableContent *cont, FILE *fout)
* Record number
*/
unsigned int rwidth = 1 + log10(cont->nrows);
+
if (opt_border == 0)
rwidth += 9; /* "* RECORD " */
else if (opt_border == 1)
@@ -1402,6 +1408,7 @@ print_aligned_vertical(const printTableContent *cont, FILE *fout)
if ((width < min_width) || (output_columns < min_width))
width = min_width - hwidth - iwidth - swidth;
else if (output_columns > 0)
+
/*
* Wrap to maximum width
*/
@@ -1412,7 +1419,7 @@ print_aligned_vertical(const printTableContent *cont, FILE *fout)
dmultiline = true;
if ((opt_border == 0) &&
(format != &pg_asciiformat_old))
- width--; /* for wrap indicators */
+ width--; /* for wrap indicators */
}
dwidth = width;
}
@@ -1440,10 +1447,11 @@ print_aligned_vertical(const printTableContent *cont, FILE *fout)
if (i % cont->ncolumns == 0)
{
unsigned int lhwidth = hwidth;
+
if ((opt_border < 2) &&
(hmultiline) &&
(format == &pg_asciiformat_old))
- lhwidth++; /* for newline indicators */
+ lhwidth++; /* for newline indicators */
if (!opt_tuples_only)
print_aligned_vertical_line(format, opt_border, record++,
@@ -1480,12 +1488,14 @@ print_aligned_vertical(const printTableContent *cont, FILE *fout)
{
int swidth = hwidth,
target_width = hwidth;
+
/*
* Left spacer or new line indicator
*/
if ((opt_border == 2) ||
(hmultiline && (format == &pg_asciiformat_old)))
fputs(hline ? format->header_nl_left : " ", fout);
+
/*
* Header text
*/
@@ -1523,6 +1533,7 @@ print_aligned_vertical(const printTableContent *cont, FILE *fout)
else
{
unsigned int swidth = hwidth + opt_border;
+
if ((opt_border < 2) &&
(hmultiline) &&
(format == &pg_asciiformat_old))
@@ -1886,9 +1897,10 @@ static void
asciidoc_escaped_print(const char *in, FILE *fout)
{
const char *p;
+
for (p = in; *p; p++)
{
- switch(*p)
+ switch (*p)
{
case '|':
fputs("\\|", fout);
@@ -1925,7 +1937,7 @@ print_asciidoc_text(const printTableContent *cont, FILE *fout)
/* print table [] header definition */
fprintf(fout, "[%scols=\"", !opt_tuples_only ? "options=\"header\"," : "");
- for(i = 0; i < cont->ncolumns; i++)
+ for (i = 0; i < cont->ncolumns; i++)
{
if (i != 0)
fputs(",", fout);
@@ -2046,7 +2058,7 @@ print_asciidoc_vertical(const printTableContent *cont, FILE *fout)
break;
case 2:
fputs(",frame=\"all\",grid=\"all\"", fout);
- break;
+ break;
}
fputs("]\n", fout);
fputs("|====\n", fout);
@@ -2729,8 +2741,8 @@ PageOutput(int lines, const printTableOpt *topt)
{
const char *pagerprog;
FILE *pagerpipe;
- unsigned short int pager = topt->pager;
- int min_lines = topt->pager_min_lines;
+ unsigned short int pager = topt->pager;
+ int min_lines = topt->pager_min_lines;
#ifdef TIOCGWINSZ
int result;
@@ -3262,7 +3274,7 @@ get_line_style(const printTableOpt *opt)
void
refresh_utf8format(const printTableOpt *opt)
{
- printTextFormat *popt = (printTextFormat *) &pg_utf8format;
+ printTextFormat *popt = (printTextFormat *) &pg_utf8format;
const unicodeStyleBorderFormat *border;
const unicodeStyleRowFormat *header;
diff --git a/src/bin/psql/print.h b/src/bin/psql/print.h
index 322db4d6ef..b0b6bf5251 100644
--- a/src/bin/psql/print.h
+++ b/src/bin/psql/print.h
@@ -90,7 +90,7 @@ typedef struct printTableOpt
* 1=dividing lines, 2=full */
unsigned short int pager; /* use pager for output (if to stdout and
* stdout is a tty) 0=off 1=on 2=always */
- int pager_min_lines;/* don't use pager unless there are at least
+ int pager_min_lines;/* don't use pager unless there are at least
* this many lines */
bool tuples_only; /* don't output headers, row counts, etc. */
bool start_table; /* print start decoration, eg <table> */
@@ -106,9 +106,9 @@ typedef struct printTableOpt
int encoding; /* character encoding */
int env_columns; /* $COLUMNS on psql start, 0 is unset */
int columns; /* target width for wrapped format */
- unicode_linestyle unicode_border_linestyle;
- unicode_linestyle unicode_column_linestyle;
- unicode_linestyle unicode_header_linestyle;
+ unicode_linestyle unicode_border_linestyle;
+ unicode_linestyle unicode_column_linestyle;
+ unicode_linestyle unicode_header_linestyle;
} printTableOpt;
/*
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
index d57901f778..28ba75a72e 100644
--- a/src/bin/psql/startup.c
+++ b/src/bin/psql/startup.c
@@ -592,7 +592,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
}
break;
default:
- unknown_option:
+ unknown_option:
fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
pset.progname);
exit(EXIT_FAILURE);
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 750e29ddf3..b9f5acc65e 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -816,10 +816,10 @@ static char *_complete_from_query(int is_schema_query,
static char *complete_from_list(const char *text, int state);
static char *complete_from_const(const char *text, int state);
static void append_variable_names(char ***varnames, int *nvars,
- int *maxvars, const char *varname,
- const char *prefix, const char *suffix);
+ int *maxvars, const char *varname,
+ const char *prefix, const char *suffix);
static char **complete_from_variables(const char *text,
- const char *prefix, const char *suffix, bool need_value);
+ const char *prefix, const char *suffix, bool need_value);
static char *complete_from_files(const char *text, int state);
static char *pg_strdup_keyword_case(const char *s, const char *ref);
@@ -961,6 +961,7 @@ psql_completion(const char *text, int start, int end)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables,
"UNION SELECT 'ALL IN TABLESPACE'");
}
+
/*
* complete with what you can alter (TABLE, GROUP, USER, ...) unless we're
* in ALTER TABLE sth ALTER
@@ -984,7 +985,7 @@ psql_completion(const char *text, int start, int end)
pg_strcasecmp(prev2_wd, "TABLESPACE") == 0)
{
static const char *const list_ALTERALLINTSPC[] =
- {"SET TABLESPACE", "OWNED BY", NULL};
+ {"SET TABLESPACE", "OWNED BY", NULL};
COMPLETE_WITH_LIST(list_ALTERALLINTSPC);
}
@@ -1129,7 +1130,7 @@ psql_completion(const char *text, int start, int end)
{
static const char *const list_ALTER_FOREIGN_TABLE[] =
{"ADD", "ALTER", "DISABLE TRIGGER", "DROP", "ENABLE", "INHERIT",
- "NO INHERIT", "OPTIONS", "OWNER TO", "RENAME", "SET",
+ "NO INHERIT", "OPTIONS", "OWNER TO", "RENAME", "SET",
"VALIDATE CONSTRAINT", NULL};
COMPLETE_WITH_LIST(list_ALTER_FOREIGN_TABLE);
@@ -1381,7 +1382,7 @@ psql_completion(const char *text, int start, int end)
else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
pg_strcasecmp(prev2_wd, "SYSTEM") == 0 &&
(pg_strcasecmp(prev_wd, "SET") == 0 ||
- pg_strcasecmp(prev_wd, "RESET") == 0))
+ pg_strcasecmp(prev_wd, "RESET") == 0))
COMPLETE_WITH_QUERY(Query_for_list_of_alter_system_set_vars);
/* ALTER VIEW <name> */
else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
@@ -1572,7 +1573,7 @@ psql_completion(const char *text, int start, int end)
pg_strcasecmp(prev_wd, "DISABLE") == 0)
{
static const char *const list_ALTERDISABLE[] =
- { "ROW LEVEL SECURITY", "RULE", "TRIGGER", NULL};
+ {"ROW LEVEL SECURITY", "RULE", "TRIGGER", NULL};
COMPLETE_WITH_LIST(list_ALTERDISABLE);
}
@@ -1598,7 +1599,7 @@ psql_completion(const char *text, int start, int end)
pg_strcasecmp(prev_wd, "SECURITY") == 0)
{
static const char *const list_DISABLERLS[] =
- { "CASCADE", NULL};
+ {"CASCADE", NULL};
COMPLETE_WITH_LIST(list_DISABLERLS);
}
@@ -2140,7 +2141,7 @@ psql_completion(const char *text, int start, int end)
pg_strcasecmp(prev4_wd, "ON") == 0) ||
(pg_strcasecmp(prev6_wd, "COMMENT") == 0 &&
pg_strcasecmp(prev5_wd, "ON") == 0)) &&
- pg_strcasecmp(prev_wd, "IS") != 0)
+ pg_strcasecmp(prev_wd, "IS") != 0)
COMPLETE_WITH_CONST("IS");
/* COPY */
@@ -2205,7 +2206,7 @@ psql_completion(const char *text, int start, int end)
{
static const char *const list_DATABASE[] =
{"OWNER", "TEMPLATE", "ENCODING", "TABLESPACE", "IS_TEMPLATE",
- "ALLOW_CONNECTIONS", "CONNECTION LIMIT", "LC_COLLATE", "LC_CTYPE",
+ "ALLOW_CONNECTIONS", "CONNECTION LIMIT", "LC_COLLATE", "LC_CTYPE",
NULL};
COMPLETE_WITH_LIST(list_DATABASE);
@@ -2309,8 +2310,8 @@ psql_completion(const char *text, int start, int end)
COMPLETE_WITH_ATTR(prev4_wd, "");
/* Complete USING with an index method */
else if ((pg_strcasecmp(prev6_wd, "INDEX") == 0 ||
- pg_strcasecmp(prev5_wd, "INDEX") == 0 ||
- pg_strcasecmp(prev4_wd, "INDEX") == 0) &&
+ pg_strcasecmp(prev5_wd, "INDEX") == 0 ||
+ pg_strcasecmp(prev4_wd, "INDEX") == 0) &&
pg_strcasecmp(prev3_wd, "ON") == 0 &&
pg_strcasecmp(prev_wd, "USING") == 0)
COMPLETE_WITH_QUERY(Query_for_list_of_access_methods);
@@ -2340,7 +2341,11 @@ psql_completion(const char *text, int start, int end)
COMPLETE_WITH_LIST(list_POLICYOPTIONS);
}
- /* Complete "CREATE POLICY <name> ON <table> FOR ALL|SELECT|INSERT|UPDATE|DELETE" */
+
+ /*
+ * Complete "CREATE POLICY <name> ON <table> FOR
+ * ALL|SELECT|INSERT|UPDATE|DELETE"
+ */
else if (pg_strcasecmp(prev6_wd, "CREATE") == 0 &&
pg_strcasecmp(prev5_wd, "POLICY") == 0 &&
pg_strcasecmp(prev3_wd, "ON") == 0 &&
@@ -2362,30 +2367,33 @@ psql_completion(const char *text, int start, int end)
COMPLETE_WITH_LIST(list_POLICYOPTIONS);
}
+
/*
- * Complete "CREATE POLICY <name> ON <table> FOR SELECT TO|USING"
- * Complete "CREATE POLICY <name> ON <table> FOR DELETE TO|USING"
+ * Complete "CREATE POLICY <name> ON <table> FOR SELECT TO|USING" Complete
+ * "CREATE POLICY <name> ON <table> FOR DELETE TO|USING"
*/
else if (pg_strcasecmp(prev6_wd, "POLICY") == 0 &&
pg_strcasecmp(prev4_wd, "ON") == 0 &&
pg_strcasecmp(prev2_wd, "FOR") == 0 &&
(pg_strcasecmp(prev_wd, "SELECT") == 0 ||
- pg_strcasecmp(prev_wd, "DELETE") == 0))
+ pg_strcasecmp(prev_wd, "DELETE") == 0))
{
static const char *const list_POLICYOPTIONS[] =
{"TO", "USING", NULL};
COMPLETE_WITH_LIST(list_POLICYOPTIONS);
}
+
/*
* Complete "CREATE POLICY <name> ON <table> FOR ALL TO|USING|WITH CHECK"
- * Complete "CREATE POLICY <name> ON <table> FOR UPDATE TO|USING|WITH CHECK"
+ * Complete "CREATE POLICY <name> ON <table> FOR UPDATE TO|USING|WITH
+ * CHECK"
*/
else if (pg_strcasecmp(prev6_wd, "POLICY") == 0 &&
pg_strcasecmp(prev4_wd, "ON") == 0 &&
pg_strcasecmp(prev2_wd, "FOR") == 0 &&
(pg_strcasecmp(prev_wd, "ALL") == 0 ||
- pg_strcasecmp(prev_wd, "UPDATE") == 0))
+ pg_strcasecmp(prev_wd, "UPDATE") == 0))
{
static const char *const list_POLICYOPTIONS[] =
{"TO", "USING", "WITH CHECK", NULL};
@@ -3336,7 +3344,7 @@ psql_completion(const char *text, int start, int end)
else if (pg_strcasecmp(prev_wd, "REINDEX") == 0)
{
static const char *const list_REINDEX[] =
- {"TABLE", "INDEX", "SYSTEM", "SCHEMA", "DATABASE", NULL};
+ {"TABLE", "INDEX", "SYSTEM", "SCHEMA", "DATABASE", NULL};
COMPLETE_WITH_LIST(list_REINDEX);
}
@@ -3346,7 +3354,7 @@ psql_completion(const char *text, int start, int end)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tm, NULL);
else if (pg_strcasecmp(prev_wd, "INDEX") == 0)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, NULL);
- else if (pg_strcasecmp(prev_wd, "SCHEMA") == 0 )
+ else if (pg_strcasecmp(prev_wd, "SCHEMA") == 0)
COMPLETE_WITH_QUERY(Query_for_list_of_schemas);
else if (pg_strcasecmp(prev_wd, "SYSTEM") == 0 ||
pg_strcasecmp(prev_wd, "DATABASE") == 0)
@@ -4374,7 +4382,7 @@ complete_from_variables(const char *text, const char *prefix, const char *suffix
"ENCODING", "FETCH_COUNT", "HISTCONTROL", "HISTFILE", "HISTSIZE",
"HOST", "IGNOREEOF", "LASTOID", "ON_ERROR_ROLLBACK", "ON_ERROR_STOP",
"PORT", "PROMPT1", "PROMPT2", "PROMPT3", "QUIET", "SINGLELINE",
- "SINGLESTEP", "USER", "VERBOSITY", NULL
+ "SINGLESTEP", "USER", "VERBOSITY", NULL
};
varnames = (char **) pg_malloc((maxvars + 1) * sizeof(char *));
@@ -4390,7 +4398,7 @@ complete_from_variables(const char *text, const char *prefix, const char *suffix
{
if (need_value && !(ptr->value))
continue;
- for (i = 0; known_varnames[i]; i++) /* remove duplicate entry */
+ for (i = 0; known_varnames[i]; i++) /* remove duplicate entry */
{
if (strcmp(ptr->name, known_varnames[i]) == 0)
continue;
@@ -4475,7 +4483,7 @@ pg_strdup_keyword_case(const char *s, const char *ref)
if (pset.comp_case == PSQL_COMP_CASE_LOWER ||
((pset.comp_case == PSQL_COMP_CASE_PRESERVE_LOWER ||
- pset.comp_case == PSQL_COMP_CASE_PRESERVE_UPPER) && islower(first)) ||
+ pset.comp_case == PSQL_COMP_CASE_PRESERVE_UPPER) && islower(first)) ||
(pset.comp_case == PSQL_COMP_CASE_PRESERVE_LOWER && !isalpha(first)))
{
for (p = ret; *p; p++)
diff --git a/src/bin/scripts/common.c b/src/bin/scripts/common.c
index da142aaa64..0deadec097 100644
--- a/src/bin/scripts/common.c
+++ b/src/bin/scripts/common.c
@@ -21,7 +21,7 @@
static PGcancel *volatile cancelConn = NULL;
-bool CancelRequested = false;
+bool CancelRequested = false;
#ifdef WIN32
static CRITICAL_SECTION cancelConnLock;
diff --git a/src/bin/scripts/reindexdb.c b/src/bin/scripts/reindexdb.c
index 32d3409e05..941729da2e 100644
--- a/src/bin/scripts/reindexdb.c
+++ b/src/bin/scripts/reindexdb.c
@@ -181,7 +181,7 @@ main(int argc, char *argv[])
}
reindex_all_databases(maintenance_db, host, port, username,
- prompt_password, progname, echo, quiet, verbose);
+ prompt_password, progname, echo, quiet, verbose);
}
else if (syscatalog)
{
@@ -233,7 +233,7 @@ main(int argc, char *argv[])
for (cell = schemas.head; cell; cell = cell->next)
{
reindex_one_database(cell->val, dbname, "SCHEMA", host, port,
- username, prompt_password, progname, echo, verbose);
+ username, prompt_password, progname, echo, verbose);
}
}
@@ -244,7 +244,7 @@ main(int argc, char *argv[])
for (cell = indexes.head; cell; cell = cell->next)
{
reindex_one_database(cell->val, dbname, "INDEX", host, port,
- username, prompt_password, progname, echo, verbose);
+ username, prompt_password, progname, echo, verbose);
}
}
if (tables.head != NULL)
@@ -254,13 +254,17 @@ main(int argc, char *argv[])
for (cell = tables.head; cell; cell = cell->next)
{
reindex_one_database(cell->val, dbname, "TABLE", host, port,
- username, prompt_password, progname, echo, verbose);
+ username, prompt_password, progname, echo, verbose);
}
}
- /* reindex database only if neither index nor table nor schema is specified */
+
+ /*
+ * reindex database only if neither index nor table nor schema is
+ * specified
+ */
if (indexes.head == NULL && tables.head == NULL && schemas.head == NULL)
reindex_one_database(dbname, dbname, "DATABASE", host, port,
- username, prompt_password, progname, echo, verbose);
+ username, prompt_password, progname, echo, verbose);
}
exit(0);
@@ -269,7 +273,7 @@ main(int argc, char *argv[])
static void
reindex_one_database(const char *name, const char *dbname, const char *type,
const char *host, const char *port, const char *username,
- enum trivalue prompt_password, const char *progname, bool echo,
+ enum trivalue prompt_password, const char *progname, bool echo,
bool verbose)
{
PQExpBufferData sql;
@@ -322,7 +326,7 @@ static void
reindex_all_databases(const char *maintenance_db,
const char *host, const char *port,
const char *username, enum trivalue prompt_password,
- const char *progname, bool echo, bool quiet, bool verbose)
+ const char *progname, bool echo, bool quiet, bool verbose)
{
PGconn *conn;
PGresult *result;
diff --git a/src/bin/scripts/t/102_vacuumdb_stages.pl b/src/bin/scripts/t/102_vacuumdb_stages.pl
index 1ff05e3c27..57b980ec6a 100644
--- a/src/bin/scripts/t/102_vacuumdb_stages.pl
+++ b/src/bin/scripts/t/102_vacuumdb_stages.pl
@@ -19,7 +19,7 @@ qr/.*statement:\ SET\ default_statistics_target=1;\ SET\ vacuum_cost_delay=0;
issues_sql_like(
[ 'vacuumdb', '--analyze-in-stages', '--all' ],
- qr/.*statement:\ SET\ default_statistics_target=1;\ SET\ vacuum_cost_delay=0;
+qr/.*statement:\ SET\ default_statistics_target=1;\ SET\ vacuum_cost_delay=0;
.*statement:\ ANALYZE.*
.*statement:\ SET\ default_statistics_target=1;\ SET\ vacuum_cost_delay=0;
.*statement:\ ANALYZE.*
diff --git a/src/bin/scripts/vacuumdb.c b/src/bin/scripts/vacuumdb.c
index 2cd4aa6544..f600b0514a 100644
--- a/src/bin/scripts/vacuumdb.c
+++ b/src/bin/scripts/vacuumdb.c
@@ -674,7 +674,7 @@ run_vacuum_command(PGconn *conn, const char *sql, bool echo,
const char *dbname, const char *table,
const char *progname, bool async)
{
- bool status;
+ bool status;
if (async)
{
@@ -943,7 +943,7 @@ help(const char *progname)
printf(_(" -Z, --analyze-only only update optimizer statistics; no vacuum\n"));
printf(_(" -j, --jobs=NUM use this many concurrent connections to vacuum\n"));
printf(_(" --analyze-in-stages only update optimizer statistics, in multiple\n"
- " stages for faster results; no vacuum\n"));
+ " stages for faster results; no vacuum\n"));
printf(_(" -?, --help show this help, then exit\n"));
printf(_("\nConnection options:\n"));
printf(_(" -h, --host=HOSTNAME database server host or socket directory\n"));