Re: BUG #17387: Working in PG13 but not in PGH14: array_agg(RECORD)

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: james.inform@pharmapp.de, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Date: 2022-01-28T23:48:00Z
Lists: pgsql-bugs

Attachments

I wrote:
> So it seems like this is specific to type record[] somehow.

Ah, no, I found it: the callers of select_common_type_from_oids
assume that its result is guaranteed valid, which is not so.
We need to explicitly check can_coerce_type.  This oversight
allows check_generic_type_consistency to succeed when it should
not, which in turn allows us to decide that record and record[]
are OK as matches to all three of those operators.

This apparently escaped notice before because we've only tested
cases in which incompatible arguments were of different typcategory.
record and record[] are both of category 'P', which might be a
dumb idea.  But this would be a bug anyway.

We need something like the attached, but I'm going to nose
around for other oversights.

			regards, tom lane

Commits

  1. Fix failure to validate the result of select_common_type().

  2. Declare assorted array functions using anycompatible not anyelement.