From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | ed despard <despareg(at)clarkson(dot)edu>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: rules question |
Date: | 2003-04-30 09:26:51 |
Message-ID: | 200304301026.51897.dev@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-sql |
On Wednesday 30 Apr 2003 5:00 am, ed despard wrote:
> hi, i have a table named pursuit which has no data in it, currently to
> get data for the table i have a function that i call like: select *
> from pursuit_select_function(raceid), but i put in the raceid that im
> selecting for. i would like to be able to treat this table like a view
> and make a query like select * from pursuit where raceid=9 or somthing
> and have a rule rewrite this into the function call. is there a way to
> have a rule that rewrites the query based on the qualifier of the query?
I think you're out of luck here.
For "where raceid=9" it's easy enough - just call "function(9)".
What if someone uses "where raceid in (7,8,9)" - does the planner write that
as "function(7) or function (8) or function(9)" and how does that interact
with your side-effects?
> the reason im not just using a normal view is that i have a sequence
> that needs to be reset before each select, so the
> pursuit_select_function resets the sequence and does the select query.
I was thinking you could create a rule with multiple queries for the action,
but unfortunately that's not supported for ON SELECT rules (according to my
docs). If it was, you could reset the sequence as the first query, then do
your processing for the second.
I take it you're using the sequence to number output rows?
--
Richard Huxton
From | Date | Subject | |
---|---|---|---|
Next Message | David Goodenough | 2003-04-30 10:55:10 | pg_dumpall -g problem |
Previous Message | Jim C. Nasby | 2003-04-30 07:41:43 | Re: Optimizer not using index on 120M row table |
From | Date | Subject | |
---|---|---|---|
Next Message | SZŰCS Gábor | 2003-04-30 11:00:40 | Re: Query Plan far worse in 7.3.2 than 7.2.1 |
Previous Message | Stephan Szabo | 2003-04-30 04:55:24 | Re: Making "SECURITY DEFINER" procedures.. - SOLVED |