Re: why is there no TRIGGER ON SELECT ?

Поиск
Список
Период
Сортировка
От David Johnston
Тема Re: why is there no TRIGGER ON SELECT ?
Дата
Msg-id 009101cbd299$3495e8a0$9dc1b9e0$@yahoo.com
обсуждение исходный текст
Ответ на Re: why is there no TRIGGER ON SELECT ?  (Melvin Davidson <melvin6925@yahoo.com>)
Ответы Re: why is there no TRIGGER ON SELECT ?  (Melvin Davidson <melvin6925@yahoo.com>)
Список pgsql-general

Melvin:  The proposal is to do something of the form

 

SELECT * FROM selecting_function()

 

And have selecting_function() perform any necessary auditing.

 

I guess this work fairly well – as long as you remember to remove “SELECT” privileges on the wrapped table from everyone and setup SECURITY DEFINER on the function itself.

 

For a normal “SELECT FROM table WHERE” construct the query planner is able to use indexes on “table” based upon the where clause.  If you do “SELECT FROM func() WHERE” does the entire table always get scanned/returned or are indexes applied in this case as well?  These (performance concerns) are the main reason that using a wrapping function is not intuitive.  It would also require a slightly different paradigm for the end-user and would require rewriting to make it work in an existing system that was directly accessing tables before (I assume if access is being done via VIEWs that incorporating the function calls into the views would work just fine).

 

David J

 

 

 

From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Melvin Davidson
Sent: Tuesday, February 22, 2011 8:47 AM
To: Dmitriy Igrishin
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] why is there no TRIGGER ON SELECT ?

 

Dmitriy

>Why not use function which returns table and wrap the
>logging (auditing) code in it ?

Because to use a trigger function, you need a trigger, and as previously stated, you cannot have a trigger on select. The same applies for a rule.

Melvin Davidson

 

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

Предыдущее
От: Dmitriy Igrishin
Дата:
Сообщение: Re: why is there no TRIGGER ON SELECT ?
Следующее
От: "Jaiswal Dhaval Sudhirkumar"
Дата:
Сообщение: Re: Mysql to Postgresql