Re: BUG #16176: NULL value returned by category_sql argument to crosstab() causes segmentation fault
Joe Conway <mail@joeconway.com>
From: Joe Conway <mail@joeconway.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: ipluta@wp.pl, pgsql-bugs@lists.postgresql.org
Date: 2019-12-23T19:00:38Z
Lists: pgsql-bugs
On 12/23/19 1:49 PM, Tom Lane wrote:
> Joe Conway <mail@joeconway.com> writes:
>> Pushed that way to all supported branches.
>
> Hmm, why'd you use ERRCODE_SYNTAX_ERROR, and not say
> ERRCODE_NULL_VALUE_NOT_ALLOWED?
To be consistent with the error just above:
--------------------
/*
* The provided categories SQL query must always return one column:
* category - the label or identifier for each column
*/
if (spi_tupdesc->natts != 1)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("provided \"categories\" SQL must " \
"return 1 column of at least one row")));
--------------------
Also, the argument itself is a SQL statement, and it isn't NULL, it just
produces a NULL value as one (or more) of its output rows. It seems like
ERRCODE_NULL_VALUE_NOT_ALLOWED might be confusing.
But I am not married to ERRCODE_SYNTAX_ERROR if you think it ought to be
changed.
Joe
--
Crunchy Data - http://crunchydata.com
PostgreSQL Support for Secure Enterprises
Consulting, Training, & Open Source Development
Commits
-
Disallow null category in crosstab_hash
- 4a3cdb531be5 9.4.26 landed
- 70fc6c4ef3c3 9.5.21 landed
- 3757c164008c 9.6.17 landed
- 81be0c57e290 10.12 landed
- f49e5efbc29a 11.7 landed
- b5e7569dddd2 12.2 landed
- d5b9c2baff66 13.0 landed