AW: Non-trivial rewriting sql query - Mailing list pgsql-hackers

From Zeugswetter Andreas SB
Subject AW: Non-trivial rewriting sql query
Date
Msg-id 11C1E6749A55D411A9670001FA68796336834D@sdexcsrv1.f000.d0188.sd.spardat.at
Whole thread Raw
List 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


pgsql-hackers by date:

Previous
From: "Reinoud van Leeuwen"
Date:
Subject: Re: AW: functions returning records
Next
From: Zeugswetter Andreas SB
Date:
Subject: AW: Re: Encrypting pg_shadow passwords