From: Tom Lane <tgl@sss.pgh.pa.us>
To: Manuel Rigger <rigger.manuel@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: No = operator for opfamily 426
Date: Tue, 19 Nov 2019 10:47:34 -0500
Message-ID: <8686.1574178454@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+u7OA7nnGYy8rY0vdTe811NuA+Frr9nbcBO9u2Z+JxqNaud+g@mail.gmail.com>
References: <CA+u7OA7nnGYy8rY0vdTe811NuA+Frr9nbcBO9u2Z+JxqNaud+g@mail.gmail.com>
Manuel Rigger <rigger.manuel@gmail.com> 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 = operator for opfamily 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=# explain SELECT * FROM t0 WHERE t0.c0::bpchar = '';
QUERY PLAN
-----------------------------------------------------------------
Bitmap Heap Scan on t0 (cost=4.21..14.35 rows=7 width=32)
Recheck Cond: ((c0)::bpchar = ''::bpchar)
-> Bitmap Index Scan on i0 (cost=0.00..4.21 rows=7 width=0)
Index Cond: ((c0)::bpchar = ''::bpchar)
(4 rows)
and even
regression=# explain SELECT * FROM t0 WHERE t0.c0::bpchar like '';
QUERY PLAN
-----------------------------------------------------------------
Bitmap Heap Scan on t0 (cost=4.21..14.35 rows=7 width=32)
Filter: ((c0)::bpchar ~~ ''::text)
-> Bitmap Index Scan on i0 (cost=0.00..4.21 rows=7 width=0)
Index Cond: ((c0)::bpchar = ''::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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, rigger.manuel@gmail.com
Subject: Re: No = operator for opfamily 426
In-Reply-To: <8686.1574178454@sss.pgh.pa.us>
References: <CA+u7OA7nnGYy8rY0vdTe811NuA+Frr9nbcBO9u2Z+JxqNaud+g@mail.gmail.com> <8686.1574178454@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox