aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2014-01-16 15:29:18 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2014-01-16 15:29:33 -0500
commit515d2c596c1b6b95d020d14edaab0d233d5d9ea9 (patch)
treeb880894afd6133ab03c52f8f665c8521f73e9c4a /src
parent3291301385ee5e9ca38d70a68b93ce31cc2674ac (diff)
downloadpostgresql-515d2c596c1b6b95d020d14edaab0d233d5d9ea9.tar.gz
postgresql-515d2c596c1b6b95d020d14edaab0d233d5d9ea9.zip
Add display of oprcode (the underlying function's name) to psql's \do+.
The + modifier of \do didn't use to do anything, but now it adds an oprcode column. This is useful both as an additional form of documentation of what the operator does, and to save a step when finding out properties of the underlying function. Marko Tiikkaja, reviewed by Rushabh Lathia, adjusted a bit by me
Diffstat (limited to 'src')
-rw-r--r--src/bin/psql/command.c2
-rw-r--r--src/bin/psql/describe.c22
-rw-r--r--src/bin/psql/describe.h2
3 files changed, 17 insertions, 9 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index f8572951f18..49f389071a1 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -410,7 +410,7 @@ exec_command(const char *cmd,
success = listSchemas(pattern, show_verbose, show_system);
break;
case 'o':
- success = describeOperators(pattern, show_system);
+ success = describeOperators(pattern, show_verbose, show_system);
break;
case 'O':
success = listCollations(pattern, show_verbose, show_system);
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index dedb0362d66..0d4b151679a 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -577,9 +577,10 @@ describeTypes(const char *pattern, bool verbose, bool showSystem)
/* \do
+ * Describe operators
*/
bool
-describeOperators(const char *pattern, bool showSystem)
+describeOperators(const char *pattern, bool verbose, bool showSystem)
{
PQExpBufferData buf;
PGresult *res;
@@ -605,16 +606,23 @@ describeOperators(const char *pattern, bool showSystem)
" 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",
+ " pg_catalog.format_type(o.oprresult, NULL) AS \"%s\",\n",
gettext_noop("Schema"),
gettext_noop("Name"),
gettext_noop("Left arg type"),
gettext_noop("Right arg type"),
- gettext_noop("Result type"),
+ gettext_noop("Result type"));
+
+ if (verbose)
+ appendPQExpBuffer(&buf,
+ " o.oprcode AS \"%s\",\n",
+ gettext_noop("Function"));
+
+ appendPQExpBuffer(&buf,
+ " 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("Description"));
if (!showSystem && !pattern)
diff --git a/src/bin/psql/describe.h b/src/bin/psql/describe.h
index 86b86f68289..491de920af6 100644
--- a/src/bin/psql/describe.h
+++ b/src/bin/psql/describe.h
@@ -22,7 +22,7 @@ extern bool describeFunctions(const char *functypes, const char *pattern, bool v
extern bool describeTypes(const char *pattern, bool verbose, bool showSystem);
/* \do */
-extern bool describeOperators(const char *pattern, bool showSystem);
+extern bool describeOperators(const char *pattern, bool verbose, bool showSystem);
/* \du, \dg */
extern bool describeRoles(const char *pattern, bool verbose);