X-Original-To: pgsql-general@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2A64A475458 for ; Wed, 30 Apr 2003 05:26:26 -0400 (EDT) Received: from anchor-post-34.mail.demon.net (anchor-post-34.mail.demon.net [194.217.242.92]) by postgresql.org (Postfix) with ESMTP id 0A983474E42 for ; Wed, 30 Apr 2003 05:26:25 -0400 (EDT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-34.mail.demon.net with esmtp (Exim 3.35 #1) id 19Anr7-000ItX-0Y; Wed, 30 Apr 2003 10:26:26 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 89E6316AEE; Wed, 30 Apr 2003 10:26:24 +0100 (BST) Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id E3ED515936; Wed, 30 Apr 2003 10:26:23 +0100 (BST) Content-Type: text/plain; charset="iso-8859-1" From: Richard Huxton Organization: Archonet Ltd To: ed despard , pgsql-general@postgresql.org Subject: Re: rules question Date: Wed, 30 Apr 2003 10:26:51 +0100 User-Agent: KMail/1.4.3 References: <55369696-7AC0-11D7-B730-0003938ABE54@clarkson.edu> In-Reply-To: <55369696-7AC0-11D7-B730-0003938ABE54@clarkson.edu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304301026.51897.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Spam-Status: No, hits=-38.9 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/1563 X-Sequence-Number: 41628 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=3D9 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=3D9" it's easy enough - just call "function(9)". What if someone uses "where raceid in (7,8,9)" - does the planner write tha= t=20 as "function(7) or function (8) or function(9)" and how does that interact= =20 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= ,=20 but unfortunately that's not supported for ON SELECT rules (according to my= =20 docs). If it was, you could reset the sequence as the first query, then do= =20 your processing for the second. I take it you're using the sequence to number output rows? --=20 Richard Huxton