Index: src/backend/catalog/namespace.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/backend/catalog/namespace.c,v retrieving revision 1.63 diff -u -r1.63 namespace.c --- src/backend/catalog/namespace.c 13 Feb 2004 01:08:20 -0000 1.63 +++ src/backend/catalog/namespace.c 9 Apr 2004 02:57:36 -0000 @@ -1806,8 +1806,7 @@ /* * Verify that all the names are either valid namespace names or * "$user". We do not require $user to correspond to a valid - * namespace. We do not check for USAGE rights, either; should - * we? + * namespace. * * When source == PGC_S_TEST, we are checking the argument of an * ALTER DATABASE SET or ALTER USER SET command. It could be that @@ -1821,12 +1820,11 @@ if (strcmp(curname, "$user") == 0) continue; - if (!SearchSysCacheExists(NAMESPACENAME, - CStringGetDatum(curname), - 0, 0, 0)) - ereport((source == PGC_S_TEST) ? NOTICE : ERROR, - (errcode(ERRCODE_UNDEFINED_SCHEMA), - errmsg("schema \"%s\" does not exist", curname))); + + /* Test to make sure the schema exists and + * that the user has USAGE privs on the + * schema. */ + LookupExplicitNamespace(curname); } } Index: src/bin/psql/describe.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/bin/psql/describe.c,v retrieving revision 1.96 diff -u -r1.96 describe.c --- src/bin/psql/describe.c 6 Apr 2004 04:05:17 -0000 1.96 +++ src/bin/psql/describe.c 9 Apr 2004 02:57:36 -0000 @@ -1612,7 +1612,9 @@ "FROM pg_catalog.pg_namespace n LEFT JOIN pg_catalog.pg_user u\n" " ON n.nspowner=u.usesysid\n" "WHERE (n.nspname NOT LIKE 'pg\\\\_temp\\\\_%%' OR\n" - " n.nspname = (pg_catalog.current_schemas(true))[1])\n", /* temp schema is first */ + " n.nspname = (pg_catalog.current_schemas(true))[1]) AND\n" /* temp schema is first */ + " pg_catalog.has_schema_privilege(n.nspname, 'USAGE')", + _("Name"), _("Owner")); processNamePattern(&buf, pattern, true, false, Index: src/bin/psql/tab-complete.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/bin/psql/tab-complete.c,v retrieving revision 1.104 diff -u -r1.104 tab-complete.c --- src/bin/psql/tab-complete.c 5 Apr 2004 03:02:09 -0000 1.104 +++ src/bin/psql/tab-complete.c 9 Apr 2004 02:57:37 -0000 @@ -341,7 +341,8 @@ #define Query_for_list_of_schemas \ "SELECT pg_catalog.quote_ident(nspname) FROM pg_catalog.pg_namespace "\ -" WHERE substring(pg_catalog.quote_ident(nspname),1,%d)='%s'" +" WHERE substring(pg_catalog.quote_ident(nspname),1,%d)='%s' "\ +" AND pg_catalog.has_schema_privilege(n.nspname, 'USAGE')" #define Query_for_list_of_system_relations \ "SELECT pg_catalog.quote_ident(relname) "\ @@ -349,7 +350,8 @@ " WHERE c.relkind IN ('r', 'v', 's', 'S') "\ " AND substring(pg_catalog.quote_ident(relname),1,%d)='%s' "\ " AND c.relnamespace = n.oid "\ -" AND n.nspname = 'pg_catalog'" +" AND n.nspname = 'pg_catalog'"\ +" AND pg_catalog.has_schema_privilege(n.nspname, 'USAGE')" #define Query_for_list_of_users \ " SELECT pg_catalog.quote_ident(usename) "\ @@ -1546,7 +1548,7 @@ appendPQExpBuffer(&query_buffer, "\nUNION\n" "SELECT pg_catalog.quote_ident(n.nspname) || '.' " "FROM pg_catalog.pg_namespace n " - "WHERE substring(pg_catalog.quote_ident(n.nspname) || '.',1,%d)='%s'", + "WHERE pg_catalog.has_schema_privilege(n.nspname, 'USAGE') AND substring(pg_catalog.quote_ident(n.nspname) || '.',1,%d)='%s'", string_length, e_text); appendPQExpBuffer(&query_buffer, " AND (SELECT pg_catalog.count(*)" @@ -1562,7 +1564,7 @@ appendPQExpBuffer(&query_buffer, "\nUNION\n" "SELECT pg_catalog.quote_ident(n.nspname) || '.' || %s " "FROM %s, pg_catalog.pg_namespace n " - "WHERE %s = n.oid AND ", + "WHERE pg_catalog.has_schema_privilege(n.nspname, 'USAGE') AND %s = n.oid AND ", qualresult, completion_squery->catname, completion_squery->namespace);