33 *
44 * Copyright 2000 by PostgreSQL Global Development Team
55 *
6- * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.13 2000/01/18 23:30:23 petere Exp $
6+ * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.14 2000/01/20 15:29:20 momjian Exp $
77 */
88#include <c.h>
99#include "describe.h"
@@ -49,10 +49,10 @@ describeAggregates(const char *name)
4949 */
5050strcpy (buf ,
5151"SELECT a.aggname AS \"Name\", t.typname AS \"Type\",\n"
52- " obj_description(a.oid) as \"Description\"\n"
53- "FROM pg_aggregate a, pg_type t\n"
54- "WHERE a.aggbasetype = t.oid\n"
55- );
52+ " obj_description(a.oid) as \"Description\"\n"
53+ "FROM pg_aggregate a, pg_type t\n"
54+ "WHERE a.aggbasetype = t.oid\n"
55+ );
5656
5757if (name )
5858{
@@ -64,10 +64,10 @@ describeAggregates(const char *name)
6464strcat (buf ,
6565"UNION\n"
6666"SELECT a.aggname AS \"Name\", '(all types)' as \"Type\",\n"
67- " obj_description(a.oid) as \"Description\"\n"
67+ " obj_description(a.oid) as \"Description\"\n"
6868"FROM pg_aggregate a\n"
69- "WHERE a.aggbasetype = 0\n"
70- );
69+ "WHERE a.aggbasetype = 0\n"
70+ );
7171
7272if (name )
7373{
@@ -107,11 +107,11 @@ describeFunctions(const char *name, bool verbose)
107107 * arguments, but have no types defined for those arguments
108108 */
109109strcpy (buf ,
110- "SELECT t.typname as \"Result\", p.proname as \"Function\",\n"
110+ "SELECT t.typname as \"Result\", p.proname as \"Function\",\n"
111111" oidvectortypes(p.proargtypes) as \"Arguments\"" );
112112if (verbose )
113113strcat (buf ,",\n u.usename as \"Owner\", l.lanname as \"Language\", p.prosrc as \"Source\",\n"
114- " obj_description(p.oid) as \"Description\"" );
114+ " obj_description(p.oid) as \"Description\"" );
115115
116116if (!verbose )
117117strcat (buf ,
@@ -159,7 +159,7 @@ describeTypes(const char *name, bool verbose)
159159
160160strcpy (buf ,"SELECT t.typname AS \"Type\"" );
161161if (verbose )
162- strcat (buf ,",\n (CASE WHEN t.typlen = -1 THEN 'var'::text ELSE t.typlen::text END) as \"Size\"" );
162+ strcat (buf ,",\n (CASE WHEN t.typlen = -1 THEN 'var'::text ELSE t.typlen::text END) as \"Size\"" );
163163strcat (buf ,",\n obj_description(t.oid) as \"Description\"" );
164164/*
165165 * do not include array types (start with underscore),
@@ -200,12 +200,12 @@ describeOperators(const char *name)
200200printQueryOpt myopt = pset .popt ;
201201
202202strcpy (buf ,
203- "SELECT o.oprname AS \"Op\",\n"
203+ "SELECT o.oprname AS \"Op\",\n"
204204" t1.typname AS \"Left arg\",\n"
205205" t2.typname AS \"Right arg\",\n"
206206" t0.typname AS \"Result\",\n"
207207" obj_description(p.oid) as \"Description\"\n"
208- "FROM pg_proc p, pg_type t0,\n"
208+ "FROM pg_proc p, pg_type t0,\n"
209209" pg_type t1, pg_type t2,\n"
210210" pg_operator o\n"
211211"WHERE p.prorettype = t0.oid AND\n"
@@ -225,8 +225,8 @@ describeOperators(const char *name)
225225" ''::name AS \"Left arg\",\n"
226226" t1.typname AS \"Right arg\",\n"
227227" t0.typname AS \"Result\",\n"
228- " obj_description(p.oid) as \"Description\"\n"
229- "FROM pg_operator o, pg_proc p, pg_type t0, pg_type t1\n"
228+ " obj_description(p.oid) as \"Description\"\n"
229+ "FROM pg_operator o, pg_proc p, pg_type t0, pg_type t1\n"
230230"WHERE RegprocToOid(o.oprcode) = p.oid AND\n"
231231" o.oprresult = t0.oid AND\n"
232232" o.oprkind = 'l' AND\n"
@@ -243,8 +243,8 @@ describeOperators(const char *name)
243243" t1.typname AS \"Left arg\",\n"
244244" ''::name AS \"Right arg\",\n"
245245" t0.typname AS \"Result\",\n"
246- " obj_description(p.oid) as \"Description\"\n"
247- "FROM pg_operator o, pg_proc p, pg_type t0, pg_type t1\n"
246+ " obj_description(p.oid) as \"Description\"\n"
247+ "FROM pg_operator o, pg_proc p, pg_type t0, pg_type t1\n"
248248"WHERE RegprocToOid(o.oprcode) = p.oid AND\n"
249249" o.oprresult = t0.oid AND\n"
250250" o.oprkind = 'r' AND\n"
@@ -284,7 +284,7 @@ listAllDbs(bool desc)
284284printQueryOpt myopt = pset .popt ;
285285
286286strcpy (buf ,
287- "SELECT pg_database.datname as \"Database\",\n"
287+ "SELECT pg_database.datname as \"Database\",\n"
288288" pg_user.usename as \"Owner\"" );
289289#ifdef MULTIBYTE
290290strcat (buf ,
@@ -299,7 +299,7 @@ listAllDbs(bool desc)
299299strcat (buf ,"\nUNION\n\n" );
300300
301301strcat (buf ,
302- "SELECT pg_database.datname as \"Database\",\n"
302+ "SELECT pg_database.datname as \"Database\",\n"
303303" NULL as \"Owner\"" );
304304#ifdef MULTIBYTE
305305strcat (buf ,
@@ -346,7 +346,7 @@ permissionsList(const char *name)
346346" relname !~ '^pg_'\n" );
347347if (name )
348348{
349- strcat (descbuf ," ANDrename ~ '" );
349+ strcat (descbuf ," ANDrelname ~ '" );
350350strncat (descbuf ,name ,REGEXP_CUTOFF );
351351strcat (descbuf ,"'\n" );
352352}
@@ -867,7 +867,7 @@ describeTableDetails(const char *name, bool desc)
867867}
868868
869869if (!error )
870- printTable (title ,headers , (const char * * )cells , (const char * * )footers ,"llll" ,& myopt ,pset .queryFout );
870+ printTable (title ,headers , (const char * * )cells , (const char * * )footers ,"llll" ,& myopt ,pset .queryFout );
871871
872872/* clean up */
873873free (title );
@@ -940,14 +940,14 @@ listTables(const char *infotype, const char *name, bool desc)
940940strcat (buf ,"'\n" );
941941}
942942
943- strcat (buf ,"UNION\n" );
943+ strcat (buf ,"UNION\n" );
944944strcat (buf ,"SELECT c.relname as \"Name\", 'table'::text as \"Type\", NULL as \"Owner\"" );
945945if (desc )
946946strcat (buf ,", obj_description(c.oid) as \"Description\"" );
947947strcat (buf ,"\nFROM pg_class c\n"
948948"WHERE c.relkind = 'r'\n"
949949" AND not exists (select 1 from pg_views where viewname = c.relname)\n"
950- " AND not exists (select 1 from pg_user where usesysid = c.relowner)\n" );
950+ " AND not exists (select 1 from pg_user where usesysid = c.relowner)\n" );
951951strcat (buf ,showSystem ?" AND c.relname ~ '^pg_'\n" :" AND c.relname !~ '^pg_'\n" );
952952if (name )
953953{
@@ -977,14 +977,14 @@ listTables(const char *infotype, const char *name, bool desc)
977977strcat (buf ,"'\n" );
978978}
979979
980- strcat (buf ,"UNION\n" );
980+ strcat (buf ,"UNION\n" );
981981strcat (buf ,"SELECT c.relname as \"Name\", 'view'::text as \"Type\", NULL as \"Owner\"" );
982982if (desc )
983983strcat (buf ,", obj_description(c.oid) as \"Description\"" );
984984strcat (buf ,"\nFROM pg_class c\n"
985985"WHERE c.relkind = 'r'\n"
986986" AND exists (select 1 from pg_views where viewname = c.relname)\n"
987- " AND not exists (select 1 from pg_user where usesysid = c.relowner)\n" );
987+ " AND not exists (select 1 from pg_user where usesysid = c.relowner)\n" );
988988strcat (buf ,showSystem ?" AND c.relname ~ '^pg_'\n" :" AND c.relname !~ '^pg_'\n" );
989989if (name )
990990{
@@ -1029,7 +1029,7 @@ listTables(const char *infotype, const char *name, bool desc)
10291029strcat (buf ,"'\n" );
10301030}
10311031
1032- strcat (buf ,"UNION\n" );
1032+ strcat (buf ,"UNION\n" );
10331033strcat (buf ,
10341034"SELECT c.relname as \"Name\",\n"
10351035" (CASE WHEN relkind = 'S' THEN 'sequence'::text ELSE 'index'::text END) as \"Type\",\n"
@@ -1078,13 +1078,13 @@ listTables(const char *infotype, const char *name, bool desc)
10781078strcat (buf ,"'\n" );
10791079}
10801080
1081- strcat (buf ,"UNION\n" );
1081+ strcat (buf ,"UNION\n" );
10821082strcat (buf ,"SELECT c.relname as \"Name\", 'special'::text as \"Type\", NULL as \"Owner\"" );
10831083if (desc )
10841084strcat (buf ,", obj_description(c.oid) as \"Description\"" );
10851085strcat (buf ,"\nFROM pg_class c\n"
10861086"WHERE c.relkind = 's'\n"
1087- " AND not exists (select 1 from pg_user where usesysid = c.relowner)" );
1087+ " AND not exists (select 1 from pg_user where usesysid = c.relowner)" );
10881088if (name )
10891089{
10901090strcat (buf ," AND c.relname ~ '" );
@@ -1102,10 +1102,10 @@ listTables(const char *infotype, const char *name, bool desc)
11021102
11031103if (PQntuples (res )== 0 && !QUIET ())
11041104 {
1105- if (name )
1106- fprintf (pset .queryFout ,"No matching relations found.\n" );
1107- else
1108- fprintf (pset .queryFout ,"No relations found.\n" );
1105+ if (name )
1106+ fprintf (pset .queryFout ,"No matching relations found.\n" );
1107+ else
1108+ fprintf (pset .queryFout ,"No relations found.\n" );
11091109 }
11101110else
11111111{