diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 10d42ca..4cd1d27 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -873,22 +873,6 @@ testdb=> - - \da[S] [ pattern ] - - - - Lists all available aggregate functions, together with their - return type and the data types they operate on. If pattern - is specified, only aggregates whose names match the pattern are shown. - By default, only user-created objects are shown; supply a - pattern or the S modifier to include system - objects. - - - - \db[+] [ pattern ] @@ -1043,11 +1027,13 @@ testdb=> Lists available functions, together with their argument and - return types. If pattern - is specified, only functions whose names match the pattern are shown. - If the form \df+ is used, additional information about - each function, including volatility, language, source code and description, is shown. + return types and their function type: 'n' for normal, 'a' for + aggregates, 't' for trigger, and 'w' for windowing. If + pattern is + specified, only functions whose names match the pattern are + shown. If the form \df+ is used, + additional information about each function, including + volatility, language, source code and description, is shown. By default, only user-created objects are shown; supply a pattern or the S modifier to include system objects. diff --git a/doc/src/sgml/release.sgml b/doc/src/sgml/release.sgml index fc56c3d..469397a 100644 --- a/doc/src/sgml/release.sgml +++ b/doc/src/sgml/release.sgml @@ -183,6 +183,14 @@ do it for earlier branch release files. + + + The \da command is no longer in psql. Instead, \df now shows + which type of function it is: 'n' for normal, 'a' for aggregate, + 't' for trigger, and 'w' for windowing. + + + diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index b39466d..3a1c8a4 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -347,9 +347,6 @@ exec_command(const char *cmd, /* standard listing of interesting things */ success = listTables("tvs", NULL, show_verbose, show_system); break; - case 'a': - success = describeAggregates(pattern, show_verbose, show_system); - break; case 'b': success = describeTablespaces(pattern, show_verbose); break; diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 731baf8..1b9ae49 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -48,77 +48,6 @@ static void printACLColumn(PQExpBuffer buf, const char *colname); *---------------- */ - -/* \da - * Takes an optional regexp to select particular aggregates - */ -bool -describeAggregates(const char *pattern, bool verbose, bool showSystem) -{ - 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; -} - /* \db * Takes an optional regexp to select particular tablespaces */ @@ -203,9 +132,16 @@ describeFunctions(const char *pattern, bool verbose, bool showSystem) 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\"", + " pg_catalog.pg_get_function_arguments(p.oid) as \"%s\",\n" + " CASE\n" + " WHEN p.proisagg THEN 'a'\n" + " WHEN p.proiswindow THEN 'w'\n" + " WHEN pg_catalog.pg_get_function_result(p.oid) = 'trigger' THEN 't'\n" + " ELSE 'n'\n" + "END as \"%s\"", gettext_noop("Result data type"), - gettext_noop("Argument data types")); + gettext_noop("Argument data types"), + gettext_noop("Function Type")); else if (pset.sversion >= 80100) appendPQExpBuffer(&buf, " CASE WHEN p.proretset THEN 'SETOF ' ELSE '' END ||\n" @@ -238,16 +174,28 @@ describeFunctions(const char *pattern, bool verbose, bool showSystem) " 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 'a'\n" + " WHEN 'trigger' = pg_catalog.format_type(p.prorettype, NULL) THEN 't'\n" + " ELSE 'n'\n" " END AS \"%s\"", gettext_noop("Result data type"), - gettext_noop("Argument data types")); + gettext_noop("Argument data types"), + gettext_noop("Function 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\"", + " pg_catalog.oidvectortypes(p.proargtypes) as \"%s\"" + " CASE\n" + " WHEN p.proisagg THEN 'a'\n" + " WHEN 'trigger' = pg_catalog.format_type(p.prorettype, NULL) THEN 't'\n" + " ELSE 'n'\n" + " END AS \"%s\"", gettext_noop("Result data type"), - gettext_noop("Argument data types")); + gettext_noop("Argument data types"), + gettext_noop("Function Type")); if (verbose) appendPQExpBuffer(&buf, @@ -274,16 +222,14 @@ describeFunctions(const char *pattern, bool verbose, bool showSystem) appendPQExpBuffer(&buf, " LEFT JOIN pg_catalog.pg_language l ON l.oid = p.prolang\n"); - appendPQExpBuffer(&buf, "WHERE NOT p.proisagg\n"); + processSQLNamePattern(pset.db, &buf, pattern, false, true, + "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"); - 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); diff --git a/src/bin/psql/describe.h b/src/bin/psql/describe.h index 57e5c7b..d3fbbb8 100644 --- a/src/bin/psql/describe.h +++ b/src/bin/psql/describe.h @@ -9,9 +9,6 @@ #define DESCRIBE_H -/* \da */ -extern bool describeAggregates(const char *pattern, bool verbose, bool showSystem); - /* \db */ extern bool describeTablespaces(const char *pattern, bool verbose); diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c index 93ff5d0..05ca071 100644 --- a/src/bin/psql/help.c +++ b/src/bin/psql/help.c @@ -196,7 +196,6 @@ slashUsage(unsigned short int pager) fprintf(output, _(" (options: S = show system objects, + = additional detail)\n")); fprintf(output, _(" \\d[S+] list tables, views, and sequences\n")); fprintf(output, _(" \\d[S+] NAME describe table, view, sequence, or index\n")); - fprintf(output, _(" \\da[S] [PATTERN] list aggregate functions\n")); fprintf(output, _(" \\db[+] [PATTERN] list tablespaces\n")); fprintf(output, _(" \\dc[S] [PATTERN] list conversions\n")); fprintf(output, _(" \\dC [PATTERN] list casts\n"));