diff --git a/doc/src/sgml/maintenance.sgml b/doc/src/sgml/maintenance.sgml
index d2bd68f501ac91bec81f69b08511d55f7f353d85..c05b5262cb3436c588ed12af0f415700ac7b7b74 100644
--- a/doc/src/sgml/maintenance.sgml
+++ b/doc/src/sgml/maintenance.sgml
@@ -632,7 +632,7 @@ HINT:  Stop the postmaster and use a standalone backend to VACUUM in "mydb".
     <varname>autovacuum_max_workers</> databases to be processed,
     the next database will be processed as soon as the first worker finishes.
     Each worker process will check each table within its database and
-    execute <command>VACUUM</> and/or <command>ANALYZE</> as needed. 
+    execute <command>VACUUM</> and/or <command>ANALYZE</> as needed.
     <varname>log_autovacuum_min_duration</varname> can be used to monitor
     autovacuum activity.
    </para>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 2f0fa53a41aff43af6fb3820574a73bcab183f72..26eca6731c2ecd1d3eb1eebed59163c2de569707 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -336,7 +336,7 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXI
      <para>
       Not-null constraints are always copied to the new table.
       <literal>CHECK</literal> constraints will be copied only if
-      <literal>INCLUDING CONSTRAINTS</literal> is specified. 
+      <literal>INCLUDING CONSTRAINTS</literal> is specified.
       Indexes, <literal>PRIMARY KEY</>, and <literal>UNIQUE</> constraints
       on the original table will be created on the new table only if the
       <literal>INCLUDING INDEXES</literal> clause is specified.
