From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Tricky query, tricky response |
Date: | 1999-10-01 01:03:46 |
Message-ID: | Pine.LNX.4.10.9910010253310.625-100000@peter-e.yi.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
As you might recognize, this is supposed to be a psql \d imitation in one
shot:
SELECT usename as "Owner", relname as "Relation",
(CASE WHEN relkind='r' THEN
(CASE WHEN 0<(select count(*) from pg_views where viewname = relname)
THEN 'view' ELSE 'table' END)
WHEN relkind='i' THEN 'index'
WHEN relkind='S' THEN 'sequence'
ELSE 'other'
END) as "Type"
FROM pg_class, pg_user
WHERE usesysid = relowner AND
( relkind = 'r' OR
relkind = 'i' OR
relkind = 'S') AND
relname !~ '^pg_' AND
(relkind != 'i' OR relname !~ '^xinx') ORDER BY relname;
ERROR: flatten_tlistentry: Cannot handle node type 108
However, if you do
- (CASE WHEN 0<(select count(*) from pg_views where viewname = relname)
- THEN 'view' ELSE 'table' END)
+ 'relation'
if works fine. No nested CASE's?
PostgreSQL 6.5.2 on i586-pc-linux-gnu, compiled by egcs
--
Peter Eisentraut - peter_e(at)gmx(dot)net
http://yi.org/peter-e
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Lockhart | 1999-10-01 02:57:06 | Re: TO_CHAR() |
Previous Message | Peter Eisentraut | 1999-10-01 00:49:03 | Re: [HACKERS] postmaster dead on startup from unportable SSL patch |