diff --git a/doc/src/sgml/xplang.sgml b/doc/src/sgml/xplang.sgml
index d215ce82d0..60e0430751 100644
--- a/doc/src/sgml/xplang.sgml
+++ b/doc/src/sgml/xplang.sgml
@@ -137,7 +137,7 @@ CREATE FUNCTION <replaceable>validator_function_name</replaceable>(oid)
      <para>
       Finally, the PL must be declared with the command
 <synopsis>
-CREATE <optional>TRUSTED</optional> LANGUAGE <replaceable>language-name</replaceable>
+CREATE <optional>TRUSTED</optional> LANGUAGE <replaceable>language_name</replaceable>
     HANDLER <replaceable>handler_function_name</replaceable>
     <optional>INLINE <replaceable>inline_function_name</replaceable></optional>
     <optional>VALIDATOR <replaceable>validator_function_name</replaceable></optional> ;
diff --git a/src/backend/access/spgist/spgvacuum.c b/src/backend/access/spgist/spgvacuum.c
index 2b1662a267..478d4c0d61 100644
--- a/src/backend/access/spgist/spgvacuum.c
+++ b/src/backend/access/spgist/spgvacuum.c
@@ -842,7 +842,7 @@ spgvacuumscan(spgBulkDeleteState *bds)
 		}
 	}
 
-	/* Propagate local lastUsedPage cache to metablock */
+	/* Propagate local lastUsedPages cache to metablock */
 	SpGistUpdateMetaPage(index);
 
 	/*
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index e7a59b0a92..e172dad07f 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2259,7 +2259,7 @@ WalSndLoop(WalSndSendDataCallback send_data)
 				WL_SOCKET_READABLE;
 
 			/*
-			 * Use fresh timestamp, not last_processed, to reduce the chance
+			 * Use fresh timestamp, not last_processing, to reduce the chance
 			 * of reaching wal_sender_timeout before sending a keepalive.
 			 */
 			sleeptime = WalSndComputeSleeptime(GetCurrentTimestamp());
@@ -2666,7 +2666,7 @@ XLogSendPhysical(void)
 	 * very close to together here so that we'll get a later position if it is
 	 * still moving.
 	 *
-	 * Because LagTrackerWriter ignores samples when the LSN hasn't advanced,
+	 * Because LagTrackerWrite ignores samples when the LSN hasn't advanced,
 	 * this gives us a cheap approximation for the WAL flush time for this
 	 * LSN.
 	 *
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index ae6780011b..fadab62950 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -3169,7 +3169,7 @@ DisplayXidCache(void)
  *
  * When we throw away subXIDs from KnownAssignedXids, we need to keep track of
  * that, similarly to tracking overflow of a PGPROC's subxids array.  We do
- * that by remembering the lastOverflowedXID, ie the last thrown-away subXID.
+ * that by remembering the lastOverflowedXid, ie the last thrown-away subXID.
  * As long as that is within the range of interesting XIDs, we have to assume
  * that subXIDs are missing from snapshots.  (Note that subXID overflow occurs
  * on primary when 65th subXID arrives, whereas on standby it occurs when 64th
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c
index 8fcdf82922..ec8fbb9a7d 100644
--- a/src/backend/utils/adt/arrayfuncs.c
+++ b/src/backend/utils/adt/arrayfuncs.c
@@ -139,7 +139,7 @@ static void array_insert_slice(ArrayType *destArray, ArrayType *origArray,
 							   int *st, int *endp,
 							   int typlen, bool typbyval, char typalign);
 static int	array_cmp(FunctionCallInfo fcinfo);
-static ArrayType *create_array_envelope(int ndims, int *dimv, int *lbv, int nbytes,
+static ArrayType *create_array_envelope(int ndims, int *dimv, int *lbsv, int nbytes,
 										Oid elmtype, int dataoffset);
 static ArrayType *array_fill_internal(ArrayType *dims, ArrayType *lbs,
 									  Datum value, bool isnull, Oid elmtype,
diff --git a/src/backend/utils/adt/like_match.c b/src/backend/utils/adt/like_match.c
index 9055a93813..5b322559aa 100644
--- a/src/backend/utils/adt/like_match.c
+++ b/src/backend/utils/adt/like_match.c
@@ -27,7 +27,8 @@
 /*
  *	Originally written by Rich $alz, mirror!rs, Wed Nov 26 19:03:17 EST 1986.
  *	Rich $alz is now <rsalz@bbn.com>.
- *	Special thanks to Lars Mathiesen <thorinn@diku.dk> for the LABORT code.
+ *	Special thanks to Lars Mathiesen <thorinn@diku.dk> for the
+ *	LIKE_ABORT code.
  *
  *	This code was shamelessly stolen from the "pql" code by myself and
  *	slightly modified :)
diff --git a/src/backend/utils/adt/windowfuncs.c b/src/backend/utils/adt/windowfuncs.c
index aa177df017..506e59afa1 100644
--- a/src/backend/utils/adt/windowfuncs.c
+++ b/src/backend/utils/adt/windowfuncs.c
@@ -75,7 +75,7 @@ rank_up(WindowObject winobj)
 
 
 /*
- * row_number
+ * window_row_number
  * just increment up from 1 until current partition finishes.
  */
 Datum
@@ -90,7 +90,7 @@ window_row_number(PG_FUNCTION_ARGS)
 
 
 /*
- * rank
+ * window_rank
  * Rank changes when key columns change.
  * The new rank number is the current row number.
  */
@@ -111,7 +111,7 @@ window_rank(PG_FUNCTION_ARGS)
 }
 
 /*
- * dense_rank
+ * window_dense_rank
  * Rank increases by 1 when key columns change.
  */
 Datum
@@ -131,7 +131,7 @@ window_dense_rank(PG_FUNCTION_ARGS)
 }
 
 /*
- * percent_rank
+ * window_percent_rank
  * return fraction between 0 and 1 inclusive,
  * which is described as (RK - 1) / (NR - 1), where RK is the current row's
  * rank and NR is the total number of rows, per spec.
@@ -160,7 +160,7 @@ window_percent_rank(PG_FUNCTION_ARGS)
 }
 
 /*
- * cume_dist
+ * window_cume_dist
  * return fraction between 0 and 1 inclusive,
  * which is described as NP / NR, where NP is the number of rows preceding or
  * peers to the current row, and NR is the total number of rows, per spec.
@@ -203,7 +203,7 @@ window_cume_dist(PG_FUNCTION_ARGS)
 }
 
 /*
- * ntile
+ * window_ntile
  * compute an exact numeric value with scale 0 (zero),
  * ranging from 1 (one) to n, per spec.
  */
@@ -329,7 +329,7 @@ leadlag_common(FunctionCallInfo fcinfo,
 }
 
 /*
- * lag
+ * window_lag
  * returns the value of VE evaluated on a row that is 1
  * row before the current row within a partition,
  * per spec.
@@ -341,7 +341,7 @@ window_lag(PG_FUNCTION_ARGS)
 }
 
 /*
- * lag_with_offset
+ * window_lag_with_offset
  * returns the value of VE evaluated on a row that is OFFSET
  * rows before the current row within a partition,
  * per spec.
@@ -353,8 +353,8 @@ window_lag_with_offset(PG_FUNCTION_ARGS)
 }
 
 /*
- * lag_with_offset_and_default
- * same as lag_with_offset but accepts default value
+ * window_lag_with_offset_and_default
+ * same as window_lag_with_offset but accepts default value
  * as its third argument.
  */
 Datum
@@ -364,7 +364,7 @@ window_lag_with_offset_and_default(PG_FUNCTION_ARGS)
 }
 
 /*
- * lead
+ * window_lead
  * returns the value of VE evaluated on a row that is 1
  * row after the current row within a partition,
  * per spec.
@@ -376,7 +376,7 @@ window_lead(PG_FUNCTION_ARGS)
 }
 
 /*
- * lead_with_offset
+ * window_lead_with_offset
  * returns the value of VE evaluated on a row that is OFFSET
  * number of rows after the current row within a partition,
  * per spec.
@@ -388,8 +388,8 @@ window_lead_with_offset(PG_FUNCTION_ARGS)
 }
 
 /*
- * lead_with_offset_and_default
- * same as lead_with_offset but accepts default value
+ * window_lead_with_offset_and_default
+ * same as window_lead_with_offset but accepts default value
  * as its third argument.
  */
 Datum
@@ -399,7 +399,7 @@ window_lead_with_offset_and_default(PG_FUNCTION_ARGS)
 }
 
 /*
- * first_value
+ * window_first_value
  * return the value of VE evaluated on the first row of the
  * window frame, per spec.
  */
@@ -420,7 +420,7 @@ window_first_value(PG_FUNCTION_ARGS)
 }
 
 /*
- * last_value
+ * window_last_value
  * return the value of VE evaluated on the last row of the
  * window frame, per spec.
  */
@@ -441,7 +441,7 @@ window_last_value(PG_FUNCTION_ARGS)
 }
 
 /*
- * nth_value
+ * window_nth_value
  * return the value of VE evaluated on the n-th row from the first
  * row of the window frame, per spec.
  */
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 04d77ad700..09eabfbe5a 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -2024,7 +2024,7 @@ make_template0(FILE *cmdfd)
 		"CREATE DATABASE template0 IS_TEMPLATE = true ALLOW_CONNECTIONS = false;\n\n",
 
 		/*
-		 * We use the OID of template0 to determine lastsysoid
+		 * We use the OID of template0 to determine datlastsysoid
 		 */
 		"UPDATE pg_database SET datlastsysoid = "
 		"    (SELECT oid FROM pg_database "
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c
index 3a8cddf4ff..48d4ebdd96 100644
--- a/src/interfaces/libpq/fe-exec.c
+++ b/src/interfaces/libpq/fe-exec.c
@@ -2250,7 +2250,7 @@ PQsendDescribe(PGconn *conn, char desc_type, const char *desc_target)
 	/* remember we are doing a Describe */
 	conn->queryclass = PGQUERY_DESCRIBE;
 
-	/* reset last-query string (not relevant now) */
+	/* reset last_query string (not relevant now) */
 	if (conn->last_query)
 	{
 		free(conn->last_query);
