Bug / Unexpected behaviour of NOT LIKE

From: Judith Meyer <yutian(dot)mei(at)gmail(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Bug / Unexpected behaviour of NOT LIKE
Date: 2021-10-06 15:55:20
Message-ID: CAD9YNfx05sRf2DSd4Z5VvudYuS_Wxk7HD9L5-=Ez8QaAJY3qzA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

I believe that I have found a bug or at least an undocumented unexpected
behaviour in the NOT LIKE operator (tested in PG 13). Namely, the query

SELECT * FROM users WHERE comment NOT LIKE 'hello%';

*never returns any users where the comment cell is empty, even though empty
also isn't "hello%".* This caused bugs in several parts of my code and
there is nothing about it in the documentation of the LIKE operator.

If this is intended behaviour, I believe that it deserves a big warning
note in the documentation: all occasions where someone might reasonably use
NOT LIKE should be combined with a IS NULL OR, i.e. "comment IS NULL OR
comment NOT LIKE 'hello%'"

Best wishes,

Judith Meyer
>>DiEM25

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Mark Dilger 2021-10-06 16:25:49 Re: BUG #17212: pg_amcheck fails on checking temporary relations
Previous Message Pavel Borisov 2021-10-06 15:14:21 Re: BUG #17212: pg_amcheck fails on checking temporary relations