aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/psql/command.c')
-rw-r--r--src/bin/psql/command.c68
1 files changed, 61 insertions, 7 deletions
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