Access tables inside pl/pgsql functions

Поиск
Список
Период
Сортировка
От Michael Davis
Тема Access tables inside pl/pgsql functions
Дата
Msg-id 01C0A7CC.6A8AC460.mdavis@sevainc.com
обсуждение исходный текст
Список pgsql-sql
I would like to create a pl/pgsql function that can select from a table 
even though users can't select from the table directly.  For example, 
create a table and function that hits the table as the postgres user.  Log 
in as another user and select function_name();.  This fails because the 
user does not have permissions to select from the table.  The issues is 
that I don't want the users to be able to select from the table but I would 
like to allow the user to call a stored procedure than can select from the 
table.  Any idea how to do this?  Any help is greatly appreciated.

Thanks, Michael

Here is an example.  Create the following table and function as the 
postgres user:

CREATE TABLE tst
(  tmp_relname name,  id smallint
);

CREATE FUNCTION test() RETURNS int AS '
BEGIN     DELETE FROM tst;      return 1;  END;'  LANGUAGE 'plpgsql';

Login as another user

Select test();  -- this will fail





В списке pgsql-sql по дате отправления:

Предыдущее
От: dev@archonet.com
Дата:
Сообщение: Re: Writing SQL functions in Postgres
Следующее
От: David Olbersen
Дата:
Сообщение: explain EXPLAIN?