diff --git a/src/backend/commands/collationcmds.c b/src/backend/commands/collationcmds.c index 9437731276f..d8ea1bb67bf 100644 --- a/src/backend/commands/collationcmds.c +++ b/src/backend/commands/collationcmds.c @@ -503,14 +503,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 {