@@ -377,7 +377,10 @@ exec_command(const char *cmd,
377
377
else if (strcmp (cmd , "if" ) == 0 )
378
378
status = exec_command_if (scan_state , cstack , query_buf );
379
379
else if (strcmp (cmd , "l" ) == 0 || strcmp (cmd , "list" ) == 0 ||
380
- strcmp (cmd , "l+" ) == 0 || strcmp (cmd , "list+" ) == 0 )
380
+ strcmp (cmd , "lx" ) == 0 || strcmp (cmd , "listx" ) == 0 ||
381
+ strcmp (cmd , "l+" ) == 0 || strcmp (cmd , "list+" ) == 0 ||
382
+ strcmp (cmd , "lx+" ) == 0 || strcmp (cmd , "listx+" ) == 0 ||
383
+ strcmp (cmd , "l+x" ) == 0 || strcmp (cmd , "list+x" ) == 0 )
381
384
status = exec_command_list (scan_state , active_branch , cmd );
382
385
else if (strncmp (cmd , "lo_" , 3 ) == 0 )
383
386
status = exec_command_lo (scan_state , active_branch , cmd );
@@ -424,7 +427,9 @@ exec_command(const char *cmd,
424
427
query_buf , previous_buf );
425
428
else if (strcmp (cmd , "x" ) == 0 )
426
429
status = exec_command_x (scan_state , active_branch );
427
- else if (strcmp (cmd , "z" ) == 0 || strcmp (cmd , "zS" ) == 0 )
430
+ else if (strcmp (cmd , "z" ) == 0 ||
431
+ strcmp (cmd , "zS" ) == 0 || strcmp (cmd , "zx" ) == 0 ||
432
+ strcmp (cmd , "zSx" ) == 0 || strcmp (cmd , "zxS" ) == 0 )
428
433
status = exec_command_z (scan_state , active_branch , cmd );
429
434
else if (strcmp (cmd , "!" ) == 0 )
430
435
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)
850
855
char * pattern ;
851
856
bool show_verbose ,
852
857
show_system ;
858
+ unsigned short int save_expanded ;
853
859
854
860
/* We don't do SQLID reduction on the pattern yet */
855
861
pattern = psql_scan_slash_option (scan_state ,
@@ -858,6 +864,16 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
858
864
show_verbose = strchr (cmd , '+' ) ? true : false;
859
865
show_system = strchr (cmd , 'S' ) ? true : false;
860
866
867
+ /*
868
+ * The 'x' option turns expanded mode on for this command only. This
869
+ * is allowed in all \d* commands, except \d by itself, since \dx is a
870
+ * separate command. So the 'x' option cannot appear immediately after
871
+ * \d, but it can appear after \d followed by other options.
872
+ */
873
+ save_expanded = pset .popt .topt .expanded ;
874
+ if (cmd [1 ] != '\0' && strchr (& cmd [2 ], 'x' ))
875
+ pset .popt .topt .expanded = 1 ;
876
+
861
877
switch (cmd [1 ])
862
878
{
863
879
case '\0' :
@@ -873,13 +889,14 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
873
889
{
874
890
char * pattern2 = NULL ;
875
891
876
- if (pattern && cmd [2 ] != '\0' && cmd [2 ] != '+' )
892
+ if (pattern && cmd [2 ] != '\0' && cmd [2 ] != '+' && cmd [ 2 ] != 'x' )
877
893
pattern2 = psql_scan_slash_option (scan_state , OT_NORMAL , NULL , true);
878
894
879
895
switch (cmd [2 ])
880
896
{
881
897
case '\0' :
882
898
case '+' :
899
+ case 'x' :
883
900
success = describeAccessMethods (pattern , show_verbose );
884
901
break ;
885
902
case 'c' :
@@ -941,6 +958,7 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
941
958
case 'p' :
942
959
case 't' :
943
960
case 'w' :
961
+ case 'x' :
944
962
success = exec_command_dfo (scan_state , cmd , pattern ,
945
963
show_verbose , show_system );
946
964
break ;
@@ -981,6 +999,7 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
981
999
case 't' :
982
1000
case 'i' :
983
1001
case 'n' :
1002
+ case 'x' :
984
1003
success = listPartitionedTables (& cmd [2 ], pattern , show_verbose );
985
1004
break ;
986
1005
default :
@@ -1041,6 +1060,7 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
1041
1060
{
1042
1061
case '\0' :
1043
1062
case '+' :
1063
+ case 'x' :
1044
1064
success = listTSConfigs (pattern , show_verbose );
1045
1065
break ;
1046
1066
case 'p' :
@@ -1093,6 +1113,9 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
1093
1113
status = PSQL_CMD_UNKNOWN ;
1094
1114
}
1095
1115
1116
+ /* Restore original expanded mode */
1117
+ pset .popt .topt .expanded = save_expanded ;
1118
+
1096
1119
free (pattern );
1097
1120
}
1098
1121
else
@@ -2044,14 +2067,23 @@ exec_command_list(PsqlScanState scan_state, bool active_branch, const char *cmd)
2044
2067
{
2045
2068
char * pattern ;
2046
2069
bool show_verbose ;
2070
+ unsigned short int save_expanded ;
2047
2071
2048
2072
pattern = psql_scan_slash_option (scan_state ,
2049
2073
OT_NORMAL , NULL , true);
2050
2074
2051
2075
show_verbose = strchr (cmd , '+' ) ? true : false;
2052
2076
2077
+ /* if 'x' option specified, force expanded mode */
2078
+ save_expanded = pset .popt .topt .expanded ;
2079
+ if (strchr (cmd , 'x' ))
2080
+ pset .popt .topt .expanded = 1 ;
2081
+
2053
2082
success = listAllDbs (pattern , show_verbose );
2054
2083
2084
+ /* restore original expanded mode */
2085
+ pset .popt .topt .expanded = save_expanded ;
2086
+
2055
2087
free (pattern );
2056
2088
}
2057
2089
else
@@ -2107,10 +2139,23 @@ exec_command_lo(PsqlScanState scan_state, bool active_branch, const char *cmd)
2107
2139
}
2108
2140
}
2109
2141
2110
- else if (strcmp (cmd + 3 , "list" ) == 0 )
2111
- success = listLargeObjects (false);
2112
- else if (strcmp (cmd + 3 , "list+" ) == 0 )
2113
- success = listLargeObjects (true);
2142
+ else if (strncmp (cmd + 3 , "list" , 4 ) == 0 )
2143
+ {
2144
+ bool show_verbose ;
2145
+ unsigned short int save_expanded ;
2146
+
2147
+ show_verbose = strchr (cmd , '+' ) ? true : false;
2148
+
2149
+ /* if 'x' option specified, force expanded mode */
2150
+ save_expanded = pset .popt .topt .expanded ;
2151
+ if (strchr (cmd , 'x' ))
2152
+ pset .popt .topt .expanded = 1 ;
2153
+
2154
+ success = listLargeObjects (show_verbose );
2155
+
2156
+ /* restore original expanded mode */
2157
+ pset .popt .topt .expanded = save_expanded ;
2158
+ }
2114
2159
2115
2160
else if (strcmp (cmd + 3 , "unlink" ) == 0 )
2116
2161
{
@@ -3061,14 +3106,23 @@ exec_command_z(PsqlScanState scan_state, bool active_branch, const char *cmd)
3061
3106
{
3062
3107
char * pattern ;
3063
3108
bool show_system ;
3109
+ unsigned short int save_expanded ;
3064
3110
3065
3111
pattern = psql_scan_slash_option (scan_state ,
3066
3112
OT_NORMAL , NULL , true);
3067
3113
3068
3114
show_system = strchr (cmd , 'S' ) ? true : false;
3069
3115
3116
+ /* if 'x' option specified, force expanded mode */
3117
+ save_expanded = pset .popt .topt .expanded ;
3118
+ if (strchr (cmd , 'x' ))
3119
+ pset .popt .topt .expanded = 1 ;
3120
+
3070
3121
success = permissionsList (pattern , show_system );
3071
3122
3123
+ /* restore original expanded mode */
3124
+ pset .popt .topt .expanded = save_expanded ;
3125
+
3072
3126
free (pattern );
3073
3127
}
3074
3128
else
0 commit comments