Hi,
On Fri, Jan 30, 2009 at 3:03 PM, Fernando Ike <[email protected]> wrote:
> Hi,,
>
> My job, I maintainer some postgres server for clients. We have
> many PL/(Java, Perl, Ruby, Python, R) and to more easy
> administration, I worked new little psql attribute to list languages
> com shorcurt/function \dL.
[..]
> I know that this moment is inappropriate to submit patch, with the
> discussions about features for 8.4. But, if can added for commitfest
> to 8.5 version. I'm appreciate.
I update patch for added gettext fields and change spaces/tab to 4 spaces. :)
Cheers,
--
Fernando Ike
*** a/src/bin/psql/command.c
--- b/src/bin/psql/command.c
***************
*** 375,380 **** exec_command(const char *cmd,
--- 375,383 ----
case 'l':
success = do_lo_list();
break;
+ case 'L':
+ success = listLanguages(pattern, show_verbose);
+ break;
case 'n':
success = listSchemas(pattern, show_verbose);
break;
*** a/src/bin/psql/describe.c
--- b/src/bin/psql/describe.c
***************
*** 2018,2023 **** listTables(const char *tabtypes, const char *pattern, bool verbose, bool showSys
--- 2018,2085 ----
return true;
}
+ /*
+ * \dL
+ *
+ * Describes Languages.
+ */
+ bool
+ listLanguages(const char *pattern, bool verbose)
+ {
+ PQExpBufferData buf;
+ PGresult *res;
+ printQueryOpt myopt = pset.popt;
+
+ initPQExpBuffer(&buf);
+
+ printfPQExpBuffer(&buf,
+ "SELECT l.lanname as \"%s\",\n"
+ " pg_catalog.pg_get_userbyid(l.lanowner) as \"%s\",\n"
+ " CASE WHEN l.lanispl = 't' THEN \'%s\' WHEN l.lanispl = 'f' THEN \'%s\' END AS \"%s\",\n"
+ " CASE WHEN l.lanpltrusted='t' THEN \'%s\' WHEN lanpltrusted='f' THEN \'%s\' 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("Name"),
+ gettext_noop("Owner"),
+ gettext_noop("Yes"),
+ gettext_noop("No"),
+ gettext_noop("Procedural Language"),
+ gettext_noop("Trusted"),
+ gettext_noop("Untrusted"),
+ 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);
+
+ 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);
#endif /* DESCRIBE_H */
*** a/src/bin/psql/help.c
--- b/src/bin/psql/help.c
***************
*** 215,220 **** slashUsage(unsigned short int pager)
--- 215,221 ----
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 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"));
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers