Re: Compare variables of composite type with slightly different column types

Lists: pgsql-hackers
From: Andrey Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Compare variables of composite type with slightly different column types
Date: 2022-05-26 11:25:52
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Hi,
Researching on join selectivity improvement I stuck into the code in
rowtypes.c:

/*
* Have two matching columns, they must be same type
*/
if (att1->atttypid != att2->atttypid)
ereport(ERROR, ...

Why, for example, isn't allowed next trivial query:

SELECT *
FROM
(SELECT ROW(1::integer, 'robert'::text)) AS s1,
(SELECT ROW(1::bigint, 'robert'::name)) AS s2
WHERE s1 = s2;

I guess, here the compatible_oper() routine can be used to find a
appropriate operator, or something like that can be invented.
I looked into the 2cd7084 and a4424c5, but don't found any rationale.

--
Regards
Andrey Lepikhov
Postgres Professional


From: Andrey Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Compare variables of composite type with slightly different column types
Date: 2022-05-28 19:53:20
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 26/5/2022 14:25, Andrey Lepikhov wrote:
> I guess, here the compatible_oper() routine can be used to find a
> appropriate operator, or something like that can be invented.
> I looked into the 2cd7084 and a4424c5, but don't found any rationale.
>
In accordance to this idea I prepared a code. For a demo only.

--
regards,
Andrey Lepikhov
Postgres Professional

Attachment Content-Type Size
0001-Try-to-search-compatible-operator-if-columns-of-comp.patch text/plain 4.8 KB