1
0
mirror of https://github.com/postgres/postgres.git synced 2026-01-27 21:43:08 +03:00

Add xheader_width pset option to psql

The setting controls tha maximum length of the header line in expanded
format output. Possible settings are full, column, page, or an integer.
the default is full, the current behaviour, and in this case the header
line is the length of the widest line of output. column causes the
header to be truncated to the width of the first column, page causes it
to be truncated to the width of the terminal page, and an integer causes
it to be truncated to that value. If the full value is less than the
page or integer value no truncation occurs. If given without an argument
this option prints its current setting.

Platon Pronko, somewhat modified by me.

Discussion: https://postgr.es/m/f03d38a3-db96-a56e-d1bc-dbbc80bbde4d@gmail.com
This commit is contained in:
Andrew Dunstan
2022-07-25 14:24:50 -04:00
parent b35617de37
commit a45388d6e0
7 changed files with 164 additions and 18 deletions

View File

@@ -66,6 +66,15 @@ typedef enum printTextLineWrap
PRINT_LINE_WRAP_NEWLINE /* Newline in data */
} printTextLineWrap;
typedef enum printXheaderWidthType
{
/* Expanded header line width variants */
PRINT_XHEADER_FULL, /* do not truncate header line (this is the default) */
PRINT_XHEADER_COLUMN, /* only print header line above the first column */
PRINT_XHEADER_PAGE, /* header line must not be longer than terminal width */
PRINT_XHEADER_EXACT_WIDTH, /* explicitly specified width */
} printXheaderWidthType;
typedef struct printTextFormat
{
/* A complete line style */
@@ -101,6 +110,8 @@ typedef struct printTableOpt
enum printFormat format; /* see enum above */
unsigned short int expanded; /* expanded/vertical output (if supported
* by output format); 0=no, 1=yes, 2=auto */
printXheaderWidthType expanded_header_width_type; /* width type for header line in expanded mode */
int expanded_header_exact_width; /* explicit width for header line in expanded mode */
unsigned short int border; /* Print a border around the table. 0=none,
* 1=dividing lines, 2=full */
unsigned short int pager; /* use pager for output (if to stdout and