Subject: Re: Typos in the code and README

From: Daniel Gustafsson <[email-masked]>
Date: Fri, 12 Apr 2024 23:17:11 +0200

> On 12 Apr 2024, at 23:15, Heikki Linnakangas <[email-masked]> wrote:
> 
> On 11/04/2024 16:05, Daniel Gustafsson wrote:
>> Now that the tree has settled down a bit post-freeze I ran some tooling to
>> check spelling.  I was primarily interested in docs and README* which were
>> mostly free from simply typos, while the code had some in various comments and
>> one in code.  The attached fixes all that I came across (not cross-referenced
>> against ongoing reverts or any other fixup threads but will be before pushing
>> of course).
> 
> Here's a few more. I've accumulate these over the past couple of months, keeping them stashed in a branch, adding to it whenever I've spotted a minor typo while reading the code.

Nice, let's lot all these together.

--
Daniel Gustafsson

---

From: David Rowley <[email-masked]>
Date: Sun, 14 Apr 2024 23:19:56 +1200

> Nice, let's lot all these together.

Here are a few additional ones to add to that.

Found with a manual trawl through git grep -E
'\b([a-zA-Z]{2,}[^long|^that])\s+\1\b' -- ':!*.po' ':!*.dat'

David
diff --git a/contrib/amcheck/verify_nbtree.c b/contrib/amcheck/verify_nbtree.c
index f71f1854e0..20da4a46ba 100644
--- a/contrib/amcheck/verify_nbtree.c
+++ b/contrib/amcheck/verify_nbtree.c
@@ -3036,7 +3036,7 @@ bt_normalize_tuple(BtreeCheckState *state, IndexTuple itup)
 	 * In the heap, tuples may contain short varlena datums with both 1B
 	 * header and 4B headers.  But the corresponding index tuple should always
 	 * have such varlena's with 1B headers.  So, if there is a short varlena
-	 * with 4B header, we need to convert it for for fingerprinting.
+	 * with 4B header, we need to convert it for fingerprinting.
 	 *
 	 * Note that we rely on deterministic index_form_tuple() TOAST compression
 	 * of normalized input.
diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c
index 2eff34c4aa..725811034f 100644
--- a/src/backend/access/nbtree/nbtutils.c
+++ b/src/backend/access/nbtree/nbtutils.c
@@ -1756,7 +1756,7 @@ _bt_start_prim_scan(IndexScanDesc scan, ScanDirection dir)
  *
  * (The rules are the same for backwards scans, except that the operators are
  * flipped: just replace the precondition's >= operator with a <=, and the
- * postcondition's <= operator with with a >=.  In other words, just swap the
+ * postcondition's <= operator with a >=.  In other words, just swap the
  * precondition with the postcondition.)
  *
  * We also deal with "advancing" non-required arrays here.  Callers whose
diff --git a/src/backend/partitioning/partbounds.c b/src/backend/partitioning/partbounds.c
index c0c49b0a0b..af3b1a90d2 100644
--- a/src/backend/partitioning/partbounds.c
+++ b/src/backend/partitioning/partbounds.c
@@ -5145,7 +5145,7 @@ get_partition_bound_spec(Oid partOid, RangeVar *name)
  * the first of new partitions) then lower bound of "spec" should be equal (or
  * greater than or equal in case defaultPart=true) to lower bound of split
  * partition. If last=true (this means that "spec" is the last of new
- * partitions) then upper bound of of "spec" should be equal (or less than or
+ * partitions) then upper bound of "spec" should be equal (or less than or
  * equal in case defaultPart=true) to upper bound of split partition.
  *
  * parent:			partitioned table
@@ -5244,7 +5244,7 @@ check_partition_bounds_for_split_range(Relation parent,
 										  false, split_upper);
 
 			/*
-			 * Upper bound of of "spec" should be equal (or less than or equal
+			 * Upper bound of "spec" should be equal (or less than or equal
 			 * in case defaultPart=true) to upper bound of split partition.
 			 */
 			if ((!defaultPart && cmpval) || (defaultPart && cmpval > 0))
