From: | "Merlin Moncure" <mmoncure(at)gmail(dot)com> |
---|---|
To: | "Jeff Davis" <pgsql(at)j-davis(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: auditing in postgresql |
Date: | 2007-08-31 17:51:23 |
Message-ID: | b42b73150708311051l70c3f91mdd961c15521dd7a@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 8/31/07, Merlin Moncure <mmoncure(at)gmail(dot)com> wrote:
> On 8/31/07, Jeff Davis <pgsql(at)j-davis(dot)com> wrote:
> > On Thu, 2007-08-30 at 21:43 -0400, Merlin Moncure wrote:
> > > Well, a SRF may be unsuitable for various reasons, but maybe views are
> > > better. I really like views more and more lately (better than
> > > functions as a rule, I think).
> > >
> > > you have some query, select yadda
> > > create view log_yadda as
> > > select yadda
> > > union all select null, null, null from log_func();
> > >
> >
> > Interesting idea, I hadn't thought of that. Not perfect, but
> > interesting.
>
> create function func() returns bool as
> $$
> begin
> raise notice 'log!';
> return true;
> end;
> $$ language plpgsql;
>
> how about this:
> create view log_yadda sa
> select yadda where (select func());
>
> the parens around the function call force it to be evaluated as a scalar.
if you declare func() immutable, you can (maybe) remove the parens
because the planner folds the call to a constant. This is faster in
some cases because
select yadda where true
is slightly faster than
select yadda where (select true)
I'm not completely sure this will prevent multiple executions of func
in some cases however.
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | Madison Kelly | 2007-08-31 18:28:56 | Re: Select question |
Previous Message | Merlin Moncure | 2007-08-31 17:45:16 | Re: auditing in postgresql |