回复: BUG #18173: ERROR: could not identify a comparison function for type unknown

From: 下雨天 <409800246(at)qq(dot)com>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: 回复: BUG #18173: ERROR: could not identify a comparison function for type unknown
Date: 2023-10-31 12:19:26
Message-ID: tencent_6BA3819715C0CE1EC6EC89EF9EA4D5ADC506@qq.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Thank you very much for your reply.

when remove the parentheses, it is OK.
because plan is diffrent:

postgres=# explain select distinct id,name,'D3Q84xpymM',123,'123' from test_v;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QUERY PLAN &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
------------------------------------------------------------------
&nbsp;HashAggregate &nbsp;(cost=28.75..30.75 rows=200 width=105)
&nbsp; &nbsp;Group Key: id, name
&nbsp; &nbsp;-&gt; &nbsp;Seq Scan on test_v &nbsp;(cost=0.00..22.50 rows=1250 width=105)
(3 rows)

postgres=# explain select distinct (id,name,'D3Q84xpymM',123,'123') from test_v;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QUERY PLAN &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
-----------------------------------------------------------------------
&nbsp;Unique &nbsp;(cost=86.80..93.05 rows=200 width=32)
&nbsp; &nbsp;-&gt; &nbsp;Sort &nbsp;(cost=86.80..89.92 rows=1250 width=32)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Sort Key: (ROW(id, name, 'D3Q84xpymM', 123, '123'))
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; &nbsp;Seq Scan on test_v &nbsp;(cost=0.00..22.50 rows=1250 width=32)
(4 rows)

Sometimes users just want to use parentheses, because &nbsp;they were used on Oracle like this &nbsp;before.

Thanks!

------------------&nbsp;原始邮件&nbsp;------------------
发件人: "Laurenz Albe" <laurenz(dot)albe(at)cybertec(dot)at&gt;;
发送时间:&nbsp;2023年10月31日(星期二) 晚上7:10
收件人:&nbsp;"下雨天"<409800246(at)qq(dot)com&gt;;"pgsql-bugs"<pgsql-bugs(at)lists(dot)postgresql(dot)org&gt;;

主题:&nbsp;Re: BUG #18173: ERROR: could not identify a comparison function for type unknown

On Mon, 2023-10-30 at 13:24 +0000, PG Bug reporting form wrote:
&gt; PostgreSQL version: 16.0
&gt;
&gt; postgres=# CREATE TABLE test_v(id int,name varchar(30));
&gt; CREATE TABLE
&gt; postgres=# insert into test_v values(9,'abc'),(9,'def'),(9,'gh'),
&gt; (9,'gh');
&gt; INSERT 0 4
&gt; postgres=# explain (costs off) select distinct
&gt; (id,name,'D3Q84xpymM',123,'123') from test_v;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; QUERY PLAN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&gt; -------------------------------------------------------------
&gt;&nbsp; Unique
&gt;&nbsp;&nbsp;&nbsp; -&gt;&nbsp; Sort
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Sort Key: (ROW(id, name, 'D3Q84xpymM', 123, '123'))
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt;&nbsp; Seq Scan on test_v
&gt; (4 rows)
&gt;
&gt; postgres=# select distinct (id,name,'D3Q84xpymM',123,'123') from test_v;
&gt; ERROR:&nbsp; could not identify a comparison function for type unknown

This is not a bug.&nbsp; You probably want to remove the parentheses.

Yours,
Laurenz Albe

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2023-10-31 14:51:52 Re: BUG #18173: ERROR: could not identify a comparison function for type unknown
Previous Message Laurenz Albe 2023-10-31 11:10:05 Re: BUG #18173: ERROR: could not identify a comparison function for type unknown