BUG #18560: Inconsistent Behavior of PostgreSQL 'LIKE' Operator

PG Bug reporting form <noreply@postgresql.org>

From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: ammmkilo@163.com
Date: 2024-07-31T04:47:23Z
Lists: pgsql-bugs
The following bug has been logged on the website:

Bug reference:      18560
Logged by:          Hang ammmkilo
Email address:      ammmkilo@163.com
PostgreSQL version: 16.3
Operating system:   ubuntu 20.04
Description:        

```create table
DROP TABLE IF EXISTS t0;
CREATE TABLE t0(c0 INT NOT NULL, c1 CHAR(1) UNIQUE);
INSERT INTO t0 VALUES (0, '1');
INSERT INTO t0 VALUES (0, '');
```

---sql1
select ('' like ''),('1' like '1');

 ?column? | ?column? 
----------+----------
 t        | t
(1 row)

---sql2
select c1,(c1 like c1) from t0;

 c1 | ?column? 
----+----------
 1  | t
    | f
(2 rows)

In sql1, the result of the (" like ") query returns true. In sql2 (c1 like
c1) the return value is false when c1 is ". 
I think this is contradictory and there may be some bug between the 'like'
and the query column.


  
---select version():
  
                                                       version              
                                        
---------------------------------------------------------------------------------------------------------------------
 PostgreSQL 16.3 (Debian 16.3-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled
by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
(1 row)