Re: strange java query behaviour

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Marti Raudsepp <marti(at)juffo(dot)org>
Cc: Szymon Guz <mabewlun(at)gmail(dot)com>, PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: strange java query behaviour
Date: 2011-10-25 16:38:39
Message-ID: 24583.1319560719@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Marti Raudsepp <marti(at)juffo(dot)org> writes:
> The documentation says: The view schemata contains all schemas in the
> current database that are owned by a currently enabled role.

> In other words: this view only displays schemas that are *owned* by
> your user, or roles that your current user inherits from (superuser
> sees everything of course). Sadly it doesn't list visible/accessible
> schemas.

> I think this is pretty surprising; not sure if it's just bad legacy or
> if there is some good reason for this behavior. I couldn't find any
> justification in the source code.

The justification is that the SQL standard requires the view to act that
way.

20.46 SCHEMATA view

Function

Identify the schemata in a catalog that are owned by a given user.

Definition

CREATE VIEW SCHEMATA AS
SELECT CATALOG_NAME, SCHEMA_NAME, SCHEMA_OWNER,
DEFAULT_CHARACTER_SET_CATALOG, DEFAULT_CHARACTER_SET_
SCHEMA,
DEFAULT_CHARACTER_SET_NAME, SQL_PATH
FROM DEFINITION_SCHEMA.SCHEMATA

WHERE ( SCHEMA_OWNER = CURRENT_USER
OR
SCHEMA_OWNER IN
( SELECT ROLE_NAME
FROM ENABLED_ROLES ) )
AND
CATALOG_NAME
= ( SELECT CATALOG_NAME
FROM INFORMATION_SCHEMA_CATALOG_NAME );

GRANT SELECT ON TABLE SCHEMATA
TO PUBLIC WITH GRANT OPTION;

> I think we should add a TODO item for fixing this?

Waste of breath. You could try lobbying the SQL committee to change the
standard, perhaps.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Basil Bourque 2011-10-25 19:31:16 Re: Problem installing PostgreSQL 9.0 via Macports on OS X Server 10.6
Previous Message Szymon Guz 2011-10-25 15:28:22 Re: strange java query behaviour