Fix ALTER COLLATION "default" REFRESH VERSION.
authorJeff Davis <[email protected]>
Sat, 29 Oct 2022 21:13:23 +0000 (14:13 -0700)
committerJeff Davis <[email protected]>
Mon, 31 Oct 2022 22:44:52 +0000 (15:44 -0700)
Issue a helpful error message rather than an internal error.

Discussion: https://postgr.es/m/51fb77507cafd43fc1a2e733c23045873d93ae60.camel%40j-davis.com
Reviewed-by: Thomas Munro
src/backend/commands/collationcmds.c

index 23468cf79da55129230e5128918d6adb00ac8d63..86fbc7fa019f96dd73fbca83814787533b2c1cc3 100644 (file)
@@ -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));