has_schema_privilege function

From: Jignesh Shah <jignesh(dot)shah1980(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>, postgresql novice <pgsql-novice(at)postgresql(dot)org>
Subject: has_schema_privilege function
Date: 2010-03-09 10:28:49
Message-ID: c11950271003090228g7c9d05bege0c51d36d9833dc0@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice

Hi, I have created below function. I am checking return value of
has_schema_privilege by using flag="f". I think this is not strong way to
make a check because if in future "f" becomes "false" my stored procedure
will work improper.

Could you tell me is there any other robust way to make sure that user1
doesn't have CREATE permissions on mydb schema?

CREATE OR REPLACE FUNCTION schema_perm_test()
RETURNS void AS
$BODY$
$rv = spi_exec_query("SELECT has_schema_privilege('user1', 'mydb',
'CREATE') AS flag;");
if(lc($rv->{rows}->[0]->{flag}) eq "f") {
# Do tasks
}
$BODY$
LANGUAGE 'plperl' VOLATILE SECURITY DEFINER

Thanks.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2010-03-09 10:37:22 Re: Can we overload = operator to word numeric = text
Previous Message venkatrao.b 2010-03-09 10:18:00 Can we overload = operator to word numeric = text

Browse pgsql-novice by date

  From Date Subject
Next Message Pavel Stehule 2010-03-09 10:37:22 Re: Can we overload = operator to word numeric = text
Previous Message venkatrao.b 2010-03-09 10:18:00 Can we overload = operator to word numeric = text