Re: Passing arguments to views

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Chris Campbell <chris(at)bignerdranch(dot)com>
Cc: Tino Wildenhain <tino(at)wildenhain(dot)de>, Greg Stark <gsstark(at)mit(dot)edu>,pgsql-hackers(at)postgresql(dot)org
Subject: Re: Passing arguments to views
Date: 2006-02-03 15:25:34
Views: Raw Message | Whole Thread | Download mbox
Lists: pgsql-hackers

On Fri, Feb 03, 2006 at 09:18:51AM -0500, Chris Campbell wrote:
> So you think approaching it from the "beefing up functions" side
> would be better than the "beefing up views" side?

Well yes, I think you're underestimating the issues with trying to
extend views.

> >Technically a bug. We should be tracking dependancies for functions
> >anyway.
> Well, it's impossible to track dependencies for all functions, since
> they're just strings (or compiled code in shared libraries) until


Sure, for most procedural languages you can't do much. But we do do
syntax checking already and checking that the necessary functions exist
can be considered part of that. It' s not terribly important though.

> Basically, how views do it? :) By auto-creating a table with the
> proper columns (for a function, that would be an auto-created type).
> I'm looking for a function/view hybrid, taking features from each. It
> seems to me that views have most of the features I want (only missing
> the ability to pass arguments), so it's a shorter distance to the
> goal than by starting with functions.

Ok, here's the deal. A view is nothing more than a RULE. Creating a
view does this automatically:

CREATE RULE blah AS ON SELECT TO myview DO INSTEAD <select statement>;

Now, say you wanted to add parameters to this, would you restrict it to
SELECT rules, what about UPDATE or DELETE rules?

UPDATE myview(3,4) SET ...;

The other issue is that currently you can tell from looking at a
statement whether something is a function or a table (is it followed by
an open parenthesis?). With the above change you can't anymore, which
might mean you can't have functions and tables with the same names
because they'd be ambiguous.

On the whole, I think allowing the server to inline SRFs would be a far
better way to go...

Have a nice day,
Martijn van Oosterhout <kleptog(at)svana(dot)org>
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2006-02-03 15:29:22 Re: [PATCHES] Fix for running from admin account on win32
Previous Message Mark Woodward 2006-02-03 15:23:06 Re: Multiple logical databases