diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2016-04-08 20:23:18 -0300 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2016-04-08 20:23:18 -0300 |
commit | c09b18f21c52cbcf8718d6c267c84fcfea3739a9 (patch) | |
tree | 14ae5d520050d3302c8ecae141a2deda7c17a962 /src/bin/psql/crosstabview.h | |
parent | 279d86afdbed550425bc9d1327ade2dc0028ad33 (diff) |
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/bin/psql/crosstabview.h')
-rw-r--r-- | src/bin/psql/crosstabview.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/bin/psql/crosstabview.h b/src/bin/psql/crosstabview.h new file mode 100644 index 00000000000..3cb4d755890 --- /dev/null +++ b/src/bin/psql/crosstabview.h @@ -0,0 +1,26 @@ +/* + * psql - the PostgreSQL interactive terminal + * + * Copyright (c) 2000-2016, PostgreSQL Global Development Group + * + * src/bin/psql/crosstabview.h + */ + +#ifndef CROSSTABVIEW_H +#define CROSSTABVIEW_H + +/* + * Limit the number of output columns generated in memory by the crosstabview + * algorithm. A new output column is added for each distinct value found in the + * column that pivots (to form the horizontal header). + * The purpose of this limit is to fail early instead of over-allocating or spending + * too much time if the crosstab to generate happens to be unreasonably large + * (worst case: a NxN cartesian product with N=number of tuples). + * The value of 1600 corresponds to the maximum columns per table in storage, + * but it could be as much as INT_MAX theorically. + */ +#define CROSSTABVIEW_MAX_COLUMNS 1600 + +/* prototypes */ +extern bool PrintResultsInCrosstab(PGresult *res); +#endif /* CROSSTABVIEW_H */ |