OSDN Git Service

Alter the xxx_pattern_ops opclasses to use the regular equality operator of
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 27 May 2008 00:13:09 +0000 (00:13 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 27 May 2008 00:13:09 +0000 (00:13 +0000)
commit7b8a63c3e922b8730e98a20a2c30c5460ddf2306
treea66a78e79e9e8efb89622f5206461e469b54fd3c
parenta3d9a2421ad3c16c22c82734a1d12be472bf9ba5
Alter the xxx_pattern_ops opclasses to use the regular equality operator of
the associated datatype as their equality member.  This means that these
opclasses can now support plain equality comparisons along with LIKE tests,
thus avoiding the need for an extra index in some applications.  This
optimization was not possible when the pattern opclasses were first introduced,
because we didn't insist that text equality meant bitwise equality; but we
do now, so there is no semantic difference between regular and pattern
equality operators.

I removed the name_pattern_ops opclass altogether, since it's really useless:
name's regular comparisons are just strcmp() and are unlikely to become
something different.  Instead teach indxpath.c that btree name_ops can be
used for LIKE whether or not the locale is C.  This might lead to a useful
speedup in LIKE queries on the system catalogs in non-C locales.

The ~=~ and ~<>~ operators are gone altogether.  (It would have been nice to
keep them for backward compatibility's sake, but since the pg_amop structure
doesn't allow multiple equality operators per opclass, there's no way.)

A not-immediately-obvious incompatibility is that the sort order within
bpchar_pattern_ops indexes changes --- it had been identical to plain
strcmp, but is now trailing-blank-insensitive.  This will impact
in-place upgrades, if those ever happen.

Per discussions a couple months ago.
15 files changed:
doc/src/sgml/indices.sgml
src/backend/access/nbtree/nbtcompare.c
src/backend/optimizer/path/indxpath.c
src/backend/utils/adt/name.c
src/backend/utils/adt/varchar.c
src/backend/utils/adt/varlena.c
src/include/catalog/catversion.h
src/include/catalog/pg_amop.h
src/include/catalog/pg_amproc.h
src/include/catalog/pg_opclass.h
src/include/catalog/pg_operator.h
src/include/catalog/pg_opfamily.h
src/include/catalog/pg_proc.h
src/include/utils/builtins.h
src/test/regress/expected/opr_sanity.out