On Thu, Jul 16, 2009 at 10:41 AM, Peter Eisentraut<pete...@gmx.net> wrote: > On Thursday 16 July 2009 00:38:31 Fernando Ike de Oliveira wrote: >> I applied the Tom Lane and Peter considerations, but I had that >> remove one column (Owner) of out command \dL to compatibility with 7.4 >> version. > > The mandate is to work as best as they can with older versions, not to provide > only the feature set that works the same across old versions. The correct > behavior should be to show the owner column if the server version supports it.
Thanks for comment, Peter Follow new version patch, now with version postgresql version. Regards, -- Fernando Ike
*** a/doc/src/sgml/ref/psql-ref.sgml --- b/doc/src/sgml/ref/psql-ref.sgml *************** *** 1179,1184 **** testdb=> --- 1179,1194 ---- <varlistentry> + <term><literal>\dL[S+]</literal></term> + <listitem> + <para> + Lists all procedural languages. 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 line, each language is listed with its associated permissions + </para> + </listitem> + </varlistentry> + + + <varlistentry> <term><literal>\dn[+] [ <replaceable class="parameter">pattern</replaceable> ]</literal></term> <listitem> *** a/src/bin/psql/command.c --- b/src/bin/psql/command.c *************** *** 390,395 **** exec_command(const char *cmd, --- 390,398 ---- case 'l': success = do_lo_list(); break; + case 'L': + success = listLanguages(pattern, show_verbose, show_system); + break; case 'n': success = listSchemas(pattern, show_verbose); break; *** a/src/bin/psql/describe.c --- b/src/bin/psql/describe.c *************** *** 2261,2266 **** listTables(const char *tabtypes, const char *pattern, bool verbose, bool showSys --- 2261,2332 ---- } + /* \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, + " CASE WHEN l.lanispl = 't' THEN 'Trusted' WHEN l.lanispl = 'f' THEN 'Untrusted' END AS \"%s\",\n" + " CASE WHEN l.lanpltrusted='t' THEN 'Trusted' WHEN lanpltrusted='f' THEN 'Untrusted' END AS \"%s\",\n" + " CASE WHEN p.oid = 0 THEN NULL ELSE p.proname END AS \"%s\",\n" + " CASE WHEN q.oid = 0 THEN NULL ELSE q.proname END AS \"%s\"\n", + gettext_noop("Procedural Language"), + gettext_noop("Trusted"), + gettext_noop("Call Handler"), + gettext_noop("Validator")); + + if (verbose) + { + appendPQExpBuffer(&buf, ",\n"); + printACLColumn(&buf, "l.lanacl"); + } + + appendPQExpBuffer(&buf, + " FROM pg_catalog.pg_language l\n"); + appendPQExpBuffer(&buf, + " LEFT JOIN pg_catalog.pg_proc p on l.lanplcallfoid = p.oid\n"); + appendPQExpBuffer(&buf, + " LEFT JOIN pg_catalog.pg_proc q on l.lanvalidator = q.oid\n"); + + processSQLNamePattern(pset.db, &buf, pattern, false, false, + NULL, "l.lanname", NULL, NULL); + if (!showSystem && !pattern) + appendPQExpBuffer(&buf, "WHERE lanplcallfoid != 0"); + 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; + + } + + /* * \dD * *** a/src/bin/psql/describe.h --- b/src/bin/psql/describe.h *************** *** 75,79 **** extern bool listForeignServers(const char *pattern, bool verbose); --- 75,81 ---- /* \deu */ extern bool listUserMappings(const char *pattern, bool verbose); + /* \dL */ + extern bool listLanguages(const char *pattern, bool verbose, bool showSystem); #endif /* DESCRIBE_H */ *** a/src/bin/psql/help.c --- b/src/bin/psql/help.c *************** *** 213,218 **** slashUsage(unsigned short int pager) --- 213,219 ---- fprintf(output, _(" \\dg [PATTERN] list roles (groups)\n")); fprintf(output, _(" \\di[S+] [PATTERN] list indexes\n")); fprintf(output, _(" \\dl list large objects, same as \\lo_list\n")); + fprintf(output, _(" \\dL[S+] 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")); *** a/src/bin/psql/tab-complete.c --- b/src/bin/psql/tab-complete.c *************** *** 628,634 **** psql_completion(char *text, int start, int end) static const char *const backslash_commands[] = { "\\a", "\\connect", "\\C", "\\cd", "\\copy", "\\copyright", "\\d", "\\da", "\\db", "\\dc", "\\dC", "\\dd", "\\dD", "\\des", "\\deu", "\\dew", "\\df", ! "\\dF", "\\dFd", "\\dFp", "\\dFt", "\\dg", "\\di", "\\dl", "\\dn", "\\do", "\\dp", "\\ds", "\\dS", "\\dt", "\\dT", "\\dv", "\\du", "\\e", "\\echo", "\\ef", "\\encoding", "\\f", "\\g", "\\h", "\\help", "\\H", "\\i", "\\l", --- 628,634 ---- static const char *const backslash_commands[] = { "\\a", "\\connect", "\\C", "\\cd", "\\copy", "\\copyright", "\\d", "\\da", "\\db", "\\dc", "\\dC", "\\dd", "\\dD", "\\des", "\\deu", "\\dew", "\\df", ! "\\dF", "\\dFd", "\\dFp", "\\dFt", "\\dg", "\\di", "\\dl", "\\dL", "\\dn", "\\do", "\\dp", "\\ds", "\\dS", "\\dt", "\\dT", "\\dv", "\\du", "\\e", "\\echo", "\\ef", "\\encoding", "\\f", "\\g", "\\h", "\\help", "\\H", "\\i", "\\l",
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers