Re: why is there no TRIGGER ON SELECT ?

From: Dmitriy Igrishin <dmitigr(at)gmail(dot)com>
To: Melvin Davidson <melvin6925(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: why is there no TRIGGER ON SELECT ?
Date: 2011-02-22 13:56:18
Message-ID: AANLkTimOBVvE4yVkVqO=H0q92SFsYs80w64ZNC7_Us-C@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2011/2/22 Melvin Davidson <melvin6925(at)yahoo(dot)com>

> 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.
>
Yes, you can't. But why do you need a *trigger* function and trigger ?
Why not select via regular function ?

CREATE OR REPLACE FUNCTION public.test_select()
RETURNS TABLE(id integer, name text)
LANGUAGE sql
SECURITY DEFINER -- note here!
AS $function$
SELECT 1, 'dima' UNION ALL
SELECT 2, 'melvin'; -- just for example I use simple union query
$function$

You can revoke SELECT privileges on table and
give to some users privileges on function (to
prevent them from selecting from table directly).

> Melvin Davidson
>
>
>
>

--
// Dmitriy.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2011-02-22 14:02:55 Re: why is there no TRIGGER ON SELECT ?
Previous Message Melvin Davidson 2011-02-22 13:47:06 Re: why is there no TRIGGER ON SELECT ?