~ubuntu-branches/ubuntu/natty/postgresql-8.4/natty-security

« back to all changes in this revision

Viewing changes to src/bin/psql/describe.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-11 16:59:35 UTC
  • mfrom: (5.1.1 karmic)
  • Revision ID: james.westby@ubuntu.com-20090711165935-jfwin6gfrxf0gfsi
Tags: 8.4.0-2
* debian/libpq-dev.install: Ship catalog/genbki.h. (Closes: #536139)
* debian/rules: Drop --enable-cassert for final release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 *
9
9
 * Copyright (c) 2000-2009, PostgreSQL Global Development Group
10
10
 *
11
 
 * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.212 2009/05/05 02:29:06 tgl Exp $
 
11
 * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.218 2009/06/13 13:43:34 petere Exp $
12
12
 */
13
13
#include "postgres_fe.h"
14
14
 
28
28
                                                const char *oid,
29
29
                                                bool verbose);
30
30
static void add_tablespace_footer(printTableContent *const cont, char relkind,
31
 
                                                Oid tablespace, const bool newline);
 
31
                                          Oid tablespace, const bool newline);
32
32
static void add_role_attribute(PQExpBuffer buf, const char *const str);
33
33
static bool listTSParsersVerbose(const char *pattern);
34
34
static bool describeOneTSParser(const char *oid, const char *nspname,
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"));
71
71
 
72
72
        if (pset.sversion >= 80200)
73
 
            appendPQExpBuffer(&buf,
74
 
                                          "  CASE WHEN p.pronargs = 0\n"
75
 
                                          "    THEN CAST('*' AS pg_catalog.text)\n"
76
 
                                          "    ELSE\n"
77
 
                                          "    pg_catalog.array_to_string(ARRAY(\n"
78
 
                                          "      SELECT\n"
79
 
                                          "        pg_catalog.format_type(p.proargtypes[s.i], NULL)\n"
80
 
                                          "      FROM\n"
81
 
                                          "        pg_catalog.generate_series(0, pg_catalog.array_upper(p.proargtypes, 1)) AS s(i)\n"
82
 
                                          "    ), ', ')\n"
83
 
                                          "  END AS \"%s\",\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"
 
76
                                                  "    ELSE\n"
 
77
                                                  "    pg_catalog.array_to_string(ARRAY(\n"
 
78
                                                  "      SELECT\n"
 
79
                                 "        pg_catalog.format_type(p.proargtypes[s.i], NULL)\n"
 
80
                                                  "      FROM\n"
 
81
                                                  "        pg_catalog.generate_series(0, pg_catalog.array_upper(p.proargtypes, 1)) AS s(i)\n"
 
82
                                                  "    ), ', ')\n"
 
83
                                                  "  END AS \"%s\",\n",
 
84
                                                  gettext_noop("Argument data types"));
85
85
        else
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"));
89
89
 
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"));
96
96
 
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");
100
100
 
101
101
        processSQLNamePattern(pset.db, &buf, pattern, true, false,
102
102
                                                  "n.nspname", "p.proname", NULL,
154
154
 
155
155
        if (verbose && pset.sversion >= 80200)
156
156
                appendPQExpBuffer(&buf,
157
 
                          ",\n  pg_catalog.shobj_description(oid, 'pg_tablespace') AS \"%s\"",
 
157
                 ",\n  pg_catalog.shobj_description(oid, 'pg_tablespace') AS \"%s\"",
158
158
                                                  gettext_noop("Description"));
159
159
 
160
160
        appendPQExpBuffer(&buf,
215
215
 
216
216
        if (showWindow && pset.sversion < 80400)
217
217
        {
218
 
                fprintf(stderr, _("\\df does not take a \"w\" option in %d.%d.\n"),
 
218
                fprintf(stderr, _("\\df does not take a \"w\" option with server version %d.%d\n"),
219
219
                                pset.sversion / 10000, (pset.sversion / 100) % 100);
220
220
                return true;
221
221
        }
235
235
                                          gettext_noop("Schema"),
236
236
                                          gettext_noop("Name"));
237
237
 
238
 
    if (pset.sversion >= 80400)
 
238
        if (pset.sversion >= 80400)
239
239
                appendPQExpBuffer(&buf,
240
 
                                                  "  pg_catalog.pg_get_function_result(p.oid) as \"%s\",\n"
241
 
                                                  "  pg_catalog.pg_get_function_arguments(p.oid) as \"%s\",\n"
 
240
                                        "  pg_catalog.pg_get_function_result(p.oid) as \"%s\",\n"
 
241
                                 "  pg_catalog.pg_get_function_arguments(p.oid) as \"%s\",\n"
242
242
                                                  " CASE\n"
243
243
                                                  "  WHEN p.proisagg THEN '%s'\n"
244
244
                                                  "  WHEN p.proiswindow THEN '%s'\n"
246
246
                                                  "  ELSE '%s'\n"
247
247
                                                  "END as \"%s\"",
248
248
                                                  gettext_noop("Result data type"),
249
 
                                                          gettext_noop("Argument data types"),
250
 
                                                          /* translator: "agg" is short for "aggregate" */
251
 
                                                          gettext_noop("agg"),
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" */
 
251
                                                  gettext_noop("agg"),
 
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"
262
 
                                          "      SELECT\n"
263
 
                                          "        CASE\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"
 
262
                                                  "      SELECT\n"
 
263
                                                  "        CASE\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"
268
 
                                          "        END ||\n"
269
 
                                          "        CASE\n"
 
266
                                        "          WHEN p.proargmodes[s.i] = 'b' THEN 'INOUT '\n"
 
267
                                 "          WHEN p.proargmodes[s.i] = 'v' THEN 'VARIADIC '\n"
 
268
                                                  "        END ||\n"
 
269
                                                  "        CASE\n"
270
270
                         "          WHEN COALESCE(p.proargnames[s.i], '') = '' THEN ''\n"
271
 
                                          "          ELSE p.proargnames[s.i] || ' ' \n"
272
 
                                          "        END ||\n"
 
271
                                                  "          ELSE p.proargnames[s.i] || ' ' \n"
 
272
                                                  "        END ||\n"
273
273
                          "        pg_catalog.format_type(p.proallargtypes[s.i], NULL)\n"
274
 
                                          "      FROM\n"
275
 
                                          "        pg_catalog.generate_series(1, pg_catalog.array_upper(p.proallargtypes, 1)) AS s(i)\n"
276
 
                                          "    ), ', ')\n"
277
 
                                          "  ELSE\n"
278
 
                                          "    pg_catalog.array_to_string(ARRAY(\n"
279
 
                                          "      SELECT\n"
280
 
                                          "        CASE\n"
 
274
                                                  "      FROM\n"
 
275
                                                  "        pg_catalog.generate_series(1, pg_catalog.array_upper(p.proallargtypes, 1)) AS s(i)\n"
 
276
                                                  "    ), ', ')\n"
 
277
                                                  "  ELSE\n"
 
278
                                                  "    pg_catalog.array_to_string(ARRAY(\n"
 
279
                                                  "      SELECT\n"
 
280
                                                  "        CASE\n"
281
281
                   "          WHEN COALESCE(p.proargnames[s.i+1], '') = '' THEN ''\n"
282
 
                                          "          ELSE p.proargnames[s.i+1] || ' '\n"
283
 
                                          "          END ||\n"
 
282
                                                  "          ELSE p.proargnames[s.i+1] || ' '\n"
 
283
                                                  "          END ||\n"
284
284
                                 "        pg_catalog.format_type(p.proargtypes[s.i], NULL)\n"
285
 
                                          "      FROM\n"
286
 
                                          "        pg_catalog.generate_series(0, pg_catalog.array_upper(p.proargtypes, 1)) AS s(i)\n"
287
 
                                          "    ), ', ')\n"
288
 
                                          "  END AS \"%s\",\n"
289
 
                                          "  CASE\n"
290
 
                                          "    WHEN p.proisagg THEN '%s'\n"
291
 
                                          "    WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN '%s'\n"
292
 
                                          "    ELSE '%s'\n"
293
 
                                          "  END AS \"%s\"",
 
285
                                                  "      FROM\n"
 
286
                                                  "        pg_catalog.generate_series(0, pg_catalog.array_upper(p.proargtypes, 1)) AS s(i)\n"
 
287
                                                  "    ), ', ')\n"
 
288
                                                  "  END AS \"%s\",\n"
 
289
                                                  "  CASE\n"
 
290
                                                  "    WHEN p.proisagg THEN '%s'\n"
 
291
                                                  "    WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN '%s'\n"
 
292
                                                  "    ELSE '%s'\n"
 
293
                                                  "  END AS \"%s\"",
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"));
301
301
        else
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"
306
 
                                          "  CASE\n"
307
 
                                          "    WHEN p.proisagg THEN '%s'\n"
308
 
                                          "    WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN '%s'\n"
309
 
                                          "    ELSE '%s'\n"
310
 
                                          "  END AS \"%s\"",
 
305
                                        "  pg_catalog.oidvectortypes(p.proargtypes) as \"%s\",\n"
 
306
                                                  "  CASE\n"
 
307
                                                  "    WHEN p.proisagg THEN '%s'\n"
 
308
                                                  "    WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN '%s'\n"
 
309
                                                  "    ELSE '%s'\n"
 
310
                                                  "  END AS \"%s\"",
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"),
323
323
                                                  "  WHEN p.provolatile = 's' THEN '%s'\n"
324
324
                                                  "  WHEN p.provolatile = 'v' THEN '%s'\n"
325
325
                                                  "END as \"%s\""
326
 
                                                  ",\n  pg_catalog.pg_get_userbyid(p.proowner) as \"%s\",\n"
 
326
                                   ",\n  pg_catalog.pg_get_userbyid(p.proowner) as \"%s\",\n"
327
327
                                                  "  l.lanname as \"%s\",\n"
328
328
                                                  "  p.prosrc as \"%s\",\n"
329
329
                                  "  pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"",
338
338
 
339
339
        appendPQExpBuffer(&buf,
340
340
                                          "\nFROM pg_catalog.pg_proc p"
341
 
                                          "\n     LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n");
 
341
        "\n     LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n");
342
342
 
343
343
        if (verbose)
344
344
                appendPQExpBuffer(&buf,
345
 
                                                  "     LEFT JOIN pg_catalog.pg_language l ON l.oid = p.prolang\n");
 
345
                   "     LEFT JOIN pg_catalog.pg_language l ON l.oid = p.prolang\n");
346
346
 
347
347
        have_where = false;
348
348
 
349
349
        /* filter by function type, if requested */
350
350
        if (showNormal && showAggregate && showTrigger && showWindow)
351
 
                /* Do nothing */;
 
351
                 /* Do nothing */ ;
352
352
        else if (showNormal)
353
353
        {
354
354
                if (!showAggregate)
387
387
        }
388
388
        else
389
389
        {
390
 
                bool    needs_or = false;
 
390
                bool            needs_or = false;
391
391
 
392
392
                appendPQExpBuffer(&buf, "WHERE (\n       ");
393
393
                have_where = true;
394
394
                /* Note: at least one of these must be true ... */
395
395
                if (showAggregate)
396
396
                {
397
 
                        appendPQExpBuffer(&buf,"p.proisagg\n");
 
397
                        appendPQExpBuffer(&buf, "p.proisagg\n");
398
398
                        needs_or = true;
399
399
                }
400
400
                if (showTrigger)
402
402
                        if (needs_or)
403
403
                                appendPQExpBuffer(&buf, "       OR ");
404
404
                        appendPQExpBuffer(&buf,
405
 
                                                          "p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype\n");
 
405
                                "p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype\n");
406
406
                        needs_or = true;
407
407
                }
408
408
                if (showWindow)
419
419
                                                  "n.nspname", "p.proname", NULL,
420
420
                                                  "pg_catalog.pg_function_is_visible(p.oid)");
421
421
 
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");
425
425
 
426
426
        appendPQExpBuffer(&buf, "ORDER BY 1, 2, 4;");
427
427
 
486
486
                                                  gettext_noop("Elements"));
487
487
 
488
488
        appendPQExpBuffer(&buf,
489
 
                                          "  pg_catalog.obj_description(t.oid, 'pg_type') as \"%s\"\n",
 
489
                                "  pg_catalog.obj_description(t.oid, 'pg_type') as \"%s\"\n",
490
490
                                          gettext_noop("Description"));
491
491
 
492
492
        appendPQExpBuffer(&buf, "FROM pg_catalog.pg_type t\n"
499
499
        appendPQExpBuffer(&buf, "WHERE (t.typrelid = 0 ");
500
500
        appendPQExpBuffer(&buf, "OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c "
501
501
                                          "WHERE c.oid = t.typrelid))\n");
 
502
 
502
503
        /*
503
504
         * do not include array types (before 8.3 we have to use the assumption
504
505
         * that their names start with underscore)
508
509
        else
509
510
                appendPQExpBuffer(&buf, "  AND t.typname !~ '^_'\n");
510
511
 
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");
514
515
 
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"));
566
567
 
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");
570
571
 
571
572
        processSQLNamePattern(pset.db, &buf, pattern, !showSystem && !pattern, true,
572
573
                                                  "n.nspname", "o.oprname", NULL,
606
607
 
607
608
        printfPQExpBuffer(&buf,
608
609
                                          "SELECT d.datname as \"%s\",\n"
609
 
                                          "       pg_catalog.pg_get_userbyid(d.datdba) as \"%s\",\n"
610
 
                                          "       pg_catalog.pg_encoding_to_char(d.encoding) as \"%s\",\n",
 
610
                                   "       pg_catalog.pg_get_userbyid(d.datdba) as \"%s\",\n"
 
611
                        "       pg_catalog.pg_encoding_to_char(d.encoding) as \"%s\",\n",
611
612
                                          gettext_noop("Name"),
612
613
                                          gettext_noop("Owner"),
613
614
                                          gettext_noop("Encoding"));
631
632
                                                  ",\n       t.spcname as \"%s\"",
632
633
                                                  gettext_noop("Tablespace"));
633
634
        if (verbose && pset.sversion >= 80200)
634
 
                    appendPQExpBuffer(&buf,
 
635
                appendPQExpBuffer(&buf,
635
636
                                                  ",\n       pg_catalog.shobj_description(d.oid, 'pg_database') as \"%s\"",
636
637
                                                  gettext_noop("Description"));
637
638
        appendPQExpBuffer(&buf,
680
681
                                          "  ",
681
682
                                          gettext_noop("Schema"),
682
683
                                          gettext_noop("Name"),
683
 
                                          gettext_noop("table"), gettext_noop("view"), gettext_noop("sequence"),
 
684
           gettext_noop("table"), gettext_noop("view"), gettext_noop("sequence"),
684
685
                                          gettext_noop("Type"));
685
686
 
686
687
        printACLColumn(&buf, "c.relacl");
769
770
                                          "  WHERE p.proisagg\n",
770
771
                                          gettext_noop("aggregate"));
771
772
 
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");
775
776
 
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"));
791
792
 
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");
795
796
 
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"));
810
811
 
811
 
        if (!showSystem && !pattern)
812
 
                appendPQExpBuffer(&buf, "WHERE n.nspname <> 'pg_catalog'\n"
813
 
                                                                "      AND n.nspname <> 'information_schema'\n");
814
 
 
 
812
        if (!showSystem && !pattern)
 
813
                appendPQExpBuffer(&buf, "WHERE n.nspname <> 'pg_catalog'\n"
 
814
                                                  "      AND n.nspname <> 'information_schema'\n");
 
815
 
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"));
829
830
 
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");
833
834
 
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"));
855
856
 
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");
859
860
 
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"));
876
877
 
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");
880
881
 
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"));
897
898
 
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");
901
902
 
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");
953
954
 
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");
957
958
 
958
959
        processSQLNamePattern(pset.db, &buf, pattern, !showSystem && !pattern, false,
959
960
                                                  "n.nspname", "c.relname", NULL,
1018
1019
        PGresult   *res = NULL;
1019
1020
        printTableOpt myopt = pset.popt.topt;
1020
1021
        printTableContent cont;
1021
 
        bool printTableInitialized = false;
 
1022
        bool            printTableInitialized = false;
1022
1023
        int                     i;
1023
1024
        char       *view_def = NULL;
1024
1025
        char       *headers[6];
1056
1057
        if (pset.sversion >= 80400)
1057
1058
        {
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",
1065
1066
                                                  (verbose ?
1066
 
                                                  "pg_catalog.array_to_string(c.reloptions || "
1067
 
                                                  "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
1068
 
                                                  : "''"),
 
1067
                                                   "pg_catalog.array_to_string(c.reloptions || "
 
1068
                                                   "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n"
 
1069
                                                   : "''"),
1069
1070
                                                  oid);
1070
1071
        }
1071
1072
        else if (pset.sversion >= 80200)
1072
1073
        {
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'",
1078
1079
                                                  (verbose ?
1079
 
                                                   "pg_catalog.array_to_string(reloptions, E', ')" : "''"),
 
1080
                                         "pg_catalog.array_to_string(reloptions, E', ')" : "''"),
1080
1081
                                                  oid);
1081
1082
        }
1082
1083
        else if (pset.sversion >= 80000)
1083
1084
        {
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'",
1091
1092
        else
1092
1093
        {
1093
1094
                printfPQExpBuffer(&buf,
1094
 
                                                  "SELECT relchecks, relkind, relhasindex, relhasrules, "
 
1095
                                          "SELECT relchecks, relkind, relhasindex, relhasrules, "
1095
1096
                                                  "reltriggers <> 0, relhasoids, "
1096
1097
                                                  "'', ''\n"
1097
1098
                                                  "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;
1124
1125
        PQclear(res);
1125
1126
        res = NULL;
1126
 
        
 
1127
 
1127
1128
        /*
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
 
1130
         * be used later.
1130
1131
         */
1131
1132
        if (tableinfo.relkind == 'S')
1132
1133
        {
1133
1134
                PGresult   *result;
1134
 
                
 
1135
 
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));
1145
 
                
 
1146
 
1146
1147
                result = PSQLexec(buf.data, false);
1147
1148
                if (!result)
1148
1149
                        goto error_return;
1149
 
                
1150
 
                seq_values = pg_malloc_zero((SEQ_NUM_COLS+1) * sizeof(*seq_values));
1151
 
                
1152
 
                for (i = 0; i < SEQ_NUM_COLS; i++) 
 
1150
 
 
1151
                seq_values = pg_malloc_zero((SEQ_NUM_COLS + 1) * sizeof(*seq_values));
 
1152
 
 
1153
                for (i = 0; i < SEQ_NUM_COLS; i++)
1153
1154
                        seq_values[i] = pg_strdup(PQgetvalue(result, 0, i));
1154
 
                
 
1155
 
1155
1156
                PQclear(result);
1156
1157
        }
1157
1158
 
1230
1231
 
1231
1232
        if (tableinfo.relkind == 'S')
1232
1233
                headers[cols++] = gettext_noop("Value");
1233
 
                
 
1234
 
1234
1235
        if (verbose)
1235
1236
        {
1236
1237
                headers[cols++] = gettext_noop("Storage");
1237
1238
                headers[cols++] = gettext_noop("Description");
1238
1239
        }
1239
 
        
 
1240
 
1240
1241
        printTableInit(&cont, &myopt, title.data, cols, numrows);
