Re: Anonymous code blocks - Mailing list pgsql-hackers
From | Petr Jelinek |
---|---|
Subject | Re: Anonymous code blocks |
Date | |
Msg-id | 4AB9A37D.4020104@pjmodos.net Whole thread Raw |
In response to | Re: Anonymous code blocks (Tom Lane <tgl@sss.pgh.pa.us>) |
Responses |
Re: Anonymous code blocks
|
List | pgsql-hackers |
Tom Lane napsal(a): <blockquote cite="mid:7067.1253663369@sss.pgh.pa.us" type="cite"><pre wrap="">Petr Jelinek <a class="moz-txt-link-rfc2396E"href="mailto:pjmodos@pjmodos.net"><pjmodos@pjmodos.net></a> writes: </pre><blockquotetype="cite"><pre wrap=""> [ anonymous code blocks patch ] </pre></blockquote><pre wrap=""> 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. </pre></blockquote><br /> Good work as always, thanks.<br /><br /><blockquote cite="mid:7067.1253663369@sss.pgh.pa.us"type="cite"><pre wrap="">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. </pre></blockquote><br /> Aside from worse wording in my version the only differenceis the example.<br /> I used (and I am killing GRANT ON ALL patch now):<br /> <para><br /> Grant allprivileges on all VIEWs in schema <literal>public</> to role <literal>webuser</>.<br /> <programlisting><br/> DO $$DECLARE r record;<br /> BEGIN<br /> FOR r IN SELECT table_schema, table_name FROM information_schema.tables<br/> WHERE table_type = 'VIEW' AND table_schema = 'public'<br /> LOOP<br /> EXECUTE 'GRANT ALL ON ' || quote_literal(r.table_schema) || '.' || quote_literal(r.table_name) || ' TO webuser';<br/> END LOOP;<br /> END$$;<br /> </programlisting><br /> </para><br /> <br /><br /><pre class="moz-signature"cols="72">-- Regards Petr Jelinek (PJMODOS)</pre>
pgsql-hackers by date: