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:
@ -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 */
|
||||
|
Reference in New Issue
Block a user