diff options
author | Joe Conway | 2004-08-11 00:49:35 +0000 |
---|---|---|
committer | Joe Conway | 2004-08-11 00:49:35 +0000 |
commit | bc8a1fc282005f6da9ff7650eadc65b160077e43 (patch) | |
tree | aa557e7317735b2b9385c30d7fe8b5ae68e75730 /contrib/tablefunc/sql | |
parent | 7d3b7db8da4132459e92a869833fe481be2ebca2 (diff) |
Hashed crosstab was dying with an SPI_finish error when the source SQL
produced no rows. Now it returns 0 rows instead. Adjusted regression
test for this case.
Diffstat (limited to 'contrib/tablefunc/sql')
-rw-r--r-- | contrib/tablefunc/sql/tablefunc.sql | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/contrib/tablefunc/sql/tablefunc.sql b/contrib/tablefunc/sql/tablefunc.sql index 5292fc2bc7..c464acbd3b 100644 --- a/contrib/tablefunc/sql/tablefunc.sql +++ b/contrib/tablefunc/sql/tablefunc.sql @@ -88,6 +88,17 @@ SELECT * FROM crosstab( 'SELECT DISTINCT rowdt, attribute FROM cth ORDER BY 2') AS c(rowid text, rowdt timestamp, temperature int4, test_result text, test_startdate timestamp, volts float8); +-- if source query returns zero rows, get zero rows returned +SELECT * FROM crosstab( + 'SELECT rowid, rowdt, attribute, val FROM cth WHERE false ORDER BY 1', + 'SELECT DISTINCT attribute FROM cth ORDER BY 1') +AS c(rowid text, rowdt timestamp, temperature text, test_result text, test_startdate text, volts text); + +-- if source query returns zero rows, get zero rows returned even if category query generates no rows +SELECT * FROM crosstab( + 'SELECT rowid, rowdt, attribute, val FROM cth WHERE false ORDER BY 1', + 'SELECT DISTINCT attribute FROM cth WHERE false ORDER BY 1') +AS c(rowid text, rowdt timestamp, temperature text, test_result text, test_startdate text, volts text); -- -- connectby |