64
64
printfPQExpBuffer(&buf,
65
65
"SELECT n.nspname as \"%s\",\n"
66
66
" p.proname AS \"%s\",\n"
67
" pg_catalog.format_type(p.prorettype, NULL) AS \"%s\",\n",
67
" pg_catalog.format_type(p.prorettype, NULL) AS \"%s\",\n",
68
68
gettext_noop("Schema"),
69
69
gettext_noop("Name"),
70
70
gettext_noop("Result data type"));
72
72
if (pset.sversion >= 80200)
73
appendPQExpBuffer(&buf,
74
" CASE WHEN p.pronargs = 0\n"
75
" THEN CAST('*' AS pg_catalog.text)\n"
77
" pg_catalog.array_to_string(ARRAY(\n"
79
" pg_catalog.format_type(p.proargtypes[s.i], NULL)\n"
81
" pg_catalog.generate_series(0, pg_catalog.array_upper(p.proargtypes, 1)) AS s(i)\n"
84
gettext_noop("Argument data types"));
73
appendPQExpBuffer(&buf,
74
" CASE WHEN p.pronargs = 0\n"
75
" THEN CAST('*' AS pg_catalog.text)\n"
77
" pg_catalog.array_to_string(ARRAY(\n"
79
" pg_catalog.format_type(p.proargtypes[s.i], NULL)\n"
81
" pg_catalog.generate_series(0, pg_catalog.array_upper(p.proargtypes, 1)) AS s(i)\n"
84
gettext_noop("Argument data types"));
86
appendPQExpBuffer(&buf,
87
" pg_catalog.format_type(p.proargtypes[0], NULL) AS \"%s\",\n",
88
gettext_noop("Argument data types"));
86
appendPQExpBuffer(&buf,
87
" pg_catalog.format_type(p.proargtypes[0], NULL) AS \"%s\",\n",
88
gettext_noop("Argument data types"));
90
90
appendPQExpBuffer(&buf,
91
91
" pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n"
94
94
"WHERE p.proisagg\n",
95
95
gettext_noop("Description"));
97
if (!showSystem && !pattern)
98
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
99
" AND n.nspname <> 'information_schema'\n");
97
if (!showSystem && !pattern)
98
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
99
" AND n.nspname <> 'information_schema'\n");
101
101
processSQLNamePattern(pset.db, &buf, pattern, true, false,
102
102
"n.nspname", "p.proname", NULL,
248
248
gettext_noop("Result data type"),
249
gettext_noop("Argument data types"),
250
/* translator: "agg" is short for "aggregate" */
252
gettext_noop("window"),
253
gettext_noop("trigger"),
254
gettext_noop("normal"),
255
gettext_noop("Type"));
256
else if (pset.sversion >= 80100)
249
gettext_noop("Argument data types"),
250
/* translator: "agg" is short for "aggregate" */
252
gettext_noop("window"),
253
gettext_noop("trigger"),
254
gettext_noop("normal"),
255
gettext_noop("Type"));
256
else if (pset.sversion >= 80100)
257
257
appendPQExpBuffer(&buf,
258
" CASE WHEN p.proretset THEN 'SETOF ' ELSE '' END ||\n"
258
" CASE WHEN p.proretset THEN 'SETOF ' ELSE '' END ||\n"
259
259
" pg_catalog.format_type(p.prorettype, NULL) as \"%s\",\n"
260
" CASE WHEN proallargtypes IS NOT NULL THEN\n"
261
" pg_catalog.array_to_string(ARRAY(\n"
264
" WHEN p.proargmodes[s.i] = 'i' THEN ''\n"
260
" CASE WHEN proallargtypes IS NOT NULL THEN\n"
261
" pg_catalog.array_to_string(ARRAY(\n"
264
" WHEN p.proargmodes[s.i] = 'i' THEN ''\n"
265
265
" WHEN p.proargmodes[s.i] = 'o' THEN 'OUT '\n"
266
" WHEN p.proargmodes[s.i] = 'b' THEN 'INOUT '\n"
267
" WHEN p.proargmodes[s.i] = 'v' THEN 'VARIADIC '\n"
266
" WHEN p.proargmodes[s.i] = 'b' THEN 'INOUT '\n"
267
" WHEN p.proargmodes[s.i] = 'v' THEN 'VARIADIC '\n"
270
270
" WHEN COALESCE(p.proargnames[s.i], '') = '' THEN ''\n"
271
" ELSE p.proargnames[s.i] || ' ' \n"
271
" ELSE p.proargnames[s.i] || ' ' \n"
273
273
" pg_catalog.format_type(p.proallargtypes[s.i], NULL)\n"
275
" pg_catalog.generate_series(1, pg_catalog.array_upper(p.proallargtypes, 1)) AS s(i)\n"
278
" pg_catalog.array_to_string(ARRAY(\n"
275
" pg_catalog.generate_series(1, pg_catalog.array_upper(p.proallargtypes, 1)) AS s(i)\n"
278
" pg_catalog.array_to_string(ARRAY(\n"
281
281
" WHEN COALESCE(p.proargnames[s.i+1], '') = '' THEN ''\n"
282
" ELSE p.proargnames[s.i+1] || ' '\n"
282
" ELSE p.proargnames[s.i+1] || ' '\n"
284
284
" pg_catalog.format_type(p.proargtypes[s.i], NULL)\n"
286
" pg_catalog.generate_series(0, pg_catalog.array_upper(p.proargtypes, 1)) AS s(i)\n"
290
" WHEN p.proisagg THEN '%s'\n"
291
" WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN '%s'\n"
286
" pg_catalog.generate_series(0, pg_catalog.array_upper(p.proargtypes, 1)) AS s(i)\n"
290
" WHEN p.proisagg THEN '%s'\n"
291
" WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN '%s'\n"
294
294
gettext_noop("Result data type"),
295
295
gettext_noop("Argument data types"),
296
/* translator: "agg" is short for "aggregate" */
296
/* translator: "agg" is short for "aggregate" */
297
297
gettext_noop("agg"),
298
298
gettext_noop("trigger"),
299
299
gettext_noop("normal"),
300
300
gettext_noop("Type"));
302
302
appendPQExpBuffer(&buf,
303
" CASE WHEN p.proretset THEN 'SETOF ' ELSE '' END ||\n"
303
" CASE WHEN p.proretset THEN 'SETOF ' ELSE '' END ||\n"
304
304
" pg_catalog.format_type(p.prorettype, NULL) as \"%s\",\n"
305
" pg_catalog.oidvectortypes(p.proargtypes) as \"%s\",\n"
307
" WHEN p.proisagg THEN '%s'\n"
308
" WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN '%s'\n"
305
" pg_catalog.oidvectortypes(p.proargtypes) as \"%s\",\n"
307
" WHEN p.proisagg THEN '%s'\n"
308
" WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN '%s'\n"
311
311
gettext_noop("Result data type"),
312
312
gettext_noop("Argument data types"),
313
/* translator: "agg" is short for "aggregate" */
313
/* translator: "agg" is short for "aggregate" */
314
314
gettext_noop("agg"),
315
315
gettext_noop("trigger"),
316
316
gettext_noop("normal"),
419
419
"n.nspname", "p.proname", NULL,
420
420
"pg_catalog.pg_function_is_visible(p.oid)");
422
if (!showSystem && !pattern)
423
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
424
" AND n.nspname <> 'information_schema'\n");
422
if (!showSystem && !pattern)
423
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
424
" AND n.nspname <> 'information_schema'\n");
426
426
appendPQExpBuffer(&buf, "ORDER BY 1, 2, 4;");
509
510
appendPQExpBuffer(&buf, " AND t.typname !~ '^_'\n");
511
if (!showSystem && !pattern)
512
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
513
" AND n.nspname <> 'information_schema'\n");
512
if (!showSystem && !pattern)
513
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
514
" AND n.nspname <> 'information_schema'\n");
515
516
/* Match name pattern against either internal or external name */
516
517
processSQLNamePattern(pset.db, &buf, pattern, true, false,
564
565
gettext_noop("Result type"),
565
566
gettext_noop("Description"));
567
if (!showSystem && !pattern)
568
appendPQExpBuffer(&buf, "WHERE n.nspname <> 'pg_catalog'\n"
569
" AND n.nspname <> 'information_schema'\n");
568
if (!showSystem && !pattern)
569
appendPQExpBuffer(&buf, "WHERE n.nspname <> 'pg_catalog'\n"
570
" AND n.nspname <> 'information_schema'\n");
571
572
processSQLNamePattern(pset.db, &buf, pattern, !showSystem && !pattern, true,
572
573
"n.nspname", "o.oprname", NULL,
769
770
" WHERE p.proisagg\n",
770
771
gettext_noop("aggregate"));
772
if (!showSystem && !pattern)
773
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
774
" AND n.nspname <> 'information_schema'\n");
773
if (!showSystem && !pattern)
774
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
775
" AND n.nspname <> 'information_schema'\n");
776
777
processSQLNamePattern(pset.db, &buf, pattern, true, false,
777
778
"n.nspname", "p.proname", NULL,
789
790
" WHERE NOT p.proisagg\n",
790
791
gettext_noop("function"));
792
if (!showSystem && !pattern)
793
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
794
" AND n.nspname <> 'information_schema'\n");
793
if (!showSystem && !pattern)
794
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
795
" AND n.nspname <> 'information_schema'\n");
796
797
processSQLNamePattern(pset.db, &buf, pattern, true, false,
797
798
"n.nspname", "p.proname", NULL,
808
809
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = o.oprnamespace\n",
809
810
gettext_noop("operator"));
811
if (!showSystem && !pattern)
812
appendPQExpBuffer(&buf, "WHERE n.nspname <> 'pg_catalog'\n"
813
" AND n.nspname <> 'information_schema'\n");
812
if (!showSystem && !pattern)
813
appendPQExpBuffer(&buf, "WHERE n.nspname <> 'pg_catalog'\n"
814
" AND n.nspname <> 'information_schema'\n");
815
816
processSQLNamePattern(pset.db, &buf, pattern, !showSystem && !pattern, false,
816
817
"n.nspname", "o.oprname", NULL,
817
818
"pg_catalog.pg_operator_is_visible(o.oid)");
827
828
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n",
828
829
gettext_noop("data type"));
830
if (!showSystem && !pattern)
831
appendPQExpBuffer(&buf, "WHERE n.nspname <> 'pg_catalog'\n"
832
" AND n.nspname <> 'information_schema'\n");
831
if (!showSystem && !pattern)
832
appendPQExpBuffer(&buf, "WHERE n.nspname <> 'pg_catalog'\n"
833
" AND n.nspname <> 'information_schema'\n");
834
835
processSQLNamePattern(pset.db, &buf, pattern, !showSystem && !pattern, false,
835
836
"n.nspname", "pg_catalog.format_type(t.oid, NULL)",
853
854
gettext_noop("index"),
854
855
gettext_noop("sequence"));
856
if (!showSystem && !pattern)
857
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
858
" AND n.nspname <> 'information_schema'\n");
857
if (!showSystem && !pattern)
858
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
859
" AND n.nspname <> 'information_schema'\n");
860
861
processSQLNamePattern(pset.db, &buf, pattern, true, false,
861
862
"n.nspname", "c.relname", NULL,
874
875
" WHERE r.rulename != '_RETURN'\n",
875
876
gettext_noop("rule"));
877
if (!showSystem && !pattern)
878
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
879
" AND n.nspname <> 'information_schema'\n");
878
if (!showSystem && !pattern)
879
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
880
" AND n.nspname <> 'information_schema'\n");
881
882
/* XXX not sure what to do about visibility rule here? */
882
883
processSQLNamePattern(pset.db, &buf, pattern, true, false,
895
896
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n",
896
897
gettext_noop("trigger"));
898
if (!showSystem && !pattern)
899
appendPQExpBuffer(&buf, "WHERE n.nspname <> 'pg_catalog'\n"
900
" AND n.nspname <> 'information_schema'\n");
899
if (!showSystem && !pattern)
900
appendPQExpBuffer(&buf, "WHERE n.nspname <> 'pg_catalog'\n"
901
" AND n.nspname <> 'information_schema'\n");
902
903
/* XXX not sure what to do about visibility rule here? */
903
904
processSQLNamePattern(pset.db, &buf, pattern, !showSystem && !pattern, false,
951
952
"FROM pg_catalog.pg_class c\n"
952
953
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n");
954
if (!showSystem && !pattern)
955
appendPQExpBuffer(&buf, "WHERE n.nspname <> 'pg_catalog'\n"
956
" AND n.nspname <> 'information_schema'\n");
955
if (!showSystem && !pattern)
956
appendPQExpBuffer(&buf, "WHERE n.nspname <> 'pg_catalog'\n"
957
" AND n.nspname <> 'information_schema'\n");
958
959
processSQLNamePattern(pset.db, &buf, pattern, !showSystem && !pattern, false,
959
960
"n.nspname", "c.relname", NULL,
1056
1057
if (pset.sversion >= 80400)
1058
1059
printfPQExpBuffer(&buf,
1059
"SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
1060
"SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, "
1060
1061
"c.relhastriggers, c.relhasoids, "
1061
1062
"%s, c.reltablespace\n"
1062
1063
"FROM pg_catalog.pg_class c\n "
1063
"LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
1064
"LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n"
1064
1065
"WHERE c.oid = '%s'\n",
1066
"pg_catalog.array_to_string(c.reloptions || "
1067
"array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
1067
"pg_catalog.array_to_string(c.reloptions || "
1068
"array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
1071
1072
else if (pset.sversion >= 80200)
1073
1074
printfPQExpBuffer(&buf,
1074
"SELECT relchecks, relkind, relhasindex, relhasrules, "
1075
"SELECT relchecks, relkind, relhasindex, relhasrules, "
1075
1076
"reltriggers <> 0, relhasoids, "
1076
1077
"%s, reltablespace\n"
1077
1078
"FROM pg_catalog.pg_class WHERE oid = '%s'",
1079
"pg_catalog.array_to_string(reloptions, E', ')" : "''"),
1080
"pg_catalog.array_to_string(reloptions, E', ')" : "''"),
1082
1083
else if (pset.sversion >= 80000)
1084
1085
printfPQExpBuffer(&buf,
1085
"SELECT relchecks, relkind, relhasindex, relhasrules, "
1086
"SELECT relchecks, relkind, relhasindex, relhasrules, "
1086
1087
"reltriggers <> 0, relhasoids, "
1087
1088
"'', reltablespace\n"
1088
1089
"FROM pg_catalog.pg_class WHERE oid = '%s'",
1118
1119
tableinfo.hastriggers = strcmp(PQgetvalue(res, 0, 4), "t") == 0;
1119
1120
tableinfo.hasoids = strcmp(PQgetvalue(res, 0, 5), "t") == 0;
1120
1121
tableinfo.reloptions = pset.sversion >= 80200 ?
1121
strdup(PQgetvalue(res, 0, 6)) : 0;
1122
strdup(PQgetvalue(res, 0, 6)) : 0;
1122
1123
tableinfo.tablespace = (pset.sversion >= 80000) ?
1123
atooid(PQgetvalue(res, 0, 7)) : 0;
1124
atooid(PQgetvalue(res, 0, 7)) : 0;
1128
* If it's a sequence, fetch its values and store into an
1129
* array that will be used later.
1129
* If it's a sequence, fetch its values and store into an array that will
1131
1132
if (tableinfo.relkind == 'S')
1133
1134
PGresult *result;
1135
1136
#define SEQ_NUM_COLS 10
1136
1137
printfPQExpBuffer(&buf,
1137
1138
"SELECT sequence_name, last_value,\n"
1142
1143
fmtId(schemaname));
1143
1144
/* must be separate because fmtId isn't reentrant */
1144
1145
appendPQExpBuffer(&buf, ".%s", fmtId(relationname));
1146
1147
result = PSQLexec(buf.data, false);
1148
1149
goto error_return;
1150
seq_values = pg_malloc_zero((SEQ_NUM_COLS+1) * sizeof(*seq_values));
1152
for (i = 0; i < SEQ_NUM_COLS; i++)
1151
seq_values = pg_malloc_zero((SEQ_NUM_COLS + 1) * sizeof(*seq_values));
1153
for (i = 0; i < SEQ_NUM_COLS; i++)
1153
1154
seq_values[i] = pg_strdup(PQgetvalue(result, 0, i));
1155
1156
PQclear(result);
1299
1300
/* Storage and Description */
1302
char *storage = PQgetvalue(res, i, 5);
1303
char *storage = PQgetvalue(res, i, 5);
1304
1305
/* these strings are literal in our syntax, so not translated. */
1305
printTableAddCell(&cont, (storage[0]=='p' ? "plain" :
1306
(storage[0]=='m' ? "main" :
1307
(storage[0]=='x' ? "extended" :
1308
(storage[0]=='e' ? "external" :
1306
printTableAddCell(&cont, (storage[0] == 'p' ? "plain" :
1307
(storage[0] == 'm' ? "main" :
1308
(storage[0] == 'x' ? "extended" :
1309
(storage[0] == 'e' ? "external" :
1311
1312
printTableAddCell(&cont, PQgetvalue(res, i, 6), false);
1427
1428
printfPQExpBuffer(&buf,
1428
1429
"SELECT c2.relname, i.indisprimary, i.indisunique, i.indisclustered, ");
1429
if (pset.sversion >= 80200)
1430
if (pset.sversion >= 80200)
1430
1431
appendPQExpBuffer(&buf, "i.indisvalid, ");
1432
1433
appendPQExpBuffer(&buf, "true as indisvalid, ");
1433
1434
appendPQExpBuffer(&buf, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true)");
1434
if (pset.sversion >= 80000)
1435
if (pset.sversion >= 80000)
1435
1436
appendPQExpBuffer(&buf, ", c2.reltablespace");
1436
1437
appendPQExpBuffer(&buf,
1437
1438
"\nFROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i\n"
1459
1460
/* Label as primary key or unique (but not both) */
1460
1461
appendPQExpBuffer(&buf,
1461
strcmp(PQgetvalue(result, i, 1), "t") == 0
1462
strcmp(PQgetvalue(result, i, 1), "t") == 0
1462
1463
? " PRIMARY KEY," :
1463
(strcmp(PQgetvalue(result, i, 2), "t") == 0
1464
(strcmp(PQgetvalue(result, i, 2), "t") == 0
1466
1467
/* Everything after "USING" is echoed verbatim */
1467
1468
indexdef = PQgetvalue(result, i, 5);
1468
1469
usingpos = strstr(indexdef, " USING ");
1555
1556
if (tableinfo.hastriggers)
1557
1558
printfPQExpBuffer(&buf,
1558
"SELECT conname, conrelid::pg_catalog.regclass,\n"
1559
" pg_catalog.pg_get_constraintdef(c.oid, true) as condef\n"
1559
"SELECT conname, conrelid::pg_catalog.regclass,\n"
1560
" pg_catalog.pg_get_constraintdef(c.oid, true) as condef\n"
1560
1561
"FROM pg_catalog.pg_constraint c\n"
1561
"WHERE c.confrelid = '%s' AND c.contype = 'f' ORDER BY 1",
1562
"WHERE c.confrelid = '%s' AND c.contype = 'f' ORDER BY 1",
1563
1564
result = PSQLexec(buf.data, false);
1571
1572
printTableAddFooter(&cont, _("Referenced by:"));
1572
1573
for (i = 0; i < tuples; i++)
1574
/* translator: the first %s is a FK name, the following are
1575
* a table name and the FK definition */
1576
printfPQExpBuffer(&buf, _(" \"%s\" IN %s %s"),
1577
PQgetvalue(result, i, 0),
1575
printfPQExpBuffer(&buf, " TABLE \"%s\" CONSTRAINT \"%s\" %s",
1578
1576
PQgetvalue(result, i, 1),
1577
PQgetvalue(result, i, 0),
1579
1578
PQgetvalue(result, i, 2));
1581
1580
printTableAddFooter(&cont, buf.data);
1919
1921
/* Append the tablespace to the latest footer */
1920
1922
printfPQExpBuffer(&buf, "%s", cont->footer->data);
1921
/* translator: before this string there's an index
1922
* description like '"foo_pkey" PRIMARY KEY, btree (a)' */
1925
* translator: before this string there's an index
1926
* description like '"foo_pkey" PRIMARY KEY, btree (a)'
1923
1928
appendPQExpBuffer(&buf, _(", tablespace \"%s\""),
1924
1929
PQgetvalue(result, 0, 0));
1925
1930
printTableSetFooter(cont, buf.data);
1955
1960
if (pset.sversion >= 80100)
1957
1962
printfPQExpBuffer(&buf,
1958
"SELECT r.rolname, r.rolsuper, r.rolinherit,\n"
1959
" r.rolcreaterole, r.rolcreatedb, r.rolcanlogin,\n"
1960
" r.rolconnlimit,\n"
1961
" ARRAY(SELECT b.rolname\n"
1962
" FROM pg_catalog.pg_auth_members m\n"
1963
" JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid)\n"
1964
" WHERE m.member = r.oid) as memberof");
1963
"SELECT r.rolname, r.rolsuper, r.rolinherit,\n"
1964
" r.rolcreaterole, r.rolcreatedb, r.rolcanlogin,\n"
1965
" r.rolconnlimit,\n"
1966
" ARRAY(SELECT b.rolname\n"
1967
" FROM pg_catalog.pg_auth_members m\n"
1968
" JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid)\n"
1969
" WHERE m.member = r.oid) as memberof");
1966
1971
if (verbose && pset.sversion >= 80200)
1974
1979
processSQLNamePattern(pset.db, &buf, pattern, false, false,
1975
1980
NULL, "r.rolname", NULL, NULL);
1979
printfPQExpBuffer(&buf,
1980
"SELECT u.usename AS rolname,\n"
1981
" u.usesuper AS rolsuper,\n"
1982
" true AS rolinherit, false AS rolcreaterole,\n"
1983
" u.usecreatedb AS rolcreatedb, true AS rolcanlogin,\n"
1984
" -1 AS rolconnlimit,\n"
1985
" ARRAY(SELECT g.groname FROM pg_catalog.pg_group g WHERE u.usesysid = ANY(g.grolist)) as memberof"
1986
"\nFROM pg_catalog.pg_user u\n");
1984
printfPQExpBuffer(&buf,
1985
"SELECT u.usename AS rolname,\n"
1986
" u.usesuper AS rolsuper,\n"
1987
" true AS rolinherit, false AS rolcreaterole,\n"
1988
" u.usecreatedb AS rolcreatedb, true AS rolcanlogin,\n"
1989
" -1 AS rolconnlimit,\n"
1990
" ARRAY(SELECT g.groname FROM pg_catalog.pg_group g WHERE u.usesysid = ANY(g.grolist)) as memberof"
1991
"\nFROM pg_catalog.pg_user u\n");
1988
1993
processSQLNamePattern(pset.db, &buf, pattern, false, false,
1989
1994
NULL, "u.usename", NULL, NULL);
1992
1997
appendPQExpBuffer(&buf, "ORDER BY 1;");
2154
2162
appendPQExpBuffer(&buf, "'S',");
2155
2163
if (showSystem || pattern)
2156
appendPQExpBuffer(&buf, "'s',"); /* was RELKIND_SPECIAL in <= 8.1 */
2164
appendPQExpBuffer(&buf, "'s',"); /* was RELKIND_SPECIAL in <=
2157
2166
appendPQExpBuffer(&buf, "''"); /* dummy */
2158
2167
appendPQExpBuffer(&buf, ")\n");
2160
if (!showSystem && !pattern)
2161
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
2162
" AND n.nspname <> 'information_schema'\n");
2169
if (!showSystem && !pattern)
2170
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
2171
" AND n.nspname <> 'information_schema'\n");
2165
2174
* TOAST objects are suppressed unconditionally. Since we don't provide
2237
2246
gettext_noop("Modifier"),
2238
2247
gettext_noop("Check"));
2240
if (!showSystem && !pattern)
2241
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
2242
" AND n.nspname <> 'information_schema'\n");
2249
if (!showSystem && !pattern)
2250
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
2251
" AND n.nspname <> 'information_schema'\n");
2244
2253
processSQLNamePattern(pset.db, &buf, pattern, true, false,
2245
2254
"n.nspname", "t.typname", NULL,
2293
2302
gettext_noop("yes"), gettext_noop("no"),
2294
2303
gettext_noop("Default?"));
2296
if (!showSystem && !pattern)
2297
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
2298
" AND n.nspname <> 'information_schema'\n");
2305
if (!showSystem && !pattern)
2306
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
2307
" AND n.nspname <> 'information_schema'\n");
2300
2309
processSQLNamePattern(pset.db, &buf, pattern, true, false,
2301
2310
"n.nspname", "c.conname", NULL,
2424
2434
appendPQExpBuffer(&buf, ",\n ");
2425
2435
printACLColumn(&buf, "n.nspacl");
2426
2436
appendPQExpBuffer(&buf,
2427
",\n pg_catalog.obj_description(n.oid, 'pg_namespace') AS \"%s\"",
2437
",\n pg_catalog.obj_description(n.oid, 'pg_namespace') AS \"%s\"",
2428
2438
gettext_noop("Description"));
2431
2441
appendPQExpBuffer(&buf,
2432
"\nFROM pg_catalog.pg_namespace n\n"
2442
"\nFROM pg_catalog.pg_namespace n\n"
2433
2443
"WHERE (n.nspname !~ '^pg_temp_' OR\n"
2434
2444
" n.nspname = (pg_catalog.current_schemas(true))[1])\n"); /* temp schema is first */