Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iX5jG-0006SB-J9 for pgsql-bugs@arkaria.postgresql.org; Tue, 19 Nov 2019 15:47:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iX5jE-00017Z-Hq for pgsql-bugs@arkaria.postgresql.org; Tue, 19 Nov 2019 15:47:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iX5jE-00017S-61 for pgsql-bugs@lists.postgresql.org; Tue, 19 Nov 2019 15:47:44 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iX5j7-0006LA-76 for pgsql-bugs@lists.postgresql.org; Tue, 19 Nov 2019 15:47:42 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id xAJFlYxU008687; Tue, 19 Nov 2019 10:47:34 -0500 From: Tom Lane To: Manuel Rigger cc: PostgreSQL mailing lists Subject: Re: No = operator for opfamily 426 In-reply-to: References: Comments: In-reply-to Manuel Rigger message dated "Tue, 19 Nov 2019 15:31:43 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <8685.1574178454.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 19 Nov 2019 10:47:34 -0500 Message-ID: <8686.1574178454@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Manuel Rigger writes: > Consider the following statements: > CREATE TABLE t0(c0 TEXT); > CREATE INDEX i0 ON t0(c0 bpchar_ops); > SELECT * FROM t0 WHERE t0.c0 LIKE ''; -- ERROR: no =3D operator for opf= amily 426 Hm. Right offhand, I'm wondering why we don't reject that index specification. I guess it's because we can use the index for weird cases like regression=3D# explain SELECT * FROM t0 WHERE t0.c0::bpchar =3D ''; QUERY PLAN = ----------------------------------------------------------------- Bitmap Heap Scan on t0 (cost=3D4.21..14.35 rows=3D7 width=3D32) Recheck Cond: ((c0)::bpchar =3D ''::bpchar) -> Bitmap Index Scan on i0 (cost=3D0.00..4.21 rows=3D7 width=3D0) Index Cond: ((c0)::bpchar =3D ''::bpchar) (4 rows) and even regression=3D# explain SELECT * FROM t0 WHERE t0.c0::bpchar like ''; QUERY PLAN = ----------------------------------------------------------------- Bitmap Heap Scan on t0 (cost=3D4.21..14.35 rows=3D7 width=3D32) Filter: ((c0)::bpchar ~~ ''::text) -> Bitmap Index Scan on i0 (cost=3D0.00..4.21 rows=3D7 width=3D0) Index Cond: ((c0)::bpchar =3D ''::bpchar) (4 rows) Really what the error is showing is that like_support.c is being too aggressive by assuming that it'll necessarily find a matching opfamily member. It should probably just silently fail if it can't construct the opclause it wants. regards, tom lane