回复: BUG #18173: ERROR: could not identify a comparison function for type unknown - Mailing list pgsql-bugs

From 下雨天
Subject 回复: BUG #18173: ERROR: could not identify a comparison function for type unknown
Date
Msg-id tencent_6BA3819715C0CE1EC6EC89EF9EA4D5ADC506@qq.com
Whole thread Raw
In response to Re: BUG #18173: ERROR: could not identify a comparison function for type iso-8859-1  (Laurenz Albe <laurenz.albe@cybertec.at>)
List 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;
                            QUERY PLAN                            
------------------------------------------------------------------
 HashAggregate  (cost=28.75..30.75 rows=200 width=105)
   Group Key: id, name
   ->  Seq Scan on test_v  (cost=0.00..22.50 rows=1250 width=105)
(3 rows)

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


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

Thanks!


------------------ 原始邮件 ------------------
发件人: "Laurenz Albe" <laurenz.albe@cybertec.at>;
发送时间: 2023年10月31日(星期二) 晚上7:10
收件人: "下雨天"<409800246@qq.com>;"pgsql-bugs"<pgsql-bugs@lists.postgresql.org>;
主题: 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:
> PostgreSQL version: 16.0
>
> postgres=# CREATE TABLE test_v(id int,name varchar(30));
> CREATE TABLE
> postgres=# insert into test_v values(9,'abc'),(9,'def'),(9,'gh'),
> (9,'gh');
> INSERT 0 4
> postgres=# explain (costs off) select distinct
> (id,name,'D3Q84xpymM',123,'123') from test_v;
>                          QUERY PLAN                         
> -------------------------------------------------------------
>  Unique
>    ->  Sort
>          Sort Key: (ROW(id, name, 'D3Q84xpymM', 123, '123'))
>          ->  Seq Scan on test_v
> (4 rows)
>
> postgres=# select distinct (id,name,'D3Q84xpymM',123,'123') from test_v;
> ERROR:  could not identify a comparison function for type unknown

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

Yours,
Laurenz Albe

pgsql-bugs by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: BUG #18173: ERROR: could not identify a comparison function for type iso-8859-1
Next
From: Tom Lane
Date:
Subject: Re: BUG #18173: ERROR: could not identify a comparison function for type iso-8859-1