pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Anton Maksimenkov <engineer@hlebprom.ru>
To: pgsql-admin@postgresql.org
Subject: Re: opportunities of inline funtions
Date: Fri, 29 Oct 2004 14:40:29 +0600
Message-ID: <20041029144029.60a415a5.engineer@hlebprom.ru> (raw)

Hi.

 Really sorry, previous post was completely inconsistent. Actually, in addition, RULES exists. I use postgresql-7.3.5. Here the dump

---------------------------------------------------------------------
CREATE TABLE t_test (
    id integer,
    message text
);

CREATE VIEW vw_test AS
    SELECT t_test.id, t_test.message FROM t_test;

REVOKE ALL ON TABLE vw_test FROM PUBLIC;
GRANT INSERT,SELECT,UPDATE ON TABLE vw_test TO testo;

CREATE FUNCTION f_test (integer, text) RETURNS integer
    AS '/var/postgresql/f_test', 'f_test'
    LANGUAGE c;

REVOKE ALL ON FUNCTION f_test (integer, text) FROM PUBLIC;
GRANT ALL ON FUNCTION f_test (integer, text) TO testo;

CREATE RULE in_vw_test AS ON INSERT TO vw_test DO INSTEAD SELECT f_test(1, '2'::text) AS f_test;
---------------------------------------------------------------------

The source of f_test function is simple:

Datum
f_test(PG_FUNCTION_ARGS)
{
        int ret, proc;
        SPI_connect();
        ret = SPI_exec("INSERT INTO t_test VALUES ('7', 'hi')", 0);
        proc = SPI_processed;
        SPI_finish();
        return (proc);
}
---------------------------------------------------------------------

After REcheck documentation I found that
http://www.postgresql.org/docs/7.3/static/rules-permissions.html
As far as I can understand that after

CREATE RULE in_vw_test AS ON INSERT TO vw_test DO INSTEAD SELECT f_test(1, '2'::text) AS f_test;

f_test will run with permissions of creator of the RULE (superuser) , and can perform the work ("INSERT INTO t_test VALUES ('7', 'hi')").
It works when started by me (superuser):

engineer=# INSERT INTO vw_test VALUES ('1','2');
 f_test 
--------
      1
(1 row)


But all the same for 'testo' user:

engineer=> INSERT INTO vw_test VALUES ('1','2');
ERROR:  t_test: permission denied


 What's wrong? Why rules permissions (changes to owner) do not work?

-- 
engineer



view thread (2+ messages)

Message-ID: <20041029144029.60a415a5.engineer@hlebprom.ru>
Permalink:  ../20041029144029.60a415a5.engineer@hlebprom.ru/
Also on:    postgresql.org/message-id/20041029144029.60a415a5.engineer@hlebprom.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: engineer@hlebprom.ru
  Subject: Re: opportunities of inline funtions
  In-Reply-To: <20041029144029.60a415a5.engineer@hlebprom.ru>
  References: <20041029144029.60a415a5.engineer@hlebprom.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox