Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r8gkP-00BAA8-Sq for pgsql-bugs@arkaria.postgresql.org; Thu, 30 Nov 2023 13:06:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1r8gkO-00HSag-Ip for pgsql-bugs@arkaria.postgresql.org; Thu, 30 Nov 2023 13:06:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r8gkO-00HSaY-Ab for pgsql-bugs@lists.postgresql.org; Thu, 30 Nov 2023 13:06:28 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r8gkL-009ME2-O4 for pgsql-bugs@lists.postgresql.org; Thu, 30 Nov 2023 13:06:27 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 3AUD6MTZ461816; Thu, 30 Nov 2023 08:06:22 -0500 From: Tom Lane To: baurzhansahariev@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18218: NOT LIKE ANY returns same result as LIKE ANY when array items are wrapped into E'' In-reply-to: <18218-8cbdd922e41ea291@postgresql.org> References: <18218-8cbdd922e41ea291@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Thu, 30 Nov 2023 10:54:36 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <461814.1701349582.1@sss.pgh.pa.us> Date: Thu, 30 Nov 2023 08:06:22 -0500 Message-ID: <461815.1701349582@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > select 'TextToMatch' like any (array[E'Te\%tch', E'nomatch']); -- true, > correct > select 'TextToMatch' NOT like any (array[E'Te\%tch', E'nomatch']); -- true > but must be false because it's a negated version of the expression above No, it is not. "NOT LIKE" is the operator to apply in this context, so the second expression returns true if the test string is NOT LIKE either of the array elements. You could write NOT ('TextToMatch' like any (array[E'Te\%tch', E'nomatch'])) to get the behavior you are after. Or write NOT LIKE ALL, as Orlov suggests. regards, tom lane