Bug / Unexpected behaviour of NOT LIKE - Mailing list pgsql-bugs

From Judith Meyer
Subject Bug / Unexpected behaviour of NOT LIKE
Date
Msg-id CAD9YNfx05sRf2DSd4Z5VvudYuS_Wxk7HD9L5-=Ez8QaAJY3qzA@mail.gmail.com
Whole thread Raw
Responses Re: Bug / Unexpected behaviour of NOT LIKE  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Bug / Unexpected behaviour of NOT LIKE  ("David G. Johnston" <david.g.johnston@gmail.com>)
List 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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #17216: No Password Provided Error - uncaught exception
Next
From: Tom Lane
Date:
Subject: Re: Bug / Unexpected behaviour of NOT LIKE