Re: Difference between text_pattern_ops and varchar_pattern_ops

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Difference between text_pattern_ops and varchar_pattern_ops
Дата
Msg-id 2737119.1624628331@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Difference between text_pattern_ops and varchar_pattern_ops  (David Morgenstern <d.morgenstern@synedra.com>)
Список 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 по дате отправления:

Предыдущее
От: David Morgenstern
Дата:
Сообщение: Difference between text_pattern_ops and varchar_pattern_ops
Следующее
От: 周书林
Дата:
Сообщение: What is the difference between context of "sighup", "super-backend", and "backend" in pg_settings?