Implement operator class parameters
authorAlexander Korotkov <[email protected]>
Mon, 30 Mar 2020 16:17:11 +0000 (19:17 +0300)
committerAlexander Korotkov <[email protected]>
Mon, 30 Mar 2020 16:17:23 +0000 (19:17 +0300)
commit911e70207703799605f5a0e8aad9f06cff067c63
tree5cdbffea1945c2c0b766db195a55bcb372d60537
parent1d53432ff940b789c2431ba476a2a6e2db3edf84
Implement operator class parameters

PostgreSQL provides set of template index access methods, where opclasses have
much freedom in the semantics of indexing.  These index AMs are GiST, GIN,
SP-GiST and BRIN.  There opclasses define representation of keys, operations on
them and supported search strategies.  So, it's natural that opclasses may be
faced some tradeoffs, which require user-side decision.  This commit implements
opclass parameters allowing users to set some values, which tell opclass how to
index the particular dataset.

This commit doesn't introduce new storage in system catalog.  Instead it uses
pg_attribute.attoptions, which is used for table column storage options but
unused for index attributes.

In order to evade changing signature of each opclass support function, we
implement unified way to pass options to opclass support functions.  Options
are set to fn_expr as the constant bytea expression.  It's possible due to the
fact that opclass support functions are executed outside of expressions, so
fn_expr is unused for them.

This commit comes with some examples of opclass options usage.  We parametrize
signature length in GiST.  That applies to multiple opclasses: tsvector_ops,
gist__intbig_ops, gist_ltree_ops, gist__ltree_ops, gist_trgm_ops and
gist_hstore_ops.  Also we parametrize maximum number of integer ranges for
gist__int_ops.  However, the main future usage of this feature is expected
to be json, where users would be able to specify which way to index particular
json parts.

Catversion is bumped.

Discussion: https://postgr.es/m/d22c3a18-31c7-1879-fc11-4c1ce2f5e5af%40postgrespro.ru
Author: Nikita Glukhov, revised by me
Reviwed-by: Nikolay Shaplov, Robert Haas, Tom Lane, Tomas Vondra, Alvaro Herrera
108 files changed:
contrib/bloom/bloom.h
contrib/bloom/blutils.c
contrib/bloom/blvalidate.c
contrib/hstore/Makefile
contrib/hstore/expected/hstore.out
contrib/hstore/hstore--1.6--1.7.sql [new file with mode: 0644]
contrib/hstore/hstore.control
contrib/hstore/hstore_gist.c
contrib/hstore/sql/hstore.sql
contrib/intarray/Makefile
contrib/intarray/_int.h
contrib/intarray/_int_bool.c
contrib/intarray/_int_gist.c
contrib/intarray/_int_tool.c
contrib/intarray/_intbig_gist.c
contrib/intarray/expected/_int.out
contrib/intarray/intarray--1.2--1.3.sql [new file with mode: 0644]
contrib/intarray/intarray.control
contrib/intarray/sql/_int.sql
contrib/ltree/Makefile
contrib/ltree/_ltree_gist.c
contrib/ltree/expected/ltree.out
contrib/ltree/ltree--1.1--1.2.sql [new file with mode: 0644]
contrib/ltree/ltree.control
contrib/ltree/ltree.h
contrib/ltree/ltree_gist.c
contrib/ltree/sql/ltree.sql
contrib/pg_trgm/Makefile
contrib/pg_trgm/expected/pg_trgm.out
contrib/pg_trgm/pg_trgm--1.4--1.5.sql [new file with mode: 0644]
contrib/pg_trgm/pg_trgm.control
contrib/pg_trgm/sql/pg_trgm.sql
contrib/pg_trgm/trgm.h
contrib/pg_trgm/trgm_gist.c
doc/src/sgml/hstore.sgml
doc/src/sgml/indices.sgml
doc/src/sgml/intarray.sgml
doc/src/sgml/ltree.sgml
doc/src/sgml/pgtrgm.sgml
doc/src/sgml/ref/create_index.sgml
doc/src/sgml/textsearch.sgml
src/backend/access/brin/brin.c
src/backend/access/brin/brin_validate.c
src/backend/access/common/reloptions.c
src/backend/access/gin/ginutil.c
src/backend/access/gin/ginvalidate.c
src/backend/access/gist/gist.c
src/backend/access/gist/gistvalidate.c
src/backend/access/hash/hash.c
src/backend/access/hash/hashvalidate.c
src/backend/access/index/amvalidate.c
src/backend/access/index/indexam.c
src/backend/access/nbtree/nbtree.c
src/backend/access/nbtree/nbtvalidate.c
src/backend/access/spgist/spgvalidate.c
src/backend/catalog/heap.c
src/backend/catalog/index.c
src/backend/catalog/toasting.c
src/backend/commands/indexcmds.c
src/backend/commands/opclasscmds.c
src/backend/commands/tablecmds.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/nodes/makefuncs.c
src/backend/nodes/outfuncs.c
src/backend/optimizer/util/plancat.c
src/backend/parser/gram.y
src/backend/parser/parse_utilcmd.c
src/backend/utils/adt/ruleutils.c
src/backend/utils/adt/selfuncs.c
src/backend/utils/adt/tsgistidx.c
src/backend/utils/cache/lsyscache.c
src/backend/utils/cache/relcache.c
src/backend/utils/fmgr/fmgr.c
src/include/access/amapi.h
src/include/access/amvalidate.h
src/include/access/brin_internal.h
src/include/access/genam.h
src/include/access/gin.h
src/include/access/gist.h
src/include/access/hash.h
src/include/access/nbtree.h
src/include/access/reloptions.h
src/include/access/spgist.h
src/include/catalog/catversion.h
src/include/catalog/heap.h
src/include/catalog/pg_amproc.dat
src/include/catalog/pg_proc.dat
src/include/fmgr.h
src/include/nodes/execnodes.h
src/include/nodes/parsenodes.h
src/include/nodes/pathnodes.h
src/include/utils/lsyscache.h
src/include/utils/rel.h
src/include/utils/relcache.h
src/include/utils/ruleutils.h
src/test/regress/expected/alter_generic.out
src/test/regress/expected/btree_index.out
src/test/regress/expected/opr_sanity.out
src/test/regress/expected/tsearch.out
src/test/regress/input/create_function_1.source
src/test/regress/output/create_function_1.source
src/test/regress/regress.c
src/test/regress/sql/alter_generic.sql
src/test/regress/sql/btree_index.sql
src/test/regress/sql/opr_sanity.sql
src/test/regress/sql/tsearch.sql
src/tools/pgindent/typedefs.list