diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 123ce0b5c40..f3044fac1fa 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -864,6 +864,13 @@ testdb=>
same line.
+
+ Many of the meta-commands also allow x to be appended
+ as an option. This will cause the results to be displayed in expanded
+ mode, as if \x or \pset expanded
+ had been used.
+
+
The following meta-commands are defined:
@@ -1272,7 +1279,7 @@ SELECT $1 \parse stmt1
- \d[S+] [ pattern ]
+ \d[Sx+] [ pattern ]
@@ -1321,12 +1328,24 @@ SELECT $1 \parse stmt1
foreign tables.
This is purely a convenience measure.
+
+ As with many other commands, if x is appended to
+ the command name, the results are displayed in expanded mode, but note
+ that this only applies when \d is used without a
+ pattern argument, and
+ the x modifier cannot appear immediately after the
+ \d (because \dx is a different
+ command); the x modifier may only appear after an
+ S or + modifier. For example,
+ \d+x is equivalent to \dtvmsE+x
+ and will show a list of all relations in expanded mode.
+
- \da[S] [ pattern ]
+ \da[Sx] [ pattern ]
@@ -1337,19 +1356,23 @@ SELECT $1 \parse stmt1
By default, only user-created objects are shown; supply a
pattern or the S modifier to include system
objects.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
- \dA[+] [ pattern ]
+ \dA[x+] [ pattern ]
Lists access methods. If pattern is specified, only access
- methods whose names match the pattern are shown. If
- + is appended to the command name, each access
+ methods whose names match the pattern are shown.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
+ If + is appended to the command name, each access
method is listed with its associated handler function and description.
@@ -1357,7 +1380,7 @@ SELECT $1 \parse stmt1
- \dAc[+]
+ \dAc[x+]
[access-method-pattern
[input-type-pattern]]
@@ -1372,6 +1395,8 @@ SELECT $1 \parse stmt1
If input-type-pattern
is specified, only operator classes associated with input types whose
names match that pattern are listed.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
If + is appended to the command name, each operator
class is listed with its associated operator family and owner.
@@ -1380,7 +1405,7 @@ SELECT $1 \parse stmt1
- \dAf[+]
+ \dAf[x+]
[access-method-pattern
[input-type-pattern]]
@@ -1395,6 +1420,8 @@ SELECT $1 \parse stmt1
If input-type-pattern
is specified, only operator families associated with input types whose
names match that pattern are listed.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
If + is appended to the command name, each operator
family is listed with its owner.
@@ -1403,7 +1430,7 @@ SELECT $1 \parse stmt1
- \dAo[+]
+ \dAo[x+]
[access-method-pattern
[operator-family-pattern]]
@@ -1419,6 +1446,8 @@ SELECT $1 \parse stmt1
If operator-family-pattern
is specified, only members of operator families whose names match that
pattern are listed.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
If + is appended to the command name, each operator
is listed with its sort operator family (if it is an ordering operator),
and whether its underlying function is leakproof.
@@ -1428,7 +1457,7 @@ SELECT $1 \parse stmt1
- \dAp[+]
+ \dAp[x+]
[access-method-pattern
[operator-family-pattern]]
@@ -1443,6 +1472,8 @@ SELECT $1 \parse stmt1
If operator-family-pattern
is specified, only functions of operator families whose names match
that pattern are listed.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
If + is appended to the command name, functions are
displayed verbosely, with their actual parameter lists.
@@ -1450,13 +1481,15 @@ SELECT $1 \parse stmt1
- \db[+] [ pattern ]
+ \db[x+] [ pattern ]
Lists tablespaces. If pattern
is specified, only tablespaces whose names match the pattern are shown.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
If + is appended to the command name, each tablespace
is listed with its associated options, on-disk size, permissions and
description.
@@ -1466,7 +1499,7 @@ SELECT $1 \parse stmt1
- \dc[S+] [ pattern ]
+ \dc[Sx+] [ pattern ]
Lists conversions between character-set encodings.
@@ -1476,6 +1509,8 @@ SELECT $1 \parse stmt1
By default, only user-created objects are shown; supply a
pattern or the S modifier to include system
objects.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
If + is appended to the command name, each object
is listed with its associated description.
@@ -1484,7 +1519,7 @@ SELECT $1 \parse stmt1
- \dconfig[+] [ pattern ]
+ \dconfig[x+] [ pattern ]
Lists server configuration parameters and their values.
@@ -1493,6 +1528,8 @@ SELECT $1 \parse stmt1
a pattern, only
parameters that are set to non-default values are listed.
(Use \dconfig * to see all parameters.)
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
If + is appended to the command name, each
parameter is listed with its data type, context in which the
parameter can be set, and access privileges (if non-default access
@@ -1503,13 +1540,15 @@ SELECT $1 \parse stmt1
- \dC[+] [ pattern ]
+ \dC[x+] [ pattern ]
Lists type casts.
If pattern
is specified, only casts whose source or target types match the
pattern are listed.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
If + is appended to the command name, additional
information about each cast is shown, including whether its underlying
function is leakproof, and the cast's description.
@@ -1519,7 +1558,7 @@ SELECT $1 \parse stmt1
- \dd[S] [ pattern ]
+ \dd[Sx] [ pattern ]
Shows the descriptions of objects of type constraint,
@@ -1536,6 +1575,8 @@ SELECT $1 \parse stmt1
By default, only user-created objects are shown; supply a
pattern or the S modifier to include system
objects.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
@@ -1548,7 +1589,7 @@ SELECT $1 \parse stmt1
- \dD[S+] [ pattern ]
+ \dD[Sx+] [ pattern ]
Lists domains. If S modifier to include system
objects.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
If + is appended to the command name, each object
is listed with its associated permissions and description.
@@ -1565,7 +1608,7 @@ SELECT $1 \parse stmt1
- \ddp [ pattern ]
+ \ddp[x] [ pattern ]
Lists default access privilege settings. An entry is shown for
@@ -1574,6 +1617,8 @@ SELECT $1 \parse stmt1
If pattern is
specified, only entries whose role name or schema name matches
the pattern are listed.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
@@ -1587,12 +1632,12 @@ SELECT $1 \parse stmt1
- \dE[S+] [ pattern ]
- \di[S+] [ pattern ]
- \dm[S+] [ pattern ]
- \ds[S+] [ pattern ]
- \dt[S+] [ pattern ]
- \dv[S+] [ pattern ]
+ \dE[Sx+] [ pattern ]
+ \di[Sx+] [ pattern ]
+ \dm[Sx+] [ pattern ]
+ \ds[Sx+] [ pattern ]
+ \dt[Sx+] [ pattern ]
+ \dv[Sx+] [ pattern ]
@@ -1605,7 +1650,10 @@ SELECT $1 \parse stmt1
You can specify any or all of
these letters, in any order, to obtain a listing of objects
of these types. For example, \dti lists
- tables and indexes. If + is
+ tables and indexes.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
+ If + is
appended to the command name, each object is listed with its
persistence status (permanent, temporary, or unlogged),
physical size on disk, and associated description if any.
@@ -1620,14 +1668,17 @@ SELECT $1 \parse stmt1
- \des[+] [ pattern ]
+ \des[x+] [ pattern ]
Lists foreign servers (mnemonic: external
servers).
If pattern is
specified, only those servers whose name matches the pattern
- are listed. If the form \des+ is used, a
+ are listed.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
+ If + is appended to the command name, a
full description of each server is shown, including the
server's access privileges, type, version, options, and description.
@@ -1636,14 +1687,17 @@ SELECT $1 \parse stmt1
- \det[+] [ pattern ]
+ \det[x+] [ pattern ]
Lists foreign tables (mnemonic: external tables).
If pattern is
specified, only entries whose table name or schema name matches
- the pattern are listed. If the form \det+
- is used, generic options and the foreign table description
+ the pattern are listed.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
+ If + is appended to the command name,
+ generic options and the foreign table description
are also displayed.
@@ -1651,15 +1705,18 @@ SELECT $1 \parse stmt1
- \deu[+] [ pattern ]
+ \deu[x+] [ pattern ]
Lists user mappings (mnemonic: external
users).
If pattern is
specified, only those mappings whose user names match the
- pattern are listed. If the form \deu+ is
- used, additional information about each mapping is shown.
+ pattern are listed.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
+ If + is appended to the command name,
+ additional information about each mapping is shown.
@@ -1674,15 +1731,18 @@ SELECT $1 \parse stmt1
- \dew[+] [ pattern ]
+ \dew[x+] [ pattern ]
Lists foreign-data wrappers (mnemonic: external
wrappers).
If pattern is
specified, only those foreign-data wrappers whose name matches
- the pattern are listed. If the form \dew+
- is used, the access privileges, options, and description of the
+ the pattern are listed.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
+ If + is appended to the command name,
+ the access privileges, options, and description of the
foreign-data wrapper are also shown.
@@ -1690,7 +1750,7 @@ SELECT $1 \parse stmt1
- \df[anptwS+] [ pattern [ arg_pattern ... ] ]
+ \df[anptwSx+] [ pattern [ arg_pattern ... ] ]
@@ -1711,7 +1771,9 @@ SELECT $1 \parse stmt1
By default, only user-created
objects are shown; supply a pattern or the S
modifier to include system objects.
- If the form \df+ is used, additional information
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
+ If + is appended to the command name, additional information
about each function is shown, including volatility,
parallel safety, owner, security classification, whether it is
leakproof, access privileges, language, internal name (for C and
@@ -1724,13 +1786,15 @@ SELECT $1 \parse stmt1
- \dF[+] [ pattern ]
+ \dF[x+] [ pattern ]
Lists text search configurations.
If pattern is specified,
only configurations whose names match the pattern are shown.
- If the form \dF+ is used, a full description of
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
+ If + is appended to the command name, a full description of
each configuration is shown, including the underlying text search
parser and the dictionary list for each parser token type.
@@ -1738,13 +1802,15 @@ SELECT $1 \parse stmt1
- \dFd[+] [ pattern ]
+ \dFd[x+] [ pattern ]
Lists text search dictionaries.
If pattern is specified,
only dictionaries whose names match the pattern are shown.
- If the form \dFd+ is used, additional information
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
+ If + is appended to the command name, additional information
is shown about each selected dictionary, including the underlying
text search template and the option values.
@@ -1752,13 +1818,15 @@ SELECT $1 \parse stmt1
- \dFp[+] [ pattern ]
+ \dFp[x+] [ pattern ]
Lists text search parsers.
If pattern is specified,
only parsers whose names match the pattern are shown.
- If the form \dFp+ is used, a full description of
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
+ If + is appended to the command name, a full description of
each parser is shown, including the underlying functions and the
list of recognized token types.
@@ -1766,13 +1834,15 @@ SELECT $1 \parse stmt1
- \dFt[+] [ pattern ]
+ \dFt[x+] [ pattern ]
Lists text search templates.
If pattern is specified,
only templates whose names match the pattern are shown.
- If the form \dFt+ is used, additional information
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
+ If + is appended to the command name, additional information
is shown about each template, including the underlying function names.
@@ -1780,7 +1850,7 @@ SELECT $1 \parse stmt1
- \dg[S+] [ pattern ]
+ \dg[Sx+] [ pattern ]
Lists database roles.
@@ -1791,7 +1861,9 @@ SELECT $1 \parse stmt1
S modifier to include system roles.
If pattern is specified,
only those roles whose names match the pattern are listed.
- If the form \dg+ is used, additional information
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
+ If + is appended to the command name, additional information
is shown about each role; currently this adds the comment for each
role.
@@ -1800,11 +1872,13 @@ SELECT $1 \parse stmt1
- \dl[+]
+ \dl[x+]
This is an alias for \lo_list, which shows a
list of large objects.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
If + is appended to the command name,
each large object is listed with its associated permissions,
if any.
@@ -1813,7 +1887,7 @@ SELECT $1 \parse stmt1
- \dL[S+] [ pattern ]
+ \dL[Sx+] [ pattern ]
Lists procedural languages. If S modifier to include system
- objects. If + is appended to the command name, each
+ objects.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
+ If + is appended to the command name, each
language is listed with its call handler, validator, access privileges,
and whether it is a system object.
@@ -1830,7 +1907,7 @@ SELECT $1 \parse stmt1
- \dn[S+] [ pattern ]
+ \dn[Sx+] [ pattern ]
@@ -1839,6 +1916,8 @@ SELECT $1 \parse stmt1
is specified, only schemas whose names match the pattern are listed.
By default, only user-created objects are shown; supply a
pattern or the S modifier to include system objects.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
If + is appended to the command name, each object
is listed with its associated permissions and description, if any.
@@ -1847,7 +1926,7 @@ SELECT $1 \parse stmt1
- \do[S+] [ pattern [ arg_pattern [ arg_pattern ] ] ]
+ \do[Sx+] [ pattern [ arg_pattern [ arg_pattern ] ] ]
Lists operators with their operand and result types.
@@ -1863,6 +1942,8 @@ SELECT $1 \parse stmt1
By default, only user-created objects are shown; supply a
pattern or the S modifier to include system
objects.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
If + is appended to the command name,
additional information about each operator is shown, including
the name of the underlying function, and whether it is leakproof.
@@ -1872,7 +1953,7 @@ SELECT $1 \parse stmt1
- \dO[S+] [ pattern ]
+ \dO[Sx+] [ pattern ]
Lists collations.
@@ -1880,7 +1961,10 @@ SELECT $1 \parse stmt1
specified, only collations whose names match the pattern are
listed. By default, only user-created objects are shown;
supply a pattern or the S modifier to
- include system objects. If + is appended
+ include system objects.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
+ If + is appended
to the command name, each collation is listed with its associated
description, if any.
Note that only collations usable with the current database's encoding
@@ -1892,7 +1976,7 @@ SELECT $1 \parse stmt1
- \dp[S] [ pattern ]
+ \dp[Sx] [ pattern ]
Lists tables, views and sequences with their
@@ -1902,6 +1986,8 @@ SELECT $1 \parse stmt1
pattern are listed. By default only user-created objects are shown;
supply a pattern or the S modifier to include
system objects.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
@@ -1916,7 +2002,7 @@ SELECT $1 \parse stmt1
- \dP[itn+] [ pattern ]
+ \dP[itnx+] [ pattern ]
Lists partitioned relations.
@@ -1936,6 +2022,8 @@ SELECT $1 \parse stmt1
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
If + is appended to the command name, the sum of the
sizes of each relation's partitions is also displayed, along with the
relation's description.
@@ -1949,7 +2037,7 @@ SELECT $1 \parse stmt1
- \drds [ role-pattern [ database-pattern ] ]
+ \drds[x] [ role-pattern [ database-pattern ] ]
Lists defined configuration settings. These settings can be
@@ -1959,6 +2047,8 @@ SELECT $1 \parse stmt1
specific roles and databases to list, respectively. If omitted, or if
* is specified, all settings are listed, including those
not role-specific or database-specific, respectively.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
@@ -1972,7 +2062,7 @@ SELECT $1 \parse stmt1
- \drg[S] [ pattern ]
+ \drg[Sx] [ pattern ]
Lists information about each granted role membership, including
@@ -1986,19 +2076,23 @@ SELECT $1 \parse stmt1
S modifier to include system roles.
If pattern is specified,
only grants to those roles whose names match the pattern are listed.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
- \dRp[+] [ pattern ]
+ \dRp[x+] [ pattern ]
Lists replication publications.
If pattern is
specified, only those publications whose names match the pattern are
listed.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
If + is appended to the command name, the tables and
schemas associated with each publication are shown as well.
@@ -2006,13 +2100,15 @@ SELECT $1 \parse stmt1
- \dRs[+] [ pattern ]
+ \dRs[x+] [ pattern ]
Lists replication subscriptions.
If pattern is
specified, only those subscriptions whose names match the pattern are
listed.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
If + is appended to the command name, additional
properties of the subscriptions are shown.
@@ -2020,12 +2116,14 @@ SELECT $1 \parse stmt1
- \dT[S+] [ pattern ]
+ \dT[Sx+] [ pattern ]
Lists data types.
If pattern is
specified, only types whose names match the pattern are listed.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
If + is appended to the command name, each type is
listed with its internal name and size, its allowed values
if it is an enum type, and its associated permissions.
@@ -2037,7 +2135,7 @@ SELECT $1 \parse stmt1
- \du[S+] [ pattern ]
+ \du[Sx+] [ pattern ]
Lists database roles.
@@ -2048,7 +2146,9 @@ SELECT $1 \parse stmt1
S modifier to include system roles.
If pattern is specified,
only those roles whose names match the pattern are listed.
- If the form \du+ is used, additional information
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
+ If + is appended to the command name, additional information
is shown about each role; currently this adds the comment for each
role.
@@ -2056,27 +2156,31 @@ SELECT $1 \parse stmt1
- \dx[+] [ pattern ]
+ \dx[x+] [ pattern ]
Lists installed extensions.
If pattern
is specified, only those extensions whose names match the pattern
are listed.
- If the form \dx+ is used, all the objects belonging
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
+ If + is appended to the command name, all the objects belonging
to each matching extension are listed.
- \dX [ pattern ]
+ \dX[x] [ pattern ]
Lists extended statistics.
If pattern
is specified, only those extended statistics whose names match the
pattern are listed.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
@@ -2092,13 +2196,15 @@ SELECT $1 \parse stmt1
- \dy[+] [ pattern ]
+ \dy[x+] [ pattern ]
Lists event triggers.
If pattern
is specified, only those event triggers whose names match the pattern
are listed.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
If + is appended to the command name, each object
is listed with its associated description.
@@ -2686,13 +2792,15 @@ SELECT
- \l[+] or \list[+] [ pattern ]
+ \l[x+] or \list[x+] [ pattern ]
List the databases in the server and show their names, owners,
character set encodings, and access privileges.
If pattern is specified,
only databases whose names match the pattern are listed.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
If + is appended to the command name, database
sizes, default tablespaces, and descriptions are also displayed.
(Size information is only available for databases that the current
@@ -2756,12 +2864,14 @@ lo_import 152801
- \lo_list[+]
+ \lo_list[x+]
Shows a list of all PostgreSQL
large objects currently stored in the database,
along with any comments provided for them.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
If + is appended to the command name,
each large object is listed with its associated permissions,
if any.
@@ -3695,7 +3805,7 @@ testdb=> \setenv LESS -imx4F
- \z[S] [ pattern ]
+ \z[Sx] [ pattern ]
Lists tables, views and sequences with their
@@ -3705,6 +3815,8 @@ testdb=> \setenv LESS -imx4F
pattern are listed. By default only user-created objects are shown;
supply a pattern or the S modifier to include
system objects.
+ If x is appended to the command name, the results
+ are displayed in expanded mode.
@@ -5388,6 +5500,31 @@ testdb=> \df int*pl * bigint
+
+ Here, the + option is used to display additional
+ information about one of these functions, and x is used
+ to display the results in expanded mode:
+
+testdb=> \df+x int*pl integer bigint
+List of functions
+-[ RECORD 1 ]-------+-----------------------------
+Schema | pg_catalog
+Name | int48pl
+Result data type | bigint
+Argument data types | integer, bigint
+Type | func
+Volatility | immutable
+Parallel | safe
+Owner | postgres
+Security | invoker
+Leakproof? | no
+Access privileges |
+Language | internal
+Internal name | int48pl
+Description | implementation of + operator
+
+
+
When suitable, query results can be shown in a crosstab representation
with the \crosstabview command:
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 5dd4c2d2687..613583145e2 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -377,7 +377,10 @@ exec_command(const char *cmd,
else if (strcmp(cmd, "if") == 0)
status = exec_command_if(scan_state, cstack, query_buf);
else if (strcmp(cmd, "l") == 0 || strcmp(cmd, "list") == 0 ||
- strcmp(cmd, "l+") == 0 || strcmp(cmd, "list+") == 0)
+ strcmp(cmd, "lx") == 0 || strcmp(cmd, "listx") == 0 ||
+ strcmp(cmd, "l+") == 0 || strcmp(cmd, "list+") == 0 ||
+ strcmp(cmd, "lx+") == 0 || strcmp(cmd, "listx+") == 0 ||
+ strcmp(cmd, "l+x") == 0 || strcmp(cmd, "list+x") == 0)
status = exec_command_list(scan_state, active_branch, cmd);
else if (strncmp(cmd, "lo_", 3) == 0)
status = exec_command_lo(scan_state, active_branch, cmd);
@@ -424,7 +427,9 @@ exec_command(const char *cmd,
query_buf, previous_buf);
else if (strcmp(cmd, "x") == 0)
status = exec_command_x(scan_state, active_branch);
- else if (strcmp(cmd, "z") == 0 || strcmp(cmd, "zS") == 0)
+ else if (strcmp(cmd, "z") == 0 ||
+ strcmp(cmd, "zS") == 0 || strcmp(cmd, "zx") == 0 ||
+ strcmp(cmd, "zSx") == 0 || strcmp(cmd, "zxS") == 0)
status = exec_command_z(scan_state, active_branch, cmd);
else if (strcmp(cmd, "!") == 0)
status = exec_command_shell_escape(scan_state, active_branch);
@@ -850,6 +855,7 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
char *pattern;
bool show_verbose,
show_system;
+ unsigned short int save_expanded;
/* We don't do SQLID reduction on the pattern yet */
pattern = psql_scan_slash_option(scan_state,
@@ -858,6 +864,16 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
show_verbose = strchr(cmd, '+') ? true : false;
show_system = strchr(cmd, 'S') ? true : false;
+ /*
+ * The 'x' option turns expanded mode on for this command only. This
+ * is allowed in all \d* commands, except \d by itself, since \dx is a
+ * separate command. So the 'x' option cannot appear immediately after
+ * \d, but it can appear after \d followed by other options.
+ */
+ save_expanded = pset.popt.topt.expanded;
+ if (cmd[1] != '\0' && strchr(&cmd[2], 'x'))
+ pset.popt.topt.expanded = 1;
+
switch (cmd[1])
{
case '\0':
@@ -873,13 +889,14 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
{
char *pattern2 = NULL;
- if (pattern && cmd[2] != '\0' && cmd[2] != '+')
+ if (pattern && cmd[2] != '\0' && cmd[2] != '+' && cmd[2] != 'x')
pattern2 = psql_scan_slash_option(scan_state, OT_NORMAL, NULL, true);
switch (cmd[2])
{
case '\0':
case '+':
+ case 'x':
success = describeAccessMethods(pattern, show_verbose);
break;
case 'c':
@@ -941,6 +958,7 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
case 'p':
case 't':
case 'w':
+ case 'x':
success = exec_command_dfo(scan_state, cmd, pattern,
show_verbose, show_system);
break;
@@ -981,6 +999,7 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
case 't':
case 'i':
case 'n':
+ case 'x':
success = listPartitionedTables(&cmd[2], pattern, show_verbose);
break;
default:
@@ -1041,6 +1060,7 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
{
case '\0':
case '+':
+ case 'x':
success = listTSConfigs(pattern, show_verbose);
break;
case 'p':
@@ -1093,6 +1113,9 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
status = PSQL_CMD_UNKNOWN;
}
+ /* Restore original expanded mode */
+ pset.popt.topt.expanded = save_expanded;
+
free(pattern);
}
else
@@ -2044,14 +2067,23 @@ exec_command_list(PsqlScanState scan_state, bool active_branch, const char *cmd)
{
char *pattern;
bool show_verbose;
+ unsigned short int save_expanded;
pattern = psql_scan_slash_option(scan_state,
OT_NORMAL, NULL, true);
show_verbose = strchr(cmd, '+') ? true : false;
+ /* if 'x' option specified, force expanded mode */
+ save_expanded = pset.popt.topt.expanded;
+ if (strchr(cmd, 'x'))
+ pset.popt.topt.expanded = 1;
+
success = listAllDbs(pattern, show_verbose);
+ /* restore original expanded mode */
+ pset.popt.topt.expanded = save_expanded;
+
free(pattern);
}
else
@@ -2107,10 +2139,23 @@ exec_command_lo(PsqlScanState scan_state, bool active_branch, const char *cmd)
}
}
- else if (strcmp(cmd + 3, "list") == 0)
- success = listLargeObjects(false);
- else if (strcmp(cmd + 3, "list+") == 0)
- success = listLargeObjects(true);
+ else if (strncmp(cmd + 3, "list", 4) == 0)
+ {
+ bool show_verbose;
+ unsigned short int save_expanded;
+
+ show_verbose = strchr(cmd, '+') ? true : false;
+
+ /* if 'x' option specified, force expanded mode */
+ save_expanded = pset.popt.topt.expanded;
+ if (strchr(cmd, 'x'))
+ pset.popt.topt.expanded = 1;
+
+ success = listLargeObjects(show_verbose);
+
+ /* restore original expanded mode */
+ pset.popt.topt.expanded = save_expanded;
+ }
else if (strcmp(cmd + 3, "unlink") == 0)
{
@@ -3061,14 +3106,23 @@ exec_command_z(PsqlScanState scan_state, bool active_branch, const char *cmd)
{
char *pattern;
bool show_system;
+ unsigned short int save_expanded;
pattern = psql_scan_slash_option(scan_state,
OT_NORMAL, NULL, true);
show_system = strchr(cmd, 'S') ? true : false;
+ /* if 'x' option specified, force expanded mode */
+ save_expanded = pset.popt.topt.expanded;
+ if (strchr(cmd, 'x'))
+ pset.popt.topt.expanded = 1;
+
success = permissionsList(pattern, show_system);
+ /* restore original expanded mode */
+ pset.popt.topt.expanded = save_expanded;
+
free(pattern);
}
else
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 54ebc889c3b..2ef99971ac0 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -309,9 +309,9 @@ describeFunctions(const char *functypes, const char *func_pattern,
/* No "Parallel" column before 9.6 */
static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false};
- if (strlen(functypes) != strspn(functypes, "anptwS+"))
+ if (strlen(functypes) != strspn(functypes, "anptwSx+"))
{
- pg_log_error("\\df only takes [anptwS+] as options");
+ pg_log_error("\\df only takes [anptwSx+] as options");
return true;
}
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index fda83465efa..da8e1ade5df 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -219,67 +219,67 @@ slashUsage(unsigned short int pager)
HELP0("\n");
HELP0("Informational\n");
- HELP0(" (options: S = show system objects, + = additional detail)\n");
- HELP0(" \\d[S+] list tables, views, and sequences\n");
- HELP0(" \\d[S+] NAME describe table, view, sequence, or index\n");
- HELP0(" \\da[S] [PATTERN] list aggregates\n");
- HELP0(" \\dA[+] [PATTERN] list access methods\n");
- HELP0(" \\dAc[+] [AMPTRN [TYPEPTRN]] list operator classes\n");
- HELP0(" \\dAf[+] [AMPTRN [TYPEPTRN]] list operator families\n");
- HELP0(" \\dAo[+] [AMPTRN [OPFPTRN]] list operators of operator families\n");
- HELP0(" \\dAp[+] [AMPTRN [OPFPTRN]] list support functions of operator families\n");
- HELP0(" \\db[+] [PATTERN] list tablespaces\n");
- HELP0(" \\dc[S+] [PATTERN] list conversions\n");
- HELP0(" \\dconfig[+] [PATTERN] list configuration parameters\n");
- HELP0(" \\dC[+] [PATTERN] list casts\n");
- HELP0(" \\dd[S] [PATTERN] show object descriptions not displayed elsewhere\n");
- HELP0(" \\dD[S+] [PATTERN] list domains\n");
- HELP0(" \\ddp [PATTERN] list default privileges\n");
- HELP0(" \\dE[S+] [PATTERN] list foreign tables\n");
- HELP0(" \\des[+] [PATTERN] list foreign servers\n");
- HELP0(" \\det[+] [PATTERN] list foreign tables\n");
- HELP0(" \\deu[+] [PATTERN] list user mappings\n");
- HELP0(" \\dew[+] [PATTERN] list foreign-data wrappers\n");
- HELP0(" \\df[anptw][S+] [FUNCPTRN [TYPEPTRN ...]]\n"
+ HELP0(" (options: S = show system objects, x = expanded mode, + = additional detail)\n");
+ HELP0(" \\d[Sx+] list tables, views, and sequences\n");
+ HELP0(" \\d[S+] NAME describe table, view, sequence, or index\n");
+ HELP0(" \\da[Sx] [PATTERN] list aggregates\n");
+ HELP0(" \\dA[x+] [PATTERN] list access methods\n");
+ HELP0(" \\dAc[x+] [AMPTRN [TYPEPTRN]] list operator classes\n");
+ HELP0(" \\dAf[x+] [AMPTRN [TYPEPTRN]] list operator families\n");
+ HELP0(" \\dAo[x+] [AMPTRN [OPFPTRN]] list operators of operator families\n");
+ HELP0(" \\dAp[x+] [AMPTRN [OPFPTRN]] list support functions of operator families\n");
+ HELP0(" \\db[x+] [PATTERN] list tablespaces\n");
+ HELP0(" \\dc[Sx+] [PATTERN] list conversions\n");
+ HELP0(" \\dconfig[x+] [PATTERN] list configuration parameters\n");
+ HELP0(" \\dC[x+] [PATTERN] list casts\n");
+ HELP0(" \\dd[Sx] [PATTERN] show object descriptions not displayed elsewhere\n");
+ HELP0(" \\dD[Sx+] [PATTERN] list domains\n");
+ HELP0(" \\ddp[x] [PATTERN] list default privileges\n");
+ HELP0(" \\dE[Sx+] [PATTERN] list foreign tables\n");
+ HELP0(" \\des[x+] [PATTERN] list foreign servers\n");
+ HELP0(" \\det[x+] [PATTERN] list foreign tables\n");
+ HELP0(" \\deu[x+] [PATTERN] list user mappings\n");
+ HELP0(" \\dew[x+] [PATTERN] list foreign-data wrappers\n");
+ HELP0(" \\df[anptw][Sx+] [FUNCPTRN [TYPEPTRN ...]]\n"
" list [only agg/normal/procedure/trigger/window] functions\n");
- HELP0(" \\dF[+] [PATTERN] list text search configurations\n");
- HELP0(" \\dFd[+] [PATTERN] list text search dictionaries\n");
- HELP0(" \\dFp[+] [PATTERN] list text search parsers\n");
- HELP0(" \\dFt[+] [PATTERN] list text search templates\n");
- HELP0(" \\dg[S+] [PATTERN] list roles\n");
- HELP0(" \\di[S+] [PATTERN] list indexes\n");
- HELP0(" \\dl[+] list large objects, same as \\lo_list\n");
- HELP0(" \\dL[S+] [PATTERN] list procedural languages\n");
- HELP0(" \\dm[S+] [PATTERN] list materialized views\n");
- HELP0(" \\dn[S+] [PATTERN] list schemas\n");
- HELP0(" \\do[S+] [OPPTRN [TYPEPTRN [TYPEPTRN]]]\n"
+ HELP0(" \\dF[x+] [PATTERN] list text search configurations\n");
+ HELP0(" \\dFd[x+] [PATTERN] list text search dictionaries\n");
+ HELP0(" \\dFp[x+] [PATTERN] list text search parsers\n");
+ HELP0(" \\dFt[x+] [PATTERN] list text search templates\n");
+ HELP0(" \\dg[Sx+] [PATTERN] list roles\n");
+ HELP0(" \\di[Sx+] [PATTERN] list indexes\n");
+ HELP0(" \\dl[x+] list large objects, same as \\lo_list\n");
+ HELP0(" \\dL[Sx+] [PATTERN] list procedural languages\n");
+ HELP0(" \\dm[Sx+] [PATTERN] list materialized views\n");
+ HELP0(" \\dn[Sx+] [PATTERN] list schemas\n");
+ HELP0(" \\do[Sx+] [OPPTRN [TYPEPTRN [TYPEPTRN]]]\n"
" list operators\n");
- HELP0(" \\dO[S+] [PATTERN] list collations\n");
- HELP0(" \\dp[S] [PATTERN] list table, view, and sequence access privileges\n");
- HELP0(" \\dP[itn+] [PATTERN] list [only index/table] partitioned relations [n=nested]\n");
- HELP0(" \\drds [ROLEPTRN [DBPTRN]] list per-database role settings\n");
- HELP0(" \\drg[S] [PATTERN] list role grants\n");
- HELP0(" \\dRp[+] [PATTERN] list replication publications\n");
- HELP0(" \\dRs[+] [PATTERN] list replication subscriptions\n");
- HELP0(" \\ds[S+] [PATTERN] list sequences\n");
- HELP0(" \\dt[S+] [PATTERN] list tables\n");
- HELP0(" \\dT[S+] [PATTERN] list data types\n");
- HELP0(" \\du[S+] [PATTERN] list roles\n");
- HELP0(" \\dv[S+] [PATTERN] list views\n");
- HELP0(" \\dx[+] [PATTERN] list extensions\n");
- HELP0(" \\dX [PATTERN] list extended statistics\n");
- HELP0(" \\dy[+] [PATTERN] list event triggers\n");
- HELP0(" \\l[+] [PATTERN] list databases\n");
- HELP0(" \\sf[+] FUNCNAME show a function's definition\n");
- HELP0(" \\sv[+] VIEWNAME show a view's definition\n");
- HELP0(" \\z[S] [PATTERN] same as \\dp\n");
+ HELP0(" \\dO[Sx+] [PATTERN] list collations\n");
+ HELP0(" \\dp[Sx] [PATTERN] list table, view, and sequence access privileges\n");
+ HELP0(" \\dP[itnx+] [PATTERN] list [only index/table] partitioned relations [n=nested]\n");
+ HELP0(" \\drds[x] [ROLEPTRN [DBPTRN]] list per-database role settings\n");
+ HELP0(" \\drg[Sx] [PATTERN] list role grants\n");
+ HELP0(" \\dRp[x+] [PATTERN] list replication publications\n");
+ HELP0(" \\dRs[x+] [PATTERN] list replication subscriptions\n");
+ HELP0(" \\ds[Sx+] [PATTERN] list sequences\n");
+ HELP0(" \\dt[Sx+] [PATTERN] list tables\n");
+ HELP0(" \\dT[Sx+] [PATTERN] list data types\n");
+ HELP0(" \\du[Sx+] [PATTERN] list roles\n");
+ HELP0(" \\dv[Sx+] [PATTERN] list views\n");
+ HELP0(" \\dx[x+] [PATTERN] list extensions\n");
+ HELP0(" \\dX[x] [PATTERN] list extended statistics\n");
+ HELP0(" \\dy[x+] [PATTERN] list event triggers\n");
+ HELP0(" \\l[x+] [PATTERN] list databases\n");
+ HELP0(" \\sf[+] FUNCNAME show a function's definition\n");
+ HELP0(" \\sv[+] VIEWNAME show a view's definition\n");
+ HELP0(" \\z[Sx] [PATTERN] same as \\dp\n");
HELP0("\n");
HELP0("Large Objects\n");
HELP0(" \\lo_export LOBOID FILE write large object to file\n");
HELP0(" \\lo_import FILE [COMMENT]\n"
" read large object from file\n");
- HELP0(" \\lo_list[+] list large objects\n");
+ HELP0(" \\lo_list[x+] list large objects\n");
HELP0(" \\lo_unlink LOBOID delete a large object\n");
HELP0("\n");
diff --git a/src/test/regress/expected/psql.out b/src/test/regress/expected/psql.out
index 954ad86aee2..e6f7b9013d9 100644
--- a/src/test/regress/expected/psql.out
+++ b/src/test/regress/expected/psql.out
@@ -2841,6 +2841,19 @@ Owned by: public.psql_serial_tab.id
pg_catalog | exp | double precision | double precision | func
pg_catalog | exp | numeric | numeric | func
+\dfx exp
+Schema | pg_catalog
+Name | exp
+Result data type | double precision
+Argument data types | double precision
+Type | func
+--------------------+-----------------
+Schema | pg_catalog
+Name | exp
+Result data type | numeric
+Argument data types | numeric
+Type | func
+
\pset tuples_only false
\pset expanded on
\d psql_serial_tab_id_seq
@@ -3047,6 +3060,49 @@ Access method: heap
tableam_display | view_heap_psql | view | regress_display_role | permanent | 0 bytes |
(4 rows)
+-- \d with 'x' enables expanded mode, but only without a pattern
+\d+x tbl_heap
+ Table "tableam_display.tbl_heap"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+----------------+-----------+----------+---------+----------+--------------+-------------
+ f1 | integer | | | | plain | |
+ f2 | character(100) | | | | extended | |
+
+\d+x
+List of relations
+-[ RECORD 1 ]---------------------
+Schema | tableam_display
+Name | mat_view_heap_psql
+Type | materialized view
+Owner | regress_display_role
+Persistence | permanent
+Size | 0 bytes
+Description |
+-[ RECORD 2 ]---------------------
+Schema | tableam_display
+Name | tbl_heap
+Type | table
+Owner | regress_display_role
+Persistence | permanent
+Size | 0 bytes
+Description |
+-[ RECORD 3 ]---------------------
+Schema | tableam_display
+Name | tbl_heap_psql
+Type | table
+Owner | regress_display_role
+Persistence | permanent
+Size | 0 bytes
+Description |
+-[ RECORD 4 ]---------------------
+Schema | tableam_display
+Name | view_heap_psql
+Type | view
+Owner | regress_display_role
+Persistence | permanent
+Size | 0 bytes
+Description |
+
RESET ROLE;
RESET search_path;
DROP SCHEMA tableam_display CASCADE;
@@ -5238,6 +5294,30 @@ List of access methods
btree | float_ops | real | double precision | 3 | in_range(real,real,double precision,boolean,boolean)
(8 rows)
+\dApx+ btree time_ops
+List of support functions of operator families
+-[ RECORD 1 ]---------+---------------------------------------------------------------------------------
+AM | btree
+Operator family | time_ops
+Registered left type | time without time zone
+Registered right type | time without time zone
+Number | 1
+Function | time_cmp(time without time zone,time without time zone)
+-[ RECORD 2 ]---------+---------------------------------------------------------------------------------
+AM | btree
+Operator family | time_ops
+Registered left type | time without time zone
+Registered right type | time without time zone
+Number | 4
+Function | btequalimage(oid)
+-[ RECORD 3 ]---------+---------------------------------------------------------------------------------
+AM | btree
+Operator family | time_ops
+Registered left type | time without time zone
+Registered right type | interval
+Number | 3
+Function | in_range(time without time zone,time without time zone,interval,boolean,boolean)
+
\dAp * pg_catalog.uuid_ops
List of support functions of operator families
AM | Operator family | Registered left type | Registered right type | Number | Function
@@ -6831,5 +6911,15 @@ CREATE TABLE defprivs (a int);
public | defprivs | table | (default) | |
(1 row)
+\zx defprivs
+Access privileges
+-[ RECORD 1 ]-----+----------
+Schema | public
+Name | defprivs
+Type | table
+Access privileges | (default)
+Column privileges |
+Policies |
+
\pset null ''
DROP TABLE defprivs;
diff --git a/src/test/regress/sql/psql.sql b/src/test/regress/sql/psql.sql
index f6c5aa1f8bc..c58308ce14f 100644
--- a/src/test/regress/sql/psql.sql
+++ b/src/test/regress/sql/psql.sql
@@ -498,6 +498,7 @@ create table psql_serial_tab (id serial);
\d psql_serial_tab_id_seq
\pset tuples_only true
\df exp
+\dfx exp
\pset tuples_only false
\pset expanded on
\d psql_serial_tab_id_seq
@@ -560,6 +561,9 @@ CREATE MATERIALIZED VIEW mat_view_heap_psql USING heap_psql AS SELECT f1 from tb
\dv+
\set HIDE_TABLEAM on
\d+
+-- \d with 'x' enables expanded mode, but only without a pattern
+\d+x tbl_heap
+\d+x
RESET ROLE;
RESET search_path;
DROP SCHEMA tableam_display CASCADE;
@@ -1309,6 +1313,7 @@ drop role regress_partitioning_role;
\dAo+ btree array_ops|float_ops
\dAo * pg_catalog.jsonb_path_ops
\dAp+ btree float_ops
+\dApx+ btree time_ops
\dAp * pg_catalog.uuid_ops
-- check \dconfig
@@ -1927,5 +1932,6 @@ ROLLBACK;
CREATE TABLE defprivs (a int);
\pset null '(default)'
\z defprivs
+\zx defprivs
\pset null ''
DROP TABLE defprivs;