
Go to the source code of this file.
Functions | |
| bool | describeAggregates (const char *pattern, bool verbose, bool showSystem) |
| bool | describeTablespaces (const char *pattern, bool verbose) |
| bool | describeFunctions (const char *functypes, const char *pattern, bool verbose, bool showSystem) |
| bool | describeTypes (const char *pattern, bool verbose, bool showSystem) |
| bool | describeOperators (const char *pattern, bool showSystem) |
| bool | describeRoles (const char *pattern, bool verbose) |
| bool | listDbRoleSettings (const char *pattern1, const char *pattern2) |
| bool | permissionsList (const char *pattern) |
| bool | listDefaultACLs (const char *pattern) |
| bool | objectDescription (const char *pattern, bool showSystem) |
| bool | describeTableDetails (const char *pattern, bool verbose, bool showSystem) |
| bool | listTSConfigs (const char *pattern, bool verbose) |
| bool | listTSParsers (const char *pattern, bool verbose) |
| bool | listTSDictionaries (const char *pattern, bool verbose) |
| bool | listTSTemplates (const char *pattern, bool verbose) |
| bool | listAllDbs (const char *pattern, bool verbose) |
| bool | listTables (const char *tabtypes, const char *pattern, bool verbose, bool showSystem) |
| bool | listDomains (const char *pattern, bool verbose, bool showSystem) |
| bool | listConversions (const char *pattern, bool verbose, bool showSystem) |
| bool | listCasts (const char *pattern, bool verbose) |
| bool | listCollations (const char *pattern, bool verbose, bool showSystem) |
| bool | listSchemas (const char *pattern, bool verbose, bool showSystem) |
| bool | listForeignDataWrappers (const char *pattern, bool verbose) |
| bool | listForeignServers (const char *pattern, bool verbose) |
| bool | listUserMappings (const char *pattern, bool verbose) |
| bool | listForeignTables (const char *pattern, bool verbose) |
| bool | listLanguages (const char *pattern, bool verbose, bool showSystem) |
| bool | listExtensions (const char *pattern) |
| bool | listExtensionContents (const char *pattern) |
| bool | listEventTriggers (const char *pattern, bool verbose) |
Definition at line 59 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, PSQLexec(), _psqlSettings::queryFout, _psqlSettings::sversion, termPQExpBuffer(), printQueryOpt::title, and printQueryOpt::translate_header.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT n.nspname as \"%s\",\n"
" p.proname AS \"%s\",\n"
" pg_catalog.format_type(p.prorettype, NULL) AS \"%s\",\n",
gettext_noop("Schema"),
gettext_noop("Name"),
gettext_noop("Result data type"));
if (pset.sversion >= 80200)
appendPQExpBuffer(&buf,
" CASE WHEN p.pronargs = 0\n"
" THEN CAST('*' AS pg_catalog.text)\n"
" 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"
" END AS \"%s\",\n",
gettext_noop("Argument data types"));
else
appendPQExpBuffer(&buf,
" pg_catalog.format_type(p.proargtypes[0], NULL) AS \"%s\",\n",
gettext_noop("Argument data types"));
appendPQExpBuffer(&buf,
" pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n"
"FROM pg_catalog.pg_proc p\n"
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n"
"WHERE p.proisagg\n",
gettext_noop("Description"));
if (!showSystem && !pattern)
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
" AND n.nspname <> 'information_schema'\n");
processSQLNamePattern(pset.db, &buf, pattern, true, false,
"n.nspname", "p.proname", NULL,
"pg_catalog.pg_function_is_visible(p.oid)");
appendPQExpBuffer(&buf, "ORDER BY 1, 2, 4;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
myopt.nullPrint = NULL;
myopt.title = _("List of aggregate functions");
myopt.translate_header = true;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
PQclear(res);
return true;
}
| bool describeFunctions | ( | const char * | functypes, | |
| const char * | pattern, | |||
| bool | verbose, | |||
| bool | showSystem | |||
| ) |
Definition at line 210 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, psql_error(), PSQLexec(), _psqlSettings::queryFout, _psqlSettings::sversion, termPQExpBuffer(), printQueryOpt::title, printQueryOpt::translate_columns, and printQueryOpt::translate_header.
Referenced by exec_command().
{
bool showAggregate = strchr(functypes, 'a') != NULL;
bool showNormal = strchr(functypes, 'n') != NULL;
bool showTrigger = strchr(functypes, 't') != NULL;
bool showWindow = strchr(functypes, 'w') != NULL;
bool have_where;
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, true, true, false, false, false, false};
if (strlen(functypes) != strspn(functypes, "antwS+"))
{
psql_error("\\df only takes [antwS+] as options\n");
return true;
}
if (showWindow && pset.sversion < 80400)
{
psql_error("\\df does not take a \"w\" option with server version %d.%d\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
if (!showAggregate && !showNormal && !showTrigger && !showWindow)
{
showAggregate = showNormal = showTrigger = true;
if (pset.sversion >= 80400)
showWindow = true;
}
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT n.nspname as \"%s\",\n"
" p.proname as \"%s\",\n",
gettext_noop("Schema"),
gettext_noop("Name"));
if (pset.sversion >= 80400)
appendPQExpBuffer(&buf,
" pg_catalog.pg_get_function_result(p.oid) as \"%s\",\n"
" pg_catalog.pg_get_function_arguments(p.oid) as \"%s\",\n"
" CASE\n"
" WHEN p.proisagg THEN '%s'\n"
" WHEN p.proiswindow THEN '%s'\n"
" WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN '%s'\n"
" ELSE '%s'\n"
" END as \"%s\"",
gettext_noop("Result data type"),
gettext_noop("Argument data types"),
/* translator: "agg" is short for "aggregate" */
gettext_noop("agg"),
gettext_noop("window"),
gettext_noop("trigger"),
gettext_noop("normal"),
gettext_noop("Type"));
else if (pset.sversion >= 80100)
appendPQExpBuffer(&buf,
" CASE WHEN p.proretset THEN 'SETOF ' ELSE '' END ||\n"
" pg_catalog.format_type(p.prorettype, NULL) as \"%s\",\n"
" CASE WHEN proallargtypes IS NOT NULL THEN\n"
" pg_catalog.array_to_string(ARRAY(\n"
" SELECT\n"
" CASE\n"
" WHEN p.proargmodes[s.i] = 'i' THEN ''\n"
" WHEN p.proargmodes[s.i] = 'o' THEN 'OUT '\n"
" WHEN p.proargmodes[s.i] = 'b' THEN 'INOUT '\n"
" WHEN p.proargmodes[s.i] = 'v' THEN 'VARIADIC '\n"
" END ||\n"
" CASE\n"
" WHEN COALESCE(p.proargnames[s.i], '') = '' THEN ''\n"
" ELSE p.proargnames[s.i] || ' ' \n"
" END ||\n"
" pg_catalog.format_type(p.proallargtypes[s.i], NULL)\n"
" FROM\n"
" pg_catalog.generate_series(1, pg_catalog.array_upper(p.proallargtypes, 1)) AS s(i)\n"
" ), ', ')\n"
" ELSE\n"
" pg_catalog.array_to_string(ARRAY(\n"
" SELECT\n"
" CASE\n"
" WHEN COALESCE(p.proargnames[s.i+1], '') = '' THEN ''\n"
" ELSE p.proargnames[s.i+1] || ' '\n"
" END ||\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"
" END AS \"%s\",\n"
" CASE\n"
" WHEN p.proisagg THEN '%s'\n"
" WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN '%s'\n"
" ELSE '%s'\n"
" END AS \"%s\"",
gettext_noop("Result data type"),
gettext_noop("Argument data types"),
/* translator: "agg" is short for "aggregate" */
gettext_noop("agg"),
gettext_noop("trigger"),
gettext_noop("normal"),
gettext_noop("Type"));
else
appendPQExpBuffer(&buf,
" CASE WHEN p.proretset THEN 'SETOF ' ELSE '' END ||\n"
" pg_catalog.format_type(p.prorettype, NULL) as \"%s\",\n"
" pg_catalog.oidvectortypes(p.proargtypes) as \"%s\",\n"
" CASE\n"
" WHEN p.proisagg THEN '%s'\n"
" WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN '%s'\n"
" ELSE '%s'\n"
" END AS \"%s\"",
gettext_noop("Result data type"),
gettext_noop("Argument data types"),
/* translator: "agg" is short for "aggregate" */
gettext_noop("agg"),
gettext_noop("trigger"),
gettext_noop("normal"),
gettext_noop("Type"));
if (verbose)
appendPQExpBuffer(&buf,
",\n CASE WHEN prosecdef THEN '%s' ELSE '%s' END AS \"%s\""
",\n CASE\n"
" WHEN p.provolatile = 'i' THEN '%s'\n"
" WHEN p.provolatile = 's' THEN '%s'\n"
" WHEN p.provolatile = 'v' THEN '%s'\n"
" END as \"%s\""
",\n pg_catalog.pg_get_userbyid(p.proowner) as \"%s\",\n"
" l.lanname as \"%s\",\n"
" p.prosrc as \"%s\",\n"
" pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"",
gettext_noop("definer"),
gettext_noop("invoker"),
gettext_noop("Security"),
gettext_noop("immutable"),
gettext_noop("stable"),
gettext_noop("volatile"),
gettext_noop("Volatility"),
gettext_noop("Owner"),
gettext_noop("Language"),
gettext_noop("Source code"),
gettext_noop("Description"));
appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_proc p"
"\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n");
if (verbose)
appendPQExpBuffer(&buf,
" LEFT JOIN pg_catalog.pg_language l ON l.oid = p.prolang\n");
have_where = false;
/* filter by function type, if requested */
if (showNormal && showAggregate && showTrigger && showWindow)
/* Do nothing */ ;
else if (showNormal)
{
if (!showAggregate)
{
if (have_where)
appendPQExpBuffer(&buf, " AND ");
else
{
appendPQExpBuffer(&buf, "WHERE ");
have_where = true;
}
appendPQExpBuffer(&buf, "NOT p.proisagg\n");
}
if (!showTrigger)
{
if (have_where)
appendPQExpBuffer(&buf, " AND ");
else
{
appendPQExpBuffer(&buf, "WHERE ");
have_where = true;
}
appendPQExpBuffer(&buf, "p.prorettype <> 'pg_catalog.trigger'::pg_catalog.regtype\n");
}
if (!showWindow && pset.sversion >= 80400)
{
if (have_where)
appendPQExpBuffer(&buf, " AND ");
else
{
appendPQExpBuffer(&buf, "WHERE ");
have_where = true;
}
appendPQExpBuffer(&buf, "NOT p.proiswindow\n");
}
}
else
{
bool needs_or = false;
appendPQExpBuffer(&buf, "WHERE (\n ");
have_where = true;
/* Note: at least one of these must be true ... */
if (showAggregate)
{
appendPQExpBuffer(&buf, "p.proisagg\n");
needs_or = true;
}
if (showTrigger)
{
if (needs_or)
appendPQExpBuffer(&buf, " OR ");
appendPQExpBuffer(&buf,
"p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype\n");
needs_or = true;
}
if (showWindow)
{
if (needs_or)
appendPQExpBuffer(&buf, " OR ");
appendPQExpBuffer(&buf, "p.proiswindow\n");
needs_or = true;
}
appendPQExpBuffer(&buf, " )\n");
}
processSQLNamePattern(pset.db, &buf, pattern, have_where, false,
"n.nspname", "p.proname", NULL,
"pg_catalog.pg_function_is_visible(p.oid)");
if (!showSystem && !pattern)
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
" AND n.nspname <> 'information_schema'\n");
appendPQExpBuffer(&buf, "ORDER BY 1, 2, 4;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
myopt.nullPrint = NULL;
myopt.title = _("List of functions");
myopt.translate_header = true;
myopt.translate_columns = translate_columns;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
PQclear(res);
return true;
}
Definition at line 574 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, PSQLexec(), _psqlSettings::queryFout, termPQExpBuffer(), printQueryOpt::title, and printQueryOpt::translate_header.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
initPQExpBuffer(&buf);
/*
* Note: before Postgres 9.1, we did not assign comments to any built-in
* operators, preferring to let the comment on the underlying function
* suffice. The coalesce() on the obj_description() calls below supports
* this convention by providing a fallback lookup of a comment on the
* operator's function. As of 9.1 there is a policy that every built-in
* operator should have a comment; so the coalesce() is no longer
* necessary so far as built-in operators are concerned. We keep it
* anyway, for now, because (1) third-party modules may still be following
* the old convention, and (2) we'd need to do it anyway when talking to a
* pre-9.1 server.
*/
printfPQExpBuffer(&buf,
"SELECT n.nspname as \"%s\",\n"
" o.oprname AS \"%s\",\n"
" CASE WHEN o.oprkind='l' THEN NULL ELSE pg_catalog.format_type(o.oprleft, NULL) END AS \"%s\",\n"
" CASE WHEN o.oprkind='r' THEN NULL ELSE pg_catalog.format_type(o.oprright, NULL) END AS \"%s\",\n"
" pg_catalog.format_type(o.oprresult, NULL) AS \"%s\",\n"
" coalesce(pg_catalog.obj_description(o.oid, 'pg_operator'),\n"
" pg_catalog.obj_description(o.oprcode, 'pg_proc')) AS \"%s\"\n"
"FROM pg_catalog.pg_operator o\n"
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = o.oprnamespace\n",
gettext_noop("Schema"),
gettext_noop("Name"),
gettext_noop("Left arg type"),
gettext_noop("Right arg type"),
gettext_noop("Result type"),
gettext_noop("Description"));
if (!showSystem && !pattern)
appendPQExpBuffer(&buf, "WHERE n.nspname <> 'pg_catalog'\n"
" AND n.nspname <> 'information_schema'\n");
processSQLNamePattern(pset.db, &buf, pattern, !showSystem && !pattern, true,
"n.nspname", "o.oprname", NULL,
"pg_catalog.pg_operator_is_visible(o.oid)");
appendPQExpBuffer(&buf, "ORDER BY 1, 2, 3, 4;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
myopt.nullPrint = NULL;
myopt.title = _("List of operators");
myopt.translate_header = true;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
PQclear(res);
return true;
}
Definition at line 2396 of file describe.c.
References _, add_role_attribute(), appendPQExpBuffer(), appendPQExpBufferStr(), buf, conns, PQExpBufferData::data, _psqlSettings::db, printTableOpt::default_footer, free, gettext_noop, i, initPQExpBuffer(), PQExpBufferData::len, _psqlSettings::logfile, ngettext, NULL, pg_malloc0(), pg_strdup(), _psqlSettings::popt, PQclear(), PQgetvalue(), PQntuples(), printfPQExpBuffer(), printTable(), printTableAddCell(), printTableAddHeader(), printTableCleanup(), printTableInit(), processSQLNamePattern(), pset, PSQLexec(), _psqlSettings::queryFout, resetPQExpBuffer(), _psqlSettings::sversion, termPQExpBuffer(), and printQueryOpt::topt.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printTableContent cont;
printTableOpt myopt = pset.popt.topt;
int ncols = 3;
int nrows = 0;
int i;
int conns;
const char align = 'l';
char **attr;
myopt.default_footer = false;
initPQExpBuffer(&buf);
if (pset.sversion >= 80100)
{
printfPQExpBuffer(&buf,
"SELECT r.rolname, r.rolsuper, r.rolinherit,\n"
" r.rolcreaterole, r.rolcreatedb, r.rolcanlogin,\n"
" r.rolconnlimit, r.rolvaliduntil,\n"
" ARRAY(SELECT b.rolname\n"
" FROM pg_catalog.pg_auth_members m\n"
" JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid)\n"
" WHERE m.member = r.oid) as memberof");
if (verbose && pset.sversion >= 80200)
{
appendPQExpBufferStr(&buf, "\n, pg_catalog.shobj_description(r.oid, 'pg_authid') AS description");
ncols++;
}
if (pset.sversion >= 90100)
{
appendPQExpBufferStr(&buf, "\n, r.rolreplication");
}
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n");
processSQLNamePattern(pset.db, &buf, pattern, false, false,
NULL, "r.rolname", NULL, NULL);
}
else
{
printfPQExpBuffer(&buf,
"SELECT u.usename AS rolname,\n"
" u.usesuper AS rolsuper,\n"
" true AS rolinherit, false AS rolcreaterole,\n"
" u.usecreatedb AS rolcreatedb, true AS rolcanlogin,\n"
" -1 AS rolconnlimit,"
" u.valuntil as rolvaliduntil,\n"
" ARRAY(SELECT g.groname FROM pg_catalog.pg_group g WHERE u.usesysid = ANY(g.grolist)) as memberof"
"\nFROM pg_catalog.pg_user u\n");
processSQLNamePattern(pset.db, &buf, pattern, false, false,
NULL, "u.usename", NULL, NULL);
}
appendPQExpBuffer(&buf, "ORDER BY 1;");
res = PSQLexec(buf.data, false);
if (!res)
return false;
nrows = PQntuples(res);
attr = pg_malloc0((nrows + 1) * sizeof(*attr));
printTableInit(&cont, &myopt, _("List of roles"), ncols, nrows);
printTableAddHeader(&cont, gettext_noop("Role name"), true, align);
printTableAddHeader(&cont, gettext_noop("Attributes"), true, align);
printTableAddHeader(&cont, gettext_noop("Member of"), true, align);
if (verbose && pset.sversion >= 80200)
printTableAddHeader(&cont, gettext_noop("Description"), true, align);
for (i = 0; i < nrows; i++)
{
printTableAddCell(&cont, PQgetvalue(res, i, 0), false, false);
resetPQExpBuffer(&buf);
if (strcmp(PQgetvalue(res, i, 1), "t") == 0)
add_role_attribute(&buf, _("Superuser"));
if (strcmp(PQgetvalue(res, i, 2), "t") != 0)
add_role_attribute(&buf, _("No inheritance"));
if (strcmp(PQgetvalue(res, i, 3), "t") == 0)
add_role_attribute(&buf, _("Create role"));
if (strcmp(PQgetvalue(res, i, 4), "t") == 0)
add_role_attribute(&buf, _("Create DB"));
if (strcmp(PQgetvalue(res, i, 5), "t") != 0)
add_role_attribute(&buf, _("Cannot login"));
if (pset.sversion >= 90100)
if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
add_role_attribute(&buf, _("Replication"));
conns = atoi(PQgetvalue(res, i, 6));
if (conns >= 0)
{
if (buf.len > 0)
appendPQExpBufferStr(&buf, "\n");
if (conns == 0)
appendPQExpBuffer(&buf, _("No connections"));
else
appendPQExpBuffer(&buf, ngettext("%d connection",
"%d connections",
conns),
conns);
}
if (strcmp(PQgetvalue(res, i, 7), "") != 0)
{
if (buf.len > 0)
appendPQExpBufferStr(&buf, "\n");
appendPQExpBufferStr(&buf, _("Password valid until "));
appendPQExpBufferStr(&buf, PQgetvalue(res, i, 7));
}
attr[i] = pg_strdup(buf.data);
printTableAddCell(&cont, attr[i], false, false);
printTableAddCell(&cont, PQgetvalue(res, i, 8), false, false);
if (verbose && pset.sversion >= 80200)
printTableAddCell(&cont, PQgetvalue(res, i, 9), false, false);
}
termPQExpBuffer(&buf);
printTable(&cont, pset.queryFout, pset.logfile);
printTableCleanup(&cont);
for (i = 0; i < nrows; i++)
free(attr[i]);
free(attr);
PQclear(res);
return true;
}
Definition at line 1047 of file describe.c.
References appendPQExpBuffer(), buf, cancel_pressed, PQExpBufferData::data, _psqlSettings::db, describeOneTableDetails(), i, initPQExpBuffer(), NULL, PQclear(), PQgetvalue(), PQntuples(), printfPQExpBuffer(), processSQLNamePattern(), pset, psql_error(), PSQLexec(), _psqlSettings::quiet, and termPQExpBuffer().
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
int i;
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT c.oid,\n"
" n.nspname,\n"
" c.relname\n"
"FROM pg_catalog.pg_class c\n"
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n");
if (!showSystem && !pattern)
appendPQExpBuffer(&buf, "WHERE n.nspname <> 'pg_catalog'\n"
" AND n.nspname <> 'information_schema'\n");
processSQLNamePattern(pset.db, &buf, pattern, !showSystem && !pattern, false,
"n.nspname", "c.relname", NULL,
"pg_catalog.pg_table_is_visible(c.oid)");
appendPQExpBuffer(&buf, "ORDER BY 2, 3;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
if (PQntuples(res) == 0)
{
if (!pset.quiet)
psql_error("Did not find any relation named \"%s\".\n",
pattern);
PQclear(res);
return false;
}
for (i = 0; i < PQntuples(res); i++)
{
const char *oid;
const char *nspname;
const char *relname;
oid = PQgetvalue(res, i, 0);
nspname = PQgetvalue(res, i, 1);
relname = PQgetvalue(res, i, 2);
if (!describeOneTableDetails(nspname, relname, oid, verbose))
{
PQclear(res);
return false;
}
if (cancel_pressed)
{
PQclear(res);
return false;
}
}
PQclear(res);
return true;
}
Definition at line 129 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printACLColumn(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, psql_error(), PSQLexec(), _psqlSettings::queryFout, _psqlSettings::sversion, termPQExpBuffer(), printQueryOpt::title, and printQueryOpt::translate_header.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
if (pset.sversion < 80000)
{
psql_error("The server (version %d.%d) does not support tablespaces.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
initPQExpBuffer(&buf);
if (pset.sversion >= 90200)
printfPQExpBuffer(&buf,
"SELECT spcname AS \"%s\",\n"
" pg_catalog.pg_get_userbyid(spcowner) AS \"%s\",\n"
" pg_catalog.pg_tablespace_location(oid) AS \"%s\"",
gettext_noop("Name"),
gettext_noop("Owner"),
gettext_noop("Location"));
else
printfPQExpBuffer(&buf,
"SELECT spcname AS \"%s\",\n"
" pg_catalog.pg_get_userbyid(spcowner) AS \"%s\",\n"
" spclocation AS \"%s\"",
gettext_noop("Name"),
gettext_noop("Owner"),
gettext_noop("Location"));
if (verbose)
{
appendPQExpBuffer(&buf, ",\n ");
printACLColumn(&buf, "spcacl");
}
if (verbose && pset.sversion >= 80200)
appendPQExpBuffer(&buf,
",\n pg_catalog.shobj_description(oid, 'pg_tablespace') AS \"%s\"",
gettext_noop("Description"));
appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_tablespace\n");
processSQLNamePattern(pset.db, &buf, pattern, false, false,
NULL, "spcname", NULL,
NULL);
appendPQExpBuffer(&buf, "ORDER BY 1;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
myopt.nullPrint = NULL;
myopt.title = _("List of tablespaces");
myopt.translate_header = true;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
PQclear(res);
return true;
}
Definition at line 467 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printACLColumn(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, PSQLexec(), _psqlSettings::queryFout, _psqlSettings::sversion, termPQExpBuffer(), printQueryOpt::title, and printQueryOpt::translate_header.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT n.nspname as \"%s\",\n"
" pg_catalog.format_type(t.oid, NULL) AS \"%s\",\n",
gettext_noop("Schema"),
gettext_noop("Name"));
if (verbose)
appendPQExpBuffer(&buf,
" t.typname AS \"%s\",\n"
" CASE WHEN t.typrelid != 0\n"
" THEN CAST('tuple' AS pg_catalog.text)\n"
" WHEN t.typlen < 0\n"
" THEN CAST('var' AS pg_catalog.text)\n"
" ELSE CAST(t.typlen AS pg_catalog.text)\n"
" END AS \"%s\",\n",
gettext_noop("Internal name"),
gettext_noop("Size"));
if (verbose && pset.sversion >= 80300)
{
appendPQExpBuffer(&buf,
" pg_catalog.array_to_string(\n"
" ARRAY(\n"
" SELECT e.enumlabel\n"
" FROM pg_catalog.pg_enum e\n"
" WHERE e.enumtypid = t.oid\n");
if (pset.sversion >= 90100)
appendPQExpBuffer(&buf,
" ORDER BY e.enumsortorder\n");
else
appendPQExpBuffer(&buf,
" ORDER BY e.oid\n");
appendPQExpBuffer(&buf,
" ),\n"
" E'\\n'\n"
" ) AS \"%s\",\n",
gettext_noop("Elements"));
}
if (verbose && pset.sversion >= 90200)
{
printACLColumn(&buf, "t.typacl");
appendPQExpBuffer(&buf, ",\n ");
}
appendPQExpBuffer(&buf,
" pg_catalog.obj_description(t.oid, 'pg_type') as \"%s\"\n",
gettext_noop("Description"));
appendPQExpBuffer(&buf, "FROM pg_catalog.pg_type t\n"
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n");
/*
* do not include complex types (typrelid!=0) unless they are standalone
* composite types
*/
appendPQExpBuffer(&buf, "WHERE (t.typrelid = 0 ");
appendPQExpBuffer(&buf, "OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c "
"WHERE c.oid = t.typrelid))\n");
/*
* do not include array types (before 8.3 we have to use the assumption
* that their names start with underscore)
*/
if (pset.sversion >= 80300)
appendPQExpBuffer(&buf, " AND NOT EXISTS(SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem AND el.typarray = t.oid)\n");
else
appendPQExpBuffer(&buf, " AND t.typname !~ '^_'\n");
if (!showSystem && !pattern)
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
" AND n.nspname <> 'information_schema'\n");
/* Match name pattern against either internal or external name */
processSQLNamePattern(pset.db, &buf, pattern, true, false,
"n.nspname", "t.typname",
"pg_catalog.format_type(t.oid, NULL)",
"pg_catalog.pg_type_is_visible(t.oid)");
appendPQExpBuffer(&buf, "ORDER BY 1, 2;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
myopt.nullPrint = NULL;
myopt.title = _("List of data types");
myopt.translate_header = true;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
PQclear(res);
return true;
}
Definition at line 644 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printACLColumn(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, PSQLexec(), _psqlSettings::queryFout, _psqlSettings::sversion, termPQExpBuffer(), printQueryOpt::title, and printQueryOpt::translate_header.
Referenced by exec_command(), and main().
{
PGresult *res;
PQExpBufferData buf;
printQueryOpt myopt = pset.popt;
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT d.datname as \"%s\",\n"
" pg_catalog.pg_get_userbyid(d.datdba) as \"%s\",\n"
" pg_catalog.pg_encoding_to_char(d.encoding) as \"%s\",\n",
gettext_noop("Name"),
gettext_noop("Owner"),
gettext_noop("Encoding"));
if (pset.sversion >= 80400)
appendPQExpBuffer(&buf,
" d.datcollate as \"%s\",\n"
" d.datctype as \"%s\",\n",
gettext_noop("Collate"),
gettext_noop("Ctype"));
appendPQExpBuffer(&buf, " ");
printACLColumn(&buf, "d.datacl");
if (verbose && pset.sversion >= 80200)
appendPQExpBuffer(&buf,
",\n CASE WHEN pg_catalog.has_database_privilege(d.datname, 'CONNECT')\n"
" THEN pg_catalog.pg_size_pretty(pg_catalog.pg_database_size(d.datname))\n"
" ELSE 'No Access'\n"
" END as \"%s\"",
gettext_noop("Size"));
if (verbose && pset.sversion >= 80000)
appendPQExpBuffer(&buf,
",\n t.spcname as \"%s\"",
gettext_noop("Tablespace"));
if (verbose && pset.sversion >= 80200)
appendPQExpBuffer(&buf,
",\n pg_catalog.shobj_description(d.oid, 'pg_database') as \"%s\"",
gettext_noop("Description"));
appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_database d\n");
if (verbose && pset.sversion >= 80000)
appendPQExpBuffer(&buf,
" JOIN pg_catalog.pg_tablespace t on d.dattablespace = t.oid\n");
if (pattern)
processSQLNamePattern(pset.db, &buf, pattern, false, false,
NULL, "d.datname", NULL, NULL);
appendPQExpBuffer(&buf, "ORDER BY 1;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
myopt.nullPrint = NULL;
myopt.title = _("List of databases");
myopt.translate_header = true;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
PQclear(res);
return true;
}
Definition at line 3078 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, PSQLexec(), _psqlSettings::queryFout, termPQExpBuffer(), printQueryOpt::title, printQueryOpt::translate_columns, and printQueryOpt::translate_header.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, true};
initPQExpBuffer(&buf);
/*
* We need a left join to pg_proc for binary casts; the others are just
* paranoia. Also note that we don't attempt to localize '(binary
* coercible)', because there's too much risk of gettext translating a
* function name that happens to match some string in the PO database.
*/
printfPQExpBuffer(&buf,
"SELECT pg_catalog.format_type(castsource, NULL) AS \"%s\",\n"
" pg_catalog.format_type(casttarget, NULL) AS \"%s\",\n"
" CASE WHEN castfunc = 0 THEN '(binary coercible)'\n"
" ELSE p.proname\n"
" END as \"%s\",\n"
" CASE WHEN c.castcontext = 'e' THEN '%s'\n"
" WHEN c.castcontext = 'a' THEN '%s'\n"
" ELSE '%s'\n"
" END as \"%s\"",
gettext_noop("Source type"),
gettext_noop("Target type"),
gettext_noop("Function"),
gettext_noop("no"),
gettext_noop("in assignment"),
gettext_noop("yes"),
gettext_noop("Implicit?"));
if (verbose)
appendPQExpBuffer(&buf,
",\n d.description AS \"%s\"\n",
gettext_noop("Description"));
appendPQExpBuffer(&buf,
"FROM pg_catalog.pg_cast c LEFT JOIN pg_catalog.pg_proc p\n"
" ON c.castfunc = p.oid\n"
" LEFT JOIN pg_catalog.pg_type ts\n"
" ON c.castsource = ts.oid\n"
" LEFT JOIN pg_catalog.pg_namespace ns\n"
" ON ns.oid = ts.typnamespace\n"
" LEFT JOIN pg_catalog.pg_type tt\n"
" ON c.casttarget = tt.oid\n"
" LEFT JOIN pg_catalog.pg_namespace nt\n"
" ON nt.oid = tt.typnamespace\n");
if (verbose)
appendPQExpBuffer(&buf,
" LEFT JOIN pg_catalog.pg_description d\n"
" ON d.classoid = c.tableoid AND d.objoid = "
"c.oid AND d.objsubid = 0\n");
appendPQExpBuffer(&buf, "WHERE ( (true");
/*
* Match name pattern against either internal or external name of either
* castsource or casttarget
*/
processSQLNamePattern(pset.db, &buf, pattern, true, false,
"ns.nspname", "ts.typname",
"pg_catalog.format_type(ts.oid, NULL)",
"pg_catalog.pg_type_is_visible(ts.oid)");
appendPQExpBuffer(&buf, ") OR (true");
processSQLNamePattern(pset.db, &buf, pattern, true, false,
"nt.nspname", "tt.typname",
"pg_catalog.format_type(tt.oid, NULL)",
"pg_catalog.pg_type_is_visible(tt.oid)");
appendPQExpBuffer(&buf, ") )\nORDER BY 1, 2;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
myopt.nullPrint = NULL;
myopt.title = _("List of casts");
myopt.translate_header = true;
myopt.translate_columns = translate_columns;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
PQclear(res);
return true;
}
Definition at line 3176 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, psql_error(), PSQLexec(), _psqlSettings::queryFout, _psqlSettings::sversion, termPQExpBuffer(), printQueryOpt::title, printQueryOpt::translate_columns, and printQueryOpt::translate_header.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, false};
if (pset.sversion < 90100)
{
psql_error("The server (version %d.%d) does not support collations.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT n.nspname AS \"%s\",\n"
" c.collname AS \"%s\",\n"
" c.collcollate AS \"%s\",\n"
" c.collctype AS \"%s\"",
gettext_noop("Schema"),
gettext_noop("Name"),
gettext_noop("Collate"),
gettext_noop("Ctype"));
if (verbose)
appendPQExpBuffer(&buf,
",\n pg_catalog.obj_description(c.oid, 'pg_collation') AS \"%s\"",
gettext_noop("Description"));
appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_collation c, pg_catalog.pg_namespace n\n"
"WHERE n.oid = c.collnamespace\n");
if (!showSystem && !pattern)
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
" AND n.nspname <> 'information_schema'\n");
/*
* Hide collations that aren't usable in the current database's encoding.
* If you think to change this, note that pg_collation_is_visible rejects
* unusable collations, so you will need to hack name pattern processing
* somehow to avoid inconsistent behavior.
*/
appendPQExpBuffer(&buf, " AND c.collencoding IN (-1, pg_catalog.pg_char_to_encoding(pg_catalog.getdatabaseencoding()))\n");
processSQLNamePattern(pset.db, &buf, pattern, true, false,
"n.nspname", "c.collname", NULL,
"pg_catalog.pg_collation_is_visible(c.oid)");
appendPQExpBuffer(&buf, "ORDER BY 1, 2;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
myopt.nullPrint = NULL;
myopt.title = _("List of collations");
myopt.translate_header = true;
myopt.translate_columns = translate_columns;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
PQclear(res);
return true;
}
Definition at line 2943 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, PSQLexec(), _psqlSettings::queryFout, termPQExpBuffer(), printQueryOpt::title, printQueryOpt::translate_columns, and printQueryOpt::translate_header.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false, true};
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT n.nspname AS \"%s\",\n"
" c.conname AS \"%s\",\n"
" pg_catalog.pg_encoding_to_char(c.conforencoding) AS \"%s\",\n"
" pg_catalog.pg_encoding_to_char(c.contoencoding) AS \"%s\",\n"
" CASE WHEN c.condefault THEN '%s'\n"
" ELSE '%s' END AS \"%s\"",
gettext_noop("Schema"),
gettext_noop("Name"),
gettext_noop("Source"),
gettext_noop("Destination"),
gettext_noop("yes"), gettext_noop("no"),
gettext_noop("Default?"));
if (verbose)
appendPQExpBuffer(&buf,
",\n d.description AS \"%s\"",
gettext_noop("Description"));
appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_conversion c\n"
" JOIN pg_catalog.pg_namespace n "
"ON n.oid = c.connamespace\n");
if (verbose)
appendPQExpBuffer(&buf,
"LEFT JOIN pg_catalog.pg_description d "
"ON d.classoid = c.tableoid\n"
" AND d.objoid = c.oid "
"AND d.objsubid = 0\n");
appendPQExpBuffer(&buf, "WHERE true\n");
if (!showSystem && !pattern)
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
" AND n.nspname <> 'information_schema'\n");
processSQLNamePattern(pset.db, &buf, pattern, true, false,
"n.nspname", "c.conname", NULL,
"pg_catalog.pg_conversion_is_visible(c.oid)");
appendPQExpBuffer(&buf, "ORDER BY 1, 2;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
myopt.nullPrint = NULL;
myopt.title = _("List of conversions");
myopt.translate_header = true;
myopt.translate_columns = translate_columns;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
PQclear(res);
return true;
}
| bool listDbRoleSettings | ( | const char * | pattern1, | |
| const char * | pattern2 | |||
| ) |
Definition at line 2555 of file describe.c.
References _, appendPQExpBufferStr(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), PQntuples(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, PSQLexec(), _psqlSettings::queryFout, _psqlSettings::quiet, resetPQExpBuffer(), _psqlSettings::sversion, printQueryOpt::title, and printQueryOpt::translate_header.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
initPQExpBuffer(&buf);
if (pset.sversion >= 90000)
{
bool havewhere;
printfPQExpBuffer(&buf, "SELECT rolname AS \"%s\", datname AS \"%s\",\n"
"pg_catalog.array_to_string(setconfig, E'\\n') AS \"%s\"\n"
"FROM pg_db_role_setting AS s\n"
"LEFT JOIN pg_database ON pg_database.oid = setdatabase\n"
"LEFT JOIN pg_roles ON pg_roles.oid = setrole\n",
gettext_noop("Role"),
gettext_noop("Database"),
gettext_noop("Settings"));
havewhere = processSQLNamePattern(pset.db, &buf, pattern, false, false,
NULL, "pg_roles.rolname", NULL, NULL);
processSQLNamePattern(pset.db, &buf, pattern2, havewhere, false,
NULL, "pg_database.datname", NULL, NULL);
appendPQExpBufferStr(&buf, "ORDER BY 1, 2;");
}
else
{
fprintf(pset.queryFout,
_("No per-database role settings support in this server version.\n"));
return false;
}
res = PSQLexec(buf.data, false);
if (!res)
return false;
if (PQntuples(res) == 0 && !pset.quiet)
{
if (pattern)
fprintf(pset.queryFout, _("No matching settings found.\n"));
else
fprintf(pset.queryFout, _("No settings found.\n"));
}
else
{
myopt.nullPrint = NULL;
myopt.title = _("List of settings");
myopt.translate_header = true;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
}
PQclear(res);
resetPQExpBuffer(&buf);
return true;
}
| bool listDefaultACLs | ( | const char * | pattern | ) |
Definition at line 800 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, DEFACLOBJ_FUNCTION, DEFACLOBJ_RELATION, DEFACLOBJ_SEQUENCE, DEFACLOBJ_TYPE, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printACLColumn(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, psql_error(), PSQLexec(), _psqlSettings::queryFout, _psqlSettings::sversion, termPQExpBuffer(), printQueryOpt::title, printQueryOpt::translate_columns, and printQueryOpt::translate_header.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, true, false};
if (pset.sversion < 90000)
{
psql_error("The server (version %d.%d) does not support altering default privileges.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT pg_catalog.pg_get_userbyid(d.defaclrole) AS \"%s\",\n"
" n.nspname AS \"%s\",\n"
" CASE d.defaclobjtype WHEN '%c' THEN '%s' WHEN '%c' THEN '%s' WHEN '%c' THEN '%s' WHEN '%c' THEN '%s' END AS \"%s\",\n"
" ",
gettext_noop("Owner"),
gettext_noop("Schema"),
DEFACLOBJ_RELATION,
gettext_noop("table"),
DEFACLOBJ_SEQUENCE,
gettext_noop("sequence"),
DEFACLOBJ_FUNCTION,
gettext_noop("function"),
DEFACLOBJ_TYPE,
gettext_noop("type"),
gettext_noop("Type"));
printACLColumn(&buf, "d.defaclacl");
appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_default_acl d\n"
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = d.defaclnamespace\n");
processSQLNamePattern(pset.db, &buf, pattern, false, false,
NULL,
"n.nspname",
"pg_catalog.pg_get_userbyid(d.defaclrole)",
NULL);
appendPQExpBuffer(&buf, "ORDER BY 1, 2, 3;");
res = PSQLexec(buf.data, false);
if (!res)
{
termPQExpBuffer(&buf);
return false;
}
myopt.nullPrint = NULL;
printfPQExpBuffer(&buf, _("Default access privileges"));
myopt.title = buf.data;
myopt.translate_header = true;
myopt.translate_columns = translate_columns;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
termPQExpBuffer(&buf);
PQclear(res);
return true;
}
Definition at line 2857 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printACLColumn(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, PSQLexec(), _psqlSettings::queryFout, _psqlSettings::sversion, termPQExpBuffer(), printQueryOpt::title, and printQueryOpt::translate_header.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT n.nspname as \"%s\",\n"
" t.typname as \"%s\",\n"
" pg_catalog.format_type(t.typbasetype, t.typtypmod) as \"%s\",\n"
" TRIM(LEADING\n",
gettext_noop("Schema"),
gettext_noop("Name"),
gettext_noop("Type"));
if (pset.sversion >= 90100)
appendPQExpBuffer(&buf,
" COALESCE((SELECT ' collate ' || c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type bt\n"
" WHERE c.oid = t.typcollation AND bt.oid = t.typbasetype AND t.typcollation <> bt.typcollation), '') ||\n");
appendPQExpBuffer(&buf,
" CASE WHEN t.typnotnull THEN ' not null' ELSE '' END ||\n"
" CASE WHEN t.typdefault IS NOT NULL THEN ' default ' || t.typdefault ELSE '' END\n"
" ) as \"%s\",\n"
" pg_catalog.array_to_string(ARRAY(\n"
" SELECT pg_catalog.pg_get_constraintdef(r.oid, true) FROM pg_catalog.pg_constraint r WHERE t.oid = r.contypid\n"
" ), ' ') as \"%s\"",
gettext_noop("Modifier"),
gettext_noop("Check"));
if (verbose)
{
if (pset.sversion >= 90200)
{
appendPQExpBuffer(&buf, ",\n ");
printACLColumn(&buf, "t.typacl");
}
appendPQExpBuffer(&buf,
",\n d.description as \"%s\"",
gettext_noop("Description"));
}
appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_type t\n"
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n");
if (verbose)
appendPQExpBuffer(&buf,
" LEFT JOIN pg_catalog.pg_description d "
"ON d.classoid = t.tableoid AND d.objoid = t.oid "
"AND d.objsubid = 0\n");
appendPQExpBuffer(&buf, "WHERE t.typtype = 'd'\n");
if (!showSystem && !pattern)
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
" AND n.nspname <> 'information_schema'\n");
processSQLNamePattern(pset.db, &buf, pattern, true, false,
"n.nspname", "t.typname", NULL,
"pg_catalog.pg_type_is_visible(t.oid)");
appendPQExpBuffer(&buf, "ORDER BY 1, 2;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
myopt.nullPrint = NULL;
myopt.title = _("List of domains");
myopt.translate_header = true;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
PQclear(res);
return true;
}
Definition at line 3017 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, PSQLexec(), _psqlSettings::queryFout, termPQExpBuffer(), printQueryOpt::title, printQueryOpt::translate_columns, and printQueryOpt::translate_header.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] =
{false, false, false, true, false, false, false};
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"select evtname as \"%s\", "
"evtevent as \"%s\", "
"pg_catalog.pg_get_userbyid(e.evtowner) AS \"%s\", "
"case evtenabled when 'O' then 'enabled' "
" when 'R' then 'replica' "
" when 'A' then 'always' "
" when 'D' then 'disabled' end as \"%s\", "
"e.evtfoid::regproc as \"%s\", "
"array_to_string(array(select x "
" from unnest(evttags) as t(x)), ', ') as \"%s\" ",
gettext_noop("Name"),
gettext_noop("Event"),
gettext_noop("Owner"),
gettext_noop("Enabled"),
gettext_noop("Procedure"),
gettext_noop("Tags"));
if (verbose)
appendPQExpBuffer(&buf,
",\npg_catalog.obj_description(e.oid, 'pg_event_trigger') as \"%s\"",
gettext_noop("Description"));
appendPQExpBuffer(&buf,
"\nFROM pg_event_trigger e ");
processSQLNamePattern(pset.db, &buf, pattern, false, false,
NULL, "evtname", NULL, NULL);
appendPQExpBuffer(&buf, "ORDER BY 1");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
myopt.nullPrint = NULL;
myopt.title = _("List of event triggers");
myopt.translate_header = true;
myopt.translate_columns = translate_columns;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
PQclear(res);
return true;
}
| bool listExtensionContents | ( | const char * | pattern | ) |
Definition at line 4220 of file describe.c.
References appendPQExpBuffer(), buf, cancel_pressed, PQExpBufferData::data, _psqlSettings::db, i, initPQExpBuffer(), listOneExtensionContents(), NULL, PQclear(), PQgetvalue(), PQntuples(), printfPQExpBuffer(), processSQLNamePattern(), pset, psql_error(), PSQLexec(), _psqlSettings::quiet, _psqlSettings::sversion, and termPQExpBuffer().
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
int i;
if (pset.sversion < 90100)
{
psql_error("The server (version %d.%d) does not support extensions.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT e.extname, e.oid\n"
"FROM pg_catalog.pg_extension e\n");
processSQLNamePattern(pset.db, &buf, pattern,
false, false,
NULL, "e.extname", NULL,
NULL);
appendPQExpBuffer(&buf, "ORDER BY 1;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
if (PQntuples(res) == 0)
{
if (!pset.quiet)
{
if (pattern)
psql_error("Did not find any extension named \"%s\".\n",
pattern);
else
psql_error("Did not find any extensions.\n");
}
PQclear(res);
return false;
}
for (i = 0; i < PQntuples(res); i++)
{
const char *extname;
const char *oid;
extname = PQgetvalue(res, i, 0);
oid = PQgetvalue(res, i, 1);
if (!listOneExtensionContents(extname, oid))
{
PQclear(res);
return false;
}
if (cancel_pressed)
{
PQclear(res);
return false;
}
}
PQclear(res);
return true;
}
| bool listExtensions | ( | const char * | pattern | ) |
Definition at line 4166 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, psql_error(), PSQLexec(), _psqlSettings::queryFout, _psqlSettings::sversion, termPQExpBuffer(), printQueryOpt::title, and printQueryOpt::translate_header.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
if (pset.sversion < 90100)
{
psql_error("The server (version %d.%d) does not support extensions.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT e.extname AS \"%s\", "
"e.extversion AS \"%s\", n.nspname AS \"%s\", c.description AS \"%s\"\n"
"FROM pg_catalog.pg_extension e "
"LEFT JOIN pg_catalog.pg_namespace n ON n.oid = e.extnamespace "
"LEFT JOIN pg_catalog.pg_description c ON c.objoid = e.oid "
"AND c.classoid = 'pg_catalog.pg_extension'::pg_catalog.regclass\n",
gettext_noop("Name"),
gettext_noop("Version"),
gettext_noop("Schema"),
gettext_noop("Description"));
processSQLNamePattern(pset.db, &buf, pattern,
false, false,
NULL, "e.extname", NULL,
NULL);
appendPQExpBuffer(&buf, "ORDER BY 1;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
myopt.nullPrint = NULL;
myopt.title = _("List of installed extensions");
myopt.translate_header = true;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
PQclear(res);
return true;
}
Definition at line 3875 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printACLColumn(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, psql_error(), PSQLexec(), _psqlSettings::queryFout, _psqlSettings::sversion, termPQExpBuffer(), printQueryOpt::title, and printQueryOpt::translate_header.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
if (pset.sversion < 80400)
{
psql_error("The server (version %d.%d) does not support foreign-data wrappers.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT fdw.fdwname AS \"%s\",\n"
" pg_catalog.pg_get_userbyid(fdw.fdwowner) AS \"%s\",\n",
gettext_noop("Name"),
gettext_noop("Owner"));
if (pset.sversion >= 90100)
appendPQExpBuffer(&buf,
" fdw.fdwhandler::pg_catalog.regproc AS \"%s\",\n",
gettext_noop("Handler"));
appendPQExpBuffer(&buf,
" fdw.fdwvalidator::pg_catalog.regproc AS \"%s\"",
gettext_noop("Validator"));
if (verbose)
{
appendPQExpBuffer(&buf, ",\n ");
printACLColumn(&buf, "fdwacl");
appendPQExpBuffer(&buf,
",\n CASE WHEN fdwoptions IS NULL THEN '' ELSE "
" '(' || array_to_string(ARRAY(SELECT "
" quote_ident(option_name) || ' ' || "
" quote_literal(option_value) FROM "
" pg_options_to_table(fdwoptions)), ', ') || ')' "
" END AS \"%s\"",
gettext_noop("FDW Options"));
if (pset.sversion >= 90100)
appendPQExpBuffer(&buf,
",\n d.description AS \"%s\" ",
gettext_noop("Description"));
}
appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_foreign_data_wrapper fdw\n");
if (verbose && pset.sversion >= 90100)
appendPQExpBuffer(&buf,
"LEFT JOIN pg_catalog.pg_description d\n"
" ON d.classoid = fdw.tableoid "
"AND d.objoid = fdw.oid AND d.objsubid = 0\n");
processSQLNamePattern(pset.db, &buf, pattern, false, false,
NULL, "fdwname", NULL, NULL);
appendPQExpBuffer(&buf, "ORDER BY 1;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
myopt.nullPrint = NULL;
myopt.title = _("List of foreign-data wrappers");
myopt.translate_header = true;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
PQclear(res);
return true;
}
Definition at line 3955 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printACLColumn(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, psql_error(), PSQLexec(), _psqlSettings::queryFout, _psqlSettings::sversion, termPQExpBuffer(), printQueryOpt::title, and printQueryOpt::translate_header.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
if (pset.sversion < 80400)
{
psql_error("The server (version %d.%d) does not support foreign servers.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT s.srvname AS \"%s\",\n"
" pg_catalog.pg_get_userbyid(s.srvowner) AS \"%s\",\n"
" f.fdwname AS \"%s\"",
gettext_noop("Name"),
gettext_noop("Owner"),
gettext_noop("Foreign-data wrapper"));
if (verbose)
{
appendPQExpBuffer(&buf, ",\n ");
printACLColumn(&buf, "s.srvacl");
appendPQExpBuffer(&buf,
",\n"
" s.srvtype AS \"%s\",\n"
" s.srvversion AS \"%s\",\n"
" CASE WHEN srvoptions IS NULL THEN '' ELSE "
" '(' || array_to_string(ARRAY(SELECT "
" quote_ident(option_name) || ' ' || "
" quote_literal(option_value) FROM "
" pg_options_to_table(srvoptions)), ', ') || ')' "
" END AS \"%s\",\n"
" d.description AS \"%s\"",
gettext_noop("Type"),
gettext_noop("Version"),
gettext_noop("FDW Options"),
gettext_noop("Description"));
}
appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_foreign_server s\n"
" JOIN pg_catalog.pg_foreign_data_wrapper f ON f.oid=s.srvfdw\n");
if (verbose)
appendPQExpBuffer(&buf,
"LEFT JOIN pg_description d\n "
"ON d.classoid = s.tableoid AND d.objoid = s.oid "
"AND d.objsubid = 0\n");
processSQLNamePattern(pset.db, &buf, pattern, false, false,
NULL, "s.srvname", NULL, NULL);
appendPQExpBuffer(&buf, "ORDER BY 1;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
myopt.nullPrint = NULL;
myopt.title = _("List of foreign servers");
myopt.translate_header = true;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
PQclear(res);
return true;
}
Definition at line 4092 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, psql_error(), PSQLexec(), _psqlSettings::queryFout, _psqlSettings::sversion, termPQExpBuffer(), printQueryOpt::title, and printQueryOpt::translate_header.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
if (pset.sversion < 90100)
{
psql_error("The server (version %d.%d) does not support foreign tables.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT n.nspname AS \"%s\",\n"
" c.relname AS \"%s\",\n"
" s.srvname AS \"%s\"",
gettext_noop("Schema"),
gettext_noop("Table"),
gettext_noop("Server"));
if (verbose)
appendPQExpBuffer(&buf,
",\n CASE WHEN ftoptions IS NULL THEN '' ELSE "
" '(' || array_to_string(ARRAY(SELECT "
" quote_ident(option_name) || ' ' || "
" quote_literal(option_value) FROM "
" pg_options_to_table(ftoptions)), ', ') || ')' "
" END AS \"%s\",\n"
" d.description AS \"%s\"",
gettext_noop("FDW Options"),
gettext_noop("Description"));
appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_foreign_table ft\n"
" INNER JOIN pg_catalog.pg_class c"
" ON c.oid = ft.ftrelid\n"
" INNER JOIN pg_catalog.pg_namespace n"
" ON n.oid = c.relnamespace\n"
" INNER JOIN pg_catalog.pg_foreign_server s"
" ON s.oid = ft.ftserver\n");
if (verbose)
appendPQExpBuffer(&buf,
" LEFT JOIN pg_catalog.pg_description d\n"
" ON d.classoid = c.tableoid AND "
"d.objoid = c.oid AND d.objsubid = 0\n");
processSQLNamePattern(pset.db, &buf, pattern, false, false,
NULL, "n.nspname", "c.relname", NULL);
appendPQExpBuffer(&buf, "ORDER BY 1, 2;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
myopt.nullPrint = NULL;
myopt.title = _("List of foreign tables");
myopt.translate_header = true;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
PQclear(res);
return true;
}
Definition at line 2782 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printACLColumn(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, PSQLexec(), _psqlSettings::queryFout, _psqlSettings::sversion, termPQExpBuffer(), printQueryOpt::title, and printQueryOpt::translate_header.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT l.lanname AS \"%s\",\n",
gettext_noop("Name"));
if (pset.sversion >= 80300)
appendPQExpBuffer(&buf,
" pg_catalog.pg_get_userbyid(l.lanowner) as \"%s\",\n",
gettext_noop("Owner"));
appendPQExpBuffer(&buf,
" l.lanpltrusted AS \"%s\"",
gettext_noop("Trusted"));
if (verbose)
{
appendPQExpBuffer(&buf,
",\n NOT l.lanispl AS \"%s\",\n"
" l.lanplcallfoid::regprocedure AS \"%s\",\n"
" l.lanvalidator::regprocedure AS \"%s\",\n ",
gettext_noop("Internal Language"),
gettext_noop("Call Handler"),
gettext_noop("Validator"));
if (pset.sversion >= 90000)
appendPQExpBuffer(&buf, "l.laninline::regprocedure AS \"%s\",\n ",
gettext_noop("Inline Handler"));
printACLColumn(&buf, "l.lanacl");
}
appendPQExpBuffer(&buf,
",\n d.description AS \"%s\""
"\nFROM pg_catalog.pg_language l\n"
"LEFT JOIN pg_catalog.pg_description d\n"
" ON d.classoid = l.tableoid AND d.objoid = l.oid\n"
" AND d.objsubid = 0\n",
gettext_noop("Description"));
if (pattern)
processSQLNamePattern(pset.db, &buf, pattern, false, false,
NULL, "l.lanname", NULL, NULL);
if (!showSystem && !pattern)
appendPQExpBuffer(&buf, "WHERE l.lanplcallfoid != 0\n");
appendPQExpBuffer(&buf, "ORDER BY 1;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
myopt.nullPrint = NULL;
myopt.title = _("List of languages");
myopt.translate_header = true;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
PQclear(res);
return true;
}
Definition at line 3251 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printACLColumn(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, PSQLexec(), _psqlSettings::queryFout, termPQExpBuffer(), printQueryOpt::title, and printQueryOpt::translate_header.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT n.nspname AS \"%s\",\n"
" pg_catalog.pg_get_userbyid(n.nspowner) AS \"%s\"",
gettext_noop("Name"),
gettext_noop("Owner"));
if (verbose)
{
appendPQExpBuffer(&buf, ",\n ");
printACLColumn(&buf, "n.nspacl");
appendPQExpBuffer(&buf,
",\n pg_catalog.obj_description(n.oid, 'pg_namespace') AS \"%s\"",
gettext_noop("Description"));
}
appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_namespace n\n");
if (!showSystem && !pattern)
appendPQExpBuffer(&buf,
"WHERE n.nspname !~ '^pg_' AND n.nspname <> 'information_schema'\n");
processSQLNamePattern(pset.db, &buf, pattern,
!showSystem && !pattern, false,
NULL, "n.nspname", NULL,
NULL);
appendPQExpBuffer(&buf, "ORDER BY 1;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
myopt.nullPrint = NULL;
myopt.title = _("List of schemas");
myopt.translate_header = true;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
PQclear(res);
return true;
}
Definition at line 2630 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), PQntuples(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, PSQLexec(), _psqlSettings::queryFout, _psqlSettings::quiet, _psqlSettings::sversion, termPQExpBuffer(), printQueryOpt::title, printQueryOpt::translate_columns, and printQueryOpt::translate_header.
Referenced by exec_command().
{
bool showTables = strchr(tabtypes, 't') != NULL;
bool showIndexes = strchr(tabtypes, 'i') != NULL;
bool showViews = strchr(tabtypes, 'v') != NULL;
bool showMatViews = strchr(tabtypes, 'm') != NULL;
bool showSeq = strchr(tabtypes, 's') != NULL;
bool showForeign = strchr(tabtypes, 'E') != NULL;
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, true, false, false, false, false};
if (!(showTables || showIndexes || showViews || showMatViews || showSeq || showForeign))
showTables = showViews = showMatViews = showSeq = showForeign = true;
initPQExpBuffer(&buf);
/*
* Note: as of Pg 8.2, we no longer use relkind 's', but we keep it here
* for backwards compatibility.
*/
printfPQExpBuffer(&buf,
"SELECT n.nspname as \"%s\",\n"
" c.relname as \"%s\",\n"
" CASE c.relkind"
" WHEN 'r' THEN '%s'"
" WHEN 'v' THEN '%s'"
" WHEN 'm' THEN '%s'"
" WHEN 'i' THEN '%s'"
" WHEN 'S' THEN '%s'"
" WHEN 's' THEN '%s'"
" WHEN 'f' THEN '%s'"
" END as \"%s\",\n"
" pg_catalog.pg_get_userbyid(c.relowner) as \"%s\"",
gettext_noop("Schema"),
gettext_noop("Name"),
gettext_noop("table"),
gettext_noop("view"),
gettext_noop("materialized view"),
gettext_noop("index"),
gettext_noop("sequence"),
gettext_noop("special"),
gettext_noop("foreign table"),
gettext_noop("Type"),
gettext_noop("Owner"));
if (showIndexes)
appendPQExpBuffer(&buf,
",\n c2.relname as \"%s\"",
gettext_noop("Table"));
if (verbose)
{
/*
* As of PostgreSQL 9.0, use pg_table_size() to show a more acurate
* size of a table, including FSM, VM and TOAST tables.
*/
if (pset.sversion >= 90000)
appendPQExpBuffer(&buf,
",\n pg_catalog.pg_size_pretty(pg_catalog.pg_table_size(c.oid)) as \"%s\"",
gettext_noop("Size"));
else if (pset.sversion >= 80100)
appendPQExpBuffer(&buf,
",\n pg_catalog.pg_size_pretty(pg_catalog.pg_relation_size(c.oid)) as \"%s\"",
gettext_noop("Size"));
appendPQExpBuffer(&buf,
",\n pg_catalog.obj_description(c.oid, 'pg_class') as \"%s\"",
gettext_noop("Description"));
}
appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_class c"
"\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace");
if (showIndexes)
appendPQExpBuffer(&buf,
"\n LEFT JOIN pg_catalog.pg_index i ON i.indexrelid = c.oid"
"\n LEFT JOIN pg_catalog.pg_class c2 ON i.indrelid = c2.oid");
appendPQExpBuffer(&buf, "\nWHERE c.relkind IN (");
if (showTables)
appendPQExpBuffer(&buf, "'r',");
if (showViews)
appendPQExpBuffer(&buf, "'v',");
if (showMatViews)
appendPQExpBuffer(&buf, "'m',");
if (showIndexes)
appendPQExpBuffer(&buf, "'i',");
if (showSeq)
appendPQExpBuffer(&buf, "'S',");
if (showSystem || pattern)
appendPQExpBuffer(&buf, "'s',"); /* was RELKIND_SPECIAL in <=
* 8.1 */
if (showForeign)
appendPQExpBuffer(&buf, "'f',");
appendPQExpBuffer(&buf, "''"); /* dummy */
appendPQExpBuffer(&buf, ")\n");
if (!showSystem && !pattern)
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
" AND n.nspname <> 'information_schema'\n");
/*
* TOAST objects are suppressed unconditionally. Since we don't provide
* any way to select relkind 't' above, we would never show toast tables
* in any case; it seems a bit confusing to allow their indexes to be
* shown. Use plain \d if you really need to look at a TOAST table/index.
*/
appendPQExpBuffer(&buf, " AND n.nspname !~ '^pg_toast'\n");
processSQLNamePattern(pset.db, &buf, pattern, true, false,
"n.nspname", "c.relname", NULL,
"pg_catalog.pg_table_is_visible(c.oid)");
appendPQExpBuffer(&buf, "ORDER BY 1,2;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
if (PQntuples(res) == 0 && !pset.quiet)
{
if (pattern)
fprintf(pset.queryFout, _("No matching relations found.\n"));
else
fprintf(pset.queryFout, _("No relations found.\n"));
}
else
{
myopt.nullPrint = NULL;
myopt.title = _("List of relations");
myopt.translate_header = true;
myopt.translate_columns = translate_columns;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
}
PQclear(res);
return true;
}
Definition at line 3677 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), listTSConfigsVerbose(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, psql_error(), PSQLexec(), _psqlSettings::queryFout, _psqlSettings::sversion, termPQExpBuffer(), printQueryOpt::title, and printQueryOpt::translate_header.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
if (pset.sversion < 80300)
{
psql_error("The server (version %d.%d) does not support full text search.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
if (verbose)
return listTSConfigsVerbose(pattern);
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT \n"
" n.nspname as \"%s\",\n"
" c.cfgname as \"%s\",\n"
" pg_catalog.obj_description(c.oid, 'pg_ts_config') as \"%s\"\n"
"FROM pg_catalog.pg_ts_config c\n"
"LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.cfgnamespace \n",
gettext_noop("Schema"),
gettext_noop("Name"),
gettext_noop("Description")
);
processSQLNamePattern(pset.db, &buf, pattern, false, false,
"n.nspname", "c.cfgname", NULL,
"pg_catalog.pg_ts_config_is_visible(c.oid)");
appendPQExpBuffer(&buf, "ORDER BY 1, 2;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
myopt.nullPrint = NULL;
myopt.title = _("List of text search configurations");
myopt.translate_header = true;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
PQclear(res);
return true;
}
Definition at line 3541 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, psql_error(), PSQLexec(), _psqlSettings::queryFout, _psqlSettings::sversion, termPQExpBuffer(), printQueryOpt::title, and printQueryOpt::translate_header.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
if (pset.sversion < 80300)
{
psql_error("The server (version %d.%d) does not support full text search.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT \n"
" n.nspname as \"%s\",\n"
" d.dictname as \"%s\",\n",
gettext_noop("Schema"),
gettext_noop("Name"));
if (verbose)
{
appendPQExpBuffer(&buf,
" ( SELECT COALESCE(nt.nspname, '(null)')::pg_catalog.text || '.' || t.tmplname FROM \n"
" pg_catalog.pg_ts_template t \n"
" LEFT JOIN pg_catalog.pg_namespace nt ON nt.oid = t.tmplnamespace \n"
" WHERE d.dicttemplate = t.oid ) AS \"%s\", \n"
" d.dictinitoption as \"%s\", \n",
gettext_noop("Template"),
gettext_noop("Init options"));
}
appendPQExpBuffer(&buf,
" pg_catalog.obj_description(d.oid, 'pg_ts_dict') as \"%s\"\n",
gettext_noop("Description"));
appendPQExpBuffer(&buf, "FROM pg_catalog.pg_ts_dict d\n"
"LEFT JOIN pg_catalog.pg_namespace n ON n.oid = d.dictnamespace\n");
processSQLNamePattern(pset.db, &buf, pattern, false, false,
"n.nspname", "d.dictname", NULL,
"pg_catalog.pg_ts_dict_is_visible(d.oid)");
appendPQExpBuffer(&buf, "ORDER BY 1, 2;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
myopt.nullPrint = NULL;
myopt.title = _("List of text search dictionaries");
myopt.translate_header = true;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
PQclear(res);
return true;
}
Definition at line 3308 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), listTSParsersVerbose(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, psql_error(), PSQLexec(), _psqlSettings::queryFout, _psqlSettings::sversion, termPQExpBuffer(), printQueryOpt::title, and printQueryOpt::translate_header.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
if (pset.sversion < 80300)
{
psql_error("The server (version %d.%d) does not support full text search.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
if (verbose)
return listTSParsersVerbose(pattern);
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT \n"
" n.nspname as \"%s\",\n"
" p.prsname as \"%s\",\n"
" pg_catalog.obj_description(p.oid, 'pg_ts_parser') as \"%s\"\n"
"FROM pg_catalog.pg_ts_parser p \n"
"LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.prsnamespace\n",
gettext_noop("Schema"),
gettext_noop("Name"),
gettext_noop("Description")
);
processSQLNamePattern(pset.db, &buf, pattern, false, false,
"n.nspname", "p.prsname", NULL,
"pg_catalog.pg_ts_parser_is_visible(p.oid)");
appendPQExpBuffer(&buf, "ORDER BY 1, 2;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
myopt.nullPrint = NULL;
myopt.title = _("List of text search parsers");
myopt.translate_header = true;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
PQclear(res);
return true;
}
Definition at line 3609 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, psql_error(), PSQLexec(), _psqlSettings::queryFout, _psqlSettings::sversion, termPQExpBuffer(), printQueryOpt::title, and printQueryOpt::translate_header.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
if (pset.sversion < 80300)
{
psql_error("The server (version %d.%d) does not support full text search.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
initPQExpBuffer(&buf);
if (verbose)
printfPQExpBuffer(&buf,
"SELECT \n"
" n.nspname AS \"%s\",\n"
" t.tmplname AS \"%s\",\n"
" t.tmplinit::pg_catalog.regproc AS \"%s\",\n"
" t.tmpllexize::pg_catalog.regproc AS \"%s\",\n"
" pg_catalog.obj_description(t.oid, 'pg_ts_template') AS \"%s\"\n",
gettext_noop("Schema"),
gettext_noop("Name"),
gettext_noop("Init"),
gettext_noop("Lexize"),
gettext_noop("Description"));
else
printfPQExpBuffer(&buf,
"SELECT \n"
" n.nspname AS \"%s\",\n"
" t.tmplname AS \"%s\",\n"
" pg_catalog.obj_description(t.oid, 'pg_ts_template') AS \"%s\"\n",
gettext_noop("Schema"),
gettext_noop("Name"),
gettext_noop("Description"));
appendPQExpBuffer(&buf, "FROM pg_catalog.pg_ts_template t\n"
"LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.tmplnamespace\n");
processSQLNamePattern(pset.db, &buf, pattern, false, false,
"n.nspname", "t.tmplname", NULL,
"pg_catalog.pg_ts_template_is_visible(t.oid)");
appendPQExpBuffer(&buf, "ORDER BY 1, 2;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
myopt.nullPrint = NULL;
myopt.title = _("List of text search templates");
myopt.translate_header = true;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
PQclear(res);
return true;
}
Definition at line 4034 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, psql_error(), PSQLexec(), _psqlSettings::queryFout, _psqlSettings::sversion, termPQExpBuffer(), printQueryOpt::title, and printQueryOpt::translate_header.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
if (pset.sversion < 80400)
{
psql_error("The server (version %d.%d) does not support user mappings.\n",
pset.sversion / 10000, (pset.sversion / 100) % 100);
return true;
}
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT um.srvname AS \"%s\",\n"
" um.usename AS \"%s\"",
gettext_noop("Server"),
gettext_noop("User name"));
if (verbose)
appendPQExpBuffer(&buf,
",\n CASE WHEN umoptions IS NULL THEN '' ELSE "
" '(' || array_to_string(ARRAY(SELECT "
" quote_ident(option_name) || ' ' || "
" quote_literal(option_value) FROM "
" pg_options_to_table(umoptions)), ', ') || ')' "
" END AS \"%s\"",
gettext_noop("FDW Options"));
appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_user_mappings um\n");
processSQLNamePattern(pset.db, &buf, pattern, false, false,
NULL, "um.srvname", "um.usename", NULL);
appendPQExpBuffer(&buf, "ORDER BY 1, 2;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
myopt.nullPrint = NULL;
myopt.title = _("List of user mappings");
myopt.translate_header = true;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
PQclear(res);
return true;
}
Definition at line 879 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printQuery(), processSQLNamePattern(), pset, PSQLexec(), _psqlSettings::queryFout, _psqlSettings::sversion, termPQExpBuffer(), printQueryOpt::title, printQueryOpt::translate_columns, and printQueryOpt::translate_header.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, true, false};
initPQExpBuffer(&buf);
appendPQExpBuffer(&buf,
"SELECT DISTINCT tt.nspname AS \"%s\", tt.name AS \"%s\", tt.object AS \"%s\", d.description AS \"%s\"\n"
"FROM (\n",
gettext_noop("Schema"),
gettext_noop("Name"),
gettext_noop("Object"),
gettext_noop("Description"));
/* Constraint descriptions */
appendPQExpBuffer(&buf,
" SELECT pgc.oid as oid, pgc.tableoid AS tableoid,\n"
" n.nspname as nspname,\n"
" CAST(pgc.conname AS pg_catalog.text) as name,"
" CAST('%s' AS pg_catalog.text) as object\n"
" FROM pg_catalog.pg_constraint pgc\n"
" JOIN pg_catalog.pg_class c "
"ON c.oid = pgc.conrelid\n"
" LEFT JOIN pg_catalog.pg_namespace n "
" ON n.oid = c.relnamespace\n",
gettext_noop("constraint"));
if (!showSystem && !pattern)
appendPQExpBuffer(&buf, "WHERE n.nspname <> 'pg_catalog'\n"
" AND n.nspname <> 'information_schema'\n");
processSQLNamePattern(pset.db, &buf, pattern, !showSystem && !pattern,
false, "n.nspname", "pgc.conname", NULL,
"pg_catalog.pg_table_is_visible(c.oid)");
/*
* pg_opclass.opcmethod only available in 8.3+
*/
if (pset.sversion >= 80300)
{
/* Operator class descriptions */
appendPQExpBuffer(&buf,
"UNION ALL\n"
" SELECT o.oid as oid, o.tableoid as tableoid,\n"
" n.nspname as nspname,\n"
" CAST(o.opcname AS pg_catalog.text) as name,\n"
" CAST('%s' AS pg_catalog.text) as object\n"
" FROM pg_catalog.pg_opclass o\n"
" JOIN pg_catalog.pg_am am ON "
"o.opcmethod = am.oid\n"
" JOIN pg_catalog.pg_namespace n ON "
"n.oid = o.opcnamespace\n",
gettext_noop("operator class"));
if (!showSystem && !pattern)
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
" AND n.nspname <> 'information_schema'\n");
processSQLNamePattern(pset.db, &buf, pattern, true, false,
"n.nspname", "o.opcname", NULL,
"pg_catalog.pg_opclass_is_visible(o.oid)");
}
/*
* although operator family comments have been around since 8.3,
* pg_opfamily_is_visible is only available in 9.2+
*/
if (pset.sversion >= 90200)
{
/* Operator family descriptions */
appendPQExpBuffer(&buf,
"UNION ALL\n"
" SELECT opf.oid as oid, opf.tableoid as tableoid,\n"
" n.nspname as nspname,\n"
" CAST(opf.opfname AS pg_catalog.text) AS name,\n"
" CAST('%s' AS pg_catalog.text) as object\n"
" FROM pg_catalog.pg_opfamily opf\n"
" JOIN pg_catalog.pg_am am "
"ON opf.opfmethod = am.oid\n"
" JOIN pg_catalog.pg_namespace n "
"ON opf.opfnamespace = n.oid\n",
gettext_noop("operator family"));
if (!showSystem && !pattern)
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
" AND n.nspname <> 'information_schema'\n");
processSQLNamePattern(pset.db, &buf, pattern, true, false,
"n.nspname", "opf.opfname", NULL,
"pg_catalog.pg_opfamily_is_visible(opf.oid)");
}
/* Rule descriptions (ignore rules for views) */
appendPQExpBuffer(&buf,
"UNION ALL\n"
" SELECT r.oid as oid, r.tableoid as tableoid,\n"
" n.nspname as nspname,\n"
" CAST(r.rulename AS pg_catalog.text) as name,"
" CAST('%s' AS pg_catalog.text) as object\n"
" FROM pg_catalog.pg_rewrite r\n"
" JOIN pg_catalog.pg_class c ON c.oid = r.ev_class\n"
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
" WHERE r.rulename != '_RETURN'\n",
gettext_noop("rule"));
if (!showSystem && !pattern)
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
" AND n.nspname <> 'information_schema'\n");
processSQLNamePattern(pset.db, &buf, pattern, true, false,
"n.nspname", "r.rulename", NULL,
"pg_catalog.pg_table_is_visible(c.oid)");
/* Trigger descriptions */
appendPQExpBuffer(&buf,
"UNION ALL\n"
" SELECT t.oid as oid, t.tableoid as tableoid,\n"
" n.nspname as nspname,\n"
" CAST(t.tgname AS pg_catalog.text) as name,"
" CAST('%s' AS pg_catalog.text) as object\n"
" FROM pg_catalog.pg_trigger t\n"
" 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 && !pattern)
appendPQExpBuffer(&buf, "WHERE n.nspname <> 'pg_catalog'\n"
" AND n.nspname <> 'information_schema'\n");
processSQLNamePattern(pset.db, &buf, pattern, !showSystem && !pattern, false,
"n.nspname", "t.tgname", NULL,
"pg_catalog.pg_table_is_visible(c.oid)");
appendPQExpBuffer(&buf,
") AS tt\n"
" JOIN pg_catalog.pg_description d ON (tt.oid = d.objoid AND tt.tableoid = d.classoid AND d.objsubid = 0)\n");
appendPQExpBuffer(&buf, "ORDER BY 1, 2, 3;");
res = PSQLexec(buf.data, false);
termPQExpBuffer(&buf);
if (!res)
return false;
myopt.nullPrint = NULL;
myopt.title = _("Object descriptions");
myopt.translate_header = true;
myopt.translate_columns = translate_columns;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
PQclear(res);
return true;
}
| bool permissionsList | ( | const char * | pattern | ) |
Definition at line 714 of file describe.c.
References _, appendPQExpBuffer(), buf, PQExpBufferData::data, _psqlSettings::db, gettext_noop, initPQExpBuffer(), _psqlSettings::logfile, NULL, printQueryOpt::nullPrint, _psqlSettings::popt, PQclear(), printACLColumn(), printfPQExpBuffer(), printQuery(), processSQLNamePattern(), pset, PSQLexec(), _psqlSettings::queryFout, _psqlSettings::sversion, termPQExpBuffer(), printQueryOpt::title, printQueryOpt::translate_columns, and printQueryOpt::translate_header.
Referenced by exec_command().
{
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, true, false, false};
initPQExpBuffer(&buf);
/*
* we ignore indexes and toast tables since they have no meaningful rights
*/
printfPQExpBuffer(&buf,
"SELECT n.nspname as \"%s\",\n"
" c.relname as \"%s\",\n"
" CASE c.relkind"
" WHEN 'r' THEN '%s'"
" WHEN 'v' THEN '%s'"
" WHEN 'm' THEN '%s'"
" WHEN 'S' THEN '%s'"
" WHEN 'f' THEN '%s'"
" END as \"%s\",\n"
" ",
gettext_noop("Schema"),
gettext_noop("Name"),
gettext_noop("table"),
gettext_noop("view"),
gettext_noop("materialized view"),
gettext_noop("sequence"),
gettext_noop("foreign table"),
gettext_noop("Type"));
printACLColumn(&buf, "c.relacl");
if (pset.sversion >= 80400)
appendPQExpBuffer(&buf,
",\n pg_catalog.array_to_string(ARRAY(\n"
" SELECT attname || E':\\n ' || pg_catalog.array_to_string(attacl, E'\\n ')\n"
" FROM pg_catalog.pg_attribute a\n"
" WHERE attrelid = c.oid AND NOT attisdropped AND attacl IS NOT NULL\n"
" ), E'\\n') AS \"%s\"",
gettext_noop("Column access privileges"));
appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_class c\n"
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
"WHERE c.relkind IN ('r', 'v', 'm', 'S', 'f')\n");
/*
* Unless a schema pattern is specified, we suppress system and temp
* tables, since they normally aren't very interesting from a permissions
* point of view. You can see 'em by explicit request though, eg with \z
* pg_catalog.*
*/
processSQLNamePattern(pset.db, &buf, pattern, true, false,
"n.nspname", "c.relname", NULL,
"n.nspname !~ '^pg_' AND pg_catalog.pg_table_is_visible(c.oid)");
appendPQExpBuffer(&buf, "ORDER BY 1, 2;");
res = PSQLexec(buf.data, false);
if (!res)
{
termPQExpBuffer(&buf);
return false;
}
myopt.nullPrint = NULL;
printfPQExpBuffer(&buf, _("Access privileges"));
myopt.title = buf.data;
myopt.translate_header = true;
myopt.translate_columns = translate_columns;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
termPQExpBuffer(&buf);
PQclear(res);
return true;
}
1.7.1