diff --git a/doc/src/sgml/ref/notify.sgml b/doc/src/sgml/ref/notify.sgml
index a9405fdd313b7ef2da46354cf224e131ffc33880..307d2f62825a0bb6aeeae2d13be4d91a377716a1 100644
--- a/doc/src/sgml/ref/notify.sgml
+++ b/doc/src/sgml/ref/notify.sgml
@@ -33,7 +33,7 @@ NOTIFY <replaceable class="PARAMETER">channel</replaceable> [ , <replaceable cla
    with an optional <quote>payload</> string to each client application that
    has previously executed
    <command>LISTEN <replaceable class="parameter">channel</></command>
-   for the specified channel name in the current database. 
+   for the specified channel name in the current database.
    Notifications are visible to all users.
   </para>
 
diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index 40ca18c75f264fdc89376fabd344b689b11d1eac..2b5e95bfe9a3d1ee909b69525f320dfa53c061c8 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -324,7 +324,7 @@ PostgreSQL documentation
         For a consistent backup, the database server needs to support synchronized snapshots,
         a feature that was introduced in <productname>PostgreSQL</productname> 9.2. With this
         feature, database clients can ensure they see the same data set even though they use
-        different connections. <command>pg_dump -j</command> uses multiple database 
+        different connections. <command>pg_dump -j</command> uses multiple database
         connections; it connects to the database once with the master process and
         once again for each worker job. Without the synchronized snapshot feature, the
         different worker jobs wouldn't be guaranteed to see the same data in each connection,
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 89e39d2fa0a05d076ff37655803b508e12ad21c8..8bfb77d7dfd551069fc20b687fee3235eadfdbd2 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -434,7 +434,7 @@ PL_TESTDB = pl_regression
 CONTRIB_TESTDB = contrib_regression
 ifneq ($(MODULE_big),)
   CONTRIB_TESTDB_MODULE = contrib_regression_$(MODULE_big)
-else 
+else
   ifneq ($(MODULES),)
     CONTRIB_TESTDB_MODULE = contrib_regression_$(MODULES)
   else
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql
index a03bfa684bf2078ea0aad60edbe665dbf0198841..81d7c4fec8c57de6acee36e2f14b21532588dd3f 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -788,10 +788,10 @@ CREATE OR REPLACE FUNCTION
   pg_start_backup(label text, fast boolean DEFAULT false)
   RETURNS text STRICT VOLATILE LANGUAGE internal AS 'pg_start_backup';
 
-CREATE OR REPLACE FUNCTION 
+CREATE OR REPLACE FUNCTION
   json_populate_record(base anyelement, from_json json, use_json_as_text boolean DEFAULT false)
   RETURNS anyelement LANGUAGE internal STABLE AS 'json_populate_record';
 
-CREATE OR REPLACE FUNCTION 
+CREATE OR REPLACE FUNCTION
   json_populate_recordset(base anyelement, from_json json, use_json_as_text boolean DEFAULT false)
   RETURNS SETOF anyelement LANGUAGE internal STABLE ROWS 100  AS 'json_populate_recordset';
diff --git a/src/test/regress/expected/json.out b/src/test/regress/expected/json.out
index 01f0679c8770f75acee10a998e08f1f17b2f2be8..1d7cf5ff2f302a59fbcd38254e6df0f743adf72f 100644
--- a/src/test/regress/expected/json.out
+++ b/src/test/regress/expected/json.out
@@ -466,15 +466,15 @@ INSERT INTO test_json VALUES
 ('scalar','"a scalar"'),
 ('array','["zero", "one","two",null,"four","five"]'),
 ('object','{"field1":"val1","field2":"val2","field3":null}');
-SELECT test_json -> 'x' 
+SELECT test_json -> 'x'
 FROM test_json
 WHERE json_type = 'scalar';
 ERROR:  cannot extract element from a scalar
-SELECT test_json -> 'x' 
+SELECT test_json -> 'x'
 FROM test_json
 WHERE json_type = 'array';
 ERROR:  cannot extract field from a non-object
-SELECT test_json -> 'x' 
+SELECT test_json -> 'x'
 FROM test_json
 WHERE json_type = 'object';
  ?column? 
@@ -490,7 +490,7 @@ WHERE json_type = 'object';
  "val2"
 (1 row)
 
-SELECT test_json->>'field2' 
+SELECT test_json->>'field2'
 FROM test_json
 WHERE json_type = 'object';
  ?column? 
@@ -498,11 +498,11 @@ WHERE json_type = 'object';
  val2
 (1 row)
 
-SELECT test_json -> 2 
+SELECT test_json -> 2
 FROM test_json
 WHERE json_type = 'scalar';
 ERROR:  cannot extract element from a scalar
-SELECT test_json -> 2 
+SELECT test_json -> 2
 FROM test_json
 WHERE json_type = 'array';
  ?column? 
diff --git a/src/test/regress/sql/json.sql b/src/test/regress/sql/json.sql
index 04b22fe297e9ccf8d1f21086724ce13dc597cb2d..8a136d7a2736ac6bea2c058e1452ad3457f7d961 100644
--- a/src/test/regress/sql/json.sql
+++ b/src/test/regress/sql/json.sql
@@ -139,15 +139,15 @@ INSERT INTO test_json VALUES
 ('array','["zero", "one","two",null,"four","five"]'),
 ('object','{"field1":"val1","field2":"val2","field3":null}');
 
-SELECT test_json -> 'x' 
+SELECT test_json -> 'x'
 FROM test_json
 WHERE json_type = 'scalar';
 
-SELECT test_json -> 'x' 
+SELECT test_json -> 'x'
 FROM test_json
 WHERE json_type = 'array';
 
-SELECT test_json -> 'x' 
+SELECT test_json -> 'x'
 FROM test_json
 WHERE json_type = 'object';
 
@@ -155,15 +155,15 @@ SELECT test_json->'field2'
 FROM test_json
 WHERE json_type = 'object';
 
-SELECT test_json->>'field2' 
+SELECT test_json->>'field2'
 FROM test_json
 WHERE json_type = 'object';
 
-SELECT test_json -> 2 
+SELECT test_json -> 2
 FROM test_json
 WHERE json_type = 'scalar';
 
-SELECT test_json -> 2 
+SELECT test_json -> 2
 FROM test_json
 WHERE json_type = 'array';
 
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index e1650a98121f9785787ef86f9c4715b5b3366633..7964c0188687ba0751f9527d2a33fa33300c39ed 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -523,8 +523,8 @@ sub mkvcbuild
 		my $mf = Project::read_file(
 			'src\backend\utils\mb\conversion_procs\\' . $sub . '\Makefile');
 		my $p = $solution->AddProject($sub, 'dll', 'conversion procs');
-		$p->AddFile('src\backend\utils\mb\conversion_procs\\' 
-			  . $sub . '\\' 
+		$p->AddFile('src\backend\utils\mb\conversion_procs\\'
+			  . $sub . '\\'
 			  . $sub
 			  . '.c');
 		if ($mf =~ m{^SRCS\s*\+=\s*(.*)$}m)
diff --git a/src/tools/pgindent/perltidyrc b/src/tools/pgindent/perltidyrc
index 60489febb583fbb9f8fd0fee18bc89c22deb1680..e8ae7c5d8b5d8fe9ed3672c4095f6b0434e2e21c 100644
--- a/src/tools/pgindent/perltidyrc
+++ b/src/tools/pgindent/perltidyrc
@@ -1,12 +1,12 @@
---add-whitespace 
---backup-and-modify-in-place 
+--add-whitespace
+--backup-and-modify-in-place
 --delete-old-whitespace
---entab-leading-whitespace=4 
---keep-old-blank-lines=2 
+--entab-leading-whitespace=4
+--keep-old-blank-lines=2
 --maximum-line-length=78
---nospace-for-semicolon 
+--nospace-for-semicolon
 --opening-brace-on-new-line
 --output-line-ending=unix
---paren-tightness=2 
---vertical-tightness=2 
+--paren-tightness=2
+--vertical-tightness=2
 --vertical-tightness-closing=2
diff --git a/src/tools/pgindent/pgindent b/src/tools/pgindent/pgindent
index 584218f384aca9a4d4fdd6d01a1e29174a4899b8..bc83c1a95c03d0f51b327a1c63c13f9c6c92c6fd 100755
--- a/src/tools/pgindent/pgindent
+++ b/src/tools/pgindent/pgindent
@@ -310,7 +310,7 @@ sub post_indent
 	$source =~ s!
 			(\n$ident[^(\n]*)\n                  # e.g. static void
 			(
-				$ident\(\n?                      # func_name( 
+				$ident\(\n?                      # func_name(
 				(.*,([ \t]*$comment)?\n)*        # args b4 final ln
 				.*\);([ \t]*$comment)?$          # final line
 			)
diff --git a/src/tools/pgindent/pgindent.man b/src/tools/pgindent/pgindent.man
index cff092ca7a71e4eaef2a2299461e706b688152b1..f3a68acc2a6e02501b8f03568cbd7d8dba511f66 100644
--- a/src/tools/pgindent/pgindent.man
+++ b/src/tools/pgindent/pgindent.man
@@ -6,9 +6,9 @@ or the environment.
 In its simplest form, if all the required objects are installed, simply run
 it without any parameters at the top of the source tree you want to process.
 
-	pgindent 
+	pgindent
 
-If you don't have all the requirements installed, pgindent will fetch and build 
+If you don't have all the requirements installed, pgindent will fetch and build
 them for you, if you're in a PostgreSQL source tree:
 
 
@@ -23,7 +23,7 @@ command line option --indent:
 Similarly, the entab program can be specified using the PGENTAB environment
 variable, or using the --entab command line option.
 
-pgindent also needs a file containing a list of typedefs. This can be 
+pgindent also needs a file containing a list of typedefs. This can be
 specified using the PGTYPEDEFS environment variable, or via the command line
 --typedefs option. If neither is used, it will look for it within the
 current source tree, or in /usr/local/etc/typedefs.list.
@@ -40,6 +40,6 @@ src/tools/pgindent/exclude_file_patterns.
 Any non-option arguments are taken as the names of files to be indented. In this
 case only these files will be changed, and nothing else will be touched. If the
 first non-option argument is not a .c or .h file, it is treated as the name
-of a typedefs file for legacy reasons, but this use is deprecated - use the 
+of a typedefs file for legacy reasons, but this use is deprecated - use the
 --typedefs option instead.