From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Morgenstern <d.morgenstern@synedra.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Difference between text_pattern_ops and varchar_pattern_ops
Date: Fri, 25 Jun 2021 09:38:51 -0400
Message-ID: <2737119.1624628331@sss.pgh.pa.us> (raw)
In-Reply-To: <2EA363D8-E6F2-4EBF-9A74-BECBBF81B76E@synedra.com>
References: <2EA363D8-E6F2-4EBF-9A74-BECBBF81B76E@synedra.com>
David Morgenstern <d.morgenstern@synedra.com> writes:
> Can somebody explain why text_pattern_ops can be used on varchar
> columns, considering it can’t be used for bpchar columns?
The underlying rule there is that an opclass can be applied to an index
column if the column's actual type is binary-coercible to what the opclass
expects. varchar is binary-coercible to text, since they're basically the
same type. bpchar is not, because we must insert a coercion function that
strips any trailing blanks. (Essentially, the restriction exists because
the index machinery won't cope with such intermediate functions.)
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-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, d.morgenstern@synedra.com
Subject: Re: Difference between text_pattern_ops and varchar_pattern_ops
In-Reply-To: <2737119.1624628331@sss.pgh.pa.us>
References: <2EA363D8-E6F2-4EBF-9A74-BECBBF81B76E@synedra.com> <2737119.1624628331@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