diff --git a/src/backend/storage/aio/read_stream.c b/src/backend/storage/aio/read_stream.c
index f54dacdd91..634cf4f0d1 100644
--- a/src/backend/storage/aio/read_stream.c
+++ b/src/backend/storage/aio/read_stream.c
@@ -541,9 +541,9 @@ read_stream_begin_relation(int flags,
 		stream->distance = 1;
 
 	/*
-	 * Since we always always access the same relation, we can initialize
-	 * parts of the ReadBuffersOperation objects and leave them that way, to
-	 * avoid wasting CPU cycles writing to them for each read.
+	 * Since we always access the same relation, we can initialize parts of
+	 * the ReadBuffersOperation objects and leave them that way, to avoid
+	 * wasting CPU cycles writing to them for each read.
 	 */
 	for (int i = 0; i < max_ios; ++i)
 	{
diff --git a/src/backend/utils/mmgr/bump.c b/src/backend/utils/mmgr/bump.c
index 449bd29344..26d2907fb7 100644
--- a/src/backend/utils/mmgr/bump.c
+++ b/src/backend/utils/mmgr/bump.c
@@ -501,8 +501,8 @@ BumpAlloc(MemoryContext context, Size size, int flags)
 #endif
 
 	/*
-	 * If requested size exceeds maximum for chunks we hand the the request
-	 * off to BumpAllocLarge().
+	 * If requested size exceeds maximum for chunks we hand the request off to
+	 * BumpAllocLarge().
 	 */
 	if (chunk_size > set->allocChunkLimit)
 		return BumpAllocLarge(context, size, flags);
diff --git a/src/bin/pg_combinebackup/reconstruct.c b/src/bin/pg_combinebackup/reconstruct.c
index 15f62c18df..d481a5c565 100644
--- a/src/bin/pg_combinebackup/reconstruct.c
+++ b/src/bin/pg_combinebackup/reconstruct.c
@@ -756,7 +756,7 @@ write_block(int fd, char *output_filename,
 }
 
 /*
- * Read a block of data (BLCKSZ bytes) into the the buffer.
+ * Read a block of data (BLCKSZ bytes) into the buffer.
  */
 static void
 read_block(rfile *s, off_t off, uint8 *buffer)
diff --git a/src/bin/pg_upgrade/t/004_subscription.pl b/src/bin/pg_upgrade/t/004_subscription.pl
index 48918e8c29..a038928fe7 100644
--- a/src/bin/pg_upgrade/t/004_subscription.pl
+++ b/src/bin/pg_upgrade/t/004_subscription.pl
@@ -241,7 +241,7 @@ my $tab_upgraded2_oid = $old_sub->safe_psql('postgres',
 
 $old_sub->stop;
 
-# Change configuration so that initial table sync sync does not get started
+# Change configuration so that initial table sync does not get started
 # automatically
 $new_sub->append_conf('postgresql.conf',
 	"max_logical_replication_workers = 0");
diff --git a/src/include/access/heapam_xlog.h b/src/include/access/heapam_xlog.h
index 551a0370aa..839f74d768 100644
--- a/src/include/access/heapam_xlog.h
+++ b/src/include/access/heapam_xlog.h
@@ -354,9 +354,9 @@ typedef struct xlhp_freeze_plan
  *
  * The backup block's data contains an array of xlhp_freeze_plan structs (with
  * nplans elements).  The individual item offsets are located in an array at
- * the end of the entire record with with nplans * (each plan's ntuples)
- * members.  Those offsets are in the same order as the plans.  The REDO
- * routine uses the offsets to freeze the corresponding heap tuples.
+ * the end of the entire record with nplans * (each plan's ntuples) members
+ * Those offsets are in the same order as the plans.  The REDO routine uses
+ * the offsets to freeze the corresponding heap tuples.
  *
  * (As of PostgreSQL 17, XLOG_HEAP2_PRUNE_VACUUM_SCAN records replace the
  * separate XLOG_HEAP2_FREEZE_PAGE records.)
diff --git a/src/include/common/hashfn_unstable.h b/src/include/common/hashfn_unstable.h
index 7b647470ab..0adb0f82f9 100644
--- a/src/include/common/hashfn_unstable.h
+++ b/src/include/common/hashfn_unstable.h
@@ -73,7 +73,7 @@
  *
  * For longer or variable-length input, fasthash_accum() is a more
  * flexible, but more verbose method. The standalone functions use this
- * internally, so see fasthash64() for an an example of this.
+ * internally, so see fasthash64() for an example of this.
  *
  * After all inputs have been mixed in, finalize the hash:
  *
diff --git a/src/test/regress/expected/copy.out b/src/test/regress/expected/copy.out
index b48365ec98..44114089a6 100644
--- a/src/test/regress/expected/copy.out
+++ b/src/test/regress/expected/copy.out
@@ -276,8 +276,8 @@ CREATE TABLE parted_si_p_even PARTITION OF parted_si FOR VALUES IN (0);
 CREATE TABLE parted_si_p_odd PARTITION OF parted_si FOR VALUES IN (1);
 -- Test that bulk relation extension handles reusing a single BulkInsertState
 -- across partitions.  Without the fix applied, this reliably reproduces
--- #18130 unless shared_buffers is extremely small (preventing any use use of
--- bulk relation extension). See
+-- #18130 unless shared_buffers is extremely small (preventing any use of bulk
+-- relation extension). See
 -- https://postgr.es/m/18130-7a86a7356a75209d%40postgresql.org
 -- https://postgr.es/m/257696.1695670946%40sss.pgh.pa.us
 \set filename :abs_srcdir '/data/desc.data'
diff --git a/src/test/regress/sql/copy.sql b/src/test/regress/sql/copy.sql
index 43d2e906dd..e2dd24cb35 100644
--- a/src/test/regress/sql/copy.sql
+++ b/src/test/regress/sql/copy.sql
@@ -306,8 +306,8 @@ CREATE TABLE parted_si_p_odd PARTITION OF parted_si FOR VALUES IN (1);
 
 -- Test that bulk relation extension handles reusing a single BulkInsertState
 -- across partitions.  Without the fix applied, this reliably reproduces
--- #18130 unless shared_buffers is extremely small (preventing any use use of
--- bulk relation extension). See
+-- #18130 unless shared_buffers is extremely small (preventing any use of bulk
+-- relation extension). See
 -- https://postgr.es/m/18130-7a86a7356a75209d%40postgresql.org
 -- https://postgr.es/m/257696.1695670946%40sss.pgh.pa.us
 \set filename :abs_srcdir '/data/desc.data'

---

From: Daniel Gustafsson <[email-masked]>
Date: Mon, 15 Apr 2024 14:25:45 +0200

> On 14 Apr 2024, at 13:19, David Rowley <[email-masked]> wrote:
> 

Thanks.  Collecting all the ones submitted here, as well as a few submitted
off-list by Alexander, the patch is now a 3-part patchset of cleanups:

0001 contains the typos and duplicate words fixups, 0002 fixes a parameter with
the wrong name in the prototype and 0003 removes a leftover prototype which was
accidentally left in a refactoring.

--
Daniel Gustafsson

---

From: Richard Guo <[email-masked]>
Date: Tue, 16 Apr 2024 16:28:24 +0800

> accidentally left in a refactoring.

BTW, it seems that 0001 needs a rebase over 9dfcac8e15.

Thanks
Richard

---

From: Nazir Bilal Yavuz <[email-masked]>
Date: Tue, 16 Apr 2024 16:37:50 +0300

Hi,

Thanks for working on this!

> accidentally left in a refactoring.

I realized two small typos: 'sgmr' -> 'smgr'. You may want to include
them in 0001.

-- 
Regards,
Nazir Bilal Yavuz
Microsoft

---

From: Daniel Gustafsson <[email-masked]>
Date: Fri, 19 Apr 2024 10:13:13 +0200

> On 16 Apr 2024, at 15:37, Nazir Bilal Yavuz <[email-masked]> wrote:

> I realized two small typos: 'sgmr' -> 'smgr'. You may want to include

Thanks, I incorporated these into 0001 before pushing.  All the commits in this
patchset are now applied.

--
Daniel Gustafsson

---

From: David Rowley <[email-masked]>
Date: Sat, 20 Apr 2024 16:09:13 +1200

> patchset are now applied.

Here are a few more to see if it motivates anyone else to do a more
thorough search for another batch.

Fixes duplicate words spanning multiple lines plus an outdated
reference to "streaming read" which was renamed to "read stream" late
in that patch's development.

duplicate words found using:
ag "\s([a-zA-Z]{2,})[\s*]*\n\1\b"
ag "\s([a-zA-Z]{2,})\n(\s*\*\s*)\1\b"

David
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 4a4cf76269..32e7d3c146 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -1122,7 +1122,7 @@ heap_beginscan(Relation relation, Snapshot snapshot,
 	/*
 	 * Set up a read stream for sequential scans and TID range scans. This
 	 * should be done after initscan() because initscan() allocates the
-	 * BufferAccessStrategy object passed to the streaming read API.
+	 * BufferAccessStrategy object passed to the read stream API.
 	 */
 	if (scan->rs_base.rs_flags & SO_TYPE_SEQSCAN ||
 		scan->rs_base.rs_flags & SO_TYPE_TIDRANGESCAN)
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index de109acc89..0c5379666b 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -13,7 +13,7 @@
  * autovacuum_work_mem) memory space to keep track of dead TIDs.  If the
  * TID store is full, we must call lazy_vacuum to vacuum indexes (and to vacuum
  * the pages that we've pruned). This frees up the memory space dedicated to
- * to store dead TIDs.
+ * store dead TIDs.
  *
  * In practice VACUUM will often complete its initial pass over the target
  * heap relation without ever running out of space to store TIDs.  This means
diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c
index 4548a91723..a2510cf80c 100644
--- a/src/backend/catalog/namespace.c
+++ b/src/backend/catalog/namespace.c
@@ -108,7 +108,7 @@
  * (if one exists).
  *
  * activeSearchPath is always the actually active path; it points to
- * to baseSearchPath which is the list derived from namespace_search_path.
+ * baseSearchPath which is the list derived from namespace_search_path.
  *
  * If baseSearchPathValid is false, then baseSearchPath (and other derived
  * variables) need to be recomputed from namespace_search_path, or retrieved
diff --git a/src/backend/replication/logical/slotsync.c b/src/backend/replication/logical/slotsync.c
index cb39adcd0e..ed8104ccb4 100644
--- a/src/backend/replication/logical/slotsync.c
+++ b/src/backend/replication/logical/slotsync.c
@@ -601,7 +601,7 @@ update_and_persist_local_synced_slot(RemoteSlot *remote_slot, Oid remote_dbid)
  * metadata of the slot as per the data received from the primary server.
  *
  * The slot is created as a temporary slot and stays in the same state until the
- * the remote_slot catches up with locally reserved position and local slot is
+ * remote_slot catches up with locally reserved position and local slot is
  * updated. The slot is then persisted and is considered as sync-ready for
  * periodic syncs.
  *
diff --git a/src/backend/storage/smgr/smgr.c b/src/backend/storage/smgr/smgr.c
index 100f6454e5..a691aed1f4 100644
--- a/src/backend/storage/smgr/smgr.c
+++ b/src/backend/storage/smgr/smgr.c
@@ -244,7 +244,7 @@ smgropen(RelFileLocator rlocator, ProcNumber backend)
 
 /*
  * smgrpin() -- Prevent an SMgrRelation object from being destroyed at end of
- *				of transaction
+ *				transaction
  */
 void
 smgrpin(SMgrRelation reln)