Re: SHOW TABLES - Mailing list pgsql-hackers

From Dimitri Fontaine
Subject Re: SHOW TABLES
Date
Msg-id E5167757-94BD-4AEC-BA3E-C7728BDA1F11@hi-media.com
Whole thread Raw
In response to Re: SHOW TABLES  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: SHOW TABLES
Re: SHOW TABLES
Re: SHOW TABLES
List pgsql-hackers
Hi,

Le 18 juil. 2010 à 05:41, Robert Haas a écrit :
> On Sat, Jul 17, 2010 at 11:14 PM, Bruce Momjian <bruce@momjian.us> wrote:
>> I am concerned that implementing a command syntax to show complex output
>> like above effectively means re-implementing a subset of SQL, and that
>> subset will never be as flexible.
>
> That's a reasonable concern, but I don't have a better idea.  Do you?

I think that SHOW could be some syntax sugar atop the current rewrite rules system. I mean it would be implemented by
meansof "parametrized" views. It could be that SQL only SRFs could do a better job at it. In both cases the idea is
thatwe should be able to write SELECT like statements. 

SHOW TABLE foo;

SHOW TABLES WHERE tablename ~ 'foo';

SHOW ANY TABLE
GROUP BY tablename  HAVING array_agg(attributes) @> array['date'::regtype, 'time'::regtype];

The last one has an "english like" trick using ANY rather than ALL, but that's just for the bikesheding of it, and
wouldlist all tables with both a date and a time column. The trick is there because if you want the attributes to show
upyou're after enhancing the SHOW TABLE query, not the SHOW TABLES one. 

So what we'd need first is a series of named queries, which I think psql provides for. Then some technique to have them
availableboth as plain and easy usage and in full SQL. I think the rewrite system is meant to allow that, I'm not sure
ifusing views or pure SQL SRFs is better, in both cases the rewritten query has to provide arguments "placeholders": if
aVIEW, that's a WHERE clause, if a SRF, any number of named arguments. 

Regards,
--
Dimitri Fontaine
PostgreSQL DBA, Architecte







pgsql-hackers by date:

Previous
From: David Christensen
Date:
Subject: psql \conninfo command (was: Patch: psql \whoami option)
Next
From: "Kevin Grittner"
Date:
Subject: Re: Review: Row-level Locks & SERIALIZABLE transactions, postgres vs. Oracle