diff --git a/src/backend/commands/collationcmds.c b/src/backend/commands/collationcmds.c index a7ee452e19..55a0e24a35 100644 --- a/src/backend/commands/collationcmds.c +++ b/src/backend/commands/collationcmds.c @@ -407,14 +407,16 @@ pg_import_system_collations(PG_FUNCTION_ARGS) Oid nspid = PG_GETARG_OID(0); int ncreated = 0; - /* silence compiler warning if we have no locale implementation at all */ - (void) nspid; - if (!superuser()) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), errmsg("must be superuser to import system collations"))); + if (!SearchSysCacheExists1(NAMESPACEOID, ObjectIdGetDatum(nspid))) + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_SCHEMA), + errmsg("schema with OID %u does not exist", nspid))); + /* Load collations known to libc, using "locale -a" to enumerate them */ #ifdef READ_LOCALE_A_OUTPUT {