Re: Difference between text_pattern_ops and varchar_pattern_ops - Mailing list pgsql-general

From Tom Lane
Subject Re: Difference between text_pattern_ops and varchar_pattern_ops
Date
Msg-id 2737119.1624628331@sss.pgh.pa.us
Whole thread Raw
In response to Difference between text_pattern_ops and varchar_pattern_ops  (David Morgenstern <d.morgenstern@synedra.com>)
List pgsql-general
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



pgsql-general by date:

Previous
From: David Morgenstern
Date:
Subject: Difference between text_pattern_ops and varchar_pattern_ops
Next
From: 周书林
Date:
Subject: What is the difference between context of "sighup", "super-backend", and "backend" in pg_settings?