Hi all, I've updated the patch to address the following points: * help string now says "list procedural languages" (no parentheses now) * the language name column is now titled "Name" * added another column in verbose mode for 9.0+ showing whether DO blocks are possible with the language. I named this column "DO Blocks?", though am open to suggestions * fixed the whitespace problems Andreas noticed with the SELECT query
Looking at the verbose output, which looks something like this: List of languages Name | Owner | Trusted | Call Handler | Validator | System Language | DO Blocks? | Access privileges -----------+-------+---------+-------------------------+------------------------+-----------------+----------- -+------------------- plpgsql | josh | t | plpgsql_call_handler() | plpgsql_validator(oid) | f | t | plpythonu | josh | f | plpython_call_handler() | - | f | t | (2 rows) I have a hard time imagining users who would find "Call Handler" or "Validator" useful. This was in Fernando's original patch, and I just didn't bother to take it out. If others feel the same way, I'd be happy to rip those columns out. Few more comments below: On Mon, Jan 17, 2011 at 3:51 PM, Andreas Karlsson <andr...@proxel.se> wrote: > On Sun, 2011-01-16 at 22:32 -0500, Josh Kupershmidt wrote: >> On Sat, Jan 15, 2011 at 8:26 PM, Andreas Karlsson <andr...@proxel.se> wrote: >> > Should we include a column in \dL+ for the laninline function (DO >> > blocks)? >> >> Hrm, I guess that could be useful for the verbose output at least. > > Magnus Hagander agreed with that idea and added that for that we need to > check the version. The column was added in 9.0 if I recall. Added. [snip] > * Missing indentation before ACL column, the other functions have it. > * One space before FROM instead of one newline like the other queries. > * The space before ORDER BY. These should be fixed now. > That's enough nitpickery for now. :) I spend enough of my time nitpicking others. Turnabout is fair play :) Thanks for all the review and feedback from everyone. Josh
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 5f61561..30d4507 100644 *** a/doc/src/sgml/ref/psql-ref.sgml --- b/doc/src/sgml/ref/psql-ref.sgml *************** testdb=> *** 1249,1254 **** --- 1249,1269 ---- </listitem> </varlistentry> + <varlistentry> + <term><literal>\dL[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term> + <listitem> + <para> + Lists all procedural languages. If <replaceable + class="parameter">pattern</replaceable> + is specified, only languages whose names match the pattern are listed. + By default, only user-created languages + are shown; supply the <literal>S</literal> modifier to include system + objects. If <literal>+</literal> is appended to the command name, each + language is listed with its call handler, validator, access privileges, + and whether it is a system object. + </para> + </listitem> + </varlistentry> <varlistentry> <term><literal>\dn[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term> diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 962c13c..301dc11 100644 *** a/src/bin/psql/command.c --- b/src/bin/psql/command.c *************** exec_command(const char *cmd, *** 416,421 **** --- 416,424 ---- case 'l': success = do_lo_list(); break; + case 'L': + success = listLanguages(pattern, show_verbose, show_system); + break; case 'n': success = listSchemas(pattern, show_verbose, show_system); break; diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 205190f..5984748 100644 *** a/src/bin/psql/describe.c --- b/src/bin/psql/describe.c *************** listTables(const char *tabtypes, const c *** 2566,2571 **** --- 2566,2638 ---- } + /* \dL + * + * Describes Languages. + */ + bool + listLanguages(const char *pattern, bool verbose, bool showSystem) + { + 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 l.lanplcallfoid::regprocedure AS \"%s\",\n" + " l.lanvalidator::regprocedure AS \"%s\",\n" + " NOT l.lanispl AS \"%s\",\n ", + gettext_noop("Call Handler"), + gettext_noop("Validator"), + gettext_noop("System Language")); + if (pset.sversion >= 90000) + appendPQExpBuffer(&buf, "l.laninline != 0 AS \"%s\",\n ", + gettext_noop("DO Blocks?")); + printACLColumn(&buf, "l.lanacl"); + } + + appendPQExpBuffer(&buf, + "\nFROM pg_catalog.pg_language l"); + + processSQLNamePattern(pset.db, &buf, pattern, false, false, + NULL, "l.lanname", NULL, NULL); + + if (!showSystem && !pattern) + appendPQExpBuffer(&buf, "\nWHERE lanplcallfoid != 0"); + + appendPQExpBuffer(&buf, "\nORDER 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; + } + + /* * \dD * diff --git a/src/bin/psql/describe.h b/src/bin/psql/describe.h index 2029ef8..4e80bcf 100644 *** a/src/bin/psql/describe.h --- b/src/bin/psql/describe.h *************** extern bool listUserMappings(const char *** 84,88 **** --- 84,90 ---- /* \det */ extern bool listForeignTables(const char *pattern, bool verbose); + /* \dL */ + extern bool listLanguages(const char *pattern, bool verbose, bool showSystem); #endif /* DESCRIBE_H */ diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c index 96c85a2..bd5c4b7 100644 *** a/src/bin/psql/help.c --- b/src/bin/psql/help.c *************** slashUsage(unsigned short int pager) *** 211,216 **** --- 211,217 ---- fprintf(output, _(" \\dg[+] [PATTERN] list roles\n")); fprintf(output, _(" \\di[S+] [PATTERN] list indexes\n")); fprintf(output, _(" \\dl list large objects, same as \\lo_list\n")); + fprintf(output, _(" \\dL[S+] [PATTERN] list procedural languages\n")); fprintf(output, _(" \\dn[+] [PATTERN] list schemas\n")); fprintf(output, _(" \\do[S] [PATTERN] list operators\n")); fprintf(output, _(" \\dp [PATTERN] list table, view, and sequence access privileges\n")); diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 8c15838..84c68a7 100644 *** a/src/bin/psql/tab-complete.c --- b/src/bin/psql/tab-complete.c *************** psql_completion(char *text, int start, i *** 713,719 **** static const char *const backslash_commands[] = { "\\a", "\\connect", "\\conninfo", "\\C", "\\cd", "\\copy", "\\copyright", "\\d", "\\da", "\\db", "\\dc", "\\dC", "\\dd", "\\dD", "\\des", "\\det", "\\deu", "\\dew", "\\df", ! "\\dF", "\\dFd", "\\dFp", "\\dFt", "\\dg", "\\di", "\\dl", "\\dn", "\\do", "\\dp", "\\drds", "\\ds", "\\dS", "\\dt", "\\dT", "\\dv", "\\du", "\\e", "\\echo", "\\ef", "\\encoding", "\\f", "\\g", "\\h", "\\help", "\\H", "\\i", "\\l", --- 713,719 ---- static const char *const backslash_commands[] = { "\\a", "\\connect", "\\conninfo", "\\C", "\\cd", "\\copy", "\\copyright", "\\d", "\\da", "\\db", "\\dc", "\\dC", "\\dd", "\\dD", "\\des", "\\det", "\\deu", "\\dew", "\\df", ! "\\dF", "\\dFd", "\\dFp", "\\dFt", "\\dg", "\\di", "\\dl", "\\dL", "\\dn", "\\do", "\\dp", "\\drds", "\\ds", "\\dS", "\\dt", "\\dT", "\\dv", "\\du", "\\e", "\\echo", "\\ef", "\\encoding", "\\f", "\\g", "\\h", "\\help", "\\H", "\\i", "\\l", *************** psql_completion(char *text, int start, i *** 2680,2685 **** --- 2680,2687 ---- else if (strncmp(prev_wd, "\\di", strlen("\\di")) == 0) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, NULL); + else if (strncmp(prev_wd, "\\dL", strlen("\\dL")) == 0) + COMPLETE_WITH_QUERY(Query_for_list_of_languages); else if (strncmp(prev_wd, "\\dn", strlen("\\dn")) == 0) COMPLETE_WITH_QUERY(Query_for_list_of_schemas); else if (strncmp(prev_wd, "\\dp", strlen("\\dp")) == 0
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers