aboutsummaryrefslogtreecommitdiff
path: root/src/fe_utils/print.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2016-04-08 20:23:18 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2016-04-08 20:23:18 -0300
commitc09b18f21c52cbcf8718d6c267c84fcfea3739a9 (patch)
tree14ae5d520050d3302c8ecae141a2deda7c17a962 /src/fe_utils/print.c
parent279d86afdbed550425bc9d1327ade2dc0028ad33 (diff)
downloadpostgresql-c09b18f21c52cbcf8718d6c267c84fcfea3739a9.tar.gz
postgresql-c09b18f21c52cbcf8718d6c267c84fcfea3739a9.zip
Support \crosstabview in psql
\crosstabview is a completely different way to display results from a query: instead of a vertical display of rows, the data values are placed in a grid where the column and row headers come from the data itself, similar to a spreadsheet. The sort order of the horizontal header can be specified by using another column in the query, and the vertical header determines its ordering from the order in which they appear in the query. This only allows displaying a single value in each cell. If more than one value correspond to the same cell, an error is thrown. Merging of values can be done in the query itself, if necessary. This may be revisited in the future. Author: Daniel Verité Reviewed-by: Pavel Stehule, Dean Rasheed
Diffstat (limited to 'src/fe_utils/print.c')
-rw-r--r--src/fe_utils/print.c50
1 files changed, 27 insertions, 23 deletions
diff --git a/src/fe_utils/print.c b/src/fe_utils/print.c
index 30efd3fdc62..1ec74f17907 100644
--- a/src/fe_utils/print.c
+++ b/src/fe_utils/print.c
@@ -3295,30 +3295,9 @@ printQuery(const PGresult *result, const printQueryOpt *opt,
for (i = 0; i < cont.ncolumns; i++)
{
- char align;
- Oid ftype = PQftype(result, i);
-
- switch (ftype)
- {
- case INT2OID:
- case INT4OID:
- case INT8OID:
- case FLOAT4OID:
- case FLOAT8OID:
- case NUMERICOID:
- case OIDOID:
- case XIDOID:
- case CIDOID:
- case CASHOID:
- align = 'r';
- break;
- default:
- align = 'l';
- break;
- }
-
printTableAddHeader(&cont, PQfname(result, i),
- opt->translate_header, align);
+ opt->translate_header,
+ column_type_alignment(PQftype(result, i)));
}
/* set cells */
@@ -3360,6 +3339,31 @@ printQuery(const PGresult *result, const printQueryOpt *opt,
printTableCleanup(&cont);
}
+char
+column_type_alignment(Oid ftype)
+{
+ char align;
+
+ switch (ftype)
+ {
+ case INT2OID:
+ case INT4OID:
+ case INT8OID:
+ case FLOAT4OID:
+ case FLOAT8OID:
+ case NUMERICOID:
+ case OIDOID:
+ case XIDOID:
+ case CIDOID:
+ case CASHOID:
+ align = 'r';
+ break;
+ default:
+ align = 'l';
+ break;
+ }
+ return align;
+}
void
setDecimalLocale(void)