*** pgsql/src/bin/psql/describe.c 2009/01/01 17:23:54 1.193 --- pgsql/src/bin/psql/describe.c 2009/01/06 21:10:30 1.194 *************** *** 8,14 **** * * Copyright (c) 2000-2009, PostgreSQL Global Development Group * ! * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.192 2008/12/31 18:33:03 tgl Exp $ */ #include "postgres_fe.h" --- 8,14 ---- * * Copyright (c) 2000-2009, PostgreSQL Global Development Group * ! * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.193 2009/01/01 17:23:54 momjian Exp $ */ #include "postgres_fe.h" *************** static void printACLColumn(PQExpBuffer b *** 53,59 **** * Takes an optional regexp to select particular aggregates */ bool ! describeAggregates(const char *pattern, bool verbose) { PQExpBufferData buf; PGresult *res; --- 53,59 ---- * Takes an optional regexp to select particular aggregates */ bool ! describeAggregates(const char *pattern, bool verbose, bool showSystem) { PQExpBufferData buf; PGresult *res; *************** describeAggregates(const char *pattern, *** 76,82 **** " ELSE\n" " pg_catalog.array_to_string(ARRAY(\n" " SELECT\n" ! " pg_catalog.format_type(p.proargtypes[s.i], NULL)\n" " FROM\n" " pg_catalog.generate_series(0, pg_catalog.array_upper(p.proargtypes, 1)) AS s(i)\n" " ), ', ')\n" --- 76,82 ---- " ELSE\n" " pg_catalog.array_to_string(ARRAY(\n" " SELECT\n" ! " pg_catalog.format_type(p.proargtypes[s.i], NULL)\n" " FROM\n" " pg_catalog.generate_series(0, pg_catalog.array_upper(p.proargtypes, 1)) AS s(i)\n" " ), ', ')\n" *************** describeAggregates(const char *pattern, *** 94,99 **** --- 94,102 ---- "WHERE p.proisagg\n", gettext_noop("Description")); + if (!showSystem) + appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"); + processSQLNamePattern(pset.db, &buf, pattern, true, false, "n.nspname", "p.proname", NULL, "pg_catalog.pg_function_is_visible(p.oid)"); *************** describeTablespaces(const char *pattern, *** 182,188 **** * Takes an optional regexp to select particular functions */ bool ! describeFunctions(const char *pattern, bool verbose) { PQExpBufferData buf; PGresult *res; --- 185,191 ---- * Takes an optional regexp to select particular functions */ bool ! describeFunctions(const char *pattern, bool verbose, bool showSystem) { PQExpBufferData buf; PGresult *res; *************** describeFunctions(const char *pattern, b *** 278,283 **** --- 281,289 ---- " AND p.proargtypes[0] IS DISTINCT FROM 'pg_catalog.cstring'::pg_catalog.regtype\n" " AND NOT p.proisagg\n"); + if (!showSystem) + appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"); + processSQLNamePattern(pset.db, &buf, pattern, true, false, "n.nspname", "p.proname", NULL, "pg_catalog.pg_function_is_visible(p.oid)"); *************** describeFunctions(const char *pattern, b *** 306,312 **** * describe types */ bool ! describeTypes(const char *pattern, bool verbose) { PQExpBufferData buf; PGresult *res; --- 312,318 ---- * describe types */ bool ! describeTypes(const char *pattern, bool verbose, bool showSystem) { PQExpBufferData buf; PGresult *res; *************** describeTypes(const char *pattern, bool *** 366,371 **** --- 372,380 ---- else appendPQExpBuffer(&buf, " AND t.typname !~ '^_'\n"); + if (!showSystem) + appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"); + /* Match name pattern against either internal or external name */ processSQLNamePattern(pset.db, &buf, pattern, true, false, "n.nspname", "t.typname", *************** describeTypes(const char *pattern, bool *** 393,399 **** /* \do */ bool ! describeOperators(const char *pattern) { PQExpBufferData buf; PGresult *res; --- 402,408 ---- /* \do */ bool ! describeOperators(const char *pattern, bool showSystem) { PQExpBufferData buf; PGresult *res; *************** describeOperators(const char *pattern) *** 418,424 **** gettext_noop("Result type"), gettext_noop("Description")); ! processSQLNamePattern(pset.db, &buf, pattern, false, true, "n.nspname", "o.oprname", NULL, "pg_catalog.pg_operator_is_visible(o.oid)"); --- 427,436 ---- gettext_noop("Result type"), gettext_noop("Description")); ! if (!showSystem) ! appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"); ! ! processSQLNamePattern(pset.db, &buf, pattern, !showSystem, true, "n.nspname", "o.oprname", NULL, "pg_catalog.pg_operator_is_visible(o.oid)"); *************** permissionsList(const char *pattern) *** 580,586 **** * lists of things, there are other \d? commands. */ bool ! objectDescription(const char *pattern) { PQExpBufferData buf; PGresult *res; --- 592,598 ---- * lists of things, there are other \d? commands. */ bool ! objectDescription(const char *pattern, bool showSystem) { PQExpBufferData buf; PGresult *res; *************** objectDescription(const char *pattern) *** 607,612 **** --- 619,628 ---- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" " WHERE p.proisagg\n", gettext_noop("aggregate")); + + if (!showSystem) + appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"); + processSQLNamePattern(pset.db, &buf, pattern, true, false, "n.nspname", "p.proname", NULL, "pg_catalog.pg_function_is_visible(p.oid)"); *************** objectDescription(const char *pattern) *** 626,631 **** --- 642,651 ---- " OR p.proargtypes[0] <> 'pg_catalog.cstring'::pg_catalog.regtype)\n" " AND NOT p.proisagg\n", gettext_noop("function")); + + if (!showSystem) + appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"); + processSQLNamePattern(pset.db, &buf, pattern, true, false, "n.nspname", "p.proname", NULL, "pg_catalog.pg_function_is_visible(p.oid)"); *************** objectDescription(const char *pattern) *** 640,646 **** " FROM pg_catalog.pg_operator o\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = o.oprnamespace\n", gettext_noop("operator")); ! processSQLNamePattern(pset.db, &buf, pattern, false, false, "n.nspname", "o.oprname", NULL, "pg_catalog.pg_operator_is_visible(o.oid)"); --- 660,670 ---- " FROM pg_catalog.pg_operator o\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = o.oprnamespace\n", gettext_noop("operator")); ! ! if (!showSystem) ! appendPQExpBuffer(&buf, " WHERE n.nspname <> 'pg_catalog'\n"); ! ! processSQLNamePattern(pset.db, &buf, pattern, !showSystem, false, "n.nspname", "o.oprname", NULL, "pg_catalog.pg_operator_is_visible(o.oid)"); *************** objectDescription(const char *pattern) *** 654,660 **** " FROM pg_catalog.pg_type t\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n", gettext_noop("data type")); ! processSQLNamePattern(pset.db, &buf, pattern, false, false, "n.nspname", "pg_catalog.format_type(t.oid, NULL)", NULL, "pg_catalog.pg_type_is_visible(t.oid)"); --- 678,688 ---- " FROM pg_catalog.pg_type t\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n", gettext_noop("data type")); ! ! if (!showSystem) ! appendPQExpBuffer(&buf, " WHERE n.nspname <> 'pg_catalog'\n"); ! ! processSQLNamePattern(pset.db, &buf, pattern, !showSystem, false, "n.nspname", "pg_catalog.format_type(t.oid, NULL)", NULL, "pg_catalog.pg_type_is_visible(t.oid)"); *************** objectDescription(const char *pattern) *** 675,680 **** --- 703,711 ---- gettext_noop("view"), gettext_noop("index"), gettext_noop("sequence")); + if (!showSystem) + appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"); + processSQLNamePattern(pset.db, &buf, pattern, true, false, "n.nspname", "c.relname", NULL, "pg_catalog.pg_table_is_visible(c.oid)"); *************** objectDescription(const char *pattern) *** 691,696 **** --- 722,731 ---- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n" " WHERE r.rulename != '_RETURN'\n", gettext_noop("rule")); + + if (!showSystem) + appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"); + /* XXX not sure what to do about visibility rule here? */ processSQLNamePattern(pset.db, &buf, pattern, true, false, "n.nspname", "r.rulename", NULL, *************** objectDescription(const char *pattern) *** 707,714 **** " JOIN pg_catalog.pg_class c ON c.oid = t.tgrelid\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n", gettext_noop("trigger")); /* XXX not sure what to do about visibility rule here? */ ! processSQLNamePattern(pset.db, &buf, pattern, false, false, "n.nspname", "t.tgname", NULL, "pg_catalog.pg_table_is_visible(c.oid)"); --- 742,752 ---- " JOIN pg_catalog.pg_class c ON c.oid = t.tgrelid\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n", gettext_noop("trigger")); + if (!showSystem) + appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"); + /* XXX not sure what to do about visibility rule here? */ ! processSQLNamePattern(pset.db, &buf, pattern, !showSystem, false, "n.nspname", "t.tgname", NULL, "pg_catalog.pg_table_is_visible(c.oid)"); *************** add_role_attribute(PQExpBuffer buf, cons *** 1856,1868 **** * (any order of the above is fine) */ bool ! listTables(const char *tabtypes, const char *pattern, bool verbose) { bool showTables = strchr(tabtypes, 't') != NULL; bool showIndexes = strchr(tabtypes, 'i') != NULL; bool showViews = strchr(tabtypes, 'v') != NULL; bool showSeq = strchr(tabtypes, 's') != NULL; - bool showSystem = strchr(tabtypes, 'S') != NULL; PQExpBufferData buf; PGresult *res; --- 1894,1905 ---- * (any order of the above is fine) */ bool ! listTables(const char *tabtypes, const char *pattern, bool verbose, bool showSystem) { bool showTables = strchr(tabtypes, 't') != NULL; bool showIndexes = strchr(tabtypes, 'i') != NULL; bool showViews = strchr(tabtypes, 'v') != NULL; bool showSeq = strchr(tabtypes, 's') != NULL; PQExpBufferData buf; PGresult *res; *************** listTables(const char *tabtypes, const c *** 1981,1987 **** * Describes domains. */ bool ! listDomains(const char *pattern) { PQExpBufferData buf; PGresult *res; --- 2018,2024 ---- * Describes domains. */ bool ! listDomains(const char *pattern, bool showSystem) { PQExpBufferData buf; PGresult *res; *************** listDomains(const char *pattern) *** 2009,2014 **** --- 2046,2054 ---- gettext_noop("Modifier"), gettext_noop("Check")); + if (!showSystem) + appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"); + processSQLNamePattern(pset.db, &buf, pattern, true, false, "n.nspname", "t.typname", NULL, "pg_catalog.pg_type_is_visible(t.oid)"); *************** listDomains(const char *pattern) *** 2036,2042 **** * Describes conversions. */ bool ! listConversions(const char *pattern) { PQExpBufferData buf; PGresult *res; --- 2076,2082 ---- * Describes conversions. */ bool ! listConversions(const char *pattern, bool showSystem) { PQExpBufferData buf; PGresult *res; *************** listConversions(const char *pattern) *** 2061,2066 **** --- 2101,2109 ---- gettext_noop("yes"), gettext_noop("no"), gettext_noop("Default?")); + if (!showSystem) + appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"); + processSQLNamePattern(pset.db, &buf, pattern, true, false, "n.nspname", "c.conname", NULL, "pg_catalog.pg_conversion_is_visible(c.oid)");