Tom Lane napsal(a):
Petr Jelinek <pjmo...@pjmodos.net> writes:
 [ anonymous code blocks patch ]

I committed this after some editorialization.  Aside from adding missing
CREATE LANGUAGE and pg_dump support, I didn't like the API for inline
handler functions.  Passing just a C string doesn't allow for any future
expansibility (eg adding parameters), and it represents a security hole
because anyone could call the function, thereby bypassing the privilege
checks.  I changed things so that the inline handlers are declared as
taking type INTERNAL, which will prevent them from being called manually
from SQL.  Also, I made the actual argument be a new Node struct type.
(I first thought of passing the DO statement's parse node as-is, but
that would require every handler to re-implement the deconstruction of
the DefElem list.  So a separate struct type seemed like a better idea.)
With this, we can add parameters or what have you without any changes
in the catalog-level representation of the languages or inline handlers.
I did some renaming too --- we generally expect that parsenodes
associated with statement types are named after the statement, for
instance.

Good work as always, thanks.

The do.sgml file was missing from both your submissions, so I cooked
up a very quick-and-dirty reference page.  It could stand to be fleshed
out a bit, probably.  If there's useful material in your original,
please submit a followon patch to add it.

Aside from worse wording in my version the only difference is the example.
I used (and I am killing GRANT ON ALL patch now):
 <para>
Grant all privileges on all VIEWs in schema <literal>public</> to role <literal>webuser</>.
<programlisting>
DO $$DECLARE r record;
BEGIN
   FOR r IN SELECT table_schema, table_name FROM information_schema.tables
            WHERE table_type = 'VIEW' AND table_schema = 'public'
   LOOP
EXECUTE 'GRANT ALL ON ' || quote_literal(r.table_schema) || '.' || quote_literal(r.table_name) || ' TO webuser';
   END LOOP;
END$$;
</programlisting>
 </para>


--
Regards
Petr Jelinek (PJMODOS)

Reply via email to