1241
1242
        printTableInitialized = true;
1242
1243
 
1249
1250
                PGresult   *result;
1250
1251
 
1251
1252
                printfPQExpBuffer(&buf,
1252
 
                                                  "SELECT pg_catalog.pg_get_viewdef('%s'::pg_catalog.oid, true)",
 
1253
                          "SELECT pg_catalog.pg_get_viewdef('%s'::pg_catalog.oid, true)",
1253
1254
                                                  oid);
1254
1255
                result = PSQLexec(buf.data, false);
1255
1256
                if (!result)
1299
1300
                /* Storage and Description */
1300
1301
                if (verbose)
1301
1302
                {
1302
 
                        char *storage = PQgetvalue(res, i, 5);
 
1303
                        char       *storage = PQgetvalue(res, i, 5);
1303
1304
 
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" :
1309
1310
                                                                                 "???")))),
1310
1311
                                                          false);
1311
1312
                        printTableAddCell(&cont, PQgetvalue(res, i, 6), false);
1319
1320
                PGresult   *result;
1320
1321
 
1321
1322
                printfPQExpBuffer(&buf,
1322
 
                                                  "SELECT i.indisunique, i.indisprimary, i.indisclustered, ");
 
1323
                                 "SELECT i.indisunique, i.indisprimary, i.indisclustered, ");
1323
1324
                if (pset.sversion >= 80200)
1324
1325
                        appendPQExpBuffer(&buf, "i.indisvalid, ");
1325
1326
                else
1426
1427
                {
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, ");
1431
 
            else
 
1432
                        else
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"
1458
1459
 
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
 
                                                                           ? " UNIQUE,"
1465
 
                                                                           : ""));
 
1464
                                                                  (strcmp(PQgetvalue(result, i, 2), "t") == 0
 
1465
                                                                   ? " UNIQUE,"
 
1466
                                                                   : ""));
1466
1467
                                        /* Everything after "USING" is echoed verbatim */
1467
1468
                                        indexdef = PQgetvalue(result, i, 5);
1468
1469
                                        usingpos = strstr(indexdef, " USING ");
1481
1482
 
1482
1483
                                        /* Print tablespace of the index on the same line */
1483
1484
                                        if (pset.sversion >= 80000)
1484
 
                                            add_tablespace_footer(&cont, 'i',
1485
 
                                                                                          atooid(PQgetvalue(result, i, 6)),
 
1485
                                                add_tablespace_footer(&cont, 'i',
 
1486
                                                                                        atooid(PQgetvalue(result, i, 6)),
1486
1487
                                                                                          false);
1487
1488
                                }
1488
1489
                        }
1496
1497
                                                          "SELECT r.conname, "
1497
1498
                                                          "pg_catalog.pg_get_constraintdef(r.oid, true)\n"
1498
1499
                                                          "FROM pg_catalog.pg_constraint r\n"
1499
 
                                        "WHERE r.conrelid = '%s' AND r.contype = 'c'\nORDER BY 1",
 
1500
                                   "WHERE r.conrelid = '%s' AND r.contype = 'c'\nORDER BY 1",
1500
1501
                                                          oid);
1501
1502
                        result = PSQLexec(buf.data, false);
1502
1503
                        if (!result)
1525
1526
                {
1526
1527
                        printfPQExpBuffer(&buf,
1527
1528
                                                          "SELECT conname,\n"
1528
 
                                   "  pg_catalog.pg_get_constraintdef(r.oid, true) as condef\n"
 
1529
                                 "  pg_catalog.pg_get_constraintdef(r.oid, true) as condef\n"
1529
1530
                                                          "FROM pg_catalog.pg_constraint r\n"
1530
1531
                                        "WHERE r.conrelid = '%s' AND r.contype = 'f' ORDER BY 1",
1531
1532
                                                          oid);
1555
1556
                if (tableinfo.hastriggers)
1556
1557
                {
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",
1562
1563
                                                          oid);
1563
1564
                        result = PSQLexec(buf.data, false);
1564
1565
                        if (!result)
1571
1572
                                printTableAddFooter(&cont, _("Referenced by:"));
1572
1573
                                for (i = 0; i < tuples; i++)
1573
1574
                                {
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));
1580
1579
 
1581
1580
                                        printTableAddFooter(&cont, buf.data);
1712
1711
                                int                     category;
1713
1712
 
1714
1713
                                /*
1715
 
                                 * split the output into 4 different categories. Enabled triggers,
1716
 
                                 * disabled triggers and the two special ALWAYS and REPLICA
1717
 
                                 * configurations.
 
1714
                                 * split the output into 4 different categories. Enabled
 
1715
                                 * triggers, disabled triggers and the two special ALWAYS and
 
1716
                                 * REPLICA configurations.
1718
1717
                                 */
1719
1718
                                for (category = 0; category < 4; category++)
1720
1719
                                {
1726
1725
                                                const char *usingpos;
1727
1726
                                                const char *tgenabled;
1728
1727
 
1729
 
                                                /* Check if this trigger falls into the current category */
 
1728
                                                /*
 
1729
                                                 * Check if this trigger falls into the current
 
1730
                                                 * category
 
1731
                                                 */
1730
1732
                                                tgenabled = PQgetvalue(result, i, 2);
1731
1733
                                                list_trigger = false;
1732
1734
                                                switch (category)
1851
1853
        termPQExpBuffer(&buf);
1852
1854
        termPQExpBuffer(&title);
1853
1855
        termPQExpBuffer(&tmpbuf);
1854
 
        
 
1856
 
1855
1857
        if (seq_values)
1856
1858
        {
1857
1859
                for (ptr = seq_values; *ptr; ptr++)
1858
1860
                        free(*ptr);
1859
1861
                free(seq_values);
1860
1862
        }
1861
 
    
 
1863
 
1862
1864
        if (modifiers)
1863
1865
        {
1864
1866
                for (ptr = modifiers; *ptr; ptr++)
1918
1920
                                {
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)' */
 
1923
 
 
1924
                                        /*
 
1925
                                         * translator: before this string there's an index
 
1926
                                         * description like '"foo_pkey" PRIMARY KEY, btree (a)'
 
1927
                                         */
1923
1928
                                        appendPQExpBuffer(&buf, _(", tablespace \"%s\""),
1924
1929
                                                                          PQgetvalue(result, 0, 0));
1925
1930
                                        printTableSetFooter(cont, buf.data);
1955
1960
        if (pset.sversion >= 80100)
1956
1961
        {
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");
1965
1970
 
1966
1971
                if (verbose && pset.sversion >= 80200)
1967
1972
                {
1973
1978
 
1974
1979
                processSQLNamePattern(pset.db, &buf, pattern, false, false,
1975
1980
                                                          NULL, "r.rolname", NULL, NULL);
1976
 
    }
1977
 
    else
1978
 
    {
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");
 
1981
        }
 
1982
        else
 
1983
        {
 
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");
1987
1992
 
1988
1993
                processSQLNamePattern(pset.db, &buf, pattern, false, false,
1989
1994
                                                          NULL, "u.usename", NULL, NULL);
1990
 
    }
 
1995
        }
1991
1996
 
1992
1997
        appendPQExpBuffer(&buf, "ORDER BY 1;");
1993
1998
 
2036
2041
                        if (conns == 0)
2037
2042
                                appendPQExpBuffer(&buf, _("No connections"));
2038
2043
                        else
2039
 
                                appendPQExpBuffer(&buf, ngettext("1 connection", "%d connections", conns), conns);
 
2044
                                appendPQExpBuffer(&buf, ngettext("%d connection",
 
2045
                                                                                                 "%d connections",
 
2046
                                                                                                 conns),
 
2047
                                                                  conns);
2040
2048
                }
2041
2049
 
2042
2050
                attr[i] = pg_strdup(buf.data);
2061
2069
        return true;
2062
2070
}
2063
2071
 
2064
 
void
 
2072
static void
2065
2073
add_role_attribute(PQExpBuffer buf, const char *const str)
2066
2074
{
2067
2075
        if (buf->len > 0)
2153
2161
        if (showSeq)
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 <=
 
2165
                                                                                                 * 8.1 */
2157
2166
        appendPQExpBuffer(&buf, "''");          /* dummy */
2158
2167
        appendPQExpBuffer(&buf, ")\n");
2159
2168
 
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");
2163
2172
 
2164
2173
        /*
2165
2174
         * TOAST objects are suppressed unconditionally.  Since we don't provide
2237
2246
                                          gettext_noop("Modifier"),
2238
2247
                                          gettext_noop("Check"));
2239
2248
 
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");
2243
2252
 
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?"));
2295
2304
 
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");
2299
2308
 
2300
2309
        processSQLNamePattern(pset.db, &buf, pattern, true, false,
2301
2310
                                                  "n.nspname", "c.conname", NULL,
2333
2342
        static const bool translate_columns[] = {false, false, false, true};
2334
2343
 
2335
2344
        initPQExpBuffer(&buf);
 
2345
 
2336
2346
        /*
2337
2347
         * We need a left join to pg_proc for binary casts; the others are just
2338
2348
         * paranoia.  Also note that we don't attempt to localize '(binary
2342
2352
        printfPQExpBuffer(&buf,
2343
2353
                           "SELECT pg_catalog.format_type(castsource, NULL) AS \"%s\",\n"
2344
2354
                           "       pg_catalog.format_type(casttarget, NULL) AS \"%s\",\n"
2345
 
                                          "       CASE WHEN castfunc = 0 THEN '(binary coercible)'\n"
 
2355
                                  "       CASE WHEN castfunc = 0 THEN '(binary coercible)'\n"
2346
2356
                                          "            ELSE p.proname\n"
2347
2357
                                          "       END as \"%s\",\n"
2348
2358
                                          "       CASE WHEN c.castcontext = 'e' THEN '%s'\n"
2363
2373
                                          gettext_noop("Source type"),
2364
2374
                                          gettext_noop("Target type"),
2365
2375
                                          gettext_noop("Function"),
2366
 
                                          gettext_noop("no"), gettext_noop("in assignment"), gettext_noop("yes"),
 
2376
          gettext_noop("no"), gettext_noop("in assignment"), gettext_noop("yes"),
2367
2377
                                          gettext_noop("Implicit?"));
2368
2378
 
2369
2379
        /*
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"));
2429
2439
        }
2430
2440
 
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 */
2435
2445
 
3123
3133
        }
3124
3134
 
3125
3135
        appendPQExpBuffer(&buf,
3126
 
                                          "\nFROM pg_catalog.pg_foreign_server s\n"
3127
 
                                          "     JOIN pg_catalog.pg_foreign_data_wrapper f ON f.oid=s.srvfdw\n");
 
3136
                                          "\nFROM pg_catalog.pg_foreign_server s\n"
 
3137
           "     JOIN pg_catalog.pg_foreign_data_wrapper f ON f.oid=s.srvfdw\n");
3128
3138
 
3129
3139
        processSQLNamePattern(pset.db, &buf, pattern, false, false,
3130
3140
                                                  NULL, "s.srvname", NULL, NULL);
3203
3213
 * printACLColumn
3204
3214
 *
3205
3215
 * Helper function for consistently formatting ACL (privilege) columns.
3206
 
 * The proper targetlist entry is appended to buf.  Note lack of any
 
3216
 * The proper targetlist entry is appended to buf.      Note lack of any
3207
3217
 * whitespace or comma decoration.
3208
3218
 */
3209
3219
static void