Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9000167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:16:35+00:00 2026-06-16T00:16:35+00:00

From http://www.postgresql.org/docs/9.1/static/sql-grant.html : USAGE … For schemas, allows access to objects contained in the

  • 0

From http://www.postgresql.org/docs/9.1/static/sql-grant.html:

USAGE

…

For schemas, allows access to objects contained in the specified schema (assuming that the objects’ own privilege requirements are also met). Essentially this allows the grantee to “look up” objects within the schema. Without this permission, it is still possible to see the object names, e.g. by querying the system tables. …

…

However, running the following script through psql seems to show that although the lack of a SELECT permission causes an error, lack on an EXECUTE permission does not, which contradicts the documentation as the ‘own privilege requirement’ is not met.

CREATE DATABASE testdb WITH OWNER postgres ENCODING 'UTF8';
\connect testdb
CREATE ROLE testrole;
CREATE SCHEMA testschema;
GRANT USAGE ON SCHEMA testschema TO testrole;
SET search_path TO testschema;

CREATE FUNCTION testfunc ()
RETURNS VOID
AS $$
BEGIN
  RAISE NOTICE 'IN TESTFUNC';
  RAISE NOTICE 'Current user: %', current_user;
END;
$$
LANGUAGE plpgsql;

CREATE TABLE testtable
(
  testrow INT
);

INSERT INTO testtable (testrow) VALUES (1), (2), (3);

SET ROLE testrole;

SELECT testfunc();
SELECT * FROM testtable;

RESET ROLE;

Output:

$ psql -f usage.sql
CREATE DATABASE
You are now connected to database "testdb" as user "postgres".
CREATE ROLE
CREATE SCHEMA
GRANT
SET
CREATE FUNCTION
CREATE TABLE
INSERT 0 3
SET
psql:usage.sql:27: NOTICE:  IN TESTFUNC
psql:usage.sql:27: NOTICE:  Current user: testrole
 testfunc 
----------

(1 row)

psql:usage.sql:28: ERROR:  permission denied for relation testtable
RESET

Have I missed something or am using the permissions incorrectly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:16:36+00:00Added an answer on June 16, 2026 at 12:16 am

    The schema is not what matters here, what you’re seeing is the default execute permissions of functions.
    Consider this excerpt from the CREATE FUNCTION documentation:

    Another point to keep in mind is that by default, execute privilege is
    granted to PUBLIC for newly created functions (see GRANT for more
    information). Frequently you will wish to restrict use of a security
    definer function to only some users. To do that, you must revoke the
    default PUBLIC privileges and then grant execute privilege
    selectively.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

a) Quote is taken from http://www.postgresql.org/docs/current/static/tutorial-window.html for each row, there is a set of
First of all, yes I've read documentation for DO statement :) http://www.postgresql.org/docs/9.1/static/sql-do.html So my
I am using Postgres 8.4.4 copy, http://www.postgresql.org/docs/8.4/static/sql-copy.html , to import CSV data into my
http://www.postgresql.org/docs/8.4/static/functions-admin.html says: pg_relation_size accepts the OID or name of a table, index or toast
How does the work_mem option in Postgres work? Here's the description from http://www.postgresql.org/docs/8.4/static/runtime-config-resource.html :
I set up a set of partitioned tables per the docs at http://www.postgresql.org/docs/8.1/interactive/ddl-partitioning.html CREATE
As I understand from http://www.kernel.org/pub/software/scm/git/docs/git-rebase.html the rebased branch is 'moved' on to another one.
From http://www.boost.org/community/implementation_variations.html ... coding differences such as changing a class from virtual to non-virtual
From http://www.faqs.org/rfcs/rfc2822.html : CR and LF MUST only occur together as CRLF; they MUST
this is copied from http://www.zenspider.com/ZSS/Products/RubyInline/Readme.html , the home of rubyinline, adding/moding as indicated in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.