1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-13 07:41:39 +03:00

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.
This commit is contained in:
Joe Conway
2004-08-11 00:49:35 +00:00
parent 7d3b7db8da
commit bc8a1fc282
3 changed files with 39 additions and 15 deletions

View File

@ -821,15 +821,6 @@ load_categories_hash(char *cats_sql, MemoryContext per_query_ctx)
MemoryContextSwitchTo(SPIcontext);
}
}
else
{
/* no qualifying tuples */
SPI_finish();
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("provided \"categories\" SQL must " \
"return 1 column of at least one row")));
}
if (SPI_finish() != SPI_OK_FINISH)
/* internal error */
@ -879,6 +870,15 @@ get_crosstab_tuplestore(char *sql,
j;
int result_ncols;
if (num_categories == 0)
{
/* no qualifying category tuples */
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("provided \"categories\" SQL must " \
"return 1 column of at least one row")));
}
/*
* The provided SQL query must always return at least three
* columns:
@ -994,11 +994,6 @@ get_crosstab_tuplestore(char *sql,
MemoryContextSwitchTo(SPIcontext);
}
else
{
/* no qualifying tuples */
SPI_finish();
}
if (SPI_finish() != SPI_OK_FINISH)
/* internal error */