From 05540853eb5738d35e143ffe02604e52f291d873 Mon Sep 17 00:00:00 2001
From: Jeff Davis <jdavis@postgresql.org>
Date: Sat, 29 Oct 2022 14:13:23 -0700
Subject: [PATCH 3/4] Fix ALTER COLLATION "default" REFRESH VERSION.

Issue a helpful error message rather than an internal error.
---
 src/backend/commands/collationcmds.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/backend/commands/collationcmds.c b/src/backend/commands/collationcmds.c
index 23468cf79d..86fbc7fa01 100644
--- a/src/backend/commands/collationcmds.c
+++ b/src/backend/commands/collationcmds.c
@@ -366,6 +366,11 @@ AlterCollation(AlterCollationStmt *stmt)
 	rel = table_open(CollationRelationId, RowExclusiveLock);
 	collOid = get_collation_oid(stmt->collname, false);
 
+	if (collOid == DEFAULT_COLLATION_OID)
+		ereport(ERROR,
+				(errmsg("cannot refresh version of default collation"),
+				 errhint("Use ALTER DATABASE ... REFRESH COLLATION VERSION instead.")));
+
 	if (!pg_collation_ownercheck(collOid, GetUserId()))
 		aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_COLLATION,
 					   NameListToString(stmt->collname));
-- 
2.34.1

