3
3
*
4
4
* Copyright 2000 by PostgreSQL Global Development Team
5
5
*
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 $
7
7
*/
8
8
#include <c.h>
9
9
#include "describe.h"
@@ -49,10 +49,10 @@ describeAggregates(const char *name)
49
49
*/
50
50
strcpy (buf ,
51
51
"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
+ );
56
56
57
57
if (name )
58
58
{
@@ -64,10 +64,10 @@ describeAggregates(const char *name)
64
64
strcat (buf ,
65
65
"UNION\n"
66
66
"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"
68
68
"FROM pg_aggregate a\n"
69
- "WHERE a.aggbasetype = 0\n"
70
- );
69
+ "WHERE a.aggbasetype = 0\n"
70
+ );
71
71
72
72
if (name )
73
73
{
@@ -107,11 +107,11 @@ describeFunctions(const char *name, bool verbose)
107
107
* arguments, but have no types defined for those arguments
108
108
*/
109
109
strcpy (buf ,
110
- "SELECT t.typname as \"Result\", p.proname as \"Function\",\n"
110
+ "SELECT t.typname as \"Result\", p.proname as \"Function\",\n"
111
111
" oidvectortypes(p.proargtypes) as \"Arguments\"" );
112
112
if (verbose )
113
113
strcat (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\"" );
115
115
116
116
if (!verbose )
117
117
strcat (buf ,
@@ -159,7 +159,7 @@ describeTypes(const char *name, bool verbose)
159
159
160
160
strcpy (buf ,"SELECT t.typname AS \"Type\"" );
161
161
if (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\"" );
163
163
strcat (buf ,",\n obj_description(t.oid) as \"Description\"" );
164
164
/*
165
165
* do not include array types (start with underscore),
@@ -200,12 +200,12 @@ describeOperators(const char *name)
200
200
printQueryOpt myopt = pset .popt ;
201
201
202
202
strcpy (buf ,
203
- "SELECT o.oprname AS \"Op\",\n"
203
+ "SELECT o.oprname AS \"Op\",\n"
204
204
" t1.typname AS \"Left arg\",\n"
205
205
" t2.typname AS \"Right arg\",\n"
206
206
" t0.typname AS \"Result\",\n"
207
207
" 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"
209
209
" pg_type t1, pg_type t2,\n"
210
210
" pg_operator o\n"
211
211
"WHERE p.prorettype = t0.oid AND\n"
@@ -225,8 +225,8 @@ describeOperators(const char *name)
225
225
" ''::name AS \"Left arg\",\n"
226
226
" t1.typname AS \"Right arg\",\n"
227
227
" 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"
230
230
"WHERE RegprocToOid(o.oprcode) = p.oid AND\n"
231
231
" o.oprresult = t0.oid AND\n"
232
232
" o.oprkind = 'l' AND\n"
@@ -243,8 +243,8 @@ describeOperators(const char *name)
243
243
" t1.typname AS \"Left arg\",\n"
244
244
" ''::name AS \"Right arg\",\n"
245
245
" 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"
248
248
"WHERE RegprocToOid(o.oprcode) = p.oid AND\n"
249
249
" o.oprresult = t0.oid AND\n"
250
250
" o.oprkind = 'r' AND\n"
@@ -284,7 +284,7 @@ listAllDbs(bool desc)
284
284
printQueryOpt myopt = pset .popt ;
285
285
286
286
strcpy (buf ,
287
- "SELECT pg_database.datname as \"Database\",\n"
287
+ "SELECT pg_database.datname as \"Database\",\n"
288
288
" pg_user.usename as \"Owner\"" );
289
289
#ifdef MULTIBYTE
290
290
strcat (buf ,
@@ -299,7 +299,7 @@ listAllDbs(bool desc)
299
299
strcat (buf ,"\nUNION\n\n" );
300
300
301
301
strcat (buf ,
302
- "SELECT pg_database.datname as \"Database\",\n"
302
+ "SELECT pg_database.datname as \"Database\",\n"
303
303
" NULL as \"Owner\"" );
304
304
#ifdef MULTIBYTE
305
305
strcat (buf ,
@@ -346,7 +346,7 @@ permissionsList(const char *name)
346
346
" relname !~ '^pg_'\n" );
347
347
if (name )
348
348
{
349
- strcat (descbuf ," ANDrename ~ '" );
349
+ strcat (descbuf ," ANDrelname ~ '" );
350
350
strncat (descbuf ,name ,REGEXP_CUTOFF );
351
351
strcat (descbuf ,"'\n" );
352
352
}
@@ -867,7 +867,7 @@ describeTableDetails(const char *name, bool desc)
867
867
}
868
868
869
869
if (!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 );
871
871
872
872
/* clean up */
873
873
free (title );
@@ -940,14 +940,14 @@ listTables(const char *infotype, const char *name, bool desc)
940
940
strcat (buf ,"'\n" );
941
941
}
942
942
943
- strcat (buf ,"UNION\n" );
943
+ strcat (buf ,"UNION\n" );
944
944
strcat (buf ,"SELECT c.relname as \"Name\", 'table'::text as \"Type\", NULL as \"Owner\"" );
945
945
if (desc )
946
946
strcat (buf ,", obj_description(c.oid) as \"Description\"" );
947
947
strcat (buf ,"\nFROM pg_class c\n"
948
948
"WHERE c.relkind = 'r'\n"
949
949
" 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" );
951
951
strcat (buf ,showSystem ?" AND c.relname ~ '^pg_'\n" :" AND c.relname !~ '^pg_'\n" );
952
952
if (name )
953
953
{
@@ -977,14 +977,14 @@ listTables(const char *infotype, const char *name, bool desc)
977
977
strcat (buf ,"'\n" );
978
978
}
979
979
980
- strcat (buf ,"UNION\n" );
980
+ strcat (buf ,"UNION\n" );
981
981
strcat (buf ,"SELECT c.relname as \"Name\", 'view'::text as \"Type\", NULL as \"Owner\"" );
982
982
if (desc )
983
983
strcat (buf ,", obj_description(c.oid) as \"Description\"" );
984
984
strcat (buf ,"\nFROM pg_class c\n"
985
985
"WHERE c.relkind = 'r'\n"
986
986
" 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" );
988
988
strcat (buf ,showSystem ?" AND c.relname ~ '^pg_'\n" :" AND c.relname !~ '^pg_'\n" );
989
989
if (name )
990
990
{
@@ -1029,7 +1029,7 @@ listTables(const char *infotype, const char *name, bool desc)
1029
1029
strcat (buf ,"'\n" );
1030
1030
}
1031
1031
1032
- strcat (buf ,"UNION\n" );
1032
+ strcat (buf ,"UNION\n" );
1033
1033
strcat (buf ,
1034
1034
"SELECT c.relname as \"Name\",\n"
1035
1035
" (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)
1078
1078
strcat (buf ,"'\n" );
1079
1079
}
1080
1080
1081
- strcat (buf ,"UNION\n" );
1081
+ strcat (buf ,"UNION\n" );
1082
1082
strcat (buf ,"SELECT c.relname as \"Name\", 'special'::text as \"Type\", NULL as \"Owner\"" );
1083
1083
if (desc )
1084
1084
strcat (buf ,", obj_description(c.oid) as \"Description\"" );
1085
1085
strcat (buf ,"\nFROM pg_class c\n"
1086
1086
"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)" );
1088
1088
if (name )
1089
1089
{
1090
1090
strcat (buf ," AND c.relname ~ '" );
@@ -1102,10 +1102,10 @@ listTables(const char *infotype, const char *name, bool desc)
1102
1102
1103
1103
if (PQntuples (res )== 0 && !QUIET ())
1104
1104
{
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" );
1109
1109
}
1110
1110
else
1111
1111
{