diff --git a/doc/src/sgml/ref/pg_amcheck.sgml b/doc/src/sgml/ref/pg_amcheck.sgml
index cfef6c0465..20c2897acc 100644
--- a/doc/src/sgml/ref/pg_amcheck.sgml
+++ b/doc/src/sgml/ref/pg_amcheck.sgml
@@ -160,7 +160,7 @@ PostgreSQL documentation
        Patterns may be unqualified, e.g. <literal>myrel*</literal>, or they
        may be schema-qualified, e.g. <literal>myschema*.myrel*</literal> or
        database-qualified and schema-qualified, e.g.
-       <literal>mydb*.myscheam*.myrel*</literal>. A database-qualified
+       <literal>mydb*.myschema*.myrel*</literal>. A database-qualified
        pattern will add matching databases to the list of databases to be
        checked.
       </para>
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index b300a4675e..0124f37911 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -1223,7 +1223,7 @@ heap_set_tidrange(TableScanDesc sscan, ItemPointer mintid,
 	 * Calculate the first block and the number of blocks we must scan. We
 	 * could be more aggressive here and perform some more validation to try
 	 * and further narrow the scope of blocks to scan by checking if the
-	 * lowerItem has an offset above MaxOffsetNumber.  In this case, we could
+	 * lowestItem has an offset above MaxOffsetNumber.  In this case, we could
 	 * advance startBlk by one.  Likewise, if highestItem has an offset of 0
 	 * we could scan one fewer blocks.  However, such an optimization does not
 	 * seem worth troubling over, currently.
diff --git a/src/backend/access/heap/pruneheap.c b/src/backend/access/heap/pruneheap.c
index 3f0342351f..087424d37a 100644
--- a/src/backend/access/heap/pruneheap.c
+++ b/src/backend/access/heap/pruneheap.c
@@ -490,7 +490,7 @@ heap_page_prune(Relation relation, Buffer buffer,
  *
  * Due to its cost we also only want to call
  * TransactionIdLimitedForOldSnapshots() if necessary, i.e. we might not have
- * done so in heap_hot_prune_opt() if pd_prune_xid was old enough. But we
+ * done so in heap_page_prune_opt() if pd_prune_xid was old enough. But we
  * still want to be able to remove rows that are too new to be removed
  * according to prstate->vistest, but that can be removed based on
  * old_snapshot_threshold. So we call TransactionIdLimitedForOldSnapshots() on
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 0a9ebd22bd..a03a7ce453 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -2571,7 +2571,7 @@ lazy_vacuum_heap_page(LVRelState *vacrel, BlockNumber blkno, Buffer buffer,
 	END_CRIT_SECTION();
 
 	/*
-	 * Now that we have removed the LD_DEAD items from the page, once again
+	 * Now that we have removed the LP_DEAD items from the page, once again
 	 * check if the page has become all-visible.  The page is already marked
 	 * dirty, exclusively locked, and, if needed, a full page image has been
 	 * emitted.
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index bf3a2b843a..9ddd5b811e 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -864,7 +864,7 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
 			else
 			{
 				/*
-				 * In the unlikely event that we exceed MAX_FLUSH_BUFFERS,
+				 * In the unlikely event that we exceed MAX_WRITEALL_BUFFERS,
 				 * fall back to treating it as a standalone write.
 				 */
 				fdata = NULL;
diff --git a/src/backend/utils/activity/backend_status.c b/src/backend/utils/activity/backend_status.c
index 391d5de043..a8f927f540 100644
--- a/src/backend/utils/activity/backend_status.c
+++ b/src/backend/utils/activity/backend_status.c
@@ -283,7 +283,7 @@ pgstat_beinit(void)
  *
  *	Apart from auxiliary processes, MyBackendId, MyDatabaseId,
  *	session userid, and application_name must be set for a
- *	backend (hence, this cannot be combined with pgbestat_beinit).
+ *	backend (hence, this cannot be combined with pgstat_beinit).
  *	Note also that we must be inside a transaction if this isn't an aux
  *	process, as we may need to do encoding conversion on some strings.
  * ----------
diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c
index 729ebd86d1..c660fd3e70 100644
--- a/src/backend/utils/adt/acl.c
+++ b/src/backend/utils/adt/acl.c
@@ -4717,8 +4717,8 @@ pg_has_role_id_id(PG_FUNCTION_ARGS)
  *		Convert text string to AclMode value.
  *
  * We use USAGE to denote whether the privileges of the role are accessible
- * (has_privs), MEMBER to denote is_member, and MEMBER WITH GRANT OPTION
- * (or ADMIN OPTION) to denote is_admin.  There is no ACL bit corresponding
+ * (has_privs_of_role), MEMBER to denote is_member, and MEMBER WITH GRANT
+ * (or ADMIN) OPTION to denote is_admin.  There is no ACL bit corresponding
  * to MEMBER so we cheat and use ACL_CREATE for that.  This convention
  * is shared only with pg_role_aclcheck, below.
  */
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index fe37e65af0..c4fcd0076e 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -4210,7 +4210,7 @@ estimate_multivariate_ndistinct(PlannerInfo *root, RelOptInfo *rel,
 			 * Process complex expressions, not just simple Vars.
 			 *
 			 * First, we search for an exact match of an expression. If we
-			 * find one, we can just discard the whole GroupExprInfo, with all
+			 * find one, we can just discard the whole GroupVarInfo, with all
 			 * the variables we extracted from it.
 			 *
 			 * Otherwise we inspect the individual vars, and try matching it
diff --git a/src/backend/utils/mb/mbutils.c b/src/backend/utils/mb/mbutils.c
index 033647011b..67a1ab2ab2 100644
--- a/src/backend/utils/mb/mbutils.c
+++ b/src/backend/utils/mb/mbutils.c
@@ -453,7 +453,7 @@ pg_do_encoding_conversion(unsigned char *src, int len,
  *
  * The output is null-terminated.
  *
- * If destlen < srclen * MAX_CONVERSION_LENGTH + 1, the converted output
+ * If destlen < srclen * MAX_CONVERSION_INPUT_LENGTH + 1, the converted output
  * wouldn't necessarily fit in the output buffer, and the function will not
  * convert the whole input.
  *
diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h
index ce0167c1b6..3c9f589278 100644
--- a/src/interfaces/libpq/libpq-int.h
+++ b/src/interfaces/libpq/libpq-int.h
@@ -872,7 +872,7 @@ extern ssize_t pg_GSS_write(PGconn *conn, const void *ptr, size_t len);
 extern ssize_t pg_GSS_read(PGconn *conn, void *ptr, size_t len);
 #endif
 
-/* === in libpq-trace.c === */
+/* === in fe-trace.c === */
 
 extern void pqTraceOutputMessage(PGconn *conn, const char *message,
 								 bool toServer);
