Re: Prep object creation hooks, and related sepgsql updates

Поиск
Список
Период
Сортировка
От Dimitri Fontaine
Тема Re: Prep object creation hooks, and related sepgsql updates
Дата
Msg-id m2fwh8uh4b.fsf@2ndQuadrant.fr
обсуждение исходный текст
Ответ на Re: Prep object creation hooks, and related sepgsql updates  (Kohei KaiGai <kaigai@kaigai.gr.jp>)
Ответы Re: Prep object creation hooks, and related sepgsql updates  (Kohei KaiGai <kaigai@kaigai.gr.jp>)
Список pgsql-hackers
Kohei KaiGai <kaigai@kaigai.gr.jp> writes:
> I found up a similar idea that acquires control on ProcessUtility_hook and
> save necessary contextual information on auto variable then kicks the
> original ProcessUtility_hook, then it reference the contextual information
> from object_access_hook.

In this case that would be an INSTEAD OF trigger, from which you can
call the original command with EXECUTE. You just have to protect
yourself against infinite recursion, but that's doable. See attached
example.

> For example, we don't want to apply permission checks on new relations
> constructed with make_new_heap. It shall be invoked when CLUSTER,
> VACUUM or ALTER TABLE, so we can skip permission checks when
> the saved command tag indicates these commands are currently running.

CREATE TRIGGER se_permission_checks
    INSTEAD OF COMMAND ALTER TABLE
       EXECUTE PROCEDURE se_permission_checks_alter_table();

In this INSTEAD OF trigger, protect against recursion, EXECUTE the
original ALTER TABLE statement which is given to you as a parameter,
enable the command trigger again.

Regards,
--
Dimitri Fontaine
http://2ndQuadrant.fr     PostgreSQL : Expertise, Formation et Support


Вложения

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

Предыдущее
От: Merlin Moncure
Дата:
Сообщение: Re: patch for type privileges
Следующее
От: Stefan Keller
Дата:
Сообщение: Re: odbc_fdw