AW: Non-trivial rewriting sql query

From: Zeugswetter Andreas SB <ZeugswetterA(at)wien(dot)spardat(dot)at>
To: "'Oleg Bartunov'" <oleg(at)sai(dot)msu(dot)su>
Cc: "'pgsql-hackers(at)postgresql(dot)org'" <pgsql-hackers(at)postgresql(dot)org>
Subject: AW: Non-trivial rewriting sql query
Date: 2001-06-27 09:01:38
Message-ID: 11C1E6749A55D411A9670001FA68796336834D@sdexcsrv1.f000.d0188.sd.spardat.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> Let's consider some simple example:
>
> create table tst ( a int4, b int4, c int4);
>
> select * from tst where a=2 and c=0;
>
> we need something like:
>
> select * from tst where str and c=0;
>
> where str is a string resulting by call ourfunc(table.a, 2)
> and looks like 'b=2*2 or b=(2-1)'
>
> i.e. instead of original select we need to execute rewritten select
>
> select * from tst where (b=2*2 or b=(2-1)) and c=0;

Can you give us a real life example ? For me this is too abstract to
understand.

Problem with the rewriter is, that it currently has no access to the
where restriction, and can thus only add restrictions without knowledge
of the where clause at hand. Of course you would also need to create
a view and replace the standard "on select" rule, and do your selects
on the view (unless the rewriter is extended to be invoked by a certain
where clause (here a=2) and the rewritten query does not contain this
clause).

Andreas

Browse pgsql-hackers by date

  From Date Subject
Next Message Zeugswetter Andreas SB 2001-06-27 09:04:38 AW: Re: Encrypting pg_shadow passwords
Previous Message Reinoud van Leeuwen 2001-06-27 08:56:43 Re: AW: functions